:root {
  --bg: #0b0f14;
  --panel: #0f1620;
  --muted: #8b98a5;
  --text: #e6edf3;
  --line: #1f2a37;
  --accent: #22d3ee;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0,0,0,0.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "JetBrains Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Inter, Roboto, Arial;
}
:root[data-theme="light"] {
  --bg: #f7fafc;
  --panel: #ffffff;
  --muted: #5b6470;
  --text: #0b1220;
  --line: #e6e8eb;
  --accent: #0ea5e9;
  --shadow: 0 8px 28px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); line-height: 1.45;
}

.app {
  display: grid; grid-template-rows: auto 1fr auto auto;
  height: 100dvh; max-width: 980px; margin: 0 auto; padding: 16px; gap: 12px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.3px; }
.caret { font-family: var(--mono); color: var(--accent); }
.title { font-size: 16px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }

.actions { display: flex; gap: 6px; }
button.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 6px 8px; border-radius: 10px; cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: var(--accent); }

.chat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; overflow: auto; box-shadow: var(--shadow);
}

.message {
  display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: flex-start;
  padding: 8px; border-radius: 12px; margin: 4px 0;
}
.avatar {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px;
}
.avatar.user { background: rgba(52,211,153,0.12); border: 1px solid rgba(52,211,153,0.35); color: #34d399; }
.avatar.bot  { background: rgba(34,211,238,0.12); border: 1px solid rgba(34,211,238,0.35); color: var(--accent); }

.bubble {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.03));
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.meta { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.role { font-family: var(--mono); }
.time { font-variant-numeric: tabular-nums; }

.text { font-size: 15px; }
.text p { margin: 0 0 0.6em 0; }
.text code { font-family: var(--mono); font-size: 0.95em; padding: 0.1em 0.35em; border-radius: 6px; background: rgba(125,211,252,0.15); border: 1px solid rgba(34,211,238,0.25); }

pre { margin: 8px 0; padding: 10px 12px; background: #090d12; border: 1px solid #17212b; border-radius: 10px; overflow: auto; }
:root[data-theme="light"] pre { background: #f3f5f7; border-color: #e2e5e8; }
pre code { font-family: var(--mono); font-size: 13px; display: block; }
pre .copy {
  float: right; margin-left: 8px; transform: translateY(-6px);
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; padding: 4px 6px; border-radius: 6px; cursor: pointer;
}

.composer {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow);
}
#prompt {
  width: 100%; resize: none; border: none; outline: none; background: transparent; color: var(--text);
  font-size: 15px; line-height: 1.4; font-family: var(--mono);
  padding: 10px 12px; border-radius: 8px;
}
#prompt::placeholder { color: var(--muted); }

.send {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(34,211,238,0.12), rgba(34,211,238,0.02)); color: var(--text);
}

.hint { text-align: center; color: var(--muted); font-size: 12px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
