/* Berlinfographics preview site — palette from themes/brand.json (2026-06-10)
   ink #19191A · yellow #FDE12D · paper #D9DAE2 · blue #4145B9 · blueBright #4A4FD4 */

:root {
  --ink: #19191A;
  --yellow: #FDE12D;
  --paper: #D9DAE2;
  --blue: #4145B9;
  --blue-bright: #4A4FD4;

  --bg: #131314;
  --bg-raised: #1E1E20;
  --bg-card: #212124;
  --border: #2E2E32;
  --text: #E8E8EE;
  --text-dim: #9A9AA6;
  --accent: var(--yellow);
  --accent-ink: #19191A;
  --link: #B9BCF5;
  --shadow: 0 10px 34px rgba(0,0,0,.45);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'EB Garamond', Georgia, serif;
}

html[data-theme="light"] {
  --bg: #E4E5EC;
  --bg-raised: #EFEFF4;
  --bg-card: #F7F7FA;
  --border: #C7C8D2;
  --text: #19191A;
  --text-dim: #5B5B66;
  --accent: var(--blue);
  --accent-ink: #FFFFFF;
  --link: #3438A8;
  --shadow: 0 10px 30px rgba(25,25,26,.14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  transition: background .25s, color .25s;
}
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
kbd {
  background: var(--bg-card); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 .45em; font-size: .85em; font-family: inherit;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  /* brand | search | tools — the outer columns share the slack equally, which
     is what keeps the field on the page's centre line rather than merely
     between its two neighbours. */
  display: grid; grid-template-columns: 1fr minmax(200px, 460px) 1fr;
  align-items: center; column-gap: 20px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--yellow); color: #19191A;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 22px; font-weight: 600;
}
.brand-text { font-weight: 700; letter-spacing: -.01em; font-size: 18px; }
.brand-text em { font-style: normal; color: var(--text-dim); font-weight: 500; }
/* display:flex on .review-tools beats the hidden attribute, so the publish and
   editor clusters stayed on screen with nothing pending. */
[hidden] { display: none !important; }

.topbar-right {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px 16px; min-width: 0;
}
/* The admin cluster is far wider than the public one. Let it wrap inside its
   column rather than overflow, which would shove the search off the page's
   centre line. */
html.admin .topbar-right { flex-wrap: wrap; }
.brand { justify-self: start; }
.topbar-search { justify-self: stretch; }
.topbar-search .search { width: 100%; max-width: none; padding: 9px 14px; font-size: 14px; }
/* Search belongs to the gallery — it has nothing to act on in the viewer. */
body.viewing .topbar-search { visibility: hidden; }
.corpus-count { color: var(--text-dim); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.theme-toggle {
  width: 52px; height: 28px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card);
  position: relative; transition: background .25s;
}
.theme-dot {
  position: absolute; top: 3px; left: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--yellow); transition: transform .25s;
}
html[data-theme="light"] .theme-dot { transform: translateX(23px); background: var(--blue); }

/* ---------- hero / gallery ---------- */
.gallery-view { max-width: 1480px; margin: 0 auto; padding: 0 28px 80px; }
.hero { padding: 60px 0 30px; max-width: 780px; }
.hero-eyebrow {
  color: var(--accent); font-size: 13px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; margin: 0 0 10px;
}
html[data-theme="dark"] .hero-eyebrow { color: var(--yellow); }
.hero-title {
  font-family: var(--font-serif); font-weight: 500; font-size: clamp(34px, 5vw, 54px);
  line-height: 1.06; margin: 0 0 16px; letter-spacing: -.01em;
}
.hero-sub { color: var(--text-dim); font-size: 17px; margin: 0 0 28px; }
.hero-tools { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
/* The search moved to the top bar; on the public page nothing is left in this
   row, so it must not leave a gap under the title. */
.hero-tools:empty { display: none; }
html:not(.admin) .hero-tools { display: none; }
.search {
  flex: 1 1 300px; max-width: 420px; min-width: 0;
  padding: 11px 16px; font-size: 15px; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  outline: none; transition: border-color .15s;
}
.search:focus { border-color: var(--accent); }
.tone-filter { display: flex; gap: 6px; }
.tf-btn {
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--text-dim);
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  transition: all .15s;
}
.tf-btn:hover { color: var(--text); }
.tf-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.grid {
  display: grid; gap: 26px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.card {
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; text-decoration: none; color: var(--text);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--accent); }
.card-thumb {
  aspect-ratio: 1 / 1; overflow: hidden; background: var(--ink);
  display: grid; place-items: start center; position: relative;
}
html[data-theme="light"] .card-thumb { background: #EDEEF3; }
.card-thumb img { width: 100%; height: auto; display: block; }
.card-num {
  position: absolute; top: 10px; left: 10px;
  background: var(--yellow); color: #19191A;
  font-size: 11px; font-weight: 800; letter-spacing: .05em;
  padding: 3px 9px; border-radius: 999px;
}
.card-tone {
  position: absolute; top: 10px; right: 10px;
  background: rgba(25,25,26,.75); color: var(--paper);
  font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
}
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.card-title { font-weight: 600; font-size: 15.5px; line-height: 1.35; margin: 0; }
.card-form { color: var(--text-dim); font-size: 12.5px; margin: 0; }
.no-results { color: var(--text-dim); padding: 40px 0; text-align: center; }

/* ---------- viewer ---------- */
.viewer { position: relative; }
.viewer-inner {
  display: grid; grid-template-columns: minmax(0, 1fr) 440px;
  gap: 0; max-width: 1780px; margin: 0 auto;
  min-height: calc(100vh - 63px);
}
.viewer-stage { padding: 22px 30px 60px; min-width: 0; }
.stage-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.back-link { color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 600; }
.back-link:hover { color: var(--text); }
.stage-pos { color: var(--text-dim); font-size: 13px; letter-spacing: .05em; }
.stage-figure {
  margin: 0; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  background: var(--ink);
}
html[data-theme="light"] .stage-figure { background: #fff; }
.stage-figure img { display: block; width: 100%; height: auto; }

.viewer-panel {
  border-left: 1px solid var(--border);
  background: var(--bg-raised);
  padding: 34px 34px 80px;
  overflow-wrap: break-word;
}
.p-eyebrow {
  color: var(--accent); font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; margin: 0 0 10px;
}
html[data-theme="dark"] .p-eyebrow { color: var(--yellow); }
.p-title {
  font-family: var(--font-serif); font-weight: 500;
  font-size: 27px; line-height: 1.18; margin: 0 0 10px; letter-spacing: -.005em;
}
.p-subtitle { color: var(--text-dim); font-size: 15px; margin: 0 0 18px; }
.p-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 26px; }
.meta-chip {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px;
}

/* social story */
.p-story {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  border-radius: 12px;
  padding: 22px 24px; margin-bottom: 28px;
}
html[data-theme="light"] .p-story { border-left-color: var(--blue); }
.story-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.story-head h3 {
  margin: 0; font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim);
}
.copy-btn {
  font-size: 12px; font-weight: 700; padding: 6px 13px;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 999px; transition: opacity .15s;
}
.copy-btn:hover { opacity: .85; }
.story-body p {
  font-family: var(--font-serif); font-size: 17px; line-height: 1.62; margin: 0 0 14px;
}
.story-body p:first-child::first-line { font-weight: 500; }
.story-body p:last-child { margin-bottom: 0; }
.story-tags { color: var(--link); font-size: 13.5px; margin: 16px 0 0; line-height: 1.7; }

/* research block */
.p-research h3 {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-dim); margin: 26px 0 10px;
}
.p-research p { font-size: 14.5px; color: var(--text); margin: 0 0 12px; line-height: 1.6; }
.p-research p.dim { color: var(--text-dim); }
.scope-note {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-card); padding: 14px 16px;
  font-size: 13.5px; color: var(--text-dim); line-height: 1.55;
}

/* nav arrows */
.nav-arrow {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 30;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border);
  font-size: 22px; line-height: 1;
  box-shadow: var(--shadow);
  transition: all .15s;
}
.nav-arrow:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.nav-prev { left: 18px; }
.nav-next { right: 458px; }
.nav-arrow[disabled] { opacity: .25; pointer-events: none; }

/* footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 26px 28px; text-align: center;
  color: var(--text-dim); font-size: 13px;
}

/* ================= admin review layer ================= */

:root {
  --ok: #3FBF7F;
  --revise: #F2A33C;
  --fact: #E2544A;
  --design: #7C8CF8;
  --mark: #FF2D6F;
}

/* topbar controls */
.review-mode {
  padding: 7px 14px; font-size: 12.5px; font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-dim); background: transparent;
  border: 1px solid var(--border); border-radius: 999px;
  transition: all .15s;
}
.review-mode:hover { color: var(--text); }
.review-mode.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.review-tools { display: flex; align-items: center; gap: 10px; }
.rv-dirty { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.rv-dirty.warn { color: var(--revise); font-weight: 600; }
.rv-tool-btn {
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  color: var(--text); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color .15s;
  font-family: inherit; line-height: 1.6;
}
.rv-tool-btn:hover { border-color: var(--accent); }

/* gallery review filter */
.review-filter {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border);
}
.rf-label {
  font-size: 11px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-dim); margin-right: 6px;
}
.rf-btn {
  padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-dim);
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  transition: all .15s;
}
.rf-btn:hover { color: var(--text); }
.rf-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* card decorations */
.card-fav {
  position: absolute; bottom: 10px; right: 10px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 17px; line-height: 1;
  background: rgba(25,25,26,.66); color: var(--paper);
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .15s, transform .15s, color .15s;
}
.card:hover .card-fav, .card-fav.on { opacity: 1; }
.card-fav:hover { transform: scale(1.12); }
.card-fav.on { color: var(--mark); border-color: var(--mark); }
.card-badges {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100% - 20px);
  margin-top: 26px;
}
.card-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(25,25,26,.78); color: var(--paper);
  border: 1px solid transparent;
}
.card-badge.b-ok { border-color: var(--ok); color: var(--ok); }
.card-badge.b-revise { border-color: var(--revise); color: var(--revise); }
.card-badge.b-fact { border-color: var(--fact); color: var(--fact); }
.card-badge.b-design { border-color: var(--design); color: var(--design); }
.card-badge.b-marks { border-color: var(--mark); color: var(--mark); }
.card.is-approved { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.card.is-revise { border-color: color-mix(in srgb, var(--revise) 55%, var(--border)); }

/* markup toolbar + overlay */
.draw-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-bottom: 12px; padding: 8px 12px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
}
.dt-label {
  font-size: 11px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-dim); margin-right: 4px;
}
.dt-btn, .dt-plain {
  padding: 5px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--text-dim); background: transparent;
  border: 1px solid var(--border); border-radius: 7px; transition: all .15s;
}
.dt-btn:hover, .dt-plain:hover { color: var(--text); border-color: var(--text-dim); }
.dt-btn.active { background: var(--mark); border-color: var(--mark); color: #fff; }
.dt-sep { flex: 1; }

.stage-canvas { position: relative; line-height: 0; }
.mark-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; touch-action: none;
}
.mark-overlay[hidden] { display: none; }   /* [hidden] is not honoured on SVG by the UA sheet */
.mark-overlay.drawing { pointer-events: auto; cursor: crosshair; }
.mark-overlay .mark.hot { filter: drop-shadow(0 0 10px var(--mark)); }

/* review panel */
.review-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--mark);
  border-radius: 12px;
  padding: 20px 22px; margin-bottom: 28px;
}
.rv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.rv-head h3 {
  margin: 0; font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim);
}
.rv-fav {
  font-size: 12px; font-weight: 700; padding: 6px 12px;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; transition: all .15s;
}
.rv-fav:hover { color: var(--text); }
.rv-fav.on { color: var(--mark); border-color: var(--mark); }

.rv-grade { display: flex; gap: 8px; margin-bottom: 10px; }
.rv-btn {
  flex: 1; padding: 11px 10px; font-size: 13.5px; font-weight: 700;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 9px; transition: all .15s;
}
.rv-btn:hover { color: var(--text); border-color: var(--text-dim); }
.rv-approve.active { background: var(--ok); border-color: var(--ok); color: #0A2417; }
.rv-revise.active { background: var(--revise); border-color: var(--revise); color: #2A1A05; }

.rv-flags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.rv-chip {
  padding: 7px 13px; font-size: 12.5px; font-weight: 600;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px; transition: all .15s;
}
.rv-chip:hover { color: var(--text); }
#rv-fact.active { background: var(--fact); border-color: var(--fact); color: #fff; }
#rv-design.active { background: var(--design); border-color: var(--design); color: #10122E; }

.rv-marks { margin-bottom: 16px; display: flex; flex-direction: column; gap: 7px; }
.rv-hint { font-size: 12.5px; color: var(--text-dim); margin: 0; line-height: 1.5; }
.rv-mark { display: flex; align-items: center; gap: 8px; }
.rv-mark-n {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--mark); color: #fff; font-size: 11.5px; font-weight: 700;
}
.rv-mark-note {
  flex: 1; min-width: 0; padding: 7px 10px; font-size: 13px;
  font-family: inherit; color: var(--text);
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 7px; outline: none;
}
.rv-mark-note:focus { border-color: var(--mark); }
.rv-mark-del {
  flex: none; width: 24px; height: 24px; border-radius: 6px;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); font-size: 15px; line-height: 1;
}
.rv-mark-del:hover { color: var(--fact); border-color: var(--fact); }

.rv-notes-label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 7px;
}
.rv-notes {
  width: 100%; padding: 11px 13px; font-size: 14px; font-family: inherit;
  line-height: 1.55; color: var(--text); resize: vertical;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 9px; outline: none;
}
.rv-notes:focus { border-color: var(--mark); }
.rv-updated { font-size: 11.5px; color: var(--text-dim); margin: 7px 0 0; min-height: 1em; }

body:not(.review-on) .review-panel,
body:not(.review-on) .draw-tools,
body:not(.review-on) .review-filter { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .viewer-inner { grid-template-columns: 1fr; }
  .viewer-panel { border-left: none; border-top: 1px solid var(--border); }
  .nav-next { right: 18px; }
  .nav-arrow { top: auto; bottom: 22px; transform: none; }
}
@media (max-width: 860px) {
  .rv-dirty { display: none; }
}
@media (max-width: 900px) {
  /* Not enough width for three columns — the field drops to its own row. */
  .topbar { grid-template-columns: 1fr auto; row-gap: 10px; }
  .brand { grid-area: 1 / 1; }
  .topbar-right { grid-area: 1 / 2; }
  .topbar-search { grid-area: 2 / 1 / 3 / 3; width: 100%; }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; row-gap: 10px; }
  .topbar-right { gap: 8px; flex-wrap: wrap; }
  .review-mode { padding: 6px 10px; font-size: 11.5px; }
  .rv-tool-btn { padding: 5px 10px; font-size: 11.5px; }
  .gallery-view { padding: 0 16px 60px; }
  .viewer-stage { padding: 16px 16px 40px; }
  .viewer-panel { padding: 26px 20px 70px; }
  .brand-text { font-size: 16px; }
  .corpus-count { display: none; }
}

/* ================= variants (photo / fable versions) ================= */
.variant-switch { display: flex; align-items: center; gap: 6px; }
.vs-btn {
  padding: 6px 14px; font-size: 12.5px; font-weight: 700;
  color: var(--text-dim); background: transparent;
  border: 1px solid var(--border); border-radius: 999px; transition: all .15s;
}
.vs-btn:hover { color: var(--text); }
.vs-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.vs-tag {
  padding: 5px 12px; font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; border-radius: 999px;
  background: linear-gradient(120deg, #FDE12D, #F2A33C); color: #19191A;
}
.stage-toolbar-right { display: flex; align-items: center; gap: 14px; }
.card-variants {
  position: absolute; bottom: 10px; left: 10px; z-index: 2;
  display: flex; gap: 4px;
}
.card-variant {
  font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(25,25,26,.8); color: var(--paper); border: 1px solid transparent;
}
.card-variant.cv-image { border-color: #3FBF7F; color: #7FE0AF; }
.card-variant.cv-fable { border-color: #FDE12D; color: #FDE12D; }
.card-variant.cv-fable-updated { border-color: #FF7A45; color: #FFA07A; }

/* ================= SVG edit mode ================= */
.edit-mode-btn {
  padding: 6px 14px; font-size: 12.5px; font-weight: 700;
  color: var(--text-dim); background: transparent; position: relative;
  border: 1px solid var(--border); border-radius: 999px; transition: all .15s;
}
.edit-mode-btn:hover { color: var(--text); border-color: var(--text-dim); }
.edit-mode-btn.active { background: var(--blue-bright); border-color: var(--blue-bright); color: #fff; }
.edit-mode-btn.has-edits::after {
  content: ''; position: absolute; top: -3px; right: -3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--revise); border: 2px solid var(--bg);
}

.edit-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 12px; padding: 9px 12px;
  background: var(--bg-card); border: 1px solid var(--blue-bright); border-radius: 10px;
}
.ed-status { font-size: 12.5px; color: var(--text-dim); }
.ed-exit {
  padding: 6px 16px; font-size: 12.5px; font-weight: 700;
  background: var(--blue-bright); color: #fff;
  border: none; border-radius: 999px;
}

.ed-svg-host { line-height: 0; cursor: default; }
.ed-svg-host svg text, .ed-svg-host svg tspan { cursor: text; }

.ed-selbox {
  position: absolute; z-index: 5; pointer-events: none;
  border: 1.5px dashed var(--blue-bright); border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.25), 0 0 14px rgba(74,79,212,.35);
}
.ed-caret {
  position: absolute; z-index: 6; width: 2px; pointer-events: none;
  background: var(--mark);
  animation: ed-blink 1.05s steps(1) infinite;
}
@keyframes ed-blink { 50% { opacity: 0; } }
.ed-tsel {
  position: absolute; z-index: 4; pointer-events: none;
  background: rgba(74,79,212,.35);
}

/* editor side panel */
.editor-panel {
  background: var(--bg-card);
  border: 1px solid var(--border); border-left: 3px solid var(--blue-bright);
  border-radius: 12px; padding: 20px 22px; margin-bottom: 28px;
}
.ed-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ed-head h3 {
  margin: 0; font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim);
}
.ed-x {
  width: 26px; height: 26px; border-radius: 7px; font-size: 16px; line-height: 1;
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
}
.ed-x:hover { color: var(--text); }
.ed-sel-info { font-size: 13px; color: var(--text-dim); margin: 0 0 12px; font-family: ui-monospace, monospace; }
.ed-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ed-mini {
  padding: 7px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--text); background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: 8px; transition: border-color .15s;
}
.ed-mini:hover { border-color: var(--blue-bright); }
.ed-danger:hover { border-color: var(--fact); color: var(--fact); }
.ed-file { cursor: pointer; display: inline-block; }
.ed-sub {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-dim); margin: 14px 0 8px;
}
.ed-hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin: 0 0 10px; }

.ed-color-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 0; border-top: 1px dashed var(--border);
}
.ed-color-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-dim); min-width: 52px;
}
.ed-color-input {
  width: 34px; height: 28px; padding: 1px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg-raised); cursor: pointer;
}
.ed-both { font-size: 11.5px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
.ed-swatches { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.ed-swatch {
  width: 20px; height: 20px; border-radius: 5px;
  border: 1px solid rgba(255,255,255,.25); cursor: pointer;
  transition: transform .1s;
}
.ed-swatch:hover { transform: scale(1.2); }
html[data-theme="light"] .ed-swatch { border-color: rgba(0,0,0,.2); }
.ed-slider { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ed-slider span {
  font-size: 11.5px; font-weight: 600; color: var(--text-dim); width: 76px; flex: none;
}
.ed-slider input { flex: 1; accent-color: var(--blue-bright); }

/* while editing, the review markup layer stays out of the way */
body.edit-on .draw-tools, body.edit-on .mark-overlay { display: none !important; }

/* ================= fable identification ================= */
.card.is-fable .card-thumb { background: var(--blue); }
html[data-theme="light"] .card.is-fable .card-thumb { background: var(--blue-bright); }
.card.is-fable:hover { border-color: var(--blue-bright); }
.tf-fable.active { background: var(--blue-bright); border-color: var(--blue-bright); color: #fff; }
.tf-fable-updated.active { background: #FF7A45; border-color: #FF7A45; color: #fff; }
/* the newest-version button reads as the live one in the viewer switcher */
.vs-btn.vs-fable-updated { border-color: rgba(255,122,69,.55); }
.vs-btn.vs-fable-updated.active { background: #FF7A45; border-color: #FF7A45; color: #fff; }

/* ================= admin gate ================= */
html:not(.admin) #review-mode,
html:not(.admin) #review-tools,
html:not(.admin) #edit-mode-btn { display: none !important; }

.admin-btn {
  padding: 7px 14px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--text-dim); background: transparent;
  border: 1px solid var(--border); border-radius: 999px; transition: all .15s;
}
.admin-btn:hover { color: var(--text); }
.admin-btn.on { border-color: var(--ok); color: var(--ok); }

.admin-modal { position: fixed; inset: 0; z-index: 90; }
.admin-modal[hidden] { display: none; }
.am-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.am-card {
  position: relative; max-width: 360px; margin: 18vh auto 0; padding: 26px 28px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.am-card h3 { margin: 0; font-size: 17px; }
.am-sub { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.am-card input {
  padding: 10px 13px; font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px; outline: none;
}
.am-card input:focus { border-color: var(--accent); }
.am-err { margin: 0; font-size: 12.5px; color: var(--fact); }
.am-row { display: flex; gap: 8px; justify-content: flex-end; }
.am-btn {
  padding: 9px 16px; font-size: 13px; font-weight: 700;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px;
}
.am-btn:hover { color: var(--text); }
.am-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ================= image export popover ================= */
.viewer-stage { position: relative; }
.export-pop {
  position: absolute; top: 54px; right: 30px; z-index: 50;
  width: 250px; padding: 18px 20px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 11px;
}
.export-pop[hidden] { display: none; }
.export-pop h4 {
  margin: 0; font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim);
}
.xp-label { font-size: 12px; font-weight: 600; color: var(--text-dim); display: flex; flex-direction: column; gap: 5px; }
.xp-select {
  padding: 8px 10px; font-size: 13px; font-family: inherit; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
}
.xp-row { display: flex; gap: 16px; font-size: 13.5px; }
.xp-row label { display: flex; align-items: center; gap: 6px; }
.xp-row input { accent-color: var(--accent); }
.xp-note { margin: 0; font-size: 12px; color: var(--ok); }
.xp-go {
  padding: 10px; font-size: 13.5px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 9px;
}
.xp-go:hover { opacity: .88; }

/* ================= public / admin visibility ================= */
html:not(.admin) .admin-only { display: none !important; }
html.admin .public-only { display: none !important; }
/* Public never renders these, but belt and braces if a script forgets. */
html:not(.admin) #review-panel,
html:not(.admin) #review-filter,
html:not(.admin) #editor-panel,
html:not(.admin) #edit-tools,
html:not(.admin) #draw-tools,
html:not(.admin) #variant-switch,
html:not(.admin) #p-meta { display: none !important; }
html:not(.admin) .hero { padding-bottom: 22px; }

/* ================= public splash ================= */
/* The gauge is an invisible square in column 1: it makes the row exactly as
   tall as one card thumbnail, whatever the column count resolves to. */
.splash-row {
  display: grid; gap: 26px; margin: 0 0 26px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  transition: opacity .3s, transform .3s;
}
.splash-gauge { grid-area: 1 / 1 / 2 / 2; aspect-ratio: 1 / 1; visibility: hidden; }
.splash-row.is-searching { opacity: 0; transform: translateY(-8px); pointer-events: none; height: 0; margin: 0; overflow: hidden; }

.splash {
  grid-area: 1 / 1 / 2 / -1;
  position: relative; overflow: hidden;
  border-radius: 14px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 16px 50px rgba(0,0,0,.42);
  isolation: isolate;
}

/* --- drifting corpus field --- */
.sp-field {
  position: absolute; inset: -10% -6%;
  display: flex; flex-direction: column; justify-content: space-evenly;
  z-index: 0; pointer-events: none;
}
.sp-strip {
  display: flex; white-space: nowrap; width: max-content;
  font-family: var(--font-sans);
  font-weight: 800; font-size: clamp(13px, 1.45vw, 22px); letter-spacing: .02em;
  color: rgba(25,25,26,.26);
  will-change: transform;
}
.sp-strip.is-running {
  animation: sp-drift var(--dur, 400s) linear infinite;
  animation-direction: var(--dir);
}
.sp-strip > span { padding-right: .3em; }
@keyframes sp-drift { from { transform: translateX(0); }
                      to   { transform: translateX(-50%); } }
.splash.is-paused .sp-strip { animation-play-state: paused; }

/* A soft vignette so the board never fights the field behind it. */
.sp-scrim {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(46% 62% at 50% 54%, rgba(253,225,45,.97) 40%, rgba(253,225,45,.55) 72%, rgba(253,225,45,0) 100%),
    linear-gradient(to bottom, rgba(253,225,45,1) 0, rgba(253,225,45,.72) 9%, rgba(253,225,45,0) 24%),
    linear-gradient(to top, rgba(253,225,45,1) 0, rgba(253,225,45,.72) 9%, rgba(253,225,45,0) 24%);
}

/* --- foreground --- */
.sp-fore {
  position: relative; z-index: 2; height: 100%;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(18px, 2.4vw, 30px) clamp(20px, 3vw, 38px);
}
.sp-top { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; }
.sp-kicker, .sp-count {
  font-size: clamp(10px, .92vw, 12.5px); font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase; color: rgba(25,25,26,.66);
}
.sp-count b { font-variant-numeric: tabular-nums; color: var(--ink); }

.sp-board {
  display: flex; flex-direction: column; gap: clamp(3px, .5vw, 7px);
  align-items: center; justify-content: center; flex: 1;
}
.sp-line { display: flex; gap: clamp(1px, .16vw, 3px); }
.sp-cell {
  --cw: clamp(13px, 1.62vw, 27px);
  width: var(--cw); height: calc(var(--cw) * 1.42);
  display: grid; place-items: center;
  font-family: var(--font-sans);
  font-size: calc(var(--cw) * .96); font-weight: 800; line-height: 1;
  color: var(--yellow);
  background: var(--ink);
  border-radius: 2px;
  /* the Solari hinge */
  background-image: linear-gradient(to bottom, rgba(255,255,255,.07) 0 49.5%, rgba(0,0,0,.55) 49.5% 50.5%, rgba(255,255,255,0) 50.5% 100%);
  transition: transform .09s ease-out, background-color .18s;
}
.sp-cell.is-blank { background-color: #201f1c; opacity: .5; }
.sp-cell.is-flipping { transform: perspective(240px) rotateX(38deg) scaleY(.9); opacity: 1; }
.sp-cell.is-set { transform: perspective(240px) rotateX(-7deg); background-color: #24241f; }

.sp-foot {
  display: flex; align-items: baseline; gap: 14px;
  font-size: clamp(10px, .95vw, 13px); font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: rgba(25,25,26,.72);
  opacity: 0; transform: translateY(6px);
  transition: opacity .5s ease, transform .5s ease;
}
.sp-foot.is-in { opacity: 1; transform: none; }
.sp-foot .sp-no { color: var(--ink); }
.sp-foot .sp-cat { font-weight: 600; letter-spacing: .08em; }

@media (prefers-reduced-motion: reduce) {
  .sp-strip { animation: none; }
  .sp-cell { transition: none; }
}
@media (max-width: 860px) {
  .splash-row { grid-template-columns: 1fr; }
  .splash-gauge { aspect-ratio: 3 / 2; }
}

/* ================= publish panel ================= */
/* Deliberately NOT .review-panel: publishing is an admin capability, not a
   review-mode one, so it must not vanish when review mode is switched off. */
.publish-panel {
  margin-top: 18px; padding: 16px 18px 18px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
}
.pb-state {
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-dim);
}
.pb-state.on { border-color: var(--ok, #3FBF7F); color: var(--ok, #3FBF7F); }
.pb-state.pending { border-color: #FF7A45; color: #FFA07A; }
.pb-hint { color: var(--text-dim); font-size: 12.5px; line-height: 1.45; margin: 6px 0 12px; }
.pb-pending {
  margin: 12px 0 0; padding: 9px 11px; border-radius: 8px;
  background: rgba(255,122,69,.1); border: 1px solid rgba(255,122,69,.4);
  color: #FFA07A; font-size: 12px; line-height: 1.45;
}
.pb-btn {
  display: block; width: 100%; margin-top: 8px; padding: 9px 12px;
  font: inherit; font-size: 13px; font-weight: 600;
  border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--text);
  transition: border-color .15s, background .15s, color .15s;
}
.pb-btn:hover { border-color: var(--accent); }
.pb-btn.pb-go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pb-btn.pb-go:hover { filter: brightness(1.07); }
.pb-btn.pb-danger:hover { border-color: var(--mark, #FF2D6F); color: var(--mark, #FF2D6F); }
.pb-btn.pb-ghost { color: var(--text-dim); }
.pb-versions { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.pb-opt {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; font-size: 13px;
  border: 1px solid transparent;
}
.pb-opt:hover { background: var(--bg-raised); }
.pb-opt:has(input:checked) { border-color: var(--accent); background: var(--bg-raised); }
.pb-opt input { accent-color: var(--accent); margin: 0; }
.pb-live { border-color: var(--accent) !important; color: var(--accent) !important; }
.pb-live:disabled { opacity: .6; cursor: default; }
.pb-say { font-size: 12px; color: var(--text-dim); max-width: 320px; line-height: 1.35; }
.pb-say.bad { color: #FFA07A; }
