:root {
  --bg: #ffffff; --fg: #0d0d0d; --muted: #6b6b6b; --faint: #9a9a9a;
  --bubble: #f2f2f2; --field: #f7f7f8; --border: #e3e3e3; --accent: #0d0d0d; --accent-fg: #fff;
  --chip: #ffffff; --chip-hover: #f2f2f2; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #212121; --fg: #ececec; --muted: #a8a8a8; --faint: #7a7a7a;
    --bubble: #2f2f2f; --field: #2f2f2f; --border: #3a3a3a; --accent: #ececec; --accent-fg: #171717;
    --chip: #262626; --chip-hover: #2f2f2f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; display: flex; flex-direction: column;
}
main { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.col { max-width: 800px; margin: 0 auto; padding: 0 16px; }

/* empty state */
.hero { min-height: calc(100vh - 262px); display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.hero h1 { font-size: 28px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 6px; }
.hero p { margin: 0 0 28px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1px solid var(--border); background: var(--chip); color: var(--fg); border-radius: 999px;
  padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer; transition: background .15s;
}
.chip:hover { background: var(--chip-hover); }

/* thread */
.thread { padding: 24px 0 8px; }
.msg { margin: 0 0 28px; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.user { display: flex; justify-content: flex-end; }
.user .bubble { background: var(--bubble); padding: 10px 16px; border-radius: 20px; max-width: 75%; white-space: pre-wrap; }
.bot .head { margin: 0 0 2px; }
.bot .head b { font-weight: 600; }
.bot .sub { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.bot .note { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.media { position: relative; border-radius: 14px; overflow: hidden; background: var(--field); aspect-ratio: 1920 / 858; box-shadow: var(--shadow); }
.media img, .media video { display: block; width: 100%; height: 100%; object-fit: cover; }
.bar { display: flex; align-items: center; gap: 14px; margin-top: 8px; font-size: 13px; color: var(--faint); }
.bar a, .bar button { color: var(--muted); text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.bar a:hover, .bar button:hover { color: var(--fg); }
.bar .spacer { flex: 1; }
.pill { font-size: 12px; color: var(--muted); }
.pill .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.bot .chips { justify-content: flex-start; margin-top: 10px; }
.err { color: #d4483f; }

/* composer */
footer { padding: 8px 0 max(14px, env(safe-area-inset-bottom)); background: var(--bg); }
.composer {
  display: flex; align-items: flex-end; gap: 8px; background: var(--field); border: 1px solid var(--border);
  border-radius: 26px; padding: 8px 8px 8px 18px; box-shadow: var(--shadow);
}
textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--fg);
  font: inherit; line-height: 24px; max-height: 160px; padding: 6px 0;
}
textarea::placeholder { color: var(--faint); }
.send {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg);
  display: grid; place-items: center; cursor: pointer; flex: none; transition: opacity .15s;
}
.send:disabled { opacity: .25; cursor: default; }
.fine { text-align: center; color: var(--faint); font-size: 12px; margin-top: 8px; }
@media (max-width: 600px) { .hero h1 { font-size: 23px; } .user .bubble { max-width: 88%; } }

/* top-left menu: aspect ratio for new replies + sign out */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; padding: 0 12px; background: var(--bg); z-index: 10; }
.menu-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--fg); font: inherit; font-size: 15px; font-weight: 600; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--chip-hover); }
.menu-btn .muted { color: var(--muted); font-weight: 400; }
.menu { position: absolute; top: 46px; left: 12px; min-width: 230px; background: var(--chip); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.menu[hidden] { display: none; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; color: var(--fg); font: inherit; font-size: 14px; text-align: left; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.menu button:hover { background: var(--chip-hover); }
.menu .shape { width: 22px; display: grid; place-items: center; }
.menu .shape i { display: block; border: 1.5px solid currentColor; border-radius: 3px; }
.menu .label { flex: 1; }
.menu .label small { display: block; color: var(--muted); font-size: 12px; }
.menu .check { width: 16px; color: var(--fg); visibility: hidden; }
.menu button[aria-checked="true"] .check { visibility: visible; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }
main { padding-top: 52px; }
.media.portrait { aspect-ratio: 1080 / 1350; max-width: 440px; }

/* sign-in page */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; text-align: center; }
.login h1 { font-size: 24px; font-weight: 600; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.login .composer { padding: 6px 6px 6px 18px; }
.login input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--fg); font: inherit; padding: 8px 0; min-width: 0; }
.login .msg-err { color: #d4483f; font-size: 14px; min-height: 22px; margin-top: 10px; }
.menu .shape i.wide { width: 20px; height: 9px; }
.menu .shape i.tall { width: 12px; height: 15px; }
