:root {
  --ink: #ecf5f5;
  --muted: #91a3a6;
  --muted-strong: #b7c6c7;
  --bg: #071016;
  --panel: rgba(11, 22, 29, 0.91);
  --panel-solid: #0b161d;
  --line: rgba(174, 225, 222, 0.12);
  --line-strong: rgba(174, 225, 222, 0.22);
  --accent: #72e0d1;
  --accent-strong: #a8f3e8;
  --accent-deep: #123e3d;
  --danger: #ff8e91;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(57, 129, 124, 0.18), transparent 42%),
    linear-gradient(160deg, #071016 0%, #09131a 48%, #071016 100%);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  width: 40vw;
  height: 40vw;
  min-width: 360px;
  min-height: 360px;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  opacity: .12;
}
.ambient-one { top: -20vw; right: -10vw; background: #54d5c3; }
.ambient-two { bottom: -28vw; left: -12vw; background: #2f7894; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: min(100%, 460px);
  padding: clamp(30px, 6vw, 52px);
  border: 1px solid var(--line-strong);
  border-radius: 30px;
  background: linear-gradient(150deg, rgba(16, 31, 40, .96), rgba(8, 18, 24, .94));
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: end;
  gap: 5px;
  padding: 13px;
  border: 1px solid rgba(114, 224, 209, .32);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(114, 224, 209, .16), rgba(114, 224, 209, .04));
  box-shadow: inset 0 1px rgba(255, 255, 255, .08);
}
.brand-mark span { width: 6px; border-radius: 8px; background: var(--accent); }
.brand-mark span:nth-child(1) { height: 14px; opacity: .58; }
.brand-mark span:nth-child(2) { height: 26px; }
.brand-mark span:nth-child(3) { height: 20px; opacity: .78; }
.brand-mark.small { width: 36px; height: 36px; padding: 8px; border-radius: 12px; gap: 3px; }
.brand-mark.small span { width: 4px; }
.brand-mark.small span:nth-child(1) { height: 9px; }
.brand-mark.small span:nth-child(2) { height: 17px; }
.brand-mark.small span:nth-child(3) { height: 13px; }

.eyebrow {
  margin: 28px 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.login-card h1, .welcome h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 54px);
  line-height: 1.04;
  letter-spacing: -.045em;
  font-weight: 630;
}
.login-copy { margin: 18px 0 32px; color: var(--muted); line-height: 1.65; }

label { color: var(--muted-strong); font-size: 13px; font-weight: 650; }
input {
  display: block;
  width: 100%;
  margin: 8px 0 18px;
  padding: 14px 15px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  outline: none;
  background: rgba(4, 11, 15, .54);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(114, 224, 209, .7);
  box-shadow: 0 0 0 3px rgba(114, 224, 209, .11);
}
.primary-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 15px 17px;
  border: 0;
  border-radius: 13px;
  color: #06201e;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  font-weight: 780;
  box-shadow: 0 12px 34px rgba(74, 202, 185, .18);
}
.primary-button:hover { filter: brightness(1.05); }
.primary-button:disabled { cursor: wait; filter: saturate(.4); opacity: .7; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.privacy-note { margin: 26px 0 0; color: #6f8286; font-size: 12px; line-height: 1.5; }
.privacy-note span { margin-right: 7px; color: var(--accent); font-size: 9px; }

.app-shell { height: 100vh; display: grid; grid-template-columns: 276px minmax(0, 1fr); position: relative; z-index: 1; }
.sidebar {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  border-right: 1px solid var(--line);
  background: rgba(5, 13, 18, .82);
  backdrop-filter: blur(26px);
}
.sidebar-head { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.wordmark { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 720; }
.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 18px 0 16px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(114, 224, 209, .055);
  font-weight: 650;
  text-align: left;
}
.new-chat:hover { border-color: rgba(114, 224, 209, .42); background: rgba(114, 224, 209, .09); }
.conversation-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 5px;
  margin: 3px 0;
  padding: 4px 5px 4px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
}
.conversation-item:hover, .conversation-item.active { background: rgba(255, 255, 255, .045); color: var(--ink); }
.conversation-item.active { border-color: var(--line); }
.conversation-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-size: 13px; }
.delete-chat { width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: #708286; opacity: 0; }
.conversation-item:hover .delete-chat, .conversation-item:focus-within .delete-chat { opacity: 1; }
.delete-chat:hover { color: var(--danger); background: rgba(255, 142, 145, .08); }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 7px 2px; border-top: 1px solid var(--line); }
.private-badge, #connection-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(114, 224, 209, .65); }
.status-dot.inactive { background: #77888b; box-shadow: none; }
.text-button { padding: 6px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.text-button:hover { color: var(--ink); }

.chat-shell { min-width: 0; height: 100vh; display: grid; grid-template-rows: 68px minmax(0, 1fr) auto; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(18px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 22, .7);
  backdrop-filter: blur(18px);
}
.model-control { display: flex; align-items: center; gap: 10px; }
.model-control label { color: #708286; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
select {
  max-width: min(42vw, 330px);
  padding: 8px 30px 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--muted-strong);
  background: var(--panel-solid);
}
.topbar-meta { display: flex; align-items: center; gap: 18px; color: #708286; font-size: 12px; }
.chat-scroll { min-height: 0; overflow-y: auto; scroll-behavior: smooth; scrollbar-width: thin; }
.welcome { width: min(900px, calc(100% - 36px)); margin: clamp(56px, 10vh, 112px) auto 34px; text-align: center; }
.welcome .eyebrow { margin-top: 18px; }
.welcome > p:last-of-type { margin: 18px auto 0; max-width: 620px; color: var(--muted); line-height: 1.7; }
.welcome-orbit {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border: 1px solid rgba(114, 224, 209, .28);
  border-radius: 50%;
  box-shadow: 0 0 60px rgba(114, 224, 209, .12);
}
.welcome-orbit::before, .welcome-orbit span { content: ""; display: block; border-radius: 50%; }
.welcome-orbit::before { width: 28px; height: 28px; border: 1px solid rgba(114, 224, 209, .52); }
.welcome-orbit span { position: absolute; width: 8px; height: 8px; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.prompt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 40px; text-align: left; }
.prompt-card { padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: rgba(13, 27, 35, .62); }
.prompt-card:hover { transform: translateY(-2px); border-color: rgba(114, 224, 209, .34); background: rgba(18, 38, 47, .78); }
.prompt-card span, .prompt-card small { display: block; }
.prompt-card span { font-weight: 650; }
.prompt-card small { margin-top: 6px; color: var(--muted); }

.messages { width: min(850px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 22px; }
.message { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 15px; padding: 18px 0; }
.message-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--accent);
  background: rgba(114, 224, 209, .07);
  font-size: 12px;
  font-weight: 780;
}
.message.user .message-avatar { color: #d9e5e6; background: rgba(255, 255, 255, .06); }
.message-body { min-width: 0; padding-top: 5px; }
.message-label { margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 720; letter-spacing: .09em; text-transform: uppercase; }
.message-content { margin: 0; color: #dbe8e8; font: 400 15px/1.75 Inter, ui-sans-serif, system-ui, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.streaming .message-content::after { content: ""; display: inline-block; width: 7px; height: 17px; margin-left: 4px; vertical-align: -3px; background: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .18; } }

.composer-wrap { padding: 12px clamp(16px, 4vw, 40px) max(13px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(7, 16, 22, .97) 23%); }
.composer { width: min(850px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin: 0 auto; padding: 11px 11px 11px 17px; border: 1px solid var(--line-strong); border-radius: 19px; background: rgba(13, 27, 35, .96); box-shadow: 0 18px 50px rgba(0, 0, 0, .22); }
textarea { width: 100%; max-height: 180px; resize: none; overflow-y: auto; padding: 8px 0; border: 0; outline: 0; color: var(--ink); background: transparent; line-height: 1.55; }
textarea::placeholder { color: #6f8185; }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.composer-hint { color: #617377; font-size: 10px; white-space: nowrap; }
.send-button, .stop-button, .icon-button { display: grid; place-items: center; border: 0; }
.send-button, .stop-button { width: 38px; height: 38px; border-radius: 12px; font-weight: 800; }
.send-button { color: #06201e; background: var(--accent); font-size: 19px; }
.send-button:disabled { cursor: not-allowed; opacity: .35; }
.stop-button { color: var(--ink); background: rgba(255, 255, 255, .09); font-size: 11px; }
.footer-note { margin: 8px auto 0; color: #5c6f73; font-size: 10px; text-align: center; }
.icon-button { width: 36px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, .05); font-size: 18px; }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 20; transform: translate(-50%, 20px); padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #12232b; box-shadow: var(--shadow); color: var(--muted-strong); font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.sidebar-scrim { position: fixed; inset: 0; z-index: 7; background: rgba(0, 0, 0, .48); }
.mobile-only { display: none; }
.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; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .mobile-only { display: grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 8; width: min(86vw, 310px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 0 14px; }
  .topbar-meta #signed-in-user { display: none; }
  .model-control label { display: none; }
  select { max-width: 47vw; }
  .welcome { margin-top: 46px; }
  .prompt-grid { grid-template-columns: 1fr; margin-top: 28px; }
  .prompt-card { padding: 14px 16px; }
  .composer-hint { display: none; }
  .message { grid-template-columns: 31px minmax(0, 1fr); gap: 11px; }
  .message-avatar { width: 30px; height: 30px; border-radius: 9px; }
}

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