:root{
  --bg: #0b0c0f;
  --panel: #121418;
  --muted: #8b90a1;
  --text: #eef1f6;
  --accent: #6ea8fe;
  --accent-strong: #4c8dff;
  --assistant: #1a1f2a;
  --user: #1e2a22;
  --border: #20232b;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin:0;
  background: radial-gradient(1200px 700px at 80% -200px, #182036 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Inter, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
}

/* Accessibility */
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

/* Top bar */
.topbar{
  position: sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 18px;
  background: rgba(10,12,16,.6);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand{ display:flex; align-items:center; gap:12px; }
.logo{
  width:36px; height:36px; display:grid; place-items:center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-strong), #9ec5ff);
  color:#0b1a33; font-weight: 800;
  box-shadow: var(--shadow);
}
.titles h1{ font-size:18px; margin:0; letter-spacing:.2px; }
.subtitle{ margin:0; color:var(--muted); font-size:12px; }
.actions{ display:flex; gap:8px; }

.btn{
  display:inline-flex; align-items:center; gap:.5rem;
  border:1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor:pointer;
  transition: transform .06s ease, border-color .2s ease, background .2s ease;
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }
.btn.icon{ padding:10px; }
.btn.ghost{ background: transparent; }
.btn.link{ text-decoration: none; }
.btn.primary{
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #071326;
  border-color: transparent;
  font-weight: 600;
}

/* Layout */
.container{
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
}
.chat{
  display:flex; flex-direction:column; gap:14px;
  padding: 10px;
  min-height: calc(100dvh - 220px);
}
.msg{ display:flex; }
.msg.assistant{ justify-content:flex-start; }
.msg.user{ justify-content:flex-end; }
.bubble{
  max-width: 72ch;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.msg.assistant .bubble{
  background: linear-gradient(180deg, var(--assistant), #121620);
}
.msg.user .bubble{
  background: linear-gradient(180deg, var(--user), #142018);
}

/* Composer */
.composer{
  position: sticky; bottom: 0;
  display:flex; gap: 10px; align-items:center;
  padding: 12px;
  background: rgba(12,14,18,.6);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  border-radius: 14px;
  margin-top: 14px;
}
.input{
  flex:1;
  background: var(--panel);
  color: var(--text);
  border:1px solid var(--border);
  padding: 12px 12px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 999px rgba(255,255,255,0); /* safari caret fix */
}
.input::placeholder{ color: var(--muted); }

/* Footnote */
.footnote{
  color: var(--muted);
  margin-top: 12px;
}
.footnote summary{
  cursor: pointer;
  padding: 8px 0;
}

/* User Sidebar */
.user-sidebar{
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0,0,0,.5);
  z-index: 100;
  overflow-y: auto;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.sidebar-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 10;
}

.sidebar-header h2{
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.sidebar-header .btn.icon{
  font-size: 28px;
  line-height: 1;
  padding: 6px 12px;
}

.sidebar-content{
  padding: 20px;
}

.user-info{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.avatar{
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-strong), #9ec5ff);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  color: #0b1a33;
}

.user-email-display{
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.sidebar-section{
  margin-bottom: 24px;
}

.sidebar-section h3{
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 12px 0;
}

.data-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.data-list .loading{
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.data-item{
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.data-item strong{
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.data-item p{
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.fabric-label{
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 10px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #f0f3ff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  pointer-events: none;
}

.sidebar-actions{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* Small screens */
@media (max-width: 560px){
  .send-text{ display:none; }
  .user-sidebar{
    width: 100%;
  }
}
