:root {
  --ink: #07060b;
  --surface: #0f0d17;
  --elevated: #161322;
  --border: #2a2440;
  --fg: #e8e3f5;
  --muted: #9a93b3;
  --violet: #9c83dd;
  --gold: #d5b763;
  --cyan: #5ad4d8;
  --danger: #e07a7a;
  --ok: #6ec9a8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--fg); }
body {
  font: 16px/1.55 Georgia, "Iowan Old Style", serif;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(156, 131, 221, 0.22), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(213, 183, 99, 0.08), transparent 55%),
    var(--ink);
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
[hidden] { display: none !important; }
.chamber { max-width: 52rem; min-height: 100%; margin: 0 auto; padding: 1.25rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.chamber-head { display: flex; align-items: center; gap: 0.85rem; }
.sigil { font-size: 2rem; color: var(--violet); text-shadow: 0 0 18px rgba(156, 131, 221, 0.7); }
.title-block { flex: 1; }
h1 { margin: 0; font-size: 1.55rem; letter-spacing: 0.08em; font-weight: 500; color: var(--gold); }
.kicker { margin: 0; color: var(--muted); font-size: 0.85rem; letter-spacing: 0.04em; }
h2 { margin: 0 0 0.4rem; font-weight: 500; color: var(--gold); font-size: 1.15rem; }
a { color: var(--cyan); }
.standalone-link { font-size: 0.85rem; }
.status-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; padding: 0.55rem 0.8rem; border: 1px solid var(--border); border-radius: 0.6rem; background: var(--surface); font-size: 0.9rem; }
#status-text { flex: 1 1 14rem; }
.status-dot { flex: none; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--muted); box-shadow: 0 0 8px currentColor; }
.status-dot[data-tone="ok"] { background: var(--ok); color: var(--ok); }
.status-dot[data-tone="wait"] { background: var(--gold); color: var(--gold); }
.status-dot[data-tone="bad"] { background: var(--danger); color: var(--danger); }
.status-meta { color: var(--muted); font-size: 0.8rem; margin-left: auto; }
.threshold, .room { border: 1px solid var(--border); border-radius: 0.8rem; background: rgba(15, 13, 23, 0.85); padding: 1rem; }
.threshold p { color: var(--muted); margin: 0 0 0.8rem; font-size: 0.92rem; }
#key-form { display: flex; gap: 0.5rem; }
input, textarea { flex: 1; width: 100%; background: var(--elevated); color: var(--fg); border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.65rem 0.75rem; font: inherit; }
textarea { resize: vertical; min-height: 4.5rem; max-height: 40vh; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
button { font: inherit; border: 0; border-radius: 0.5rem; padding: 0.6rem 1.1rem; background: var(--gold); color: var(--ink); cursor: pointer; min-height: 2.75rem; }
button:disabled { opacity: 0.5; cursor: progress; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); padding: 0.35rem 0.75rem; min-height: 2.25rem; font-size: 0.85rem; }
button.ghost:hover { color: var(--fg); border-color: var(--violet); }
.room { flex: 1; display: flex; flex-direction: column; gap: 0.75rem; min-height: 55vh; }
.room-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.session-label { flex: 1; color: var(--muted); font-size: 0.8rem; font-family: ui-monospace, monospace; }
.thread { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.65rem; max-height: 62vh; }
.thread li { padding: 0.6rem 0.8rem; border-radius: 0.6rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 92%; }
.thread li .who { display: block; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.2rem; }
.thread li.user { align-self: flex-end; background: var(--surface); color: var(--gold); border: 1px solid rgba(213, 183, 99, 0.25); }
.thread li.assistant { align-self: flex-start; background: var(--elevated); border: 1px solid rgba(90, 212, 216, 0.3); }
.thread li.pending { color: var(--muted); font-style: italic; }
.thread li.empty { align-self: center; color: var(--muted); border: 1px dashed var(--border); text-align: center; }
.notice { margin: 0; padding: 0.55rem 0.8rem; border-radius: 0.5rem; border: 1px solid rgba(224, 122, 122, 0.45); background: rgba(224, 122, 122, 0.08); font-size: 0.9rem; }
.notice[data-tone="info"] { border-color: rgba(213, 183, 99, 0.45); background: rgba(213, 183, 99, 0.08); }
.composer { display: flex; flex-direction: column; gap: 0.4rem; }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.counter { color: var(--muted); font-size: 0.78rem; }
.chamber-foot { color: var(--muted); font-size: 0.78rem; text-align: center; }
/* Docked inside a Cathedral host frame: drop the outer chrome, keep the room. */
.embedded .chamber { padding: 0.6rem; max-width: none; }
.embedded .chamber-head h1 { font-size: 1.2rem; }
.embedded .sigil { font-size: 1.4rem; }
@media (max-width: 560px) {
  .chamber { padding: 0.75rem 0.6rem; }
  #key-form { flex-direction: column; }
  .thread li { max-width: 100%; }
  .status-meta { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .thread li.pending::after { content: ' ⋯'; animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.3; } }
}
