:root {
  --bg: #1c1712;
  --paper: #241e18;
  --paper-2: #2c241c;
  --ink: #f3ead8;
  --muted: #9a8c78;
  --line: #3d342b;
  --copper: #c9843a;
  --live: #6aae86;
  --tool: #7a9bb8;
  --user: #3a3228;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: "Noto Sans SC", "Source Han Sans SC", sans-serif; }
body { display: grid; grid-template-rows: auto 1fr; }
.grain { pointer-events: none; position: fixed; inset: 0; opacity: 0.06; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

header { display: flex; align-items: center; gap: 24px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; }
.mark { width: 12px; height: 12px; background: var(--copper); }
h1 { margin: 0; font-family: "Noto Serif SC", serif; font-size: 22px; letter-spacing: 0.14em; font-weight: 600; }
.kicker { margin: 2px 0 0; font-size: 10px; letter-spacing: 0.32em; color: var(--copper); }
.filters { display: flex; gap: 8px; flex: 1; min-width: 0; }
select, input, textarea, button { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 2px; padding: 8px 10px; }
select { min-width: 0; flex: 1; }
button { background: var(--copper); color: #1c1712; border-color: var(--copper); cursor: pointer; letter-spacing: 0.08em; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }

main { display: grid; grid-template-columns: 280px 1fr; min-height: 0; }
aside { border-right: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
h2 { margin: 0; font-size: 11px; letter-spacing: 0.2em; color: var(--muted); font-weight: 500; }
.chk { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
#sessionList { list-style: none; margin: 0; padding: 0; overflow: auto; }
#sessionList li { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
#sessionList li:hover, #sessionList li.sel { background: var(--paper-2); }
#sessionList .sid { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6b6258; margin-right: 6px; }
.dot.live { background: var(--live); }

.chat { display: grid; grid-template-rows: 1fr auto; min-height: 0; }
.thread { overflow: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 72%; padding: 10px 12px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--user); border: 1px solid var(--line); }
.bubble.assistant { align-self: flex-start; background: var(--paper-2); border: 1px solid var(--line); }
.bubble.tool_call, .bubble.tool_result { align-self: flex-start; max-width: 86%; background: #1a2228; border: 1px solid #31404c; color: #c5d4e0; font-family: ui-monospace, monospace; font-size: 12px; }
.bubble .who { display: block; font-size: 10px; letter-spacing: 0.14em; color: var(--copper); margin-bottom: 4px; }
footer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
#prompt { resize: none; }
.empty { color: var(--muted); padding: 24px; }

.login-body { display: grid; place-items: center; }
.gate { width: min(420px, 92vw); padding: 36px 32px; background: var(--paper); border: 1px solid var(--line); display: grid; gap: 12px; }
.gate h1 { font-size: 28px; }
.gate .hint { margin: 0; color: var(--muted); font-size: 13px; }
.gate input { width: 100%; }
