:root {
  --bg: #0d0f12;
  --panel: #161a1f;
  --text: #e6e3dc;
  --muted: #9a968d;
  --accent: #c9b78a;
  --line: #2a2f36;
  --visitor: #1d2530;
  --diplomat: #2a2419;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f4ef;
    --panel: #ffffff;
    --text: #1d1c1a;
    --muted: #66625a;
    --accent: #7a6532;
    --line: #dcd7cc;
    --visitor: #eef2f7;
    --diplomat: #f5efe1;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 Georgia, "Times New Roman", serif;
}
main { max-width: 760px; margin: 0 auto; padding: 48px 16px 80px; }
h1 { font-weight: normal; letter-spacing: 0.3em; text-transform: uppercase; font-size: 1.4rem; color: var(--accent); }
h2 { font-weight: normal; font-size: 1.1rem; margin-top: 2.5em; border-bottom: 1px solid var(--line); padding-bottom: 0.3em; }
p, li { color: var(--text); }
.muted, small { color: var(--muted); }
a { color: var(--accent); }
code, pre, textarea, input, button, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9rem; }
/* 16px keeps mobile Safari from zooming in when a field is focused. */
textarea, input, select { font-size: 16px; }
pre { background: var(--panel); border: 1px solid var(--line); padding: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
textarea, input {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 4px;
}
textarea { min-height: 110px; resize: vertical; }
button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.danger { color: #c96a5a; border-color: #c96a5a; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row > * { flex: 1 1 200px; }
.thread { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.msg { padding: 10px 14px; border-radius: 6px; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg.visitor { background: var(--visitor); }
.msg.diplomat { background: var(--diplomat); }
.msg .meta { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; font-family: ui-monospace, Menlo, monospace; }
.hidden { display: none; }
.channel-list { list-style: none; padding: 0; margin: 0; }
.channel-list li { padding: 8px; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 6px; cursor: pointer; }
.channel-list li.active { border-color: var(--accent); }
.status { color: var(--muted); font-size: 0.85rem; min-height: 1.4em; }

/* Diplomat console */
main.console { max-width: 640px; padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(48px, env(safe-area-inset-bottom)); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 8px 0; }
.check input { width: auto; }
button { min-height: 44px; }
button.quiet { color: var(--muted); border-color: var(--line); }
.channel-list li { padding: 12px; }
.channel-list li .title { font-size: 1.05rem; }
.channel-list li small { display: block; }
.channel-list li.awaiting { border-color: var(--accent); }
.channel-list li.awaiting small { color: var(--accent); }
.small { font-size: 0.75rem; word-break: break-all; }
details { margin-bottom: 8px; }
summary { cursor: pointer; color: var(--accent); padding: 6px 0; }
.row.secondary { margin-top: 24px; }

/* Origin questions */
#story { margin: 12px 0; }
#story textarea { min-height: 70px; margin: 6px 0; }
label.field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.9rem; }
select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  font-family: inherit;
}

.story-view { border-left: 2px solid var(--accent); padding: 4px 0 4px 12px; margin: 8px 0 16px; }
.story-view p { margin: 0 0 6px; font-size: 0.85rem; }
.story-view dl { margin: 0; }
.story-view dt { color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
.story-view dd { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }
