@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #08090b;
  --panel: #0e1116;
  --panel-2: #12171e;
  --line: #1d242d;
  --line-soft: #161c24;
  --text: #e9eef5;
  --muted: #8d9aab;
  --dim: #5f6b7b;
  --accent: #6ee7ff;
  --accent-dim: #2b5f6d;
  --good: #3ddc97;
  --warn: #ff6b6b;
  --violet: #b18cff;
  --radius: 14px;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must win over the display rules below. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1100px 520px at 50% -12%, rgba(110, 231, 255, 0.07), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 18px;
}

/* ---------------------------------------------------------------- header */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 2px 14px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, rgba(8, 9, 11, 0.96), rgba(8, 9, 11, 0.86));
  backdrop-filter: blur(8px);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 11px; }

.mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--panel-2), #0a0d11);
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-text .dot { color: var(--accent); }
.brand-text .sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #7e8b9c;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.model-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--panel);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button { font: inherit; color: inherit; cursor: pointer; }

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.ghost:hover { color: var(--text); border-color: #2a3441; background: var(--panel-2); }

/* ----------------------------------------------------------------- thread */

.thread {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 6px 8px 2px;
  scrollbar-width: thin;
  scrollbar-color: #232b35 transparent;
}
.thread::-webkit-scrollbar { width: 8px; }
.thread::-webkit-scrollbar-thumb { background: #232b35; border-radius: 8px; }

.empty { padding: 8vh 0 0; max-width: 620px; }
.empty h1 {
  font-size: clamp(24px, 4.4vw, 31px);
  line-height: 1.18;
  letter-spacing: -0.025em;
  margin: 0 0 10px;
  font-weight: 600;
}
.empty p { color: var(--muted); font-size: 14.5px; margin: 0 0 22px; max-width: 54ch; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 13px;
  text-align: left;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  transition: color .16s ease, border-color .16s ease, transform .16s ease;
}
.chip:hover { color: var(--text); border-color: var(--accent-dim); transform: translateY(-1px); }

.msg { display: flex; gap: 12px; margin: 0 0 22px; animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg .avatar {
  flex: 0 0 27px; height: 27px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  margin-top: 2px;
}
.msg.user .avatar { color: var(--text); background: var(--panel-2); }
.msg.assistant .avatar { color: var(--accent); border-color: var(--accent-dim); }

.bubble { min-width: 0; flex: 1; }

.msg.user .bubble .body {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.body { overflow-wrap: anywhere; }
.body > *:first-child { margin-top: 0; }
.body > *:last-child { margin-bottom: 0; }
.body p { margin: 0 0 10px; }
.body h1, .body h2, .body h3 { font-size: 15.5px; font-weight: 600; margin: 16px 0 8px; letter-spacing: -0.01em; }
.body ul, .body ol { margin: 0 0 10px; padding-left: 22px; }
.body li { margin: 3px 0; }
.body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-dim); }
.body a:hover { border-bottom-color: var(--accent); }
.body strong { font-weight: 600; color: #f4f8fc; }
.body code {
  font-family: var(--mono);
  font-size: 12.8px;
  background: #10151b;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 1px 5px;
}
.body pre {
  position: relative;
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 44px 12px 13px;
  overflow-x: auto;
  margin: 0 0 12px;
}
.body pre code {
  background: none; border: 0; padding: 0;
  font-size: 12.6px; line-height: 1.5;
}
.code-copy {
  position: absolute;
  top: 7px; right: 7px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  background: #10151b;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  opacity: 0;
  transition: opacity .15s ease, color .15s ease;
}
.body pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--text); }

.body blockquote {
  margin: 0 0 10px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
  color: var(--muted);
}
.body hr { border: 0; border-top: 1px solid var(--line-soft); margin: 14px 0; }

.caret {
  display: inline-block;
  width: 7px; height: 15px;
  translate: 1px 2px;
  background: var(--accent);
  border-radius: 1px;
  animation: blink 1.05s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.msg-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity .18s ease;
}
.msg:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.tool {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 3px 8px;
  transition: color .16s ease, border-color .16s ease;
}
.tool:hover { color: var(--text); border-color: var(--line); }

.msg.error .body {
  border: 1px solid #402026;
  background: #14090b;
  color: #ffc7cc;
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 14px;
}

/* --------------------------------------------------------------- composer */

.composer { padding: 10px 0 16px; position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 62%, transparent); }

.field {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 8px 8px 8px 14px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.field:focus-within { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(110, 231, 255, 0.07); }

textarea#input {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.55;
  max-height: 190px;
  padding: 6px 0;
}
textarea#input::placeholder { color: var(--dim); }

.send, .stop {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--accent-dim);
  background: linear-gradient(170deg, #123b45, #0d2a32);
  color: var(--accent);
  transition: filter .16s ease, opacity .16s ease;
}
.send:hover, .stop:hover { filter: brightness(1.22); }
.send:disabled { opacity: .38; cursor: not-allowed; filter: none; }
.stop { border-color: #40202a; background: #1a0e12; color: var(--warn); }

.hint {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: #7e8b9c;
  padding: 8px 4px 0;
}
.status.busy::after { content: "…"; animation: blink 1.2s steps(2, start) infinite; }
.status.err { color: var(--warn); }

@media (max-width: 560px) {
  .app { padding: 0 12px; }
  .brand-text .sub { display: none; }
  .hint span:first-child { display: none; }
  .empty { padding-top: 4vh; }
  .msg { gap: 9px; }
  .msg .avatar { flex-basis: 24px; height: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
