/* MNEMOSYNE design system (spec §12): black field, thin lines, monospaced numbers, colour carries meaning
   and is always paired with a word. */
:root {
  --void: #05070E;
  --panel: #0C1222;
  --line: #1B2440;
  --text: #E4EAF7;
  --muted: #7E8AA8;
  --cyan: #38D9F5;
  --amber: #FFB13B;
  --green: #3EE59A;
  --red: #FF5A6E;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--void);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body::before { /* fade the grid so it stays faint */
  content: ""; position: fixed; inset: 0; background: rgba(5, 7, 14, 0.9); pointer-events: none; z-index: -1;
}

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--void);
  position: sticky; top: 0; z-index: 2;
}
.brand { font: 700 14px var(--mono); letter-spacing: 0.3em; }
.status { font: 12px var(--mono); letter-spacing: 0.12em; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status.online { color: var(--green); } .status.online .dot { background: var(--green); }
.status.offline { color: var(--red); }  .status.offline .dot { background: var(--red); }

.label { font: 12px var(--mono); letter-spacing: 0.16em; color: var(--cyan); margin: 0 0 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }

/* pairing */
.pair { padding: 24px 16px; }
.pair form { display: flex; gap: 8px; margin-top: 12px; }
.error { color: var(--red); min-height: 1.4em; margin: 8px 0 0; }

/* chat */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.log { list-style: none; margin: 0; padding: 16px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.turn { display: flex; flex-direction: column; gap: 6px; }
.who { font: 11px var(--mono); letter-spacing: 0.16em; }
.who.me { color: var(--amber); } .who.mnemo { color: var(--cyan); }
.who time { color: var(--muted); margin-left: 8px; letter-spacing: 0.04em; }
.bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; border-color: #3a2c14; max-width: 88%; }
.bubble.pending { color: var(--muted); }
.bubble.failed { border-color: var(--red); }
.actions { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.actions li { font: 12px var(--mono); color: var(--muted); }
.actions .ok { color: var(--green); } .actions .rejected, .actions .error { color: var(--red); }
.meta { font: 11px var(--mono); color: var(--muted); }
.notice { color: var(--amber); }
.empty { color: var(--muted); text-align: center; margin-top: 30vh; font: 13px var(--mono); letter-spacing: 0.1em; }

.quick { display: flex; gap: 8px; padding: 0 16px 8px; overflow-x: auto; }
.quick button { background: transparent; border: 1px solid var(--line); color: var(--muted); font: 12px var(--mono); letter-spacing: 0.08em; padding: 0 14px; min-height: 36px; border-radius: 18px; white-space: nowrap; }

.composer { display: flex; gap: 8px; padding: 8px 16px 12px; border-top: 1px solid var(--line); background: var(--void); }
input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 16px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 24px;
  font: 16px var(--sans); /* 16px stops iOS zooming on focus */
}
input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
button { min-height: 48px; min-width: 48px; border-radius: 24px; border: 0; background: var(--cyan); color: var(--void); font: 700 16px var(--sans); cursor: pointer; padding: 0 16px; }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.link { background: none; color: var(--muted); font: 12px var(--mono); min-height: 36px; margin: 0 auto 8px; }

@media (prefers-reduced-motion: no-preference) {
  .bubble.pending::after { content: ""; animation: dots 1.2s steps(4) infinite; }
  @keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
}
