/* ===========================================================================
   Test Automation Koans — Zen temple theme
   parchment · sumi ink · bamboo · cinnabar seal
   =========================================================================== */

:root {
  --paper:      #ece3cf;
  --paper-tone: #e4d8be;
  --paper-deep: #d8c9a8;
  --card:       #fbf7ea;
  --ink:        #2a2521;
  --ink-2:      #574d3f;
  --ink-3:      #8a7c66;
  --bamboo:     #6b8e5a;
  --bamboo-deep:#4f6f43;
  --cinnabar:   #b5462f;
  --cinnabar-deep:#8f3320;
  --gold:       #b88a3e;
  --line:       rgba(42, 37, 33, 0.16);
  --topbar-h:   66px;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "STSong", Georgia, "Times New Roman", serif;
  --mono:  "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over our display rules (#app, #enlightenment). */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.5), transparent 42%),
    radial-gradient(circle at 86% 88%, rgba(168, 146, 102, 0.22), transparent 50%),
    repeating-linear-gradient(0deg, rgba(120, 100, 60, 0.025) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(90deg, rgba(120, 100, 60, 0.018) 0 2px, transparent 2px 4px);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

code, .mono { font-family: var(--mono); }

/* ---- buttons ------------------------------------------------------------ */
.btn {
  font-family: var(--serif);
  font-size: 0.98rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:hover { box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary {
  background: linear-gradient(180deg, #779a64, var(--bamboo-deep));
  color: #f7f3e6;
  border-color: var(--bamboo-deep);
  font-weight: 600;
}
.btn--ghost { background: transparent; }
.btn--chip { padding: 7px 13px; font-size: 0.9rem; border-radius: 999px; }

.lotus-icon {
  width: 17px; height: 17px; vertical-align: -3px; margin-left: 4px;
  fill: currentColor; opacity: 0.92;
}

/* ===========================================================================
   The Gate (loading)
   =========================================================================== */
#gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 38%, #f2ead6, #d6c6a3);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
#gate.gate--lifting { opacity: 0; transform: scale(1.04); pointer-events: none; }
.gate__inner { text-align: center; padding: 24px; }
.enso-spinner {
  width: 96px; height: 96px; margin: 0 auto 26px;
  border-radius: 50%;
  border: 6px solid rgba(181, 70, 47, 0.22);
  border-top-color: var(--cinnabar);
  animation: spin 1.1s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gate__title { font-size: 2.7rem; margin: 0; letter-spacing: 0.01em; }
.gate__subtitle { margin: 4px 0 22px; color: var(--cinnabar-deep); font-style: italic; font-size: 1.15rem; }
.gate__stage { font-family: var(--mono); font-size: 0.92rem; color: var(--ink-2); min-height: 1.4em; }
.gate__progress { margin: 16px auto 0; width: min(340px, 90vw); }
.gate__progress-bar { height: 6px; background: rgba(181,70,47,0.18); border-radius: 3px; overflow: hidden; }
.gate__progress-fill { height: 100%; width: 0%; background: var(--cinnabar); border-radius: 3px; transition: width 0.2s ease; }
.gate__progress-label { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-3); margin: 6px 0 0; text-align: center; }
.gate__blessing { margin-top: 14px; color: var(--ink-3); font-style: italic; max-width: 30rem; }
.gate__blessing code { color: var(--cinnabar-deep); }

/* ===========================================================================
   Topbar
   =========================================================================== */
#app { display: grid; grid-template-rows: var(--topbar-h) 1fr; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 0 20px; height: var(--topbar-h);
  background: linear-gradient(180deg, #efe6d2, #e6dabf);
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent) 1;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 230px; }
.seal {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 14px;
  background: var(--cinnabar); color: #f1e7d3;
  font-size: 1.4rem; box-shadow: 0 2px 6px rgba(143, 51, 32, 0.35);
}
.brand__title { font-size: 1.22rem; font-weight: 700; line-height: 1.15; }
.brand__rank { font-size: 0.82rem; color: var(--ink-2); }
.brand__rank strong { color: var(--cinnabar-deep); }

.progress { flex: 1; display: flex; flex-direction: column; gap: 5px; max-width: 620px; margin: 0 auto; }
.progress__bar {
  height: 9px; border-radius: 999px;
  background: rgba(42, 37, 33, 0.1);
  border: none; overflow: hidden;
}
.progress__fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #8fae72, var(--bamboo-deep));
  border-radius: 999px; transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.progress__label { font-size: 0.8rem; color: var(--ink-2); text-align: center; font-family: var(--mono); }
.controls { display: flex; gap: 8px; }

/* ===========================================================================
   Layout
   =========================================================================== */
#layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 300px;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ---- The Path (left) ---------------------------------------------------- */
#path { overflow-y: auto; border-right: 1px solid var(--line); padding: 14px 10px 60px; }
.path__header {
  font-variant: small-caps; letter-spacing: 0.12em;
  color: var(--ink-3); font-size: 0.95rem; padding: 4px 10px 12px;
}
.group { margin-bottom: 14px; }
.group__title {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 0.95rem; padding: 8px 10px;
  color: var(--ink); border-bottom: 1px solid rgba(42, 37, 33, 0.08);
}
.group--done .group__title { color: var(--bamboo-deep); }
.count { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); font-weight: 400; }

.file { margin: 2px 0; }
.file__summary {
  list-style: none; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px 6px 14px; border-radius: 8px; font-size: 0.92rem;
  transition: background 0.15s ease;
}
.file__summary::-webkit-details-marker { display: none; }
.file__summary:hover { background: rgba(42, 37, 33, 0.05); }
.file__summary::before { content: "▸"; margin-right: 6px; color: var(--ink-3); font-size: 0.8em; }
.file[open] > .file__summary::before { content: "▾"; }
.file--done .file__name { color: var(--bamboo-deep); }

.koan-list { list-style: none; margin: 2px 0 8px; padding: 0 0 0 12px; }
.koan-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; margin: 1px 0; border-radius: 7px;
  font-size: 0.86rem; cursor: pointer; color: var(--ink-2);
  border-left: 2px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
.koan-item:hover { background: rgba(42, 37, 33, 0.05); }
.koan-dot { width: 1.1em; text-align: center; color: var(--ink-3); flex: none; }
.koan-item.is-solved { color: var(--bamboo-deep); }
.koan-item.is-solved .koan-dot { color: var(--bamboo); }
.koan-item.is-current {
  background: rgba(181, 70, 47, 0.1);
  border-left-color: var(--cinnabar);
  color: var(--ink); font-weight: 600;
}
.koan-item.is-current .koan-dot { color: var(--cinnabar); }
.koan-item.is-locked { color: var(--ink-3); opacity: 0.55; cursor: not-allowed; }

/* ---- The Stage (center) ------------------------------------------------- */
#stage { overflow-y: auto; padding: 32px clamp(16px, 4vw, 54px) 80px; }
.card {
  background: var(--card);
  border: 1px solid rgba(42, 37, 33, 0.07);
  border-radius: 22px;
  padding: 34px 36px;
  box-shadow: 0 14px 38px rgba(76, 60, 32, 0.09);
  max-width: 820px; margin: 0 auto;
}
.koan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.koan-title { margin: 0; font-size: 1.85rem; line-height: 1.25; }
.koan-sub { color: var(--ink-3); font-size: 0.85rem; margin-top: 6px; }
.koan-sub code { color: var(--ink-2); }
.badge-solved {
  font-size: 0.62rem; vertical-align: middle; font-variant: small-caps; letter-spacing: 0.08em;
  background: var(--bamboo); color: #f6f3e8; padding: 3px 9px; border-radius: 999px; font-family: var(--serif);
}

.teaching {
  margin: 22px 0 8px; padding: 16px 20px;
  border-left: 3px solid var(--gold);
  background: rgba(184, 138, 62, 0.08);
  border-radius: 4px 16px 16px 4px;
  color: var(--ink-2); font-style: italic; line-height: 1.65;
}
.teaching code { font-style: normal; color: var(--cinnabar-deep); }

.code {
  position: relative;
  margin: 22px 0 8px;
  background: #fcf9ee;
  border: 1px solid rgba(42, 37, 33, 0.07);
  border-left: 4px solid var(--bamboo);
  border-radius: 4px 16px 16px 4px;
  padding: 20px 22px;
  overflow-x: auto;
  font-family: var(--mono); font-size: 13.6px; line-height: 2.1;
  color: #3a3328;
  box-shadow: inset 0 1px 0 #fff;
  white-space: pre-wrap;
}
.code .tok { white-space: pre-wrap; }

.blank {
  /* content-box so the `ch` width is for the text only (border-box would
     subtract the padding and clip the last character). */
  box-sizing: content-box;
  font-family: var(--mono); font-size: 0.95em;
  color: var(--cinnabar-deep); font-weight: 600;
  background: rgba(181, 70, 47, 0.07);
  border: none; border-bottom: 2px dashed var(--cinnabar);
  border-radius: 4px 4px 0 0; padding: 1px 4px;
  text-align: center; min-width: 2ch;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.blank::placeholder { color: rgba(181, 70, 47, 0.45); }
.blank:focus {
  outline: none;
  background: rgba(107, 142, 90, 0.16);
  border-bottom-color: var(--bamboo-deep);
  box-shadow: 0 2px 0 rgba(107, 142, 90, 0.35);
}
.blank--solved {
  color: var(--bamboo-deep);
  border-bottom-style: solid; border-bottom-color: var(--bamboo);
  background: rgba(107, 142, 90, 0.14);
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

.actions-hint {
  margin: 12px 2px 0; font-size: 0.82rem; color: var(--ink-3);
}
.actions-hint strong { color: var(--ink-2); }

/* ---- documentation links (per-koan, only authored for a few so far) ---- */
.koan-docs {
  margin: 14px 2px 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  font-size: 0.86rem;
}
.koan-docs__label { color: var(--ink-3); font-variant: small-caps; letter-spacing: 0.04em; }
.koan-docs__link {
  color: var(--cinnabar-deep);
  text-decoration: none;
  border-bottom: 1px dotted var(--cinnabar);
  transition: border-bottom-color 0.15s ease, color 0.15s ease;
}
.koan-docs__link:hover { color: var(--cinnabar); border-bottom-style: solid; }

.feedback { margin-top: 22px; border-radius: 16px; padding: 16px 18px; border: 1px solid rgba(42, 37, 33, 0.08); }
.feedback--pass { background: rgba(107, 142, 90, 0.13); border-color: rgba(107, 142, 90, 0.4); }
.feedback--fail { background: rgba(181, 70, 47, 0.08); border-color: rgba(181, 70, 47, 0.34); }
.feedback--hint { background: rgba(184, 138, 62, 0.12); border-color: rgba(184, 138, 62, 0.42); }
.feedback--answer { background: rgba(181, 70, 47, 0.08); border-color: rgba(181, 70, 47, 0.3); }
.feedback--neutral { background: rgba(42, 37, 33, 0.05); }
.verdict { font-size: 1.06rem; font-weight: 600; }
.fortune { margin-top: 8px; font-style: italic; color: var(--ink-2); }
.master-says { font-variant: small-caps; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 6px; }
.rspec-msg {
  font-family: var(--mono); font-size: 12.6px;
  background: #29241f; color: #ecb9ad;
  padding: 11px 13px; border-radius: 9px; margin: 4px 0 0;
  white-space: pre-wrap; overflow-x: auto;
}

/* ---- ink splash + shake ------------------------------------------------- */
.ink-splash {
  position: absolute; inset: 0; pointer-events: none;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 50%, rgba(107, 142, 90, 0.35), transparent 60%);
  animation: splash 0.8s ease-out forwards;
}
@keyframes splash { 0% { opacity: 0; transform: scale(0.6); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.15); } }
.shake { animation: shake 0.4s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* ===========================================================================
   The Master (right)
   =========================================================================== */
#sensei-panel {
  position: relative; overflow: hidden;
  border-left: 1px solid var(--line);
  padding: 26px 18px; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 30%);
}

/* ---- the zen garden backdrop --------------------------------------------- */
.zen-garden-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; opacity: 0.5;
}
.mountain { fill: var(--ink-3); opacity: 0.16; }
.mountain--front { opacity: 0.24; fill: var(--bamboo-deep); }
.sand-rake path {
  fill: none; stroke: var(--gold); stroke-width: 1.4; opacity: 0.28;
}
.zen-rock {
  fill: var(--ink-3); opacity: 0.3; stroke: var(--ink-2); stroke-width: 0.5;
}
.zen-rock--small { opacity: 0.24; }
.bamboo-stalk {
  fill: none; stroke: var(--bamboo-deep); stroke-width: 6; stroke-linecap: round; opacity: 0.3;
}
.bamboo-nodes path {
  fill: none; stroke: var(--paper); stroke-width: 2; opacity: 0.5;
}
.bamboo-leaves path { fill: var(--bamboo); opacity: 0.28; }

/* Abstract backdrop reads as clutter at small sizes — keep it desktop-only. */
@media (max-width: 1040px) {
  .zen-garden-bg { display: none; }
}

/* ---- the seated monk ------------------------------------------------------ */
#sensei-figure, .sensei-speech-wrap, .sensei-caption { position: relative; z-index: 1; }
.sensei { width: 167px; height: 188px; }
.sensei--bounce { animation: bob 0.6s ease 2; }
@keyframes bob { 50% { transform: translateY(-12px); } }
.sensei--flip { animation: flip 1.3s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes flip { to { transform: rotate(360deg); } }
.sensei-svg { width: 100%; height: 100%; overflow: visible; }

/* A hand-drawn enso (ink circle) rather than a perfect dashed ring — an
   open brush stroke with a thicker "ink pool" where the stroke begins. */
.enso-ring, .enso-ring-accent {
  fill: none; stroke: var(--cinnabar); stroke-linecap: round;
  transform-origin: 80px 64px; animation: enso-breathe 6s ease-in-out infinite;
}
.enso-ring { stroke-width: 4.5; opacity: 0.5; }
.enso-ring-accent { stroke-width: 9; opacity: 0.55; }
@keyframes enso-breathe { 50% { transform: rotate(6deg); opacity: 0.72; } }
.robe { fill: var(--gold); stroke: var(--ink); stroke-width: 2.5; }
.robe-fold { fill: none; stroke: rgba(42, 37, 33, 0.32); stroke-width: 2; stroke-linecap: round; }
.hands { fill: #f4eddb; stroke: var(--ink); stroke-width: 1.5; opacity: 0.92; }
.head { fill: #f4eddb; stroke: var(--ink); stroke-width: 2.5; }
circle.knot { fill: #4a4034; stroke: var(--ink); stroke-width: 2; }
path.knot { fill: none; stroke: #4a4034; stroke-width: 4; stroke-linecap: round; }
.eyes circle { fill: var(--ink); }
.eyes path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.brows path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.mouth { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.mouth--delighted { fill: var(--cinnabar-deep); stroke: var(--ink); }
.zzz text { fill: var(--ink-3); font-family: var(--serif); font-style: italic; font-size: 15px; }

/* mood machine: hide all variants, reveal per mood */
.sensei .eyes, .sensei .mouth, .sensei .brows, .sensei .zzz { display: none; }
.sensei.mood-serene    .eyes--open,    .sensei.mood-serene    .mouth--serene,    .sensei.mood-serene    .brows--neutral { display: block; }
.sensei.mood-pleased   .eyes--closed,  .sensei.mood-pleased   .mouth--pleased,   .sensei.mood-pleased   .brows--neutral { display: block; }
.sensei.mood-delighted .eyes--closed,  .sensei.mood-delighted .mouth--delighted, .sensei.mood-delighted .brows--raised  { display: block; }
.sensei.mood-rueful    .eyes--open,    .sensei.mood-rueful    .mouth--rueful,    .sensei.mood-rueful    .brows--raised  { display: block; }
.sensei.mood-asleep    .eyes--sleepy,  .sensei.mood-asleep    .mouth--neutral,   .sensei.mood-asleep    .brows--neutral { display: block; }
.sensei.mood-asleep .zzz { display: block; animation: zfloat 3s ease-in-out infinite; }
@keyframes zfloat { 50% { transform: translate(3px, -4px); } }

.sensei-speech-wrap { width: 100%; }
.sensei-speech {
  position: relative;
  background: var(--card); border: 1px solid rgba(42, 37, 33, 0.07);
  border-radius: 18px; padding: 15px 17px;
  font-size: 0.92rem; line-height: 1.6; color: var(--ink-2); font-style: italic;
  min-height: 3em; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.sensei-speech::before {
  content: ""; position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  border: 9px solid transparent; border-top: none;
  border-bottom-color: var(--card); filter: drop-shadow(0 -1px 0 var(--line));
}
.sensei-caption { font-variant: small-caps; letter-spacing: 0.12em; color: var(--ink-3); font-size: 0.85rem; }

/* ===========================================================================
   Toasts, petals, endgame
   =========================================================================== */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 55; overflow: hidden; }
.petal { position: fixed; top: -40px; z-index: 55; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(420deg); opacity: 0.7; } }

#toast-host {
  position: fixed; right: 18px; bottom: 18px; z-index: 70;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid rgba(42, 37, 33, 0.07); border-left: 4px solid var(--gold);
  border-radius: 4px 18px 18px 4px; padding: 14px 17px; min-width: 250px; max-width: 320px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
  transform: translateX(130%); transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast--in { transform: none; }
.toast__emoji { font-size: 1.8rem; }
.toast__title { font-weight: 700; }
.toast__desc { font-size: 0.84rem; color: var(--ink-2); }

#enlightenment {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: radial-gradient(circle at center, rgba(236, 227, 207, 0.97), rgba(214, 198, 163, 0.98));
}
.enlight__card {
  text-align: center; max-width: 580px; padding: 40px;
  background: var(--card); border: 1px solid rgba(42, 37, 33, 0.07); border-radius: 26px;
  box-shadow: 0 24px 70px rgba(76, 60, 32, 0.25);
}
.enlight__card h2 { color: var(--bamboo-deep); font-size: 1.9rem; margin: 12px 0; }
.enlight__card p { color: var(--ink-2); line-height: 1.6; }
.enlight__art { color: var(--gold); font-family: var(--mono); letter-spacing: 2px; overflow: hidden; white-space: nowrap; }
.enlight__stats { font-family: var(--mono); font-size: 0.86rem; color: var(--ink-3); margin: 16px 0; }

/* ---- custom confirm modal (never relies on window.confirm) -------------- */
#confirm-modal,
#report-modal,
#auth-modal {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(42, 37, 33, 0.35);
  opacity: 0; transition: opacity 0.2s ease;
}
#confirm-modal.confirm--in,
#report-modal.confirm--in,
#auth-modal.confirm--in { opacity: 1; }
.confirm__card {
  max-width: 420px; margin: 16px; padding: 30px 32px;
  background: var(--card); border: 1px solid rgba(42, 37, 33, 0.07); border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  transform: translateY(8px) scale(0.98); transition: transform 0.2s ease;
}
#confirm-modal.confirm--in .confirm__card,
#report-modal.confirm--in .confirm__card,
#auth-modal.confirm--in .confirm__card { transform: none; }
.confirm__title { margin: 0 0 8px; font-size: 1.25rem; }
.confirm__body { color: var(--ink-2); line-height: 1.55; margin: 0; }
.confirm__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---- "Flag this koan" report affordance + form -------------------------- */
.koan-report { margin-top: 18px; }
.btn-link {
  font-family: var(--serif); font-size: 0.86rem;
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--ink-3); border-bottom: 1px dashed transparent;
  transition: color 0.15s ease, border-bottom-color 0.15s ease;
}
.btn-link:hover { color: var(--cinnabar); border-bottom-color: var(--cinnabar); }

#report-modal .report__context {
  font-family: var(--mono); font-size: 0.8rem; color: var(--ink-3);
  margin: 0 0 16px; word-break: break-word;
}
.report__label {
  display: block; margin-top: 14px;
  font-size: 0.92rem; color: var(--ink-2);
}
.report__opt { color: var(--ink-3); font-size: 0.82rem; }
.report__label textarea,
.report__label input {
  display: block; width: 100%; box-sizing: border-box; margin-top: 6px;
  font-family: var(--serif); font-size: 0.95rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.report__label textarea:focus,
.report__label input:focus {
  outline: none; border-color: var(--bamboo);
  box-shadow: 0 0 0 3px rgba(107, 142, 90, 0.18);
}
/* Honeypot: off-screen, never shown to humans, but visible to dumb bots. */
.report__hp {
  position: absolute; left: -9999px; width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}
.report__status {
  margin-top: 14px; border-radius: 12px; padding: 10px 13px;
  font-size: 0.9rem; color: var(--ink-2);
  border: 1px solid rgba(42, 37, 33, 0.08); background: rgba(42, 37, 33, 0.05);
}
.report__status--fail {
  background: rgba(181, 70, 47, 0.08); border-color: rgba(181, 70, 47, 0.34); color: var(--ink);
}

/* ---- Accounts: sign-in / sign-up modal --------------------------------- */
.auth__card { max-width: 380px; }
.auth__status {
  margin: 12px 0 4px; border-radius: 12px; padding: 9px 12px;
  font-size: 0.88rem; color: var(--ink-2);
  border: 1px solid rgba(42, 37, 33, 0.08); background: rgba(42, 37, 33, 0.05);
}
.auth__status--fail { background: rgba(181, 70, 47, 0.08); border-color: rgba(181, 70, 47, 0.34); color: var(--ink); }
.auth__status--ok { background: rgba(107, 142, 90, 0.1); border-color: rgba(107, 142, 90, 0.34); color: var(--ink); }
.auth__actions { margin-top: 18px; }
.auth__divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 12px; color: var(--ink-3); font-size: 0.82rem;
}
.auth__divider::before, .auth__divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.auth__google { width: 100%; justify-content: center; border: 1px solid var(--line); }
.auth__toggle { display: block; margin: 16px auto 0; text-align: center; }
#auth-resend { margin-top: 8px; }

/* ---- Gentle "sign in to save your progress" nudge (bottom snackbar) ----- */
/* Non-blocking: sits above content (z 80) but below the modals (z 90), so
   clicking "Sign in" opens the auth modal on top of it. */
#signin-nudge {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 150%);
  z-index: 80; width: min(420px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  padding: 16px 18px 14px;
  opacity: 0; transition: transform 0.32s cubic-bezier(.2, .8, .2, 1), opacity 0.32s ease;
}
#signin-nudge.nudge--in { transform: translate(-50%, 0); opacity: 1; }
.nudge__close {
  position: absolute; top: 6px; right: 10px; padding: 4px;
  border: none; background: none; cursor: pointer;
  font-size: 1.25rem; line-height: 1; color: var(--ink-3);
}
.nudge__close:hover { color: var(--ink); }
.nudge__title { font-family: var(--serif); font-weight: 600; margin-bottom: 4px; padding-right: 18px; }
.nudge__text { color: var(--ink-2); font-size: 0.9rem; line-height: 1.5; margin: 0 0 12px; }
.nudge__actions { display: flex; gap: 10px; }
.nudge__never { display: block; margin-top: 10px; font-size: 0.8rem; }

@media (max-width: 1040px) {
  #signin-nudge { left: 16px; right: 16px; bottom: 16px; width: auto; transform: translateY(150%); }
  #signin-nudge.nudge--in { transform: translateY(0); }
}

/* ===========================================================================
   Responsive: collapse to a single column on narrow screens
   =========================================================================== */
@media (max-width: 1040px) {
  #layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
  #app { height: auto; min-height: 100vh; }
  #path { max-height: 34vh; border-right: none; border-bottom: 1px solid var(--line); }
  #sensei-panel { order: -1; border-left: none; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .sensei { width: 120px; height: 134px; }
  .sensei-speech-wrap { flex: 1; min-width: 220px; }
  .progress { display: none; }
}

/* ===========================================================================
   Phone widths: the topbar needs its own row instead of squeezing into one,
   and inputs need >=16px or iOS Safari auto-zooms on focus.
   =========================================================================== */
@media (max-width: 640px) {
  /* The topbar now wraps to two rows — its grid track must grow with it,
     or the wrapped row overlaps the content below (was hard-pinned to
     --topbar-h). */
  #app { grid-template-rows: auto 1fr; }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
    row-gap: 8px;
  }
  .brand { min-width: 0; flex: 1 1 auto; }
  .brand__title { font-size: 1rem; }
  .brand__rank { font-size: 0.76rem; }
  .controls { flex: 1 1 100%; justify-content: flex-end; }
  .btn--chip { padding: 8px 12px; font-size: 0.84rem; white-space: nowrap; }

  #path { max-height: 30vh; }
  .path__header { padding: 8px 6px 8px; }

  /* Bigger tap targets for the koan list on touchscreens. */
  .koan-item { padding: 9px 10px; font-size: 0.9rem; }

  #stage { padding: 16px 14px 60px; }
  .card { padding: 20px 16px; border-radius: 12px; }
  .koan-title { font-size: 1.3rem; }
  .code { font-size: 13px; padding: 14px; }

  /* >=16px stops iOS Safari from zooming the whole page in on focus. */
  .blank { font-size: 16px; }

  .actions { gap: 8px; }
  .btn { padding: 11px 16px; } /* ~44px tall — a comfortable touch target */

  #sensei-panel { padding: 16px 14px; }
  .sensei { width: 84px; height: 94px; }
  .sensei-speech { font-size: 0.86rem; padding: 11px 13px; }

  .toast { right: 0; max-width: none; }
  #toast-host { right: 10px; left: 10px; bottom: 10px; }
  .toast { min-width: 0; }

  .confirm__card { padding: 20px 18px; }
  .confirm__actions { flex-direction: column-reverse; }
  .confirm__actions .btn { width: 100%; text-align: center; }

  /* >=16px stops iOS Safari from zooming the page in when these focus. */
  .report__label textarea,
  .report__label input { font-size: 16px; }

  .enlight__card { padding: 24px 18px; }
}

/* ===========================================================================
   First-run spotlight tour: a single highlight box dims the page around the
   current landmark (box-shadow cut-out), with a caption bubble beside it.
   Sits below the modals (90) but above the signin-nudge (80).
   =========================================================================== */
#tour {
  position: fixed; inset: 0; z-index: 88;
  pointer-events: none;             /* clicks pass through except on the bubble */
  opacity: 0; transition: opacity 0.22s ease;
}
#tour.tour--in { opacity: 1; }

#tour-highlight {
  position: absolute; top: 0; left: 0; width: 0; height: 0;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(42, 37, 33, 0.45);   /* the dimming cut-out */
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  pointer-events: auto; cursor: pointer;             /* click highlight to advance */
  transition: top 0.28s cubic-bezier(.2, .8, .2, 1),
              left 0.28s cubic-bezier(.2, .8, .2, 1),
              width 0.28s cubic-bezier(.2, .8, .2, 1),
              height 0.28s cubic-bezier(.2, .8, .2, 1);
}

#tour-bubble {
  position: absolute; max-width: 300px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  padding: 16px 18px 14px;
  pointer-events: auto;
  transition: top 0.28s ease, left 0.28s ease;
}
#tour-text {
  font-family: var(--serif); color: var(--ink-2);
  font-size: 0.94rem; line-height: 1.5; margin: 0 0 12px;
}
.tour__foot { display: flex; align-items: center; gap: 12px; }
.tour__foot .btn-link { margin-right: auto; }
.tour__step { font-size: 0.8rem; color: var(--ink-3); }
