:root {
  color-scheme: light;
  --ink: #201a2a;
  --muted: #756c80;
  --purple: #6e49c7;
  --purple-dark: #4c2a9c;
  --lavender: #eee7ff;
  --lavender-soft: #f8f5ff;
  --peach: #ffb690;
  --paper: rgba(255, 255, 255, 0.82);
  --line: rgba(59, 39, 83, 0.11);
  --shadow: 0 22px 70px rgba(72, 43, 111, 0.16);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--ink);
  background: #f5f0ff;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", sans-serif;
}
button, textarea, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(77, 42, 156, .55);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(30px);
  opacity: .56;
  pointer-events: none;
}
.ambient-one { width: 34rem; height: 34rem; top: -13rem; right: -7rem; background: #e2c8ff; }
.ambient-two { width: 28rem; height: 28rem; bottom: -15rem; left: 8%; background: #ffd1bd; }

.login-shell {
  height: 100dvh;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  overscroll-behavior: contain;
}
.loading-shell {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}
.loading-mark { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 20px; background: linear-gradient(145deg, #805ee0, #5430a5); color: white; box-shadow: var(--shadow); font: italic 700 28px Georgia, serif; animation: pulse 1.4s ease-in-out infinite; }
.loading-shell p { margin: 0; font-size: 14px; font-weight: 700; }
.login-card {
  width: min(460px, 100%);
  padding: 54px 46px 42px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 34px;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(22px);
}
.mark, .welcome-mark, .brand-mark {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #805ee0, #5430a5);
  color: white;
  box-shadow: 0 10px 30px rgba(92, 57, 165, .28);
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
}
.mark { width: 66px; height: 66px; margin: 0 auto 30px; border-radius: 22px; font-size: 32px; }
.eyebrow {
  margin: 0 0 12px;
  color: var(--purple);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.login-card h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(38px, 8vw, 54px); line-height: .98; letter-spacing: -.04em; }
.login-copy { margin: 24px auto 30px; max-width: 330px; color: var(--muted); font-size: 16px; line-height: 1.6; }
.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 54px;
  border-radius: 16px;
  background: var(--ink);
  color: white;
  text-decoration: none;
  font-weight: 750;
  transition: transform .18s ease, box-shadow .18s ease;
}
.google-button:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(32,26,42,.18); }
.google-g { font-family: Arial, sans-serif; font-weight: 900; }
.invite-note { margin: 18px 0 0; color: #685f72; font-size: 12px; }
.preview-login { display: grid; gap: 12px; margin-top: 18px; text-align: left; }
.preview-login label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.preview-login input { min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--ink); font-size: 16px; }
.preview-login button { min-height: 48px; border: 0; border-radius: 14px; background: var(--purple); color: white; font-weight: 800; cursor: pointer; }

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  width: 100%;
  height: 100dvh;
}
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 22px 16px 14px;
  border-right: 1px solid var(--line);
  background: rgba(247, 243, 255, .78);
  backdrop-filter: blur(20px);
}
.sidebar-head, .brand, .profile, .topbar, .topbar-title, .mode { display: flex; align-items: center; }
.sidebar-head { justify-content: space-between; padding: 0 5px 18px; }
.brand { gap: 10px; font-weight: 850; letter-spacing: -.02em; }
.brand-mark { width: 33px; height: 33px; border-radius: 11px; }
.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid rgba(110,73,199,.16);
  border-radius: 14px;
  background: rgba(255,255,255,.72);
  font-weight: 750;
  cursor: pointer;
}
.new-chat span { color: var(--purple); font-size: 20px; }
.history { flex: 1; overflow-y: auto; padding: 20px 2px; }
.history-label { margin: 8px 10px; color: #655c6e; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.history-item {
  min-height: 44px;
  width: 100%;
  padding: 11px 12px;
  overflow: hidden;
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.history-item:hover, .history-item.active { background: rgba(255,255,255,.68); }
.clear-history { min-height: 44px; margin: 0 2px 10px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.clear-history:hover { background: rgba(255,255,255,.68); color: var(--purple-dark); }
.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--line); }
.profile { gap: 10px; padding: 6px; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; overflow: hidden; border-radius: 50%; background: #e7dcff; color: var(--purple-dark); font-weight: 850; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.profile-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy span { color: var(--muted); font-size: 11px; }
.logout { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--muted); text-decoration: none; }

.chat { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; height: 100dvh; }
.topbar {
  z-index: 3;
  min-height: 66px;
  justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(252,250,255,.68);
  backdrop-filter: blur(18px);
}
.topbar-title { flex-direction: column; align-items: flex-start; gap: 3px; }
.topbar-title strong { font-size: 15px; }
.topbar-title span { color: var(--muted); font-size: 11px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #59b77d; }
.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 13px;
  background: rgba(255,255,255,.65);
  cursor: pointer;
}
.topbar-spacer { width: 44px; height: 44px; }

.messages { overflow-y: auto; scroll-behavior: smooth; }
.welcome { width: min(720px, calc(100% - 40px)); margin: min(12vh, 110px) auto 44px; text-align: center; }
.welcome-orbit { position: relative; width: 94px; height: 84px; margin: auto; }
.welcome-mark { width: 70px; height: 70px; margin: auto; border-radius: 24px; font-size: 34px; transform: rotate(-3deg); }
.spark { position: absolute; color: var(--peach); font-size: 25px; }
.spark-one { top: -7px; right: 1px; }
.spark-two { bottom: 4px; left: -1px; color: #9c7ee8; }
.welcome h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(38px, 7vw, 58px); letter-spacing: -.045em; }
.welcome > p:last-of-type { margin: 12px 0 30px; color: var(--muted); font-size: 18px; }
.starters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.starters button {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.64);
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.starters button:hover { transform: translateY(-2px); background: white; }
.starters span { color: var(--purple); font-size: 19px; }
.thread { width: min(760px, calc(100% - 34px)); margin: 28px auto; }
.message { display: flex; gap: 12px; margin: 22px 0; animation: rise .25s ease both; }
.message.user { justify-content: flex-end; }
.answer { max-width: min(650px, 88%); }
.bubble { padding: 13px 17px; border-radius: 20px; line-height: 1.62; }
.bubble p { margin: 0 0 .75em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h3, .bubble h4, .bubble h5 { margin: 1.05em 0 .4em; font-family: Georgia, serif; line-height: 1.18; }
.bubble ul, .bubble ol { margin: .45em 0 .8em; padding-left: 1.45em; }
.bubble li + li { margin-top: .3em; }
.bubble blockquote { margin: .7em 0; padding-left: .9em; border-left: 3px solid #b69de9; color: var(--muted); }
.bubble a { color: var(--purple-dark); font-weight: 700; }
.bubble pre { max-width: 100%; overflow-x: auto; padding: 12px; border-radius: 12px; background: #272131; color: #fff; }
.bubble code { padding: .12em .35em; border-radius: 5px; background: rgba(78,43,132,.09); font-size: .9em; }
.bubble pre code { padding: 0; background: transparent; }
.user .bubble { border-bottom-right-radius: 6px; background: var(--purple); color: white; }
.assistant .bubble { border: 1px solid var(--line); border-top-left-radius: 7px; background: rgba(255,255,255,.72); }
.assistant .speaker { display: grid; place-items: center; flex: 0 0 30px; height: 30px; margin-top: 4px; border-radius: 10px; background: var(--lavender); font-size: 15px; }
.assistant .speaker.fast { background: #fff0cf; }
.assistant .speaker.high { background: #e9ddff; color: var(--purple-dark); }
.assistant .speaker.sean { background: #ffd9ce; }
.mode-chip { display: inline-block; margin: 0 0 5px 5px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.user .mode-chip { display: none; }
.thinking .bubble::after { content: "  ●  ●  ●"; color: var(--purple); animation: pulse 1.2s infinite; }
.wait-copy { display: block; color: var(--muted); font-size: 13px; font-weight: 650; }
.error .bubble { border-color: #efb4b4; background: #fff1f1; color: #822d2d; }

.composer-wrap { z-index: 3; padding: 10px 22px max(13px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(248,245,255,.96) 25%); }
.mode-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(520px, 100%);
  margin: 0 auto 9px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.65);
  box-shadow: 0 8px 28px rgba(61,41,90,.07);
  backdrop-filter: blur(14px);
}
.mode {
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.mode strong, .mode small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode small { color: var(--muted); font-size: 11px; }
.mode.active { background: white; box-shadow: 0 4px 14px rgba(74,45,111,.12); }
.mode.active strong { color: var(--purple-dark); }
.mode[data-mode="fast"].active { background: #fff9e8; }
.mode[data-mode="high"].active { background: #f5efff; }
.mode[data-mode="sean"].active { background: #fff0eb; }
.mode-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(620px, 100%);
  margin: 0 auto 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.mode-guide strong { color: var(--purple-dark); }
.mode-guide > span { min-width: 0; }
.mode-guide button { min-height: 30px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--lavender); color: var(--purple-dark); font-size: 11px; font-weight: 800; cursor: pointer; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: min(760px, 100%);
  margin: auto;
  padding: 9px 9px 9px 18px;
  border: 1px solid rgba(77,49,111,.16);
  border-radius: 22px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 12px 38px rgba(67,43,98,.12);
}
.composer:focus-within { border-color: rgba(110,73,199,.45); box-shadow: 0 12px 38px rgba(67,43,98,.16), 0 0 0 3px rgba(110,73,199,.08); }
textarea {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-height: 150px;
  padding: 8px 0;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.45;
}
textarea::placeholder { color: #6d6476; }
.send {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--purple);
  color: white;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}
.send:disabled { opacity: .45; cursor: not-allowed; }
.fine-print { margin: 7px 0 0; color: #655d6c; font-size: 11px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.mobile-only { display: none; }
.scrim { display: none; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 20px 0 55px rgba(40,25,57,.18);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; z-index: 19; inset: 0; background: rgba(25,17,34,.28); backdrop-filter: blur(2px); }
  .scrim.open { display: block; }
  .topbar { min-height: 58px; padding: 8px 13px; }
  .topbar-title { align-items: center; }
  .welcome { width: calc(100% - 28px); margin-top: 7vh; }
  .welcome-orbit { transform: scale(.88); }
  .welcome > p:last-of-type { margin-bottom: 22px; font-size: 16px; }
  .starters { grid-template-columns: 1fr; }
  .starters button { min-height: 52px; }
  .composer-wrap { padding-inline: 10px; }
  .mode { flex-wrap: wrap; gap: 3px 5px; padding: 7px 4px; }
  .mode > span { flex: 0 0 100%; text-align: center; }
  .mode small { flex-basis: 100%; }
  .answer { max-width: 92%; }
  .mode-guide { flex-wrap: wrap; align-items: flex-start; line-height: 1.35; padding-inline: 10px; }
  .mode-guide > span { flex: 1 1 230px; }
  .mode-guide button { flex: 0 0 auto; }
  .composer { min-width: 0; }
}

@media (max-width: 420px) {
  .login-shell { place-items: start center; padding: 16px; }
  .login-card { margin: auto 0; padding: 36px 24px 28px; border-radius: 28px; }
  .mode-picker { border-radius: 14px; }
  .mode { font-size: 13px; }
  .thread { width: calc(100% - 22px); }
}

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