@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/inter-500-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/inter-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/inter-600-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/inter-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #111111;
  --muted: #5f5f5f;
  --line: #e4e4e7;
  --surface: #ffffff;
  --chip: #f4f4f5;
  --user: #f4f4f5;
  --code: #f4f4f5;
  --accent: #0f8f6f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(15, 143, 111, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 28px rgba(0, 0, 0, 0.05);
  --top: rgba(255, 255, 255, 0.9);
  --danger: #b42318;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #212121;
    --text: #ececec;
    --muted: #a3a3a3;
    --line: #3f3f3f;
    --surface: #2f2f2f;
    --chip: #2a2a2a;
    --user: #303030;
    --code: #3a3a3a;
    --accent: #1aa37a;
    --accent-ink: #ffffff;
    --accent-soft: rgba(26, 163, 122, 0.24);
    --shadow: none;
    --top: rgba(33, 33, 33, 0.92);
    --danger: #f0a8a0;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }

.shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: var(--top);
  backdrop-filter: blur(10px);
}
.brand { min-width: 0; display: flex; flex-direction: column; }
.brand-name { font-weight: 600; font-size: 0.95rem; letter-spacing: -0.02em; }
.brand-role {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(16rem, 58vw);
}
.shell:not(.has-chat) .brand { visibility: hidden; }
.lang { display: flex; gap: 0.25rem; flex: none; }
.lang a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 0.28rem 0.5rem;
}
.lang a[aria-current="true"] { color: var(--text); background: var(--chip); }
.lang a:focus-visible, .suggest:focus-visible, .send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.thread {
  flex: 1;
  min-height: 0;
  width: min(46rem, 100%);
  margin: 0 auto;
  padding: 0 1rem;
}
.shell:not(.has-chat) .thread {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.shell.has-chat .thread { overflow-y: auto; padding-top: 0.5rem; padding-bottom: 1rem; }

.hero { text-align: center; padding: 0 0.25rem 1rem; }
.hero h1 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.lede {
  margin: 0.45rem auto 0;
  max-width: 38rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.transcript { display: flex; flex-direction: column; gap: 1.15rem; width: 100%; }
.msg.user {
  align-self: flex-end;
  max-width: min(34rem, 88%);
  background: var(--user);
  border-radius: 1.25rem;
  padding: 0.65rem 0.9rem;
  white-space: pre-wrap;
}
.msg.assistant { width: 100%; }
.msg .who {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}
.md p { margin: 0 0 0.65rem; }
.md p:last-child { margin-bottom: 0; }
.md ul { margin: 0 0 0.65rem; padding-left: 1.15rem; }
.md a { color: var(--accent); }
.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code);
  border-radius: 0.35rem;
  padding: 0.1rem 0.3rem;
}
.md pre {
  margin: 0 0 0.65rem;
  padding: 0.75rem 0.85rem;
  background: var(--code);
  border-radius: 0.75rem;
  overflow-x: auto;
}
.md pre code { background: none; padding: 0; }

.typing { display: flex; gap: 0.28rem; align-items: center; height: 1.4rem; }
.typing i {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--muted);
  display: block;
  animation: blink 1s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.balance { flex: 1; }
.shell.has-chat .balance { display: none; }
.dock {
  width: min(46rem, 100%);
  margin: 0 auto;
  padding: 0.35rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.box {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 1.6rem;
  padding: 0.4rem 0.4rem 0.4rem 0.95rem;
  box-shadow: var(--shadow);
}
.box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea {
  flex: 1;
  resize: none;
  border: 0;
  margin: 0;
  padding: 0.55rem 0;
  min-height: 1.6rem;
  max-height: 9rem;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
}
textarea:focus { outline: none; }
textarea::placeholder { color: var(--muted); }
.send {
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.send:disabled { opacity: 0.35; cursor: default; }
.turnstile { display: flex; justify-content: center; }
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.shell.has-chat .chips { display: none; }
.suggest {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.35;
  cursor: pointer;
}
.suggest:hover { border-color: var(--muted); }
.status, .fine, .noscript {
  margin: 0.55rem 0.15rem 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
}
.status { color: var(--danger); }
.fine { flex-basis: 100%; }
.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: 640px) {
  .chips { flex-direction: column; align-items: stretch; }
  .suggest { border-radius: 0.85rem; text-align: left; }
  .brand-role { max-width: 11rem; }
  .hero { padding-bottom: 0.75rem; }
}

@media (min-width: 720px) {
  .brand-role { max-width: 36rem; }
}

@media (prefers-reduced-motion: reduce) {
  .typing i { animation: none; opacity: 0.7; }
}
