/* BornOnce — original stylesheet. System fonts only, no webfonts, no external assets.
 * v1.3: color/type scale systematised on the warm-paper direction; desktop wide
 * layout (1024px+), tablet (700–1023px), mobile 320/360/390px checked by CSS
 * reasoning in tools/verify-harness.mjs (no fixed width >= 320px anywhere). */
:root {
  --paper: #f7f2e9;
  --paper-2: #efe7d6;
  --card: #fffdf7;
  --ink: #221d16;
  --ink-soft: #3d362b;
  --muted: #6f6657;
  --line: #e3d9c4;
  --accent: #9a3b26;   /* brick red */
  --accent-soft: #f3e2d8;
  --teal: #1f5c4d;
  --gold: #b98a2f;
  --gold-soft: #fdf8ec;
  --lm-neg: #e6dcc4;    /* life-map / happiness-bar colours */
  --lm-zero: #b7c9a8;
  --lm-pos: #1f5c4d;
  --chip-bg: rgba(247, 242, 233, .88); /* small label chip over a canvas */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --shadow: 0 2px 12px rgba(34, 29, 22, .12);
  --tap: 44px;         /* minimum touch target */
}
/* v1.9 theme: dark / light. The light values above are the page default;
 * these overrides flip the whole page (all surfaces use the variables).
 * The same palette lives in theme.js (LIGHT/DARK) — the harness asserts
 * the two agree on the shared keys. */
html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1d1913;
  --paper-2: #2a251c;
  --card: #26211a;
  --ink: #f2ead9;
  --ink-soft: #ddd2bd;
  --muted: #a89a80;
  --line: #453d2e;
  --accent: #d96a4a;
  --accent-soft: #3d2a20;
  --teal: #4fae97;
  --gold: #d4a94e;
  --gold-soft: #33291a;
  --lm-neg: #4a4132;
  --lm-zero: #3f5a44;
  --lm-pos: #4fae97;
  --chip-bg: rgba(38, 33, 26, .88);
  --shadow: 0 2px 12px rgba(0, 0, 0, .45);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.65;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
/* tablet: a little wider; desktop: wide layout, life view goes two-column */
@media (min-width: 700px) and (max-width: 1023px) { .wrap { max-width: 860px; } }
@media (min-width: 1024px) {
  .wrap { max-width: 1080px; }
  .hero, .card { padding: 24px 28px; }
}
.hidden { display: none !important; }
h1 { font-size: 1.7rem; line-height: 1.3; margin: .4em 0; }
h2 { font-size: 1.3rem; margin: .2em 0 .5em; }
h3 { font-size: 1.05rem; margin: 1.2em 0 .4em; }
a { color: var(--teal); }
p { margin: .5em 0; }
.kicker { color: var(--accent); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; margin: 0; font-weight: 700; }
.lede { color: #3d362b; }
.fine { color: var(--muted); font-size: .85rem; }
.center { text-align: center; }

/* header */
.site-head { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.head-in { display: flex; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand span { color: var(--accent); font-weight: 700; font-size: .95rem; }
.nav { display: flex; gap: 14px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-size: .92rem; padding: 6px 2px; }
.nav a:hover { color: var(--ink); }
.head-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font-size: .85rem; cursor: pointer;
  min-height: 32px;
}
.chip.on, .chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
button { font: inherit; }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin: 18px 0;
}
.hero { margin-top: 18px; }
.counters { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 4px; }
.counter strong { display: block; font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter span { color: var(--muted); font-size: .85rem; }

/* setup form */
.setup fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; padding: 10px 12px; }
.setup legend { font-weight: 700; font-size: .9rem; padding: 0 6px; }
.radio, .check { display: block; padding: 4px 0; cursor: pointer; }
.field { display: block; margin: 12px 0; }
.field span { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
select, input[type="search"], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit; font-size: 1rem;
}
.big {
  display: block; width: 100%; margin: 16px 0 8px; padding: 14px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 1.15rem; font-weight: 800; cursor: pointer;
}
.big:hover { filter: brightness(1.08); }
.btn {
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--ink); }
.share-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.share-row .btn { flex: 1 1 160px; }

/* life view */
.life-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; margin: 12px 0; box-shadow: var(--shadow);
}
.life-bar .speeds { display: flex; gap: 6px; flex-wrap: wrap; }
.life-bar .speeds .chip { min-width: var(--tap); min-height: var(--tap); padding: 6px 8px; }
.life-bar #pauseBtn { min-height: var(--tap); }
/* v1.5 music control: sits in the life bar (next to pause/speed) and on home. */
.music-ctl { display: inline-flex; align-items: center; gap: 8px; }
.music-ctl input[type="range"] { width: 84px; accent-color: var(--accent); }
.music-ctl .chip.music-waiting::after { content: " ·"; } /* pref ON, waiting for first gesture */
@media (max-width: 640px) {
  .music-ctl input[type="range"] { width: 64px; }
}
.bar-age { font-weight: 800; font-variant-numeric: tabular-nums; margin-left: auto; }
.life-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.speeds { display: flex; gap: 6px; flex-wrap: wrap; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 12px 0 6px; }
.progress > div { height: 100%; width: 0%; background: var(--accent); transition: width .3s linear; }
.age-line { font-weight: 700; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; margin: 12px 0 0; padding: 0; }
.stats div { border-top: 1px solid var(--line); padding-top: 6px; }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats dd small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.life-grid { display: grid; gap: 0 18px; }
@media (min-width: 700px) { .life-grid { grid-template-columns: 1.6fr 1fr; } }
@media (min-width: 1024px) {
  .life-grid { grid-template-columns: 2fr 1fr; gap: 0 24px; }
  .life-grid .peers { position: sticky; top: 76px; align-self: start; }
}
.timeline { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.timeline li { padding: 8px 0 8px 12px; border-left: 3px solid var(--line); margin-left: 4px; position: relative; }
.timeline li b { color: var(--accent); font-variant-numeric: tabular-nums; }
.timeline li.milestone { border-left-color: var(--gold); background: var(--gold-soft); margin-left: 0; padding-left: 16px; border-radius: 0 8px 8px 0; }
.stage {
  display: inline-block; font-size: .72rem; font-weight: 700; color: var(--teal);
  background: var(--paper-2); border-radius: 999px; padding: 1px 8px; margin-left: 6px;
  vertical-align: 1px; white-space: nowrap;
}
.peer-list { list-style: none; margin: 0; padding: 0; }
.peer-list li { border-top: 1px solid var(--line); padding: 8px 0; }
.peer-list .bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.peer-list .bar > div { height: 100%; background: var(--teal); }
.peer-list small { color: var(--muted); }

/* end of life */
.grain { display: grid; gap: 10px; margin: 8px 0; }
.grain-row { display: grid; grid-template-columns: 70px 1fr 70px; gap: 8px; align-items: center; font-size: .9rem; }
.grain-row .track { height: 8px; background: var(--line); border-radius: 99px; position: relative; }
.grain-row .dot { position: absolute; top: -4px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); transform: translateX(-50%); }
.keepsake { border: 1.5px dashed var(--gold); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; background: var(--gold-soft); }
.packs { border: 1px dashed var(--gold); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; background: var(--gold-soft); }
.packs ul li { margin: 6px 0; }
.past-list { list-style: none; padding: 0; margin: 0; }
.past-list li { border-top: 1px solid var(--line); padding: 8px 0; font-size: .95rem; }
.move-code { margin-top: 10px; font-family: ui-monospace, monospace; font-size: .8rem; }

/* explorer */
.exp-year { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin: 12px 0; }
.exp-year label { font-weight: 700; font-size: .9rem; }
.exp-year .stats { flex: 1 1 100%; margin: 0; }
.exp-ctl { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.exp-ctl input { flex: 2 1 200px; }
.exp-ctl select { flex: 1 1 160px; }
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.exp-toggle { display: block; width: 100%; min-height: 44px; margin: 12px 0 0; padding: 10px 16px; font-size: 1rem; font-weight: 700; color: var(--ink); background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.exp-toggle.hidden { display: none; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; min-width: 560px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-size: .8rem; }
td small { color: var(--muted); }

/* about lists */
.plain { padding-left: 20px; }
.plain li { margin: 8px 0; }

.site-foot { border-top: 1px solid var(--line); padding: 20px 0 40px; color: var(--muted); }
.foot-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0; }
.foot-nav a { color: var(--muted); text-decoration: none; font-size: .9rem; padding: 6px 0; }
.foot-nav a:hover { color: var(--ink); text-decoration: underline; }

/* code sample (API section) */
.code {
  font-family: var(--font-mono); font-size: .85rem; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; overflow-x: auto; white-space: pre;
}

/* modals */
.modal {
  position: fixed; inset: 0; background: rgba(34, 29, 22, .55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 0;
}
@media (min-width: 600px) { .modal { align-items: center; padding: 20px; } }
.modal-box {
  background: var(--card); border-radius: 16px 16px 0 0; padding: 22px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto;
}
@media (min-width: 600px) { .modal-box { border-radius: 16px; } }
.dec-options { display: grid; gap: 10px; margin-top: 14px; }
.dec-options button {
  text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; line-height: 1.5;
}
.dec-options button:hover { border-color: var(--accent); background: var(--accent-soft); }
.dec-options button b { display: block; }
.dec-options button span { color: var(--muted); font-size: .88rem; }

/* accessibility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
[dir="rtl"] .timeline li { padding: 8px 12px 8px 0; border-left: 0; border-right: 3px solid var(--line); margin-left: 0; margin-right: 4px; }
[dir="rtl"] .timeline li.milestone { border-right-color: var(--gold); }
[dir="rtl"] .brand span { font-size: .95rem; }

/* language controls */
.lang-select { max-width: 130px; padding: 6px 8px; font-size: .85rem; }
.year-select { width: auto; display: inline-block; padding: 6px 8px; margin-left: 6px; vertical-align: middle; }

/* keepsake: film + album */
#filmCanvas { width: 100%; max-width: 300px; height: auto; display: block; margin: 10px auto; border-radius: 12px; background: #221d16; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; }
.album-grid img { width: 100%; height: auto; border-radius: 10px; cursor: pointer; display: block; }
.book-box { max-width: 720px; }
.book-box table { min-width: 0; }
.candle-lit { font-size: 1.6rem; }
.word-picked { background: var(--accent-soft); border-color: var(--accent); }

/* ---- small screens: 390px, 360px, 320px ----
 * Header collapses to a scrollable single-row nav (never wraps into a wall
 * of links); tap targets reach 44px; stats/grain grids shrink; nothing
 * uses a fixed width >= 320px, so there is no horizontal overflow. */
@media (max-width: 640px) {
  .head-in { flex-wrap: wrap; }
  .nav { order: 3; flex: 1 1 100%; margin-left: 0; overflow-x: auto; flex-wrap: nowrap; gap: 12px; padding-bottom: 2px; scrollbar-width: none; }
  .nav a { flex: none; padding: 10px 2px; }
  .head-btns { margin-left: auto; }
  .chip, .btn { min-height: var(--tap); }
  .speeds .chip { min-width: var(--tap); }
  .lang-select { max-width: 110px; }
}
@media (max-width: 390px) {
  body { font-size: 15px; }
  h1 { font-size: 1.5rem; }
  .card { padding: 16px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .grain-row { grid-template-columns: 56px 1fr 56px; }
}
@media (max-width: 380px) {
  body { font-size: 15px; }
  h1 { font-size: 1.45rem; }
  .card { padding: 16px; }
  .counter strong { font-size: 1.6rem; }
  .nav { gap: 10px; }
}

/* print: only the record book */
@media print {
  body * { visibility: hidden; }
  #bookModal, #bookModal * { visibility: visible; }
  #bookModal { position: absolute; inset: 0; background: #fff; }
  #bookModal .share-row { display: none; }
}

/* ---- v1.4: social trio, life map, house, village, world map ---- */
.social { border: 1px dashed var(--gold); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; background: var(--gold-soft); }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.trio-card { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); padding: 12px; }
.trio-card h4 { margin: 0 0 4px; font-size: 1rem; }
.trio-card .btn { width: 100%; min-height: var(--tap); }
#trailerCanvas { width: 100%; max-width: 300px; height: auto; display: block; margin: 10px auto; border-radius: 12px; background: #221d16; }
#eggCard img { width: 100%; max-width: 300px; height: auto; display: block; margin: 10px auto; border-radius: 12px; }

/* life map: one square per year */
.lifemap-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 10px 0; max-width: 560px; }
.lifemap-grid .lm { aspect-ratio: 1; border-radius: 4px; border: 1px solid var(--line); }
.lifemap-grid .lm-neg { background: var(--lm-neg); }
.lifemap-grid .lm-zero { background: var(--lm-zero); }
.lifemap-grid .lm-pos { background: var(--lm-pos); }
.lifemap-grid .lm-outline { background: transparent; border-style: dashed; }
.lm-legend { display: inline-flex; gap: 4px; vertical-align: middle; }
.lm-cell { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); }
.lm-neg { background: var(--lm-neg); }
.lm-zero { background: var(--lm-zero); }
.lm-pos { background: var(--lm-pos); }

/* pixel scenes + maps: fluid canvases, never wider than their card */
#worldMapCanvas, #houseCanvas, #villageCanvas, #survivalCanvas { width: 100%; height: auto; display: block; border-radius: 12px; background: var(--card); }
#worldMapCanvas, #houseCanvas, #villageCanvas { border: 1px solid var(--line); cursor: pointer; }
#survivalCanvas { border: 1px solid var(--line); cursor: default; }
#villageTalk, #villageRecord { border-left: 3px solid var(--gold); padding: 4px 0 4px 12px; margin: 12px 0; }


@media (max-width: 640px) {
  .trio { grid-template-columns: 1fr; }
  .lifemap-grid { grid-template-columns: repeat(10, 1fr); }
}

/* ---- v1.5: memorial hall + birth registry ---- */
.hall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 12px 0; }
.hall-seat { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-2); padding: 14px; }
.hall-seat h3 { margin: 4px 0; }
.hall-candle { display: block; margin: 0 auto; width: 64px; height: 80px; }
.hall-quote { font-style: italic; }
.hall-seat .share-row { margin: 10px 0 0; }
.hall-seat .share-row .btn { flex: 1 1 120px; min-height: var(--tap); }
/* candle flicker is canvas-driven (see memorial.js drawCandle); the
   site-wide prefers-reduced-motion rule already kills CSS motion,
   and the JS loop draws one static frame when reduced motion is on. */
.registry-row-btn { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 0; cursor: pointer; font: inherit; color: var(--ink); }
#registryRows li.on .registry-row-btn { background: var(--accent-soft); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.reg-num { font-family: var(--font-mono); font-size: .85rem; color: var(--teal); }
.reg-card { border: 1.5px dashed var(--gold); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; background: var(--gold-soft); }
.reg-card-number { font-family: var(--font-mono); color: var(--teal); font-size: 1.15rem; }

/* ---- v1.11 B: birth-draw roulette ---- */
.birth-draw { text-align: center; }
.birth-draw-country { font-size: 2rem; font-weight: 800; line-height: 1.25; margin: .3em 0 .1em; min-height: 2.6rem; overflow-wrap: break-word; }
.birth-draw-pct { font-family: var(--font-mono); color: var(--teal); font-size: 1.2rem; margin: .1em 0; font-variant-numeric: tabular-nums; }
#birthDrawLanded { font-weight: 700; }

/* ---- v1.11 B: birth registry page ---- */
.birth-reg-country { overflow-wrap: break-word; }
.birth-reg-number { overflow-wrap: break-word; }
.birth-reg-table { min-width: 0; font-size: .92rem; }
.birth-reg-table th, .birth-reg-table td { white-space: normal; }
.birth-reg-table th:first-child, .birth-reg-table td:first-child { text-align: left; }
.birth-reg-table th:not(:first-child), .birth-reg-table td:not(:first-child) { text-align: right; }
#birthMapCanvas { display: block; width: 100%; max-width: 480px; height: auto; border-radius: var(--radius-sm); }
#birthRegPeers { margin-bottom: 14px; }

/* ---- v1.11 B: 320px ---- */
@media (max-width: 390px) {
  .birth-draw-country { font-size: 1.6rem; min-height: 2.1rem; }
  .birth-draw-pct { font-size: 1.05rem; }
  .birth-reg-table { font-size: .85rem; }
  .birth-reg-table th, .birth-reg-table td { padding: 6px 4px; }
}

/* ---- v1.11 B: reduced motion ----
 * The roulette has no CSS animation at all (it is JS-driven text swaps,
 * skipped entirely under reduced motion — see birthDrawReducedMotion()
 * in fragment 02), so there is nothing to animate here. This rule is
 * the belt-and-braces guard: if a transition is ever added to these
 * elements, reduced-motion users still see instant swaps. */
@media (prefers-reduced-motion: reduce) {
  .birth-draw-country, .birth-draw-pct, #birthDrawLanded { transition: none; animation: none; }
}

@media (max-width: 390px) {
  .hall-grid { grid-template-columns: 1fr; }
}

/* ---- v1.6: death-record cause shares ---- */
/* Cause-of-death bars (gaps.js deathRecordHTML): label | bar | value. */
.cause-bars { margin: 10px 0; }
.cause-sentence { margin: 6px 0 10px; }
.cause-row { display: grid; grid-template-columns: 150px 1fr 52px; gap: 8px; align-items: center; margin: 6px 0; font-size: .92rem; }
.cause-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.cause-bar { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.cause-bar > div { height: 100%; background: var(--teal); border-radius: 5px; }
@media (max-width: 640px) {
  .cause-row { grid-template-columns: 110px 1fr 48px; }
}

/* v1.5 module 6a: texture flower + MRZ card (gaps.js) */
#flowerCanvas { width: 100%; max-width: 480px; height: auto; display: block; margin: 10px auto; border-radius: 12px; }
.mrz-card { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); padding: 12px 14px; margin: 12px 0; }
.mrz-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--accent); padding-bottom: 6px; margin-bottom: 8px; }
.mrz-lines { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .06em; background: var(--paper-2); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre; }
#sharePreviewCanvas { width: 100%; max-width: 360px; height: auto; display: block; margin: 10px auto; border-radius: 12px; border: 1px solid var(--line); }

/* v1.5: mapfx overlay anchors to the section; v1.8: village is tap-only, page scrolls */
#worldmap { position: relative; }
#mapFxCanvas { border-radius: 12px; }
#villageCanvas { touch-action: manipulation; }

/* ---- v1.7: house memory panel (from tools/v17-specs/house.css) ---- */
#houseMemoryPanel {
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: var(--gold-soft);
  color: var(--ink);
}
#houseMemoryTitle {
  margin: 0 0 6px;
  font-size: 16px;
}
#houseMemoryBody {
  font-size: 14px;
  line-height: 1.6;
}
#houseMemoryBody p {
  margin: 6px 0;
}
#houseMemoryBody img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px auto 0;
  border-radius: 8px;
}
#houseMemoryClose {
  margin-top: 8px;
}
#houseMemoryHint {
  margin-top: 8px;
}

/* ---- v1.7: world-map depth (from tools/v17-specs/map.css) ---- */
#mapFxCanvas { border-radius: 12px; }
.mapfx-viewport { touch-action: none; overscroll-behavior: contain; }
.mapfx-stage { will-change: transform; }
.mapfx-zoom-btn {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line, #e3dcc8);
  border-radius: 10px;
  background: var(--card, #fffdf6);
  color: inherit;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.mapfx-zoom-btn:disabled { opacity: 0.4; cursor: default; }
.mapfx-zoom-btn:focus-visible { outline: 2px solid var(--accent, #1f5c4d); outline-offset: 2px; }
.mapfx-tip-close {
  border: 1px solid var(--line, #e3dcc8);
  border-radius: 8px;
  background: var(--card, #fffdf6);
  color: inherit;
  cursor: pointer;
}
.mapfx-tip-close:focus-visible { outline: 2px solid var(--accent, #1f5c4d); outline-offset: 2px; }
.mapfx-note { margin-top: 4px; }

/* ---- v1.7: music mood label (from tools/v17-specs/music.css) ---- */
.music-mood {
  font-size: 12px;
  color: var(--muted, #888);
  white-space: nowrap;
}
.music-mood:empty { display: none; }
/* v1.9 (M1): the end-page + memorial-view controls sit in a card, not a
 * bar — give them the same breathing room as a paragraph. */
#end .music-ctl, #memorialView .music-ctl { margin: 12px 0; }
@media (max-width: 640px) {
  .music-mood { font-size: 11px; }
}

/* ---- v1.9: world map legend + side list, life-map year detail ---- */
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 2px 0 10px; font-size: .85rem; color: var(--muted); }
.map-legend-title { font-weight: 700; color: var(--ink); }
.map-legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.map-legend-bubble { display: inline-block; border-radius: 50%; background: rgba(154, 59, 38, .55); border: 1px solid rgba(154, 59, 38, .9); }
.map-legend-bubble--s { width: 6px; height: 6px; }
.map-legend-bubble--m { width: 11px; height: 11px; }
.map-legend-bubble--l { width: 17px; height: 17px; }
.map-legend-dash { display: inline-block; width: 28px; border-top: 2px dashed var(--teal); }
.map-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.worldmap-layout { display: grid; grid-template-columns: 1fr; gap: 4px 20px; }
.worldmap-side h3 { margin-top: 0; }
.worldmap-side ul { margin: 0; }
@media (min-width: 1024px) {
  .worldmap-layout { grid-template-columns: 2fr 1fr; align-items: start; }
  .worldmap-side { position: sticky; top: 76px; border-left: 1px solid var(--line); padding-left: 20px; }
}
.lifemap-grid .lm { cursor: pointer; padding: 0; position: relative; }
.lifemap-grid .lm:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lm-age { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 10px; line-height: 1; color: var(--ink); background: var(--chip-bg); border-radius: 3px; padding: 1px 2px; pointer-events: none; }
#lifeYearDetail { margin: 10px 0; padding: 12px 14px; border: 1px solid var(--gold); border-radius: var(--radius-sm); background: var(--gold-soft); }
#lifeYearDetail h4 { margin: 0 0 6px; font-size: 1rem; }
#lifeYearDetail p { margin: 6px 0; font-size: .95rem; }
#lifeYearDetail .btn { margin-top: 6px; }
.survival-scroll { overflow-x: visible; }
@media (max-width: 640px) {
  .survival-scroll { overflow-x: auto; }
  #survivalCanvas { min-width: 560px; }
  .lm-age { font-size: 9px; }
}

/* ---- v1.9: house two-column + hall backfill ---- */
/* All colours reuse the existing :root palette (var(--...)); no new
 * hex colours are introduced here. The canvas portrait reads the
 * same palette through window.BornOnceTheme / portrait.js. */
.house-layout { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
@media (min-width: 700px) {
  .house-layout { grid-template-columns: 1fr 2fr; gap: 24px; }
}
.house-portrait-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
}
#housePortraitCanvas { width: 100%; height: auto; display: block; border-radius: 16px; }
.house-name { font-size: 28px; line-height: 1.25; text-align: center; margin: 14px 0 4px; }
.house-years { text-align: center; color: var(--muted); margin: 0 0 2px; }
.house-country { text-align: center; margin: 0 0 10px; }
.house-oneline { font-weight: 700; font-size: 1.1rem; line-height: 1.5; margin: 10px 0; }
.house-happiness {
  display: flex; align-items: flex-end; gap: 2px;
  height: 30px; margin: 12px 0 4px; overflow: hidden;
}
.house-hb { flex: 1 1 0; min-width: 2px; border-radius: 2px 2px 0 0; }
.house-hb-neg { background: var(--lm-neg); }
.house-hb-zero { background: var(--lm-zero); }
.house-hb-pos { background: var(--lm-pos); }
.house-candle-card {
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius-lg); padding: 18px 16px; margin-top: 16px;
  text-align: center;
}
.house-candle-card .fine { color: var(--paper); opacity: .8; }
.house-candle-card .hall-candle { background: transparent; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--card); }
.house-tabs {
  display: flex; gap: 6px; overflow-x: auto;
  background: var(--paper-2); border-radius: 12px 12px 0 0; padding: 6px 6px 0;
  -webkit-overflow-scrolling: touch;
}
.house-tab {
  flex: 1 0 auto; min-height: var(--tap); padding: 8px 12px;
  border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0;
  background: transparent; color: var(--muted); font: inherit; white-space: nowrap;
  cursor: pointer;
}
.house-tab.on {
  background: var(--card); color: var(--ink);
  border-color: var(--line); font-weight: 700;
}
#houseTabPanel { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; padding: 14px; background: var(--card); }
#houseTabRoom { min-width: 0; }
#houseCanvas { border: 3px solid var(--ink); border-radius: 4px; }
.house-items { font-size: .95rem; margin: 10px 0; }
.hall-portrait {
  display: block; margin: 0 auto; width: 120px; height: 120px;
  border-radius: 12px; border: 1px solid var(--line);
}
#hallActions { margin: 10px 0; }
@media (max-width: 390px) {
  .house-name { font-size: 24px; }
  .house-portrait-card { padding: 16px; }
}

/* ---- v1.10 (C lane): phone layout 320/390px ----
 * CSS only: no class/id/HTML changes, no JS hooks touched.
 * 320px maths (wrap pad 16px + card pad 16px): card content is 256px.
 * Map bleed (card padding 16px <=390px, 20px at 391-640px) takes the
 * map from 256px to 288px at 320px. Desktop >=1024px is untouched:
 * the worldmap-layout side-by-side rule lives outside these queries. */
@media (max-width: 640px) {
  /* 1. Map full-bleed: the viewport (mapfx.js wrapper) escapes the card
   * padding on both sides. The bare-canvas fallback only applies while
   * the canvas is still a direct child of .worldmap-main (before
   * mapfx.js wraps it); once wrapped, the viewport rule carries it. */
  .mapfx-viewport { margin-left: -20px; margin-right: -20px; }
  .worldmap-main > #worldMapCanvas { margin-left: -20px; margin-right: -20px; width: calc(100% + 40px); }
  /* 3. House six tabs: single-row horizontal scroll, never two rows. */
  .house-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .house-tab { min-height: var(--tap); }
  /* 4. Life bar: pause is a full 44px target; speeds wrap as a group
   * (.life-bar and .speeds already flex-wrap: wrap). */
  .life-bar #pauseBtn { min-width: var(--tap); min-height: var(--tap); }
  /* 5. Detail panel: title clears the JS-placed close button, whose
   * 32px inline size is lifted to 44px by min-width/min-height below
   * (min-width wins over an inline width). Zoom buttons overlay the
   * map viewport only, never this panel below the map. */
  #worldMapTip h3 { padding-right: 48px; }
  .mapfx-tip-close { min-width: 44px; min-height: 44px; }
  /* 5. Status line + A-lane retry button (.btn, created by JS): wrap,
   * never overflow the card. */
  #worldMapStatus { overflow-wrap: break-word; }
  #worldMapStatus .btn { max-width: 100%; margin-top: 8px; }
  /* 6. Survival curve: momentum scroll on iOS (the scroll container +
   * 560px fixed canvas already exist in the v1.9 block above). */
  .survival-scroll { -webkit-overflow-scrolling: touch; }
}
/* 2. House grid children may shrink below content width, so neither
 * column can push the page wider than the viewport. Covers the whole
 * single-column range (<700px), not just <=640px. */
@media (max-width: 699px) {
  .house-layout > * { min-width: 0; }
}
@media (max-width: 390px) {
  /* 1. Card padding is 16px here, so the bleed is 16px a side:
   * 320px map = 256px content + 2x16px = 288px. */
  .mapfx-viewport { margin-left: -16px; margin-right: -16px; }
  .worldmap-main > #worldMapCanvas { margin-left: -16px; margin-right: -16px; width: calc(100% + 32px); }
  /* 6. Life-map cells: (256px - 9x2px gaps) / 10 = 23.8px per cell. */
  .lifemap-grid { gap: 2px; }
}

/* BornOnce v1.11 A — home CSS fragment.
 * MERGE: append this whole block at the END of styles.css (after the
 * v1.10 C phone block). Only existing palette variables are used
 * (var(--...)); no new hex colours. No transitions, no animations in
 * this block — the bars are set by inline width, the counters are plain
 * text updates, and the site-wide prefers-reduced-motion rule already
 * nulls transitions elsewhere, so reduced-motion stays still by
 * construction. The float CTA uses the site's own deep green
 * var(--teal), NOT brick red. */

/* ---- v1.11 A: home ---- */
/* A-2: the "which baby are you" line sits inside .counters; it needs no
 * layout of its own — .fine already sizes it. Keep it full-width so it
 * never sits beside a counter on narrow screens. */
.born-nth { flex: 1 1 100%; margin: 0; }

/* A-3: today's theme — a soft inset block inside the hero card. */
.theme-day {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 14px 0;
}
.theme-day-name { font-size: 1.25rem; font-weight: 800; margin: 2px 0; }
.theme-day .fine { margin: 2px 0 0; }

/* A-4: birth-odds bars. Grid mirrors the v1.6 .cause-row pattern
 * (label | bar | value). Bar width IS the share (out of 100%) — no
 * re-scaling, no transition. */
.odds { margin: 14px 0; }
.odds h2 { margin-bottom: 2px; }
.odds-list { list-style: none; padding: 0; margin: 10px 0 0; }
.odds-row {
  display: grid; grid-template-columns: 110px 1fr 52px; gap: 8px;
  align-items: center; margin: 6px 0; font-size: .92rem;
}
.odds-name { overflow-wrap: break-word; }
.odds-pct { text-align: right; font-variant-numeric: tabular-nums; }
.odds-bar { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.odds-bar > i { display: block; height: 100%; background: var(--teal); border-radius: 5px; }

/* A-5: floating birth bar — fixed to the viewport bottom, home only
 * (syncFloatBar toggles .hidden + body.has-floatbar). The bar reserves
 * its own space via body padding so it never covers the footer. */
.float-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 10px; align-items: center;
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 12px rgba(34, 29, 22, .12);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
}
.float-resume {
  flex: 1 1 auto; min-width: 0; text-align: left;
  background: none; border: 0; padding: 0 4px; margin: 0;
  color: var(--ink); font: inherit; font-weight: 700;
  min-height: var(--tap); cursor: pointer;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.float-born {
  flex: none; min-height: var(--tap); padding: 10px 20px;
  border: 0; border-radius: 12px; cursor: pointer;
  background: var(--teal); color: var(--paper);
  font-size: 1.05rem; font-weight: 800;
}
.float-born:hover { filter: brightness(1.08); }
body.has-floatbar { padding-bottom: 76px; }

/* A-4 + A-5 at 320px: card content is 256px (wrap 16px + card 16px).
 * Odds label column shrinks so the bar keeps room; the float bar keeps
 * a 44px birth button and lets the resume label ellipsize. No fixed
 * width >= 320px anywhere. */
@media (max-width: 390px) {
  .odds-row { grid-template-columns: 88px 1fr 44px; }
  .float-bar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .float-born { padding: 10px 16px; }
}

/* BornOnce v1.11 C — 13-styles.css
 * FRAGMENT. Append the whole file to the END of styles.css (after the
 * 320px media block). Nothing in the existing stylesheet is edited.
 * Rules use only variables already defined in styles.css (:root /
 * [data-theme="dark"]): --line, --muted, --accent, --accent-soft,
 * --gold, --teal, --tap (44px). No new colours, no new fonts.
 * No transition or animation property is declared anywhere in this
 * file, so there is nothing to disable under prefers-reduced-motion —
 * the harness asserts that absence here (it scans this file for
 * those property declarations).
 * No fixed width >= 320px: widths are fr / % / var(--tap) only, so
 * the v1.10-C "no fixed width >= 320px" check still passes on the
 * whole file. */

/* ---- 1. Speed: the "next event" chip (44px, like the speed chips) ---- */
.life-bar #nextEventBtn { min-width: var(--tap); min-height: var(--tap); }

/* ---- 2. Four vitals ---- */
.vitals { display: grid; gap: 10px; margin: 12px 0 0; padding: 0; }
.vital { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.vital dt { font-weight: 700; }
.vital dd { margin: 0; display: grid; grid-template-columns: 1fr 36px; gap: 10px; align-items: center; }
.vital-bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.vital-bar > div { height: 100%; background: var(--teal); border-radius: 99px; }
.vital-val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* ---- 3. Timeline star: floated to the row's end, 44px tap target ---- */
.tl-star { float: right; min-width: var(--tap); min-height: var(--tap); padding: 0; border: 0; background: none; color: var(--muted); font-size: 1.15rem; line-height: 1; cursor: pointer; }
.tl-star.on { color: var(--gold); }
[dir="rtl"] .tl-star { float: left; }

/* ---- 4. Focus picker ---- */
.focus-card select { min-height: var(--tap); max-width: 100%; font-size: 1rem; }
.focus-card .share-row { align-items: center; flex-wrap: wrap; }

/* ---- 5. Live life map: the current-year cell gets an accent outline ---- */
.lifemap-grid .lm-now { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- 6. Decision controls + pending-decision button ---- */
.dec-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.dec-controls .btn { min-height: var(--tap); flex: 1 1 auto; }
#pendingDecisionBtn { border-color: var(--gold); font-weight: 700; min-height: var(--tap); }

/* ---- 7. House room top bar + breadcrumb + closed row ---- */
.house-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }
.house-crumb { font-size: .9rem; color: var(--muted); min-width: 0; overflow-wrap: break-word; }
.house-crumb a { color: inherit; }
.house-topbar-spacer { flex: 1 1 auto; }
.house-topbar .chip { min-height: var(--tap); }
#houseClosedRow:not(.hidden) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---- 8. Narrow phones: vitals label column shrinks, top-bar chips share the row ---- */
@media (max-width: 390px) {
  .vital { grid-template-columns: 56px 1fr; }
  .house-topbar .chip { flex: 1 1 auto; }
}

/* BornOnce v1.11 D — FILM / SHARE CSS (styles.css addition).
   MERGE: §7 — append at the end of styles.css. Progress bars match the
   film/trailer canvas width rule already in the file (#filmCanvas /
   #trailerCanvas: width 100%, max-width 300px). */
#filmProgress, #trailerProgress { width: 100%; max-width: 300px; display: block; margin: 10px auto 0; height: 8px; }
#filmProgressText, #trailerProgressText { text-align: center; }

/* ================= v1.13 (A auth + B backup + C presence/shares + D engine) ================= */
/* BornOnce v1.13 A 路 — 登录界面（styles.css 片段）。
 * 锚点：粘在 styles.css 末尾。
 * 本片段不声明任何动效，沿用 styles.css 全站 reduced-motion 规则；
 * 320px 下：页眉按钮区可换行，登录按钮限宽 + 省略号，不溢出。
 * 颜色只用现有变量（--accent / --line / --card / --muted / --ink）。
 */

.auth-btn {
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-box { max-width: 440px; }

.auth-label {
  display: block;
  font-size: .88rem;
  font-weight: 700;
  margin: 14px 0 6px;
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

.auth-input:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.auth-msg {
  margin: 12px 0 0;
  color: var(--accent);
  font-size: .92rem;
  line-height: 1.5;
  min-height: 1.4em;
}

.auth-row { margin-top: 16px; flex-wrap: wrap; }

.auth-row .btn { min-height: var(--tap); }

@media (max-width: 390px) {
  .auth-btn { max-width: 88px; }
  .auth-box { padding: 18px; }
}

/* BornOnce v1.13 B — styles-fragment.css
 * 粘贴位置：styles.css 末尾。只用现有变量（--teal / --muted /
 * --accent / --tap），深色主题自动跟随；无 transition / animation。 */

/* Backup status marks in the past-lives list: glyph + short text only. */
.backup-status { font-size: .85rem; white-space: nowrap; }
.backup-done { color: var(--teal); }
.backup-pending { color: var(--muted); }
.backup-failed { color: var(--accent); }
.backup-busy { color: var(--muted); }

/* Manual "Back up" button: same ghost button as the hall button,
 * compact, but keeps the 44px minimum touch target. */
.past-list .backup-now-btn { min-height: var(--tap); padding: 2px 10px; font-size: .85rem; }

/* 320px: the status text shrinks one step so a long line still wraps
 * inside the list item instead of overflowing the card. */
@media (max-width: 320px) {
  .backup-status { font-size: .8rem; }
  .past-list .backup-now-btn { padding: 2px 8px; }
}

/* BornOnce v1.13 — C lane: presence + share-board styles.
   PASTE ANCHOR (styles.css): append at the END of styles.css.
   Uses only existing variables (--tap, --line, --muted, --gold,
   --gold-soft). No transition / animation anywhere in this fragment.
   320px rules are in the media query at the bottom. */

/* ---- 1. Presence block (inside the hero .counters row) ---- */
.presence-block { color: var(--muted); font-size: .9rem; }
.presence-block #presenceCount { font-variant-numeric: tabular-nums; }

/* ---- 2. Server share cards (rendered into #sharedList) ---- */
.share-card { overflow-wrap: break-word; }
.share-card small { color: var(--muted); }
.share-card .share-retract-btn { min-height: var(--tap); margin-top: 6px; }

/* ---- 3. Board chrome: "更多" button + local-wall notes ---- */
#sharedMoreBtn { min-height: var(--tap); min-width: 120px; }
#sharedLocalNote { border-top: 1px solid var(--line); padding-top: 8px; }
#sharedUnavailableNote { color: var(--muted); }

/* ---- 4. Per-life share button in the past-lives list ---- */
.share-past-btn { min-height: var(--tap); }
.share-past-btn:disabled { opacity: .6; }

/* ---- 5. Narrow phones (320px): share buttons go full-width so the
   retract / share targets stay tappable and never overflow. ---- */
@media (max-width: 390px) {
  .share-card .share-retract-btn,
  .share-past-btn,
  #sharedMoreBtn { width: 100%; }
}

/* BornOnce v1.13 D — ENGINE API DOCS PAGE (styles.css addition).
   MERGE: append at the end of styles.css. No transition/animation anywhere
   in this file (the page-wide prefers-reduced-motion rule covers the rest).
   Reuses existing vars only: --accent (brick red, both themes), --gold,
   --gold-soft, --accent-soft, --muted, --tap. No fixed width >= 320px:
   the key code and the curl block scroll horizontally instead of overflowing.
   320px rule at the bottom: the paste input takes the full row so the
   "try once" button never squeezes off-screen. */

.engine-note { border: 1px solid var(--accent); border-radius: 8px; padding: 12px; margin: 12px 0; }
.engine-unavailable { background: var(--accent-soft); }
.engine-unavailable p { margin: 4px 0; }
.engine-gate { border: 1px solid var(--gold); border-radius: 8px; padding: 12px; margin: 12px 0; background: var(--gold-soft); }
.engine-gate p { margin: 0 0 10px; }
.engine-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.engine-row .btn { min-height: var(--tap); }
.engine-once { border: 2px solid var(--gold); border-radius: 8px; padding: 12px; margin: 12px 0; background: var(--gold-soft); }
.engine-once p { margin: 6px 0; }
.engine-warn { color: var(--accent); font-weight: 700; }
.engine-key { display: block; overflow-x: auto; white-space: nowrap; font-size: .85rem; overflow-wrap: normal; }
.engine-keylist, .engine-usagelist { list-style: none; padding: 0; margin: 8px 0; }
.engine-keyitem, .engine-usageitem { border-top: 1px solid var(--muted); padding: 10px 0; }
.engine-keyitem:first-child, .engine-usageitem:first-child { border-top: none; }
.engine-keyhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.engine-keyhead code { font-size: .95rem; overflow-wrap: anywhere; }
.engine-units { font-variant-numeric: tabular-nums; font-weight: 700; }
.engine-revoke { min-height: var(--tap); margin-top: 8px; }
.engine-keyitem.is-revoked, .engine-usageitem.is-revoked { opacity: .55; }
.engine-revoked { color: var(--muted); font-weight: 700; }
.engine-bar { height: 8px; border-radius: 4px; background: var(--accent-soft); margin: 8px 0 4px; overflow: hidden; }
.engine-bar-fill { height: 100%; background: var(--accent); }
.engine-usageitem.is-over .engine-bar-fill { background: var(--accent); }
.engine-over { color: var(--accent); font-weight: 700; }
.engine-code { overflow-x: auto; white-space: pre; max-width: 100%; font-size: .85rem; }
.engine-paste { flex: 1 1 220px; min-width: 0; min-height: var(--tap); padding: 8px; font: inherit; }
.engine-result { border: 1px solid var(--gold); border-radius: 8px; padding: 12px; margin: 12px 0; background: var(--gold-soft); }

/* ---- 320px: paste input takes the full row, try button drops below ---- */
@media (max-width: 390px) {
  .engine-paste { flex: 1 1 100%; }
  .engine-code { font-size: .78rem; }
  .engine-key { font-size: .78rem; }
}
