:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #10161d;
  --panel-2: #151d26;
  --line: rgba(255,255,255,.09);
  --text: #f4f7f9;
  --muted: #8d9aa8;
  --accent: #43d0a4;
  --accent-2: #8b7cf6;
  --danger: #ff6b74;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.auth-view {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(360px, 46%);
  gap: clamp(30px, 8vw, 140px);
  align-items: center;
  padding: clamp(24px, 6vw, 96px);
  background:
    radial-gradient(circle at 15% 22%, rgba(67,208,164,.14), transparent 30%),
    radial-gradient(circle at 74% 85%, rgba(139,124,246,.12), transparent 28%), var(--bg);
}
.auth-brand { align-self: start; display: flex; gap: 14px; align-items: center; }
.auth-brand > div:last-child { display: grid; gap: 3px; }
.auth-brand strong { font-size: 20px; letter-spacing: -.3px; }
.auth-brand span { color: var(--muted); font-size: 13px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center;
  color: #07130f; font-weight: 900; font-size: 23px;
  background: linear-gradient(145deg, #8ff0d1, var(--accent));
  box-shadow: 0 12px 40px rgba(67,208,164,.2);
}
.brand-mark.small { width: 34px; height: 34px; border-radius: 11px; font-size: 16px; }
.auth-card {
  border: 1px solid var(--line); background: rgba(16,22,29,.82);
  box-shadow: 0 30px 90px rgba(0,0,0,.35); backdrop-filter: blur(18px);
  border-radius: 28px; padding: clamp(26px, 5vw, 48px);
}
.auth-copy h1 { font-size: clamp(30px, 4vw, 42px); letter-spacing: -1.6px; line-height: 1.05; margin: 10px 0 12px; }
.auth-copy p { color: var(--muted); margin: 0 0 28px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: #0b1016; border-radius: 13px; margin-bottom: 24px; }
.auth-tab { border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 10px; cursor: pointer; }
.auth-tab.active { background: var(--panel-2); color: var(--text); }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field span { color: #c7d0d8; font-size: 12px; font-weight: 700; }
.field input {
  width: 100%; border: 1px solid var(--line); outline: 0; border-radius: 13px;
  background: #0b1016; color: var(--text); padding: 14px 15px;
}
.field input:focus { border-color: rgba(67,208,164,.6); box-shadow: 0 0 0 3px rgba(67,208,164,.09); }
.form-error { color: #ff9299; min-height: 18px; font-size: 13px; margin: 0 0 10px; }
.primary-btn {
  width: 100%; border: 0; border-radius: 13px; padding: 14px; cursor: pointer;
  font-weight: 800; color: #062019; background: linear-gradient(135deg, #79e6c4, var(--accent));
}
.primary-btn:disabled { opacity: .55; cursor: wait; }
.auth-link { display: flex; justify-content: space-between; align-items: center; text-decoration: none; margin-top: 28px; }
.secondary-link { display: block; color: #b8c3cc; text-align: center; font-size: 13px; margin: 17px 0 4px; text-decoration: none; }
.secondary-link:hover { color: var(--accent); }
.privacy-note { color: var(--muted); text-align: center; font-size: 11px; margin: 18px 0 0; }

.app-view { height: 100dvh; display: grid; grid-template-columns: 276px minmax(0, 1fr); overflow: hidden; }
.sidebar {
  min-height: 0; padding: 18px 14px 12px; border-right: 1px solid var(--line);
  background: #0d1218; display: flex; flex-direction: column;
}
.sidebar-head, .brand, .account-card, .topbar, .top-actions, .composer-actions { display: flex; align-items: center; }
.sidebar-head { justify-content: space-between; padding: 0 5px 18px; }
.brand { gap: 10px; color: inherit; text-decoration: none; }
.new-chat {
  display: flex; align-items: center; gap: 10px; border: 1px solid rgba(67,208,164,.35);
  background: rgba(67,208,164,.07); padding: 12px 14px; border-radius: 13px; cursor: pointer; font-weight: 700;
}
.new-chat:hover { background: rgba(67,208,164,.12); }
.history-label { display: flex; justify-content: space-between; color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: 1.2px; font-weight: 800; padding: 24px 10px 8px; }
.history { min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 3px; }
.history-item {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 4px;
  border-radius: 11px; padding: 3px 5px 3px 11px; color: #aab5bf;
}
.history-item.active { color: var(--text); background: var(--panel-2); }
.history-open { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; border: 0; background: transparent; padding: 9px 0; cursor: pointer; }
.history-delete { opacity: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 7px; }
.history-item:hover .history-delete, .history-delete:focus { opacity: 1; }
.account-card { gap: 10px; margin-top: auto; border-top: 1px solid var(--line); padding: 15px 5px 3px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #24323a; color: var(--accent); font-weight: 800; }
.account-copy { min-width: 0; display: grid; flex: 1; }
.account-copy strong, .account-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 13px; }.account-copy span { color: var(--muted); font-size: 10px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 8px; cursor: pointer; border-radius: 9px; font-size: 18px; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.05); }

.main { min-width: 0; display: grid; grid-template-rows: 64px minmax(0, 1fr) auto; position: relative; }
.topbar { justify-content: space-between; border-bottom: 1px solid var(--line); padding: 0 22px; background: rgba(11,15,20,.88); backdrop-filter: blur(12px); z-index: 2; }
.title-button { border: 0; background: transparent; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; cursor: pointer; }
.top-actions { gap: 10px; }
.model-pill { color: var(--muted); border: 1px solid var(--line); padding: 7px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.model-pill i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 5px; box-shadow: 0 0 8px var(--accent); }
.voice-button { display: flex; align-items: center; gap: 8px; border: 1px solid rgba(139,124,246,.35); background: rgba(139,124,246,.08); border-radius: 999px; padding: 8px 13px; cursor: pointer; font-size: 12px; font-weight: 750; }
.voice-bars { height: 14px; display: inline-flex; gap: 2px; align-items: center; }
.voice-bars i { display: block; width: 2px; height: 40%; background: #a89cff; border-radius: 2px; }
.voice-bars i:nth-child(2) { height: 100%; }.voice-bars i:nth-child(3) { height: 65%; }

.empty-state { grid-row: 2; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px 80px; text-align: center; }
.hero-orb { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; background: linear-gradient(145deg, rgba(67,208,164,.18), rgba(139,124,246,.18)); border: 1px solid var(--line); margin-bottom: 22px; }
.hero-orb span { font-size: 25px; font-weight: 900; color: var(--accent); }
.empty-state h1 { margin: 8px 0 12px; font-size: clamp(28px, 4vw, 46px); letter-spacing: -1.8px; }
.empty-state > p:not(.eyebrow) { color: var(--muted); max-width: 560px; margin: 0; line-height: 1.6; }
.suggestions { width: min(720px,100%); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 34px; }
.suggestions button { text-align: left; display: grid; gap: 4px; border: 1px solid var(--line); background: var(--panel); border-radius: 15px; padding: 15px 16px; cursor: pointer; }
.suggestions button:hover { border-color: rgba(67,208,164,.35); transform: translateY(-1px); }
.suggestions b { font-size: 13px; }.suggestions span { color: var(--muted); font-size: 11px; }

.messages { grid-row: 2; min-height: 0; overflow-y: auto; padding: 28px max(20px, calc((100% - 820px)/2)) 120px; scroll-behavior: smooth; }
.message { display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 13px; margin-bottom: 30px; }
.message.user { grid-template-columns: minmax(0,1fr); justify-items: end; }
.message-avatar { width: 32px; height: 32px; border-radius: 11px; display: grid; place-items: center; font-size: 12px; font-weight: 900; color: #071610; background: var(--accent); }
.message-body { min-width: 0; max-width: 100%; }
.message.user .message-body { max-width: min(78%,680px); border-radius: 18px 18px 4px 18px; padding: 12px 15px; background: #1b2630; }
.message-label { color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 9px; font-weight: 800; margin-bottom: 7px; }
.message-text { line-height: 1.7; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.assistant.streaming .message-text::after { content: ""; display: inline-block; width: 7px; height: 16px; background: var(--accent); margin-left: 4px; vertical-align: -2px; animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer-wrap { grid-row: 3; width: 100%; padding: 0 max(16px, calc((100% - 840px)/2)) max(10px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 28%); }
.composer { border: 1px solid rgba(255,255,255,.13); background: var(--panel); border-radius: 20px; padding: 11px 11px 9px 16px; box-shadow: 0 14px 40px rgba(0,0,0,.32); }
.composer:focus-within { border-color: rgba(67,208,164,.42); }
.composer textarea { width: 100%; min-height: 28px; max-height: 180px; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.5; padding: 3px 0; }
.composer-actions { justify-content: flex-end; gap: 8px; }
.send-status { color: var(--muted); font-size: 9px; margin-right: auto; }
.round-btn { width: 34px; height: 34px; border-radius: 11px; border: 0; cursor: pointer; background: var(--accent); color: #072018; font-weight: 900; }
.round-btn:disabled { opacity: .35; cursor: default; }.round-btn.stop { color: var(--text); background: #27333d; }
.disclaimer { text-align: center; color: #697682; font-size: 9px; margin: 7px 0 0; }

.voice-modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(4,7,10,.78); backdrop-filter: blur(18px); }
.voice-panel { width: min(440px,100%); min-height: 560px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; border: 1px solid var(--line); border-radius: 32px; background: radial-gradient(circle at 50% 35%, rgba(139,124,246,.18), transparent 45%), var(--panel); padding: 38px; text-align: center; }
.voice-close { position: absolute; top: 18px; right: 18px; }
.voice-status { position: absolute; top: 26px; left: 28px; color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.voice-orb { width: 168px; height: 168px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle, rgba(67,208,164,.28), rgba(139,124,246,.13) 58%, transparent 60%); box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 0 80px rgba(67,208,164,.12); margin-bottom: 30px; transition: transform .2s; }
.voice-orb.active { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.055); box-shadow: 0 0 0 1px rgba(255,255,255,.1), 0 0 110px rgba(67,208,164,.23); } }
.voice-bars.large { height: 54px; gap: 7px; }.voice-bars.large i { width: 6px; border-radius: 8px; background: var(--accent); }.voice-bars.large i:nth-child(4) { height: 80%; }.voice-bars.large i:nth-child(5) { height: 45%; }
.voice-panel h2 { font-size: 27px; margin: 0 0 10px; }.voice-panel > p { color: var(--muted); line-height: 1.5; margin: 0; }
.voice-controls { display: flex; gap: 12px; margin-top: 48px; }.voice-control { border: 1px solid var(--line); background: var(--panel-2); padding: 12px 18px; border-radius: 999px; cursor: pointer; }.voice-control.end { border-color: rgba(255,107,116,.3); color: #ff9da3; background: rgba(255,107,116,.09); }
.toast { position: fixed; z-index: 50; bottom: 24px; left: 50%; transform: translateX(-50%); background: #26313b; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; box-shadow: 0 15px 40px rgba(0,0,0,.35); font-size: 12px; }
.scrim, .mobile-only { display: none; }

@media (max-width: 760px) {
  .auth-view { display: flex; flex-direction: column; justify-content: center; align-items: stretch; padding: 22px; }
  .auth-brand { align-self: auto; margin-bottom: 28px; }.auth-card { padding: 26px 22px; border-radius: 22px; }
  .app-view { grid-template-columns: 1fr; }
  .mobile-only { display: inline-flex; }
  .sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: min(86vw,320px); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 20px 0 60px rgba(0,0,0,.4); }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; z-index: 9; border: 0; background: rgba(0,0,0,.48); }
  .scrim.open { display: block; }
  .topbar { padding: 0 12px; }.topbar > .title-button { margin-right: auto; margin-left: 4px; }
  .model-pill { display: none; }.voice-button span:last-child { display: none; }.voice-button { padding: 10px 13px; }
  .empty-state { justify-content: flex-start; padding-top: clamp(54px,15vh,110px); }
  .suggestions { grid-template-columns: 1fr 1fr; }.suggestions button { padding: 13px; }.suggestions span { display: none; }
  .messages { padding: 22px 16px 120px; }.message.user .message-body { max-width: 88%; }
  .send-status { display: none; }.composer-wrap { padding-left: 10px; padding-right: 10px; }
  .voice-panel { min-height: min(620px,88dvh); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
