/* archive underground — see docs/architecture/UI_STYLE.md */
:root {
  --bg: #0B0B0A;
  --surface: #13120F;
  --hairline: #262420;
  --text: #E6E1D1;
  --muted: #7C776B;
  --accent: #C9A24A;
  --alert: #A5432A;
  --affirm: #5F7048;
  --mono: "Berkeley Mono", "JetBrains Mono", "IBM Plex Mono", ui-monospace,
    SFMono-Regular, Menlo, Consolas, monospace;
  --cjk: "Noto Sans HK", "Noto Sans TC", "Noto Sans SC", sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ECE6D3;
    --surface: #F6F1DE;
    --hairline: #C5BDA5;
    --text: #141310;
    --muted: #6A6455;
    --accent: #8A5A1A;
    --alert: #7A2A15;
    --affirm: #3F4E2A;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--mono);
  display: grid;
  grid-template-rows: 40px 1fr;
  grid-template-columns: 1fr 340px;
  grid-template-areas:
    "header header"
    "main   trace";
}
:lang(yue), :lang(zh-Hant), :lang(zh-Hans), :lang(ja), :lang(ko) { font-family: var(--cjk), var(--mono); }

.chrome {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
header.chrome {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
}
.label { color: var(--muted); }
.header-spacer { flex: 1; }
.session { color: var(--muted); }
.session span { color: var(--text); }

.lang-selector {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  padding: 4px 8px;
  cursor: pointer;
}
.lang-selector:hover, .lang-selector:focus-within { border-color: var(--accent); }
.lang-prefix { color: var(--muted); }
.lang-selector select {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  padding-right: 14px;
  cursor: pointer;
}
.lang-selector::after {
  content: "▾";
  color: var(--muted);
  margin-left: -16px;
  pointer-events: none;
}
.lang-selector select option { background: var(--surface); color: var(--text); }

main {
  grid-area: main;
  display: grid;
  grid-template-rows: 1fr 56px;
  overflow: hidden;
}

.dialogue {
  overflow-y: auto;
  padding: 24px 28px 16px;
}
.dialogue .msg { margin-bottom: 22px; max-width: 72ch; }
.dialogue .meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
  text-transform: lowercase;
}
.dialogue .meta .who { color: var(--accent); }
.dialogue .meta .time { margin-left: 8px; }
.dialogue .meta .lang { margin-left: 8px; }
.dialogue .body { white-space: pre-wrap; word-wrap: break-word; }
.dialogue .body.streaming::after {
  content: "▌";
  color: var(--accent);
  margin-left: 2px;
  animation: blink 0.8s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }
.dialogue .agent { border-left: 2px solid var(--accent); padding-left: 14px; }
.dialogue .system .body { color: var(--muted); font-style: italic; }
.dialogue .footer-src {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}
.dialogue .chip {
  display: inline-block;
  border: 1px solid var(--hairline);
  padding: 0 6px;
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-right: 6px;
  color: var(--muted);
}
.dialogue .chip.translated { color: var(--alert); border-color: var(--alert); }
.dialogue .chip.native { color: var(--affirm); border-color: var(--affirm); }

.warning-strip {
  background: var(--alert);
  color: var(--bg);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  padding: 6px 16px;
  margin: 0 0 16px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-top: 1px solid var(--hairline);
  border-bottom: none;
}
.prompt-glyph { color: var(--accent); }
.input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
}
.input-row input::placeholder { color: var(--muted); }
.input-row input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

aside.trace {
  grid-area: trace;
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  overflow-y: auto;
  padding: 14px 16px 20px;
}
.trace-head {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 6px;
}
.trace-list { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.trace-list li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--hairline);
  color: var(--text);
}
.trace-list li .idx { color: var(--muted); margin-right: 6px; }
.trace-list li .name { color: var(--accent); }
.trace-list li .status.ok { color: var(--affirm); }
.trace-list li .status.error, .trace-list li .status.timeout { color: var(--alert); }
.trace-list li .status.running { color: var(--accent); }
.trace-list li .status.rate_limited { color: var(--alert); }
.trace-list li .args { color: var(--muted); font-size: 11px; margin-left: 4px; }
.trace-list li .latency { color: var(--muted); margin-left: 8px; }

/* scanline overlay — dark theme only */
body[data-theme="dark"] .scanlines::before {
  content: "";
  position: fixed;
  inset: 40px 340px 0 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 9;
}
@media (prefers-reduced-motion: reduce) { .scanlines::before { display: none; } }

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--accent); }

/* mobile */
@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: 40px 1fr 180px;
    grid-template-areas:
      "header"
      "main"
      "trace";
  }
  aside.trace { border-left: none; border-top: 1px solid var(--hairline); }
  body[data-theme="dark"] .scanlines::before { inset: 40px 0 180px 0; }
}
