/* face together face: text only. white on black or black on white, plus one accent per face. */
:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #666666;
  --line: #000000;
  --face-l: 36%;      /* lightness of face accent colours in light theme */
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #000000; --fg: #ffffff; --muted: #9a9a9a; --line: #ffffff; --face-l: 66%; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #000000; --fg: #ffffff; --muted: #9a9a9a; --line: #ffffff; --face-l: 66%; color-scheme: dark; }
:root[data-theme="light"] { --bg: #ffffff; --fg: #000000; --muted: #666666; --line: #000000; --face-l: 36%; color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body { font-family: var(--mono); font-size: 15px; line-height: 1.45; min-height: 100vh; padding: 0 16px 48px; }
a { color: inherit; text-decoration: none; }
a:hover, .linklike:hover, .btn:hover { background: var(--fg); color: var(--bg); }
main { max-width: 84ch; margin: 0 auto; }
h1, h2, h3 { font-weight: normal; margin: 1.2em 0 .5em; }
h1 { font-size: 1.4em; } h2 { font-size: 1.15em; } h3 { font-size: 1em; }
h2::before { content: "== "; color: var(--muted); }
h3::before { content: "-- "; color: var(--muted); }
p { margin: .6em 0; }
hr { border: 0; border-top: 1px dashed var(--line); margin: 1.5em 0; }
pre { margin: 0; font-family: var(--mono); }
.muted { color: var(--muted); }
.tiny { font-size: .8em; }
.center { text-align: center; }
.hidden { display: none !important; }
code { background: none; }

/* off-screen but still part of the page text (not display:none); aria-hidden keeps it from screen readers */
.for-agents { position: absolute; left: -10000px; top: 0; width: 1px; height: 1px; overflow: hidden; }

/* header */
#header { max-width: 84ch; margin: 0 auto; padding: 14px 0; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; justify-content: space-between; border-bottom: 1px dashed var(--line); }
#header .brand { font-weight: bold; letter-spacing: .04em; }
#header nav { display: flex; flex-wrap: wrap; gap: 4px 12px; }
#header nav .active { text-decoration: underline; }
.badge { color: var(--fg); font-weight: bold; }

/* buttons as text */
.btn, .linklike { font: inherit; color: inherit; background: none; border: 0; padding: 0 2px; cursor: pointer; white-space: nowrap; }
.btn.primary { font-weight: bold; }
.btn:disabled { color: var(--muted); cursor: default; background: none; }
.btn.big { font-size: 1.15em; padding: 4px 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: .8em 0; }

select, input { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); padding: 3px 6px; }
label { cursor: pointer; }

/* faces */
.face { font-family: var(--mono); line-height: 1; letter-spacing: 0; font-size: 11px; white-space: pre; display: inline-block; text-align: left; user-select: none; }
.face.lg { font-size: clamp(9px, 2.2vw, 16px); }
.face.md { font-size: 12px; }
.face .c1 { color: hsl(var(--h1, 0) 78% var(--face-l)); }
.face .c2 { color: hsl(var(--h2, 180) 70% var(--face-l)); }
.face.clickable { cursor: pointer; }
.facelink, .facelink:hover { background: none; color: inherit; display: block; }
.facelink:hover .face { outline: 1px dashed var(--muted); outline-offset: 4px; }
.face.speaking { outline: 1px dashed var(--muted); outline-offset: 6px; }

/* message cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin: 1em 0; }
.card { border: 1px dashed var(--line); padding: 10px 10px 8px; text-align: center; display: flex; flex-direction: column; gap: 8px; }
.card.highlight { border-style: solid; border-width: 2px; }
.card .card-actions { display: flex; justify-content: center; }
.bubble { display: inline-block; border: 1px solid var(--line); border-radius: 12px; padding: 2px 10px; }
.bubble:hover { background: var(--fg); color: var(--bg); }

/* home */
.home-actions { margin: 0 0 12px; }
.home .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.flow { white-space: pre; overflow-x: auto; font-size: .85em; color: var(--muted); padding: 8px 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

/* qr */
.qr-wrap { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.qr-wrap canvas { width: 100%; max-width: 320px; height: auto; image-rendering: pixelated; border: 1px solid var(--line); background: #fff; }
.qr-text { font-size: 6px; line-height: 1; letter-spacing: 0; white-space: pre; background: #fff; color: #000; padding: 6px; display: inline-block; max-width: 100%; overflow: auto; }
details summary { cursor: pointer; }

/* recorder modal */
.modal { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 75%, transparent); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-box { background: var(--bg); border: 1px solid var(--line); padding: 18px 20px; max-width: 46rem; width: 100%; }
.modal-title { font-weight: bold; margin-bottom: 6px; }
.modal-title::before { content: "> "; }
.rec-meter { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--fg); }
.rec-dot.live { background: var(--fg); animation: blink 1s steps(2) infinite; }
@keyframes blink { to { opacity: .2; } }
.rec-bar { flex: 1; height: 4px; border: 1px solid var(--line); }
.rec-fill { display: block; height: 100%; background: var(--fg); width: 100%; transition: width .1s linear; }
.rec-text { min-height: 3.5em; border: 1px dashed var(--muted); padding: 8px; margin: 8px 0; white-space: pre-wrap; word-break: break-word; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.dev-input { width: 100%; }

/* login steps */
.step { border-left: 3px solid var(--line); padding: 4px 14px; margin: 18px 0; }
.heard { border: 1px dashed var(--muted); padding: 8px 10px; margin: 8px 0; white-space: pre-wrap; }
.genlog { color: var(--muted); font-size: .85em; min-height: 6em; white-space: pre-wrap; }

#busy { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 55; padding: 16px; }
#busy .busy-text { font-size: 1.1em; }
@media (max-width: 700px) { #step-gen .two-col .center { order: -1; } }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--fg); color: var(--bg); padding: 8px 14px; opacity: 0; transition: all .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  body { font-size: 14px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 6px; }
  .face { font-size: 8.5px; }
}
