/* ---- css/game.css ---- */
/* ==========================================================================
   gamos — design tokens, base components, arcade
   Every colour comes from a token, so the four themes only need to redefine them.
   ========================================================================== */

:root,
[data-theme="minimal"] {
  color-scheme: dark;
  --bg: #080a12;
  --glow-a: rgba(46, 230, 246, 0.10);
  --glow-b: rgba(255, 77, 157, 0.07);
  --surface: #10131f;
  --card: #161a2a;
  --card-hover: #1c2136;
  --field: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.2);
  --accent: #2ee6f6;
  --accent-ink: #04151a;
  --accent-soft: rgba(46, 230, 246, 0.14);
  --a2: #ff4d9d;
  --a3: #ffd84a;
  --text: #eef2f9;
  --muted: #8f9ab2;
  --faint: #5d6882;
  --danger: #fb5b7a;
  --danger-soft: rgba(251, 91, 122, 0.14);
  --ok: #34d399;
  --stage: #070911;
  --overlay: rgba(6, 8, 16, 0.78);
  --radius: 16px;
  --radius-sm: 10px;
  --bw: 1px;
  --card-shadow: none;
  --lift: 0 18px 50px rgba(0, 0, 0, 0.55);
  --glow: 0 0 22px rgba(46, 230, 246, 0.25);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="paul-rand"] {
  --bg: #111216;
  --glow-a: rgba(255, 213, 0, 0.07);
  --glow-b: rgba(255, 34, 0, 0.05);
  --surface: #1a1b21;
  --card: #22232b;
  --card-hover: #2b2c36;
  --field: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.28);
  --accent: #ffd500;
  --accent-ink: #14120a;
  --accent-soft: rgba(255, 213, 0, 0.15);
  --a2: #ff3b1d;
  --a3: #4a7bff;
  --text: #ffffff;
  --muted: #a6abb7;
  --faint: #6c7080;
  --danger: #ff3b1d;
  --danger-soft: rgba(255, 59, 29, 0.16);
  --ok: #00cc66;
  --stage: #141416;
  --overlay: rgba(14, 14, 16, 0.82);
  --radius: 8px;
  --radius-sm: 6px;
  --glow: none;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

[data-theme="tadao-ando"] {
  --bg: #14161a;
  --glow-a: rgba(245, 237, 224, 0.05);
  --glow-b: transparent;
  --surface: #1d1f24;
  --card: #25282e;
  --card-hover: #2c3037;
  --field: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.22);
  --accent: #ece5d8;
  --accent-ink: #17181b;
  --accent-soft: rgba(236, 229, 216, 0.12);
  --a2: #c8ccd6;
  --a3: #8f96a5;
  --text: #eef0f4;
  --muted: #8d93a4;
  --faint: #626879;
  --danger: #e27d85;
  --danger-soft: rgba(226, 125, 133, 0.14);
  --ok: #98c379;
  --stage: #1a1c20;
  --overlay: rgba(18, 20, 24, 0.82);
  --radius: 3px;
  --radius-sm: 2px;
  --lift: 0 14px 40px rgba(0, 0, 0, 0.5);
  --glow: none;
}

[data-theme="mondrian"] {
  color-scheme: light;
  --bg: #f2f0e6;
  --glow-a: transparent;
  --glow-b: transparent;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #faf9f2;
  --field: #ffffff;
  --line: #0a0a0a;
  --line-strong: #0a0a0a;
  --accent: #d41c1c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(212, 28, 28, 0.1);
  --a2: #1a3db8;
  --a3: #e8b923;
  --text: #0a0a0a;
  --muted: #4d4d4d;
  --faint: #7a7a7a;
  --danger: #d41c1c;
  --danger-soft: rgba(212, 28, 28, 0.1);
  --ok: #1a3db8;
  --stage: #f4f3ed;
  --overlay: rgba(244, 243, 237, 0.88);
  --radius: 0px;
  --radius-sm: 0px;
  --bw: 2px;
  --card-shadow: 3px 3px 0 #0a0a0a;
  --lift: 6px 6px 0 #0a0a0a;
  --glow: none;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(60% 50% at 50% 0%, var(--glow-a), transparent 70%),
    radial-gradient(50% 40% at 90% 100%, var(--glow-b), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: 0.4; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-theme="mondrian"] :focus-visible { outline-color: var(--a2); }

.hidden { display: none !important; }

kbd {
  font-family: var(--mono);
  font-size: 0.78em;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  border: var(--bw) solid var(--line-strong);
  border-bottom-width: calc(var(--bw) + 1px);
  background: var(--field);
  color: var(--text);
}

/* CRT scanline effect (optional) */
body.crt::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 30000;
  pointer-events: none;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.16) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.025), rgba(0, 255, 0, 0.012), rgba(0, 0, 255, 0.025));
  background-size: 100% 3px, 5px 100%;
}

/* ---------- icons ---------- */
.ic {
  width: 1.2em;
  height: 1.2em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: var(--bw) solid var(--line);
  background: var(--field);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); background: var(--card-hover); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
[data-theme="mondrian"] .btn { border-color: #0a0a0a; }
[data-theme="mondrian"] .btn.primary { box-shadow: 3px 3px 0 #0a0a0a; }

.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.danger-soft:hover:not(:disabled) { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--field); border-color: var(--line); }
.btn.danger-hover:hover:not(:disabled) { color: var(--danger); }
.btn.big { min-height: 48px; padding: 0 28px; font-size: 16px; border-radius: calc(var(--radius-sm) + 2px); }
.btn.block { width: 100%; }
.btn.grow { flex: 1; }
.btn.icon-only { padding: 0; width: 40px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: var(--bw) solid var(--line);
  background: var(--field);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.icon-btn:hover:not(:disabled) { border-color: var(--line-strong); background: var(--card-hover); }
.icon-btn:active:not(:disabled) { transform: scale(0.94); }
.icon-btn.active, .icon-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn.sm { width: 32px; height: 32px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.sm:hover:not(:disabled) { background: var(--field); color: var(--text); }
.icon-btn.sm.on { color: var(--accent); }
.icon-btn.danger-hover:hover:not(:disabled) { color: var(--danger); }
[data-theme="mondrian"] .icon-btn:not(.sm) { border-color: #0a0a0a; }

/* ---------- form fields ---------- */
.field, .select {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: var(--bw) solid var(--line);
  background: var(--field);
  color: var(--text);
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field.slim, .select { min-height: 38px; font-size: 14px; }
.select { width: auto; padding-right: 8px; cursor: pointer; }
.field::placeholder { color: var(--faint); }
.field:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
[data-theme="mondrian"] .field, [data-theme="mondrian"] .select { border-color: #0a0a0a; }
.select option { background: var(--surface); color: var(--text); }

.field-label { display: block; margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field-label .optional { font-weight: 500; color: var(--faint); margin-left: 4px; }
.field-wrap { position: relative; }
.field-wrap .field { padding-right: 46px; }
.field-btn {
  position: absolute; right: 4px; top: 4px; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.field-btn:hover { color: var(--text); background: var(--field); }
.form-error { min-height: 20px; margin: 10px 0 4px; color: var(--danger); font-size: 13px; font-weight: 500; }

.strength { height: 18px; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); position: relative; padding-left: 0; }
.strength[data-level="1"] { color: var(--danger); }
.strength[data-level="2"] { color: var(--a3); }
.strength[data-level="3"], .strength[data-level="4"] { color: var(--ok); }

/* ==========================================================================
   Arcade
   ========================================================================== */
#arcade-app {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 20px; height: 28px; }
.brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.topbar-actions { display: flex; gap: 6px; }

/* Scoreboard */
.scoreboard {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  align-items: stretch;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--card-shadow);
}
.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 9px 6px;
}
.score-box + .score-box { border-left: var(--bw) solid var(--line); }
.score-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.score-val {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
}
.score-val.accent2 { color: var(--a2); }
.score-box.best .score-val { color: var(--a3); }
.score-box.best { -webkit-user-select: none; user-select: none; }
.trophy { width: 15px; height: 15px; }
[data-theme="mondrian"] .score-val, [data-theme="mondrian"] .score-box.best .score-val { color: #0a0a0a; }
[data-theme="mondrian"] .score-val.accent2 { color: var(--accent); }

/* Tadao Ando form-tie holes */
[data-theme="tadao-ando"] .scoreboard::after {
  content: "";
  position: absolute;
  top: 6px; right: 8px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #0f1013;
  box-shadow: inset 0 1px 1px #000, 0 1px 0 rgba(255, 255, 255, 0.1), -14px 0 0 #0f1013;
}

/* Game tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.tab {
  flex: 1;
  min-height: 38px;
  border: var(--bw) solid transparent;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: var(--accent-ink); }
[data-theme="mondrian"] .tabs { gap: 2px; background: #0a0a0a; padding: 2px; border-color: #0a0a0a; }
[data-theme="mondrian"] .tab { background: #fff; color: #0a0a0a; }
[data-theme="mondrian"] .tab.active { background: #d41c1c; color: #fff; }
[data-theme="mondrian"] .tab.active[data-game="snake"] { background: #e8b923; color: #0a0a0a; }
[data-theme="mondrian"] .tab.active[data-game="tetris"] { background: #1a3db8; color: #fff; }

/* Stage */
.stage {
  position: relative;
  flex: 1;
  min-height: 240px;
  overflow: hidden;
  border: var(--bw) solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--stage);
  box-shadow: var(--card-shadow), var(--glow);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
[data-theme="mondrian"] .stage { border-width: 3px; }
#game-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }

.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}
.overlay-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; max-width: 300px; }
.overlay-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.stage-overlay[data-state="over"] .overlay-kicker { color: var(--a3); }
[data-theme="mondrian"] .stage-overlay[data-state="over"] .overlay-kicker { color: var(--accent); }
.overlay-title { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin-bottom: 8px; }
.stage-overlay[data-state="over"] .overlay-title { color: var(--a2); }
[data-theme="mondrian"] .stage-overlay[data-state="over"] .overlay-title { color: #0a0a0a; }
.overlay-score { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.overlay-score strong { font-family: var(--mono); font-size: 28px; color: var(--text); margin-left: 6px; }
.overlay-hint { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* On-screen controls (touch) */
.controls { display: none; }
@media (pointer: coarse) {
  .controls { display: block; }
  .hints { display: none !important; }
}

.pad-row { display: flex; gap: 8px; }
.pad-row.tetris { display: grid; grid-template-columns: repeat(4, 1fr); }
.pad-row.tetris #tetris-btn-rotate, .pad-row.tetris #tetris-btn-drop { grid-column: span 2; }

.pad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  flex: 1;
  border: var(--bw) solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.08s, background 0.1s;
}
.pad-btn .ic { width: 22px; height: 22px; }
.pad-btn:active, .pad-btn.active { transform: scale(0.95); background: var(--accent-soft); border-color: var(--accent); }
.pad-btn.accent { color: var(--accent); }
.pad-btn.accent2 { color: var(--a2); }
.pad-btn.wide { min-height: 58px; }
[data-theme="mondrian"] .pad-btn { border-color: #0a0a0a; box-shadow: 2px 2px 0 #0a0a0a; }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 62px);
  grid-template-rows: repeat(2, 54px);
  gap: 8px;
  justify-content: center;
}
.dpad #snake-btn-up { grid-column: 2; grid-row: 1; }
.dpad #snake-btn-left { grid-column: 1; grid-row: 2; }
.dpad #snake-btn-down { grid-column: 2; grid-row: 2; }
.dpad #snake-btn-right { grid-column: 3; grid-row: 2; }

/* Keyboard hints (mouse devices) */
.hints {
  display: flex;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  min-height: 24px;
}
.hint { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.hint i { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); margin: 0 6px; }

/* Very narrow phones (≈320px): keep the header on one line */
@media (max-width: 360px) {
  #arcade-app { padding-left: 10px; padding-right: 10px; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .icon-btn { width: 34px; height: 34px; }
  .brand { gap: 8px; }
  .brand-mark { width: 16px; height: 22px; }
  .brand-name { font-size: 18px; }
  .score-val { font-size: 17px; }
  .score-val .trophy { width: 13px; height: 13px; }
  .tab { font-size: 12px; }
}
@media (max-width: 340px) {
  #btn-crt-toggle { display: none; }
}

/* Desktop: float the arcade as a card */
@media (min-width: 600px) and (min-height: 720px) {
  #arcade-app {
    height: min(100dvh - 40px, 860px);
    margin-top: 20px;
    padding: 16px;
    border: var(--bw) solid var(--line);
    border-radius: calc(var(--radius) + 10px);
    background: color-mix(in srgb, var(--surface) 55%, transparent);
    box-shadow: var(--lift);
  }
}

/* ==========================================================================
   Modals, dialogs, toasts (shared with the vault)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.18s ease;
}
.dialog-overlay { z-index: 20000; }

.modal-card {
  width: 100%;
  max-width: 380px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 22px;
  border: var(--bw) solid var(--line-strong);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  box-shadow: var(--lift);
  animation: popIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-card.wide { max-width: 460px; }
.modal-card.shake { animation: shake 0.35s; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.modal-title { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.modal-sub { margin: 6px 0 4px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.modal-sub.center { text-align: center; }
.dialog-message { margin: 8px 0 4px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Theme picker */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.theme-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px;
  text-align: left;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  transition: border-color 0.15s, background 0.15s;
}
.theme-card:hover { border-color: var(--line-strong); }
.theme-card.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
[data-theme="mondrian"] .theme-card.active { box-shadow: 3px 3px 0 #0a0a0a; }
.theme-swatches { display: flex; gap: 0; margin-bottom: 6px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(128, 128, 128, 0.4); }
.theme-swatches i { width: 22px; height: 22px; display: block; }
.theme-name { font-size: 14px; font-weight: 700; }
.theme-desc { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* Toasts */
#toasts {
  position: fixed;
  left: 0; right: 0;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 30000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: min(92vw, 420px);
  padding: 10px 16px;
  border: var(--bw) solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--lift);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: var(--danger); color: var(--danger); }
[data-theme="mondrian"] .toast { border-radius: 0; border-color: #0a0a0a; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* filled icons (hearts for lives, etc.) */
.ic.fill { fill: currentColor; stroke: currentColor; }
.score-val .ic.fill { width: 15px; height: 15px; }
kbd .ic { width: 12px; height: 12px; vertical-align: -0.15em; }

/* ==========================================================================
   First-run tour
   ========================================================================== */
.tour { position: fixed; inset: 0; z-index: 15000; pointer-events: none; }
.tour-block { position: absolute; inset: 0; pointer-events: auto; }
.tour-block.dim { background: rgba(3, 5, 12, 0.72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
[data-theme="mondrian"] .tour-block.dim { background: rgba(244, 243, 237, 0.8); }
.tour-ring {
  position: fixed;
  border-radius: calc(var(--radius) + 4px);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(3, 5, 12, 0.72), 0 0 24px var(--accent-soft);
  pointer-events: none;
  transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1), top 0.3s cubic-bezier(0.16, 1, 0.3, 1), width 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  animation: tourPulse 2s ease-in-out infinite;
}
[data-theme="mondrian"] .tour-ring { box-shadow: 0 0 0 9999px rgba(244, 243, 237, 0.8); border-radius: 0; border-width: 3px; }
@keyframes tourPulse { 0%, 100% { border-color: var(--accent); } 50% { border-color: color-mix(in srgb, var(--accent) 45%, transparent); } }

.tour-card {
  position: fixed;
  pointer-events: auto;
  padding: 18px;
  border: var(--bw) solid var(--line-strong);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  box-shadow: var(--lift);
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}
.tour-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.tour-ic { flex: none; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
[data-theme="mondrian"] .tour-ic { border-radius: 0; }
.tour-ic .ic { width: 19px; height: 19px; }
.tour-title { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.tour-text { font-size: 14.5px; line-height: 1.55; color: var(--muted); }
.tour-text b { color: var(--text); }
.tour-inline { display: inline-flex; vertical-align: -0.25em; margin: 0 2px; color: var(--accent); }
.tour-inline .ic { width: 18px; height: 18px; }
.tour-hint { display: flex; gap: 8px; margin-top: 10px; font-size: 12.5px; line-height: 1.5; color: var(--faint); }
.tour-hint .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.tour-install { margin-top: 12px; }
.tour-dots { display: flex; gap: 5px; margin: 14px 0 12px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); transition: width 0.2s, background 0.2s; }
.tour-dots i.done { background: var(--accent-soft); }
.tour-dots i.on { width: 18px; border-radius: 3px; background: var(--accent); }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-actions .grow { flex: 1; }
.tour-actions .btn { min-height: 38px; }
.tour-count { margin-top: 12px; display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-weight: 800; font-size: 14px; }
.tour-count i { flex: 1; height: 8px; border-radius: 999px; background: var(--field); overflow: hidden; }
.tour-count b { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
@media (prefers-reduced-motion: reduce) { .tour-ring { animation: none; } }

/* ---- css/vault.css ---- */
/* ==========================================================================
   gamos — vault (list, editor, voice, settings, lightbox)
   Uses the tokens defined in game.css.
   ========================================================================== */

#stealth-vault-container {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--bg);
  background-image:
    radial-gradient(60% 40% at 50% 0%, var(--glow-a), transparent 70%);
  overflow: hidden;
}

.vault-bar,
.vault-tools,
.notes-list,
.vault-home {
  width: 100%;
  max-width: 760px;
}

.vault-scroll {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 130px;
}
.vault-home { padding: 4px 16px 6px; }
.vault-home:empty { display: none; }

.vault-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 10px;
}
.vault-bar-actions { display: flex; align-items: center; gap: 8px; }
.vault-bar-actions .btn { min-height: 38px; padding: 0 12px; }

/* Search / folders / filters */
.vault-tools { padding: 0 16px 8px; display: flex; flex-direction: column; gap: 10px; }
.search-row { display: flex; gap: 8px; }
.search-box {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.search-box .ic { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.search-box input {
  width: 100%;
  min-height: 42px;
  padding: 0 14px 0 38px;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box input::placeholder { color: var(--faint); }
[data-theme="mondrian"] .search-box input { border-color: #0a0a0a; }
.search-row .select { min-height: 42px; flex: none; max-width: 112px; font-size: 14px; }
.search-box { min-width: 0; }

.pill-row, .chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pill-row::-webkit-scrollbar, .chip-row::-webkit-scrollbar { display: none; }
.chip-row.wrap { flex-wrap: wrap; overflow: visible; }

.pill, .filter-chip, .mood-chip, .template-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  border: var(--bw) solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
[data-theme="mondrian"] .pill, [data-theme="mondrian"] .filter-chip, [data-theme="mondrian"] .mood-chip, [data-theme="mondrian"] .template-chip { border-radius: 0; border-color: #0a0a0a; color: #0a0a0a; background: #fff; }
.pill:hover, .filter-chip:hover, .mood-chip:hover, .template-chip:hover { color: var(--text); border-color: var(--line-strong); }
.pill.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill-count { font-size: 11px; opacity: 0.7; font-weight: 700; }
.pill-add { border-style: dashed; }
.filter-chip { min-height: 30px; font-size: 12px; padding: 0 12px; }
.filter-chip.active, .mood-chip.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
[data-theme="mondrian"] .filter-chip.active, [data-theme="mondrian"] .mood-chip.selected { background: var(--accent); color: #fff; border-color: #0a0a0a; }
.template-chip { border-style: dashed; border-radius: var(--radius-sm); font-weight: 500; }

/* Notes list */
/* notes-list is a plain column; .vault-scroll does the scrolling */
.notes-list {
  flex: none;
  padding: 4px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.group-label {
  margin: 10px 2px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.group-label:first-child { margin-top: 2px; }

.note-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 12px 16px;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.note-card:hover { background: var(--card-hover); border-color: var(--line-strong); }
.note-card:active { transform: scale(0.995); }
.note-card.pinned { box-shadow: inset 3px 0 0 var(--accent), var(--card-shadow); }
[data-theme="mondrian"] .note-card { border-color: #0a0a0a; }
[data-theme="mondrian"] .note-card.pinned { box-shadow: inset 6px 0 0 var(--accent), 3px 3px 0 #0a0a0a; }

.note-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note-title { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.01em; }
.note-actions { display: flex; flex: none; margin-right: -6px; }
.note-excerpt {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-excerpt:empty { display: none; }
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-date { font-size: 12px; color: var(--faint); white-space: nowrap; }
.note-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; min-width: 0; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge .ic { width: 12px; height: 12px; }
.badge.mood { background: var(--accent-soft); color: var(--accent); }
[data-theme="mondrian"] .badge { border: 1px solid #0a0a0a; border-radius: 0; }
[data-theme="mondrian"] .badge.mood { color: var(--accent); }

.voice-row { display: flex; align-items: center; gap: 12px; }
.play-btn {
  flex: none;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}
[data-theme="mondrian"] .play-btn { border: 2px solid #0a0a0a; }
.audio-progress { flex: 1; min-width: 0; accent-color: var(--accent); cursor: pointer; }
.audio-time { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

.empty-state { margin: auto; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.empty-icon { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.empty-icon .ic { width: 26px; height: 26px; }
[data-theme="mondrian"] .empty-icon { border-radius: 0; border: 2px solid #0a0a0a; }
.empty-title { font-size: 18px; font-weight: 800; }
.empty-sub { max-width: 300px; font-size: 14px; color: var(--muted); line-height: 1.5; margin-bottom: 8px; }

/* Floating actions */
.fab-dock {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 5100;
  display: flex;
  align-items: center;
  gap: 10px;
}
.fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  border-radius: 999px;
  border: var(--bw) solid var(--line-strong);
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s;
}
.fab:active { transform: scale(0.95); }
.fab.primary { padding: 0 22px 0 18px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.fab.secondary { width: 52px; background: var(--surface); color: var(--text); }
[data-theme="mondrian"] .fab { border-radius: 0; border: 2px solid #0a0a0a; box-shadow: 4px 4px 0 #0a0a0a; }
@media (min-width: 800px) {
  .fab-dock { right: calc(50% - 360px); }
}

/* ==========================================================================
   Editor
   ========================================================================== */
.editor {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.editor.dragging::after {
  content: "Drop photos to attach";
  position: absolute; inset: 12px;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--overlay);
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: var(--bw) solid var(--line);
  background: var(--surface);
}
.editor-bar .btn { min-height: 38px; }
.editor-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.save-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ok);
  white-space: nowrap;
}
.save-badge.saving { color: var(--muted); }
[data-theme="mondrian"] .save-badge { color: var(--a2); }

.editor-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.editor-inner {
  width: 100%;
  max-width: 720px;
  min-height: 100%;
  margin: 0 auto;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.editor-title {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  outline: none;
}
.editor-title::placeholder { color: var(--faint); }

.editor-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.meta-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.meta-field.grow { flex: 1; min-width: 160px; }
.meta-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.meta-field .select { max-width: 100%; }

.prompts { border: var(--bw) solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.prompts summary {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  cursor: pointer; list-style: none;
}
.prompts summary::-webkit-details-marker { display: none; }
.prompts summary::after { content: "+"; margin-left: auto; font-size: 18px; line-height: 1; color: var(--faint); }
.prompts[open] summary::after { content: "–"; }
.prompts[open] summary { color: var(--text); }
.prompts-body { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.prompts-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin-top: 4px; }
[data-theme="mondrian"] .prompts { border-color: #0a0a0a; }

.editor-body {
  flex: 1;
  width: 100%;
  min-height: 46vh;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  line-height: 1.7;
  resize: none;
  outline: none;
}
.editor-body::placeholder { color: var(--faint); }

.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px max(10px, env(safe-area-inset-bottom));
  border-top: var(--bw) solid var(--line);
  background: var(--surface);
  font-size: 12px;
  color: var(--faint);
}
.editor-mood { color: var(--accent); font-weight: 600; }
[data-theme="mondrian"] .editor-mood { color: var(--accent); }

/* Photo strip */
.img-strip { display: flex; gap: 10px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.img-strip::-webkit-scrollbar { display: none; }
.img-chip {
  position: relative;
  flex: none;
  width: 84px; height: 84px;
  overflow: hidden;
  border: var(--bw) solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--field);
  cursor: zoom-in;
}
.img-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.7); color: #fff;
}
.img-remove .ic { width: 12px; height: 12px; }
.img-remove:hover { background: var(--danger); }

/* Markdown preview */
.md { flex: 1; min-height: 46vh; font-size: 17px; line-height: 1.7; }
.md h1 { font-size: 26px; margin: 18px 0 8px; letter-spacing: -0.02em; }
.md h2 { font-size: 21px; margin: 16px 0 6px; letter-spacing: -0.01em; }
.md h3 { font-size: 17px; margin: 14px 0 4px; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 12px 22px; }
.md li { margin: 3px 0; }
.md li.todo { list-style: none; margin-left: -22px; display: flex; gap: 10px; align-items: flex-start; }
.md li.todo .box {
  flex: none; width: 18px; height: 18px; margin-top: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--line-strong); border-radius: 5px; font-size: 12px; font-weight: 800; color: var(--accent-ink);
}
.md li.todo.done { color: var(--muted); text-decoration: line-through; }
.md li.todo.done .box { background: var(--accent); border-color: var(--accent); }
.md blockquote { margin: 0 0 12px; padding: 2px 0 2px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.md code { padding: 2px 6px; border-radius: 5px; background: var(--field); font-family: var(--mono); font-size: 0.85em; }
.md pre { margin: 0 0 12px; padding: 12px 14px; overflow-x: auto; border-radius: var(--radius-sm); background: var(--field); }
.md pre code { padding: 0; background: none; }
.md hr { border: 0; border-top: var(--bw) solid var(--line-strong); margin: 16px 0; }
.md-empty { color: var(--faint); }

/* ==========================================================================
   Voice memo modal
   ========================================================================== */
#voice-record-canvas {
  display: block;
  width: 100%;
  height: 60px;
  margin: 14px 0 6px;
  border-radius: var(--radius-sm);
  background: var(--field);
}
.voice-timer { text-align: center; font-family: var(--mono); font-size: 34px; font-weight: 800; letter-spacing: 0.04em; }
.voice-controls { display: flex; justify-content: center; margin: 12px 0 16px; }
.modal-card > .field { margin-bottom: 8px; }
.rec-btn {
  width: 68px; height: 68px;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--danger);
}
.rec-btn .dot { width: 40px; height: 40px; border-radius: 50%; background: var(--danger); transition: transform 0.15s; }
.rec-btn:hover .dot { transform: scale(0.92); }
.rec-btn.recording { border-color: var(--danger); animation: pulseRec 1.4s infinite; }
.rec-btn .ic { width: 28px; height: 28px; }
[data-theme="mondrian"] .rec-btn { border-radius: 0; border-color: #0a0a0a; }
[data-theme="mondrian"] .rec-btn .dot { border-radius: 0; }
@keyframes pulseRec {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); }
  70% { box-shadow: 0 0 0 16px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ==========================================================================
   Settings
   ========================================================================== */
.modal-card.scroll { overflow-y: auto; }
.settings-section { padding: 16px 0; border-top: var(--bw) solid var(--line); }
.settings-section:first-of-type { border-top: 0; padding-top: 8px; }
.settings-section h3 { font-size: 14px; font-weight: 800; margin-bottom: 4px; }
.settings-section .theme-grid { margin-top: 10px; }
.hint-text { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin: 4px 0 10px; }
.hint-text code { font-family: var(--mono); font-size: 0.92em; padding: 1px 5px; border-radius: 4px; background: var(--field); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; font-size: 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form .field { flex: 1; }
.danger-zone h3 { color: var(--danger); }

.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 44px; height: 26px;
  border-radius: 999px;
  border: var(--bw) solid var(--line-strong);
  background: var(--field);
  position: relative;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: var(--accent-ink); }
[data-theme="mondrian"] .switch, [data-theme="mondrian"] .switch::after { border-radius: 0; }
[data-theme="mondrian"] .switch { border-color: #0a0a0a; }

/* ==========================================================================
   Lightbox
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  background: rgba(4, 6, 12, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
}
.lightbox-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
}
.lightbox-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.lightbox-actions { display: flex; gap: 6px; flex: none; }
.lightbox .btn.ghost { color: #fff; }
.lightbox .btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.2); }
.lightbox-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px 16px 24px; }
.lightbox-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }

/* ==========================================================================
   Small screens
   ========================================================================== */
@media (max-width: 520px) {
  .editor-bar .btn-label { display: none; }
  .editor-bar .btn:not(.icon-only) { padding: 0 10px; }
  .editor-title { font-size: 23px; }
  .theme-grid { grid-template-columns: 1fr 1fr; }
  .brand-name { font-size: 20px; }
  .vault-bar-actions .btn span { display: inline; }
}

/* ==========================================================================
   Guided journaling (new entries)
   ========================================================================== */
:root { --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif; }

/* The writing page itself feels like paper, not a form */
.editor-body, .md { font-family: var(--serif); font-size: 19px; line-height: 1.85; }
.editor-body { min-height: 38vh; }
.editor-title { font-family: var(--serif); }

/* Which parts show at which step */
.editor .guide { display: none; }
.editor.stage-welcome #guide-welcome,
.editor.stage-done #guide-done { display: flex; }
.editor.stage-welcome .editor-scroll, .editor.stage-done .editor-scroll,
.editor.stage-welcome .editor-foot, .editor.stage-done .editor-foot,
.editor.stage-welcome .editor-actions, .editor.stage-done .editor-actions,
.editor.stage-welcome .save-badge, .editor.stage-done .save-badge { display: none; }
.editor.mode-edit .empathy, .editor.mode-edit .prompt-card, .editor.mode-edit .starter-block { display: none !important; }

.guide {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 40px;
  background:
    radial-gradient(70% 45% at 50% 0%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.guide-inner { width: 100%; max-width: 440px; margin: auto; animation: riseIn 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.guide-inner.center { text-align: center; display: flex; flex-direction: column; align-items: center; }
.guide-greeting { font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
[data-theme="mondrian"] .guide-greeting { color: var(--accent); }
.guide-title { font-family: var(--serif); font-size: 31px; line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 10px; }
.guide-sub { font-size: 15px; line-height: 1.6; color: var(--muted); margin-bottom: 22px; }

.mood-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.mood-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 92px; padding: 10px 4px;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--card-shadow);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.mood-tile .emoji { font-size: 30px; line-height: 1; }
.mood-tile .name { font-size: 13px; font-weight: 700; color: var(--text); }
.mood-tile:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--card-hover); }
.mood-tile:active { transform: scale(0.96); }
.mood-tile.selected { border-color: var(--accent); background: var(--accent-soft); }
[data-theme="mondrian"] .mood-tile { border-color: #0a0a0a; }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 2px; border: 0; background: none;
  color: var(--muted); font-size: 14px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-strong);
}
.link-btn:hover { color: var(--text); }
.guide-inner > .link-btn { display: flex; margin: 0 auto; }

.done-mark {
  width: 76px; height: 76px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  animation: popIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.done-mark .ic { width: 38px; height: 38px; stroke-width: 2.5; }
[data-theme="mondrian"] .done-mark { border-radius: 0; border: 3px solid #0a0a0a; box-shadow: 4px 4px 0 #0a0a0a; }
.done-count { font-size: 14px; font-weight: 600; color: var(--accent); margin: -10px 0 26px; }
[data-theme="mondrian"] .done-count { color: var(--a2); }
.done-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.done-actions .btn { width: 100%; max-width: 320px; }

/* Writing page helpers */
.empathy {
  font-family: var(--serif); font-size: 19px; line-height: 1.55; font-style: italic;
  color: var(--text); padding: 2px 0 0 14px; border-left: 3px solid var(--accent);
  animation: riseIn 0.45s ease both;
}
.prompt-card {
  padding: 16px 16px 12px;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  animation: riseIn 0.5s 0.08s ease both;
}
[data-theme="mondrian"] .prompt-card { border-color: #0a0a0a; background: #fff; box-shadow: 3px 3px 0 #0a0a0a; }
.prompt-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
[data-theme="mondrian"] .prompt-kicker { color: var(--accent); }
.prompt-text { font-family: var(--serif); font-size: 21px; line-height: 1.4; font-weight: 600; margin-bottom: 12px; }
.prompt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: -6px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

.starter-block { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 4px; }
.starter-chip {
  min-height: 36px; padding: 0 14px;
  border: var(--bw) dashed var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: var(--serif); font-size: 15px; font-style: italic;
  transition: background 0.15s, border-color 0.15s;
}
.starter-chip:hover { background: var(--accent-soft); border-color: var(--accent); }
[data-theme="mondrian"] .starter-chip { border-radius: 0; border-color: #0a0a0a; border-style: solid; background: #fff; }

.prompts-body .meta-field { margin-bottom: 4px; }
.prompts-body .editor-meta { margin-bottom: 4px; }

@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (max-width: 380px) {
  .guide-title { font-size: 26px; }
  .mood-tile { min-height: 82px; }
  .mood-tile .emoji { font-size: 26px; }
}

/* Once they've started writing, get the helpers out of the way */
.editor.has-text .starter-block { display: none; }
.editor.has-text .prompt-card { padding-bottom: 10px; }
.editor-body { min-height: 30vh; }

/* ==========================================================================
   Home card (top of the journal)
   ========================================================================== */
.home { display: flex; flex-direction: column; gap: 12px; margin-bottom: 6px; }
.home-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.home-greet { font-family: var(--serif); font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; margin-top: 2px; }

.week-card, .msg .week-card {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  padding: 12px 10px;
  border: var(--bw) solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--card-shadow);
}
[data-theme="mondrian"] .week-card { border-color: #0a0a0a; }
.wk { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wk i {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px dashed var(--line-strong);
  font-style: normal; font-size: 18px; color: var(--accent); font-weight: 800;
}
.wk b { font-size: 11px; font-weight: 700; color: var(--faint); }
.wk.on i { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.wk.today i { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.wk.today b { color: var(--text); }
.wk.future i { opacity: 0.4; }
[data-theme="mondrian"] .wk i { border-radius: 0; }
.week-line { font-size: 14px; color: var(--muted); margin-top: -2px; }
.cue-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: -6px; }
.cue-line .ic { color: var(--accent); }

.home-actions { display: flex; flex-direction: column; gap: 8px; }
.home-actions-row { display: flex; gap: 8px; }

.home-card {
  padding: 14px 16px;
  border: var(--bw) solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--card-shadow);
}
[data-theme="mondrian"] .home-card { border-color: #0a0a0a; }
.home-card .kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.daily-q { font-family: var(--serif); font-size: 20px; line-height: 1.4; font-weight: 600; margin-bottom: 12px; }
.home-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.step-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.step-row + .step-row { border-top: var(--bw) solid var(--line); }
.step-text { font-size: 15px; font-weight: 600; }
.step-when { font-size: 12px; color: var(--faint); text-transform: capitalize; }
.step-btns { display: flex; align-items: center; gap: 4px; flex: none; }

.insight { display: flex; gap: 10px; font-size: 14px; line-height: 1.5; padding: 5px 0; }
.insight span { flex: none; width: 22px; text-align: center; }
.insight.muted { color: var(--muted); }

/* ==========================================================================
   Blank page extras
   ========================================================================== */
.dear-line { font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--muted); }
.editor.mode-edit .dear-line, .editor.mode-edit .cats-block { display: none; }
.cat-chip {
  min-height: 32px; padding: 0 12px;
  border: var(--bw) solid var(--line); border-radius: 999px;
  background: var(--field); color: var(--muted); font-size: 13px; font-weight: 600;
}
.cat-chip:hover { color: var(--text); border-color: var(--line-strong); }
.cat-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
[data-theme="mondrian"] .cat-chip { border-radius: 0; border-color: #0a0a0a; background: #fff; color: #0a0a0a; }
[data-theme="mondrian"] .cat-chip.active { background: var(--accent); color: #fff; }
.editor.has-text .cats-block { display: none; }

/* ==========================================================================
   The conversation
   ========================================================================== */
.companion {
  position: fixed; inset: 0; z-index: 7000;
  display: flex; flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(70% 40% at 50% 0%, var(--accent-soft), transparent 70%);
}
.comp-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: var(--bw) solid var(--line); background: var(--surface);
}
.comp-bar .btn { justify-self: start; min-height: 38px; }
.comp-title { font-family: var(--serif); font-size: 19px; font-weight: 700; text-align: center; }
.comp-dear { font-style: italic; font-weight: 400; color: var(--muted); }

.comp-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }
.comp-feed { width: 100%; max-width: 560px; margin: 0 auto; padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 8px; }

.msg { max-width: 86%; padding: 11px 15px; border-radius: 18px; font-size: 16px; line-height: 1.5; animation: riseIn 0.3s ease both; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.diary { align-self: flex-start; background: var(--card); border: var(--bw) solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--card-shadow); font-family: var(--serif); font-size: 17px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; font-weight: 600; }
[data-theme="mondrian"] .msg { border-radius: 0; border: 2px solid #0a0a0a; }
[data-theme="mondrian"] .msg.diary { box-shadow: 3px 3px 0 #0a0a0a; }
.msg blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--accent); font-style: italic; }
.msg:has(.week-card) { max-width: 100%; align-self: stretch; padding: 0; background: none; border: 0; box-shadow: none; }
.msg b { font-weight: 800; }

.msg.typing { display: inline-flex; gap: 5px; padding: 15px 16px; }
.msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.1s infinite ease-in-out; }
.msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.comp-dock { flex: none; width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px max(14px, env(safe-area-inset-bottom)); }
.comp-dock:empty { display: none; }
.comp-dock.tall { max-height: 56vh; overflow-y: auto; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }
/* short labels sit as compact chips instead of full-width rows */
.choices.cols .choice { flex: 0 0 auto; min-height: 42px; padding: 8px 16px; border-radius: 999px; align-items: center; text-align: center; }
[data-theme="mondrian"] .choices.cols .choice { border-radius: 0; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  flex: 1 1 100%; min-height: 48px; padding: 10px 16px;
  border: var(--bw) solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); font-size: 16px; font-weight: 600; text-align: left;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.choice small { font-size: 12px; font-weight: 500; color: var(--muted); }
.choice:hover { border-color: var(--accent); background: var(--card-hover); }
.choice:active { transform: scale(0.985); }
.choice.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
[data-theme="mondrian"] .choice { border-color: #0a0a0a; }

.dock-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; }
.dock-row:empty { display: none; }
.dock-row .btn { min-width: 110px; }

.text-row { display: flex; align-items: flex-end; gap: 8px; padding-top: 6px; }
.comp-input {
  flex: 1; min-height: 48px; max-height: 160px; padding: 12px 14px; resize: none;
  border: var(--bw) solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--field); color: var(--text); font-size: 16px; line-height: 1.45; outline: none;
}
.comp-input.one { min-height: 48px; }
.comp-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.send-btn {
  flex: none; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
}
.send-btn:disabled { opacity: 0.3; }
[data-theme="mondrian"] .send-btn { border-radius: 0; border: 2px solid #0a0a0a; }

.mood-grid.comp { margin: 6px 0 0; gap: 8px; }
.mood-grid.comp .mood-tile { min-height: 76px; }
.mood-grid.comp .mood-tile .emoji { font-size: 26px; }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding-top: 6px; }
.scale-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px;
  border: var(--bw) solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card);
}
.scale-btn b { font-size: 20px; font-family: var(--mono); }
.scale-btn small { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.1; }
.scale-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
[data-theme="mondrian"] .scale-btn { border-color: #0a0a0a; }

.comp-dock.pour { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pour-box { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.pour-input {
  flex: 1; min-height: 160px; width: 100%; padding: 16px; resize: none;
  border: var(--bw) solid var(--line-strong); border-radius: var(--radius);
  background: var(--card); color: var(--text); outline: none;
  font-family: var(--serif); font-size: 19px; line-height: 1.8;
}
.pour-input:focus { border-color: var(--accent); }
.pour-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pour-time { font-family: var(--mono); font-size: 12px; color: var(--faint); }

.breathe { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 0 6px; }
.breath-orb {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-soft));
  box-shadow: 0 0 40px var(--accent-soft);
  transform: scale(0.6); transition: transform 4s ease-in-out;
}
.breath-orb.in { transform: scale(1.15); transition-duration: 4s; }
.breath-orb.hold { transform: scale(1.15); transition-duration: 0.2s; }
.breath-orb.out { transform: scale(0.6); transition-duration: 6s; }
[data-theme="mondrian"] .breath-orb { border-radius: 0; background: var(--accent); box-shadow: none; border: 3px solid #0a0a0a; }
.breath-text { font-family: var(--serif); font-size: 20px; font-style: italic; min-height: 28px; }

/* ==========================================================================
   Icons inside the vault (no emoji anywhere: everything is the gamos icon set)
   ========================================================================== */
.pill .ic, .mood-chip .ic, .cat-chip .ic, .badge .ic { width: 14px; height: 14px; flex: none; }
.mood-chip { gap: 6px; }
.editor-mood { display: inline-flex; align-items: center; gap: 6px; }
.editor-mood .ic { width: 15px; height: 15px; }
.badge.mood { gap: 5px; }
.wk i .ic { width: 18px; height: 18px; }
.insight span .ic { width: 18px; height: 18px; color: var(--accent); }
.insight span { display: flex; justify-content: center; padding-top: 2px; }
.md li.todo .box .ic { width: 12px; height: 12px; stroke-width: 3; }
.cue-line .ic, .week-line .ic { width: 15px; height: 15px; }

/* mood tiles: a tinted icon disc, coloured by how the feeling sits (light / even / heavy) */
.mood-tile { --tone: var(--muted); }
.mood-tile[data-tone="pos"] { --tone: var(--ok); }
.mood-tile[data-tone="neg"] { --tone: var(--a2); }
[data-theme="mondrian"] .mood-tile[data-tone="pos"] { --tone: #1a3db8; }
[data-theme="mondrian"] .mood-tile[data-tone="neg"] { --tone: #d41c1c; }
.mood-tile .mood-ic {
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--tone);
  background: color-mix(in srgb, var(--tone) 16%, transparent);
  transition: transform 0.15s;
}
.mood-tile .mood-ic .ic { width: 22px; height: 22px; }
.mood-tile:hover .mood-ic { transform: scale(1.08); }
[data-theme="mondrian"] .mood-tile .mood-ic { border-radius: 0; }
.mood-grid.comp .mood-tile { min-height: 82px; gap: 6px; }

/* ==========================================================================
   Diary conversation: finer details
   ========================================================================== */
.comp-progress { height: 3px; background: var(--line); }
.comp-progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 0 2px 2px 0; transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1); }

.who { display: flex; align-items: center; gap: 8px; margin: 14px 0 2px 2px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); }
.who:first-child { margin-top: 2px; }
.who-mark { width: 12px; height: 17px; }
.msg.diary { padding: 12px 16px; border-radius: 4px 20px 20px 20px; }
.msg.me { border-radius: 20px 4px 20px 20px; }
[data-theme="mondrian"] .msg.diary, [data-theme="mondrian"] .msg.me { border-radius: 0; }
.msg-ic { display: inline-flex; vertical-align: -0.2em; margin-right: 8px; color: var(--accent); }
.msg-ic .ic { width: 18px; height: 18px; }
.me-ic { display: inline-flex; vertical-align: -0.2em; margin-right: 6px; }
.me-ic .ic { width: 17px; height: 17px; }
.msg-list { margin: 8px 0 0 18px; display: flex; flex-direction: column; gap: 4px; font-family: var(--font); font-size: 15px; }

.comp-dock {
  padding-top: 10px;
  border-top: var(--bw) solid var(--line);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--surface) 92%, transparent), var(--surface));
  max-width: none;
}
.comp-dock > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.comp-dock:empty { border-top: 0; background: none; }
.comp-dock.pour { background: var(--bg); border-top: 0; }

.scale { gap: 8px; align-items: end; }
.scale-btn { align-items: center; justify-content: flex-end; padding: 8px 2px 8px; min-height: 92px; }
.scale-btn::before {
  content: ""; width: 60%; border-radius: 4px; background: var(--accent); opacity: 0.35;
  height: calc(10px + var(--n) * 8px); transition: opacity 0.15s;
}
.scale-btn:nth-child(1) { --n: 1; } .scale-btn:nth-child(2) { --n: 2; } .scale-btn:nth-child(3) { --n: 3; }
.scale-btn:nth-child(4) { --n: 4; } .scale-btn:nth-child(5) { --n: 5; }
.scale-btn:hover::before { opacity: 1; }
[data-theme="mondrian"] .scale-btn::before { border-radius: 0; }

.pour-time { display: inline-flex; align-items: center; gap: 6px; }
.pour-time .ic { width: 13px; height: 13px; }

/* ==========================================================================
   Reading it back (long-form analysis)
   ========================================================================== */
.analysis { max-width: 560px; }
.an-sec { padding: 16px 0; border-top: var(--bw) solid var(--line); }
.an-sec:first-child, .an-care + .an-sec { border-top: 0; padding-top: 6px; }
.an-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.an-h .ic { width: 16px; height: 16px; color: var(--accent); }
.an-summary { font-family: var(--serif); font-size: 19px; line-height: 1.55; }
.an-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.an-stats span, .an-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border: var(--bw) solid var(--line); border-radius: 999px; background: var(--field);
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.an-stats .ic { width: 14px; height: 14px; color: var(--accent); }
.an-chip { color: var(--text); font-size: 14px; }
.an-chip b { font-family: var(--mono); font-size: 11px; color: var(--accent); }
[data-theme="mondrian"] .an-stats span, [data-theme="mondrian"] .an-chip { border-radius: 0; border-color: #0a0a0a; }
.an-muted { font-size: 14px; color: var(--muted); line-height: 1.55; }
.an-muted.small { font-size: 12.5px; margin-top: 6px; }

.arc { width: 100%; height: auto; display: block; overflow: visible; }
.arc-zero { stroke: var(--line-strong); stroke-dasharray: 3 5; }
.arc-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.arc-area { fill: var(--accent-soft); stroke: none; }
.arc-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.arc-axis { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.arc-axis span:nth-child(2) { color: var(--muted); text-align: center; flex: 1; }
.arc-key { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11.5px; color: var(--faint); }
.arc-key span { display: inline-flex; align-items: center; gap: 5px; }
.arc-key .ic { width: 13px; height: 13px; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 118px 1fr 26px; align-items: center; gap: 10px; font-size: 14px; }
.bar-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.bar-label .ic { width: 16px; height: 16px; color: var(--accent); }
.bar { height: 10px; border-radius: 999px; background: var(--field); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar-n { font-family: var(--mono); font-size: 12px; color: var(--faint); text-align: right; }
[data-theme="mondrian"] .bar, [data-theme="mondrian"] .bar i { border-radius: 0; }

.an-quote {
  margin: 0 0 8px; padding: 2px 0 2px 14px; border-left: 3px solid var(--accent);
  font-family: var(--serif); font-size: 17px; line-height: 1.5; font-style: italic;
}
.an-quote.small { font-size: 15px; color: var(--muted); }

.pattern { padding: 12px 14px; margin-bottom: 10px; border: var(--bw) solid var(--line); border-radius: var(--radius-sm); background: var(--field); }
[data-theme="mondrian"] .pattern { border-color: #0a0a0a; }
.pattern-top { display: flex; align-items: center; gap: 8px; }
.pattern-top .ic { width: 17px; height: 17px; color: var(--accent); }
.pattern-n { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--faint); }
.pattern-meaning { font-size: 13.5px; color: var(--muted); margin: 4px 0 8px; line-height: 1.5; }
.pattern-ask { display: flex; gap: 8px; font-size: 14px; font-weight: 600; line-height: 1.45; }
.pattern-ask .ic { width: 16px; height: 16px; margin-top: 2px; color: var(--accent); }

.agency { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.agency-bar { height: 10px; border-radius: 999px; background: var(--a2); overflow: hidden; }
.agency-bar i { display: block; height: 100%; background: var(--ok); }
[data-theme="mondrian"] .agency-bar, [data-theme="mondrian"] .agency-bar i { border-radius: 0; }

.an-next { background: var(--accent-soft); margin: 4px -22px 0; padding: 18px 22px; border-radius: var(--radius); border-top: 0; }
.an-q { font-family: var(--serif); font-size: 20px; line-height: 1.4; font-weight: 600; margin-bottom: 12px; }
.an-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.an-next .inline-form { margin-top: 10px; }
.an-care { display: flex; gap: 12px; padding: 14px; margin-bottom: 14px; border: var(--bw) solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 14px; line-height: 1.55; }
.an-care .ic { width: 20px; height: 20px; flex: none; color: var(--accent); margin-top: 2px; }
.an-foot { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 12px; color: var(--faint); }
.an-foot .ic { width: 14px; height: 14px; flex: none; }
.an-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 24px 10px; }

@media (max-width: 420px) {
  .bar-row { grid-template-columns: 100px 1fr 22px; }
  .an-next { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
}

/* ==========================================================================
   Support numbers
   ========================================================================== */
.helplines { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.hl-emergency {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: var(--bw) solid var(--danger); background: var(--danger-soft);
}
.hl-emergency strong { font-size: 14px; }
.hl-line {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: var(--bw) solid var(--line); border-radius: var(--radius-sm); background: var(--field);
}
[data-theme="mondrian"] .hl-line { border-color: #0a0a0a; }
.hl-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hl-info strong { font-size: 15px; }
.hl-info span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.hl-calls { display: flex; flex-direction: column; gap: 6px; flex: none; align-items: flex-end; }
.hl-note { font-size: 13px; color: var(--muted); line-height: 1.5; }
.call-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 13px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; text-decoration: none; white-space: nowrap;
}
.call-btn .ic { width: 15px; height: 15px; }
.hl-emergency .call-btn { background: var(--danger); color: #fff; }
[data-theme="mondrian"] .call-btn { border-radius: 0; border: 2px solid #0a0a0a; }
.msg .helplines { margin-top: 0; font-family: var(--font); min-width: 240px; }
.msg:has(.helplines) { max-width: 94%; }
.support .meta-field { margin-top: 10px; }

@media (max-width: 460px) {
  .hl-line { flex-direction: column; align-items: flex-start; }
  .hl-calls { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
}

/* full-screen panels follow the visible viewport (keyboard-aware) */
.companion, .editor { height: var(--vvh, auto); }

/* very narrow phones: keep the whole editor toolbar on screen */
@media (max-width: 380px) {
  .editor-bar { gap: 2px; padding-left: 6px; padding-right: 6px; }
  .editor-bar .btn { padding: 0 8px; }
  .editor-bar .btn.icon-only { width: 36px; padding: 0; }
  .editor-actions { gap: 0; }
  .save-badge { font-size: 0; }
  .save-badge .ic { width: 16px; height: 16px; }
  .save-badge.saving::before { content: ""; width: 8px; height: 8px; margin: 0 4px; border-radius: 50%; background: var(--muted); }
}

.more-btn { margin-top: 6px; }

/* children of the answer area always span it (a flex column would otherwise shrink them when centred) */
.comp-dock > * { width: 100%; }

/* ---------- PDF export dialog (sits above Settings) ---------- */
#pdf-modal { z-index: 12500; }
#pdf-modal .select.block { width: 100%; margin-bottom: 4px; }
#pdf-modal .setting-row { margin-top: 6px; }
#pdf-modal .btn.block { margin-top: 10px; }
#unavailable-msg { margin-bottom: 14px; }

/* ---------- Legacy access + database ---------- */
#legacy-modal { z-index: 12500; }
#legacy-modal .select.block { width: 100%; margin-bottom: 4px; }
.alt-link { text-align: center; margin: 12px 0 0; }
.field.mono, .legacy-pw { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; }
.legacy-card { border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 14px; padding: 14px; margin: 10px 0; }
.legacy-who { font-weight: 700; margin-bottom: 6px; }
.legacy-pw { display: block; font-size: 15px; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.06); margin-bottom: 10px; word-break: break-all; user-select: all; }

/* ---------- Remembering the past ---------- */
.past-banner { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; color: var(--accent, #6ee7f9); background: rgba(110, 231, 249, .08); border: 1px solid rgba(110, 231, 249, .25); }
.past-banner .ic { width: 16px; height: 16px; flex: none; }
.past-banner span { flex: 1; }
.when-field .field, .when-field .select { margin-top: 6px; width: 100%; }
.badge.past { color: var(--accent, #6ee7f9); }

/* ---------- Time machine (the past conversation): its own look, apart from daily journaling ---------- */
.past-card { border-color: rgba(240, 180, 106, .35); background: linear-gradient(160deg, rgba(240, 180, 106, .10), transparent 70%), var(--surface, transparent); }
.past-card .kicker { color: #f0b46a; display: flex; align-items: center; gap: 6px; }
.past-card .kicker .ic { width: 14px; height: 14px; }
.companion.past { --accent: #f0b46a; --accent-soft: rgba(240, 180, 106, .18); box-shadow: inset 0 0 140px rgba(240, 180, 106, .10); }
.companion.past .comp-title { letter-spacing: .02em; }
.companion.past .msg.diary { font-family: var(--serif); }
.companion.past .comp-progress i { background: linear-gradient(90deg, #f0b46a, #e58a8a); }

/* ---------- photos in the list and the conversations ---------- */
.note-thumb { display: block; width: 100%; max-height: 150px; object-fit: cover; border-radius: 10px; margin: 8px 0 4px; }
.photo-pick { display: grid; gap: 10px; }
.photo-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line, rgba(255,255,255,.14)); }

/* ---------- calmer first run, backup box ---------- */
.more-opts { margin: 10px 0 4px; }
.more-opts summary { cursor: pointer; font-size: 13.5px; color: var(--muted); list-style: none; padding: 6px 0; }
.more-opts summary::-webkit-details-marker { display: none; }
.more-opts summary::after { content: " +"; }
.more-opts[open] summary::after { content: " –"; }
.backup-box { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line, rgba(255,255,255,.1)); }
.backup-box .btn.block { margin: 6px 0; }

/* ---------- the decoy: a plain "Saved items" keeper ---------- */
#decoy-app { position: fixed; inset: 0; z-index: 5000; display: flex; flex-direction: column; align-items: center; background-color: var(--bg); overflow: hidden; }
#decoy-app .vault-bar, #decoy-app .vault-tools, #decoy-app .notes-list { width: 100%; max-width: 760px; }
.decoy-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; margin: 0 0 8px; border-radius: 14px; border: 1px solid var(--line, rgba(255,255,255,.1)); background: var(--surface, transparent); color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.decoy-row .ic { width: 18px; height: 18px; color: var(--faint); flex: none; }
.decoy-row b { display: block; font-weight: 600; }
.decoy-row small { color: var(--faint); }
#decoy-app .notes-list { padding: 0 16px; }
#decoy-editor { z-index: 5200; }
#decoy-editor textarea { width: 100%; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
#decoy-app .notes-list { padding-top: 8px; }
