/* Inter — vendored locally (latin subset) so it works offline and matches the
   brand site's typography. Source: @fontsource/inter (SIL Open Font License). */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/inter-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/inter-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/inter-latin-700-normal.woff2") format("woff2");
}

:root {
  /* GeoSmart / FloodSmart brand palette */
  --brand: #411459;        /* deep purple — header bar, headings */
  --brand-dark: #2f0f41;   /* darker purple for hover on brand */
  --accent: #a71580;       /* magenta — primary CTA buttons, links */
  --accent-hover: #8a0f68; /* darker magenta for hover */
  --brand-ink: #ffffff;

  --bg: #f5f3f7;           /* very light purple-tinted grey */
  --card: #ffffff;
  --ink: #1f1b24;          /* near-black with a purple cast */
  --muted: #6b6577;
  --line: #e6e1ec;         /* purple-tinted border */
  --danger: #dc2626;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  /* Inter to match the brand site, with a graceful system fallback. */
  font: 15px/1.5 "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f2eef6; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 2px 10px rgba(65, 20, 89, 0.25);
}
.topbar .brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.15rem; color: var(--brand-ink); }
.topbar .brand:hover { text-decoration: none; opacity: 0.9; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-app {
  font-weight: 600; font-size: 0.95rem; letter-spacing: 0.01em;
  padding-left: 12px; border-left: 1px solid rgba(249, 243, 231, 0.35);
  color: rgba(255, 255, 255, 0.92);
}
@media (max-width: 560px) { .brand-app { display: none; } }
.topbar nav { display: flex; align-items: center; gap: 20px; white-space: nowrap; }
.topbar nav a { color: var(--brand-ink); opacity: 0.9; }
.topbar nav a:hover { opacity: 1; text-decoration: none; border-bottom: 2px solid var(--accent); }

/* Account menu: the signed-in user is a person icon that opens a dropdown. */
.user-menu { position: relative; display: inline-flex; }
.nav-user {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; border: none; padding: 0;
  background: rgba(255, 255, 255, 0.16); color: var(--brand-ink);
  cursor: pointer; flex: none;
}
.nav-user:hover { background: rgba(255, 255, 255, 0.30); }
.nav-user svg { width: 18px; height: 18px; display: block; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 10px);
  min-width: 200px; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(65, 20, 89, 0.18); padding: 6px; z-index: 60;
}
.user-dropdown[hidden] { display: none; }
.user-dropdown .user-email {
  font-size: 0.8rem; color: var(--muted); padding: 6px 10px 8px;
  border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all;
}
.topbar nav .user-dropdown a {
  display: block; padding: 8px 10px; color: var(--ink); opacity: 1; border-radius: 6px;
}
.topbar nav .user-dropdown a:hover {
  background: #f2eef6; text-decoration: none; border-bottom: none;
}

.container { max-width: 900px; margin: 0 auto; padding: 28px 24px 80px; }
.container.wide { max-width: 1200px; }
h1 { margin-top: 0; color: var(--brand); }
h2 { color: var(--brand); }
.lead { color: var(--muted); font-size: 1.05rem; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: 0.85rem; margin: 2px 0 6px; }
.error { color: var(--danger); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } }
/* Three equal cards on one row, collapsing to fewer as the viewport narrows. */
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .grid.cols-3 { grid-template-columns: 1fr; } }

.section { margin-top: 28px; }
.section-title {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 0 0 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.list { list-style: none; padding: 0; }
.list li { padding: 4px 0; border-bottom: 1px solid var(--line); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.actions { margin-top: 20px; }
.report-actions { display: flex; gap: 8px; }
/* Row action cells: buttons and single-button POST forms side by side, since a
   <form> is block-level and would otherwise push the next action onto its own line. */
.row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }

.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 0.95rem;
}
.btn:hover { text-decoration: none; border-color: #c9c0d4; }
.btn.primary { background: var(--accent); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #f0c4c4; }
.btn.small { padding: 4px 9px; font-size: 0.85rem; }
/* Icon-only button: square, centred glyph (e.g. the delete bin). */
.btn.icon-only {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px; line-height: 0;
}
.btn.icon-only svg { display: block; }
.btn.danger.icon-only:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: progress; }
form { display: inline; }

/* Inline spinner: a spinning ring, sized to the current text. */
.spinner {
  display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
.spinner + * { margin-left: 0.4em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Outline-upload indicator: an inline spinner + label under the file field,
   shown only while the GeoJSON is being uploaded with the job. */
.outline-uploading {
  display: flex; align-items: center;
  margin: 0.4em 0 0; font-size: 0.9em; color: var(--accent);
}
.outline-uploading[hidden] { display: none; }

/* Blockly template editor */
.badge {
  font-size: 0.6em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--accent); color: #fff; padding: 2px 7px; border-radius: 999px;
  vertical-align: middle; margin-left: 6px;
}
/* Editor row: main building canvas beside the always-open library canvas.
   Report templates get large, so the row breaks out of the 900px page column
   (full-bleed) to a wide, tall workspace: ~70vw canvas + ~20vw library. */
.workspace-row {
  display: flex; gap: 2vw; align-items: stretch; justify-content: center;
  width: 96vw; margin-left: calc(50% - 48vw);   /* centre the full-bleed row */
  height: calc(100vh - 230px); min-height: 500px;
  margin-bottom: 14px;
}
.blockly-area { flex: 0 0 70vw; min-width: 0; }
.blockly-div {
  height: 100%; width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); overflow: hidden;
}
/* Narrow screens: stack the two canvases and drop the full-bleed. */
@media (max-width: 820px) {
  .workspace-row {
    flex-direction: column; width: auto; margin-left: 0;
    height: auto; gap: 16px;
  }
  .blockly-area { flex: 1 1 auto; }
  .blockly-div { height: 60vh; }
}
.blockly-toolbar { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; }
.blockly-output {
  background: #1f1b24; color: #f2eef6; border-radius: var(--radius);
  padding: 14px 16px; font-size: 0.82rem; line-height: 1.45;
  max-height: 320px; overflow: auto; white-space: pre; margin: 0;
}
.blockly-output:empty { display: none; }

/* Section library — its own always-open canvas you drag saved sections out of. */
.library-canvas {
  flex: 0 0 20vw; min-width: 230px;
  display: flex; flex-direction: column;
  padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
@media (max-width: 820px) {
  .library-canvas { flex: 1 1 auto; height: 46vh; }
}
.library-head { margin-bottom: 4px; }
.library-head h2 { margin: 0; font-size: 1.1rem; }
.library-controls { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.library-hint { margin: 0 0 10px; font-size: 0.82rem; }
/* Selected library section: a gold outline (contrasts with the magenta block). */
.library-flyout .lib-selected > .blocklyPath { stroke: #ffcf33; stroke-width: 3.5px; }
/* The standalone Blockly flyout is injected here; it fills the remaining height. */
.library-flyout {
  flex: 1 1 auto; min-height: 0; position: relative;
  border: 1px dashed var(--line); border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(
    -45deg, #faf7fc, #faf7fc 10px, #f4eef7 10px, #f4eef7 20px);
}
.library-flyout svg { display: block; }
/* Bin overlay: a drop target in the corner of the library for removing a saved
   section. pointer-events:none so it never intercepts the Blockly drag — the
   drop is detected by hit-testing the pointer against this element's box. */
.library-bin {
  position: absolute; right: 10px; bottom: 10px; z-index: 5;
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.92); border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  pointer-events: none; user-select: none;
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
}
/* Same trashcan glyph as the workspace (Blockly sprite paths), tinted grey; it
   turns brand-magenta when a section is dragged over the bin. */
.library-bin svg { width: 26px; height: 26px; display: block; fill: #888; }
.library-bin.hot { background: #f7dceb; border-color: var(--accent); transform: scale(1.14); }
.library-bin.hot svg { fill: var(--accent); }

.field { margin: 12px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; font: inherit; background: #fff;
}
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 21, 128, 0.15);
}
textarea { resize: vertical; }
.inline-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 180px; margin: 0; }

.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

/* Template builder */
.builder h2 { margin-top: 26px; }
.section-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; background: #faf8fc; }
.section-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.section-title { font-weight: 600; }
.field-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.field-row .f-label { flex: 2; }
.field-row select { flex: 1; }
.field-row .f-help { flex: 2; }

/* Authoring */
.title-row { display: flex; align-items: center; gap: 10px; }
.report-id-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.report-title { font-size: 1.4rem; font-weight: 700; border: none; border-bottom: 2px solid var(--line); border-radius: 0; padding-left: 0; }
.report-title:focus { outline: none; border-bottom-color: var(--brand); }
.save-indicator { font-size: 0.8rem; color: #16a34a; min-height: 1em; }
.saved { color: #16a34a; }

/* Who else has this report open. Quiet: it is a hint, not a warning. */
.presence {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.8rem; color: #475569;
}
.presence-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e; flex: none;
}

/* A block whose save was declined because somebody else changed it first. */
.save-conflict {
  display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  font-size: 0.8rem; color: #92400e;
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 4px;
  padding: 0.25rem 0.5rem;
}
.save-conflict .btn.small { font-size: 0.75rem; padding: 0.1rem 0.4rem; }
.conflict-theirs {
  margin: 0.4rem 0 0; padding: 0.5rem;
  font-size: 0.8rem; white-space: pre-wrap; word-break: break-word;
  background: #f8fafc; border-left: 3px solid #fcd34d; border-radius: 3px;
}

/* Report editing: collapsible section with editable text blocks + "done" ticks */
.report-section {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 14px;
}
.section-summary {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 14px 18px; list-style: none; user-select: none;
}
.section-summary::-webkit-details-marker { display: none; }
/* Disclosure caret (rotates when the section is open). */
.section-summary::before {
  content: "▸"; color: var(--muted); font-size: 0.9rem;
  transition: transform 0.15s ease;
}
.report-section[open] > .section-summary::before { transform: rotate(90deg); }
.section-title { font-weight: 600; font-size: 1.05rem; }
.section-progress {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.prog-tick { display: none; color: #16a34a; font-weight: 700; }
.section-progress.all-done { color: #16a34a; }
.section-progress.all-done .prog-tick { display: inline; }
.section-body { padding: 0 18px 16px; border-top: 1px solid var(--line); }

.edit-text { margin-top: 14px; }
.edit-text-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.edit-text-label { font-weight: 600; }
.done-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.85rem; color: var(--muted); cursor: pointer; font-weight: 500;
}
.done-toggle input { cursor: pointer; }
.edit-text.is-done .done-toggle { color: #16a34a; }
.edit-text.is-done textarea { border-color: #bbe7c6; background: #f6fdf8; }

/* Template author's guidance for a text block, above its textarea (read-only). */
.block-notes {
  border-left: 3px solid #0e7490; background: #ecfeff;
  padding: 6px 10px; border-radius: var(--radius); margin-bottom: 6px;
}
.block-notes-label {
  font-weight: 700; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: #0e7490;
}
.block-notes-text { white-space: pre-wrap; margin: 2px 0 0; font-size: 0.9rem; }

/* ---- Editable table grid (a `table` content block) ---- */
.edit-table { margin-top: 2px; }
.report-grid-scroll { overflow-x: auto; }
.report-grid { border-collapse: collapse; width: 100%; }
.report-grid th, .report-grid td { border: 1px solid var(--line); padding: 0; }
.report-grid th {
  background: #f4f2f8; font-weight: 600; text-align: left;
  padding: 5px 8px; font-size: 0.85rem; white-space: nowrap;
}
.report-grid td input {
  border: 0; width: 100%; padding: 5px 8px; font: inherit;
  background: transparent; box-sizing: border-box;
}
.report-grid td input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.edit-table.readonly .report-grid td input { color: var(--muted); }
.edit-table.readonly .report-grid { background: #faf9fc; }
.grid-controls { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.grid-controls .save-indicator { margin-left: auto; }
.edit-text.is-done .report-grid { border-color: #bbe7c6; }

/* Shown when the block editor could not load a template in full. Loud on
   purpose: the canvas looks plausible but is missing blocks, and the damage
   would be done by saving over the template. */
.load-failure {
  border: 2px solid var(--danger); background: #fef2f2; color: #7f1d1d;
  padding: 10px 14px; border-radius: var(--radius); margin: 0 0 12px;
  line-height: 1.5;
}
.load-failure-detail {
  display: block; margin-top: 4px; font-family: ui-monospace, monospace;
  font-size: 0.8rem; color: #991b1b; white-space: pre-wrap;
}

/* ---- Image gallery (a `gallery` content block) ----
   A card per image in print order: thumbnail, caption, and the controls that
   reorder or remove it. The thumbnail is the small server-made copy, never the
   print original, so a forty-photograph appendix stays a usable page. */
.edit-gallery { margin-top: 2px; }
.gal-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gal-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 8px; background: #fff;
}
.gal-thumb {
  width: 96px; height: 72px; object-fit: cover; flex: 0 0 auto;
  border-radius: 4px; background: #f4f2f8;
}
.gal-body { flex: 1 1 auto; min-width: 0; }
.gal-caption {
  width: 100%; border: 1px solid transparent; background: transparent;
  padding: 4px 6px; font: inherit; border-radius: 4px;
}
.gal-caption:hover { border-color: var(--line); }
.gal-caption:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
/* Locked, the caption is read as prose (it wraps, and shows its formatting);
   editing swaps back to the input. Same trade the review page makes for text. */
.gal-caption-text { display: none; padding: 4px 6px; }
.edit-gallery.readonly .gal-caption-text { display: block; }
.edit-gallery.readonly .gal-caption { display: none; }
.gal-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.gal-badge {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 700; color: var(--muted); background: #f4f2f8;
  padding: 1px 6px; border-radius: 999px;
}
.gal-badge-new { color: #fff; background: var(--accent); }
.gal-badge-gone { color: #fff; background: var(--danger); }
.gal-controls { display: flex; gap: 4px; flex: 0 0 auto; }
.gal-add { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.gal-add .save-indicator { margin-left: auto; }
.gal-empty { margin: 6px 0 0; font-size: 0.9rem; }
/* Nothing to add to while the list is locked, so the picker goes away rather
   than sitting there greyed out; "Edit content" brings it back. */
.edit-gallery.readonly .gal-add { display: none; }
.gal-note { margin: 0 0 8px; font-size: 0.85rem; color: var(--muted); }
.edit-gallery.readonly .gal-caption { color: var(--muted); }
.edit-gallery.readonly .gal-item { background: #faf9fc; }
.edit-text.is-done .gal-item { border-color: #bbe7c6; }

/* Review page: what the writer did to the list since the baseline. */
.gal-added, .gal-recaptioned { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.gal-removed { margin-top: 8px; }
.gal-ghost { opacity: 0.72; background: #faf9fc; }
.gal-thumb-gone {
  width: 96px; height: 72px; flex: 0 0 auto; border-radius: 4px;
  background: #f4f2f8; color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.gal-gone-caption { text-decoration: line-through; color: var(--muted); }

/* ---- Report management: status badges, progress, review feedback ---- */
/* Status pill colour variants (defined after the base .badge so they win). */
.badge.muted { background: var(--line); color: var(--muted); }
.badge.info  { background: #dbeafe; color: #1e40af; }
.badge.warn  { background: #fde9c8; color: #92400e; }
.badge.ok    { background: #dcfce7; color: #166534; }
.badge.small { margin-left: 4px; }

/* Compact progress indicator used across the report lists. */
.progress { display: inline-flex; align-items: center; gap: 8px; }
.progress-bar { width: 84px; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--accent); }
.progress-num { font-size: 0.8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Collapsible card sections (My reports buckets, admin "New report"). */
.collapsible-section > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
}
.collapsible-section > summary::-webkit-details-marker { display: none; }
.collapsible-section > summary::before {
  content: "\25B8"; color: var(--muted); font-size: 0.9em; transition: transform 0.15s ease;
}
.collapsible-section[open] > summary::before { transform: rotate(90deg); }
.collapsible-section > summary h2 { margin: 0; }
.section-count {
  font-size: 0.75rem; font-weight: 700; color: var(--muted); background: var(--line);
  padding: 1px 8px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
/* Hover-for-an-explanation marker; the wording lives in the summary title. */
.section-hint {
  cursor: help; width: 16px; height: 16px; border-radius: 999px; background: var(--line);
  color: var(--muted);
  font-size: 0.65rem; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Admin: per-row writer/reviewer assignment form. */
.assign-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.assign-label { display: flex; flex-direction: column; gap: 2px; font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.assign-label select { min-width: 160px; }
.inline-submit { display: inline; margin: 0; }

/* Writer edit page: "changes requested" banner + inline reviewer comments. */
.review-feedback { border-left: 4px solid #f59e0b; background: #fffbeb; }
.feedback-overall { white-space: pre-wrap; font-weight: 500; margin: 4px 0; }
.feedback-jump { margin: 6px 0 0; padding-left: 18px; }
.feedback-jump li { margin: 2px 0; }

.edit-text.has-comment {
  border-left: 3px solid #f59e0b; background: #fffbeb;
  padding: 10px 12px; border-radius: var(--radius); margin-top: 18px;
}
.edit-text.has-comment.comment-resolved {
  border-left-color: #16a34a; background: #f6fdf8; opacity: 0.75;
}
.reviewer-comment { margin-bottom: 8px; }
.reviewer-comment.muted-comment { opacity: 0.8; }
.rc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rc-label { font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: #92400e; }
.rc-text { white-space: pre-wrap; margin: 4px 0 0; }
.resolve-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; color: var(--muted); cursor: pointer; }

/* Help pages: a contents strip, and the template-shape diagram. */
.help-toc { display: flex; flex-wrap: wrap; gap: 14px; align-items: baseline; }
.help-toc strong { margin-right: 4px; }
.help-tree {
  background: #faf9fc; border: 1px solid var(--line); border-radius: 6px; padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem;
  line-height: 1.5; overflow-x: auto;
}

/* Block comment threads (reports/_thread.html) — the same on both pages. */
.cmt-thread { display: flex; flex-direction: column; gap: 6px; }
.cmt-head { display: flex; align-items: center; gap: 8px; }
.cmt-label { font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: #92400e; }
.cmt-msg { border-left: 3px solid var(--line); padding: 2px 0 2px 8px; }
.cmt-meta { display: flex; gap: 8px; align-items: baseline; font-size: 0.8rem; }
.cmt-text { white-space: pre-wrap; margin: 2px 0 0; }
.cmt-form { display: flex; gap: 6px; align-items: flex-start; }
.cmt-form textarea { flex: 1; }
.cmt-empty { margin: 0; font-size: 0.85rem; }
/* A settled thread stays readable but stops competing for attention. */
.cmt-thread.is-resolved .cmt-msg { border-left-color: #86efac; opacity: 0.75; }

/* Reviewer page: text beside its comment, plus the edit-content toggle. */
.review-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.edit-toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.review-block {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.review-block:last-child { border-bottom: none; }
/* `display: grid` above would otherwise beat the hidden attribute the
   "changed blocks only" filter sets. */
.review-block[hidden] { display: none; }
.review-body textarea, .review-comment textarea { width: 100%; }
.rv-body[readonly] { background: #faf9fc; }
.rv-body.editing { background: #fff; border-color: var(--accent); }
@media (max-width: 720px) { .review-block { grid-template-columns: 1fr; } }

/* What the writer changed from the generated draft (app/textdiff.py). Added text
   is underlined as well as tinted, and removed text struck through, so the two
   are still told apart without relying on colour. */
.diff-toolbar { margin-bottom: 12px; }
.diff-since { font-size: 0.9rem; color: var(--muted); }
.diff-since strong { color: var(--ink); }
.rt-diff ins, .rt-diff-source ins {
  background: #dcfce7; color: #14532d; text-decoration: underline; text-decoration-thickness: 2px;
}
.rt-diff del, .rt-diff-source del { background: #fee2e2; color: #7f1d1d; }
.diff-source { margin-top: 8px; }
.diff-source > summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.rt-diff-source {
  margin-top: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 6px;
  background: #faf9fc; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem; white-space: pre-wrap; word-break: break-word;
}
.badge.edited { background: #dcfce7; color: #166534; }
.badge.muted-badge { background: var(--line); color: var(--muted); }
.report-grid td.cell-changed input { background: #dcfce7; }
.report-grid td.cell-changed.no-highlight input { background: inherit; }
/* A section whose blocks are all filtered out keeps its heading but says nothing
   more; hiding the card entirely would make the report look shorter than it is. */
.card.section-empty .review-block { display: none; }

/* Site & maps panel: two columns — inputs/status on the left, downloads right */
.maps-card-cols { display: flex; gap: 20px; align-items: flex-start; }
.maps-main { flex: 1; min-width: 0; }
.maps-downloads {
  flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px;
  padding-left: 20px; border-left: 1px solid var(--line);
}
.maps-downloads .btn { text-align: center; white-space: nowrap; }
@media (max-width: 720px) {
  .maps-card-cols { flex-direction: column; }
  .maps-downloads { flex-direction: row; padding-left: 0; border-left: none; }
}

/* Site & maps panel: per-map render status list */
.maps-rows { list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: 0.85rem; }
.maps-rows li { padding: 0.15rem 0; font-variant-numeric: tabular-nums; }
.maps-rows li.ok { color: #16a34a; }

/* Half-screen PDF preview panel (width is user-resizable via --pdf-w) */
:root { --pdf-w: 50vw; }
.pdf-panel {
  position: fixed; top: 0; right: 0; width: var(--pdf-w); height: 100vh;
  background: #fff; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 100;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.10);
}
.pdf-panel.hidden { display: none; }
.pdf-resizer {
  position: absolute; left: -3px; top: 0; width: 8px; height: 100%;
  cursor: col-resize; z-index: 110;
}
.pdf-resizer:hover, body.resizing .pdf-resizer { background: var(--brand); opacity: 0.35; }
.pdf-panel-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--card);
}
.pdf-panel-bar .spacer { flex: 1; }
.pdf-status { font-size: 0.8rem; color: var(--muted); }
.auto-toggle { font-size: 0.85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.auto-toggle input { width: auto; }
.pdf-panel-body { position: relative; flex: 1; }
.pdf-panel iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pdf-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); background: #fafbfc; font-size: 0.95rem;
  white-space: pre-line; text-align: center; padding: 24px; overflow: auto;
}
.pdf-loading.hidden { display: none; }

/* When the panel is open, the editor fills the remaining width */
body.pdf-open .container { margin: 0; max-width: none; width: calc(100vw - var(--pdf-w)); padding-right: 24px; }
/* While dragging, don't let the iframe swallow the mouse move events */
body.resizing { user-select: none; }
body.resizing #pdf-frame { pointer-events: none; }

@media (max-width: 820px) {
  .pdf-panel { width: 100vw; }
  body.pdf-open .container { width: 100vw; }
}

/* ======================================================================== */
/* Text-block prose window + value-picker field                             */
/*                                                                          */
/* The text block's logic is authored on the canvas as blocks; this window  */
/* edits only the prose (with a {token} highlight overlay), and the value    */
/* picker is the searchable field the Value block uses against the catalog.  */
/* ======================================================================== */
.te-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(31, 27, 36, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 16px; overflow-y: auto;
}
.te-panel {
  background: var(--card); color: var(--ink);
  border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  width: min(880px, 100%); max-height: 92vh;
  display: flex; flex-direction: column;
}
.te-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.te-header h2 { margin: 0; font-size: 1.1rem; color: var(--brand); }
.te-close {
  background: none; border: 0; font-size: 1.1rem; cursor: pointer;
  color: var(--muted); line-height: 1; padding: 4px;
}
.te-close:hover { color: var(--ink); }
.te-content { padding: 16px 18px; overflow-y: auto; }
.te-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.te-footer .te-status { margin-right: auto; }

.te-label { font-weight: 600; font-size: 0.9rem; color: var(--ink); display: block; margin-bottom: 2px; }
.te-hint { font-size: 0.8rem; margin: 0 0 8px; }
.te-tokenline { margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Prose editor: a highlight backdrop under a transparent textarea, so {tokens}
   can be marked without a rich-text editor. Both must share identical box
   metrics so the text aligns exactly. */
.te-prose-wrap { position: relative; }
.te-highlights,
.te-prose {
  width: 100%; min-height: 150px; box-sizing: border-box;
  margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word;
}
.te-highlights {
  position: absolute; inset: 0; overflow: hidden;
  color: transparent; pointer-events: none; background: #fff;
}
.te-highlights .te-tok {
  background: #ede9fe; color: transparent; border-radius: 3px;
  box-shadow: 0 0 0 1px #c4b5fd inset;
}
.te-prose {
  position: relative; background: transparent; color: var(--ink);
  resize: vertical; caret-color: var(--ink);
}
.te-prose:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.te-notes {
  width: 100%; min-height: 150px; box-sizing: border-box; resize: vertical;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-size: 0.9rem; line-height: 1.5;
}
.te-notes:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* --- Rich text: formatting toolbar, reference picker, live preview --------- */
/* The dialect is documented in app/richtext.py; these styles dress the toolbar
   that inserts its markers (static/js/richtext_toolbar.js) and the preview pane
   that shows the rendered result. */
.rt-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-bottom: 6px; position: relative;
}
.rt-btn {
  font: inherit; font-size: 0.85rem; line-height: 1;
  min-width: 30px; padding: 6px 8px; cursor: pointer;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
}
.rt-btn:hover { background: var(--bg); border-color: var(--accent); }
.rt-btn.rt-b { font-weight: 700; }
.rt-btn.rt-i { font-style: italic; }
.rt-btn.rt-refbtn { margin-left: auto; }
.rt-hint {
  font-size: 0.78rem; color: var(--muted); margin: 4px 0 0;
}
.rt-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); padding: 0 3px; border-radius: 3px;
}

/* Reference picker: a popup list of the template's labelled sections, maps and
   tables. An entry that isn't numbered/captioned is shown but disabled, with the
   reason on hover — hiding it would just look like the label had been lost. */
.rt-refmenu {
  position: absolute; top: 100%; right: 0; z-index: 30; margin-top: 4px;
  width: 340px; max-width: 90vw; max-height: 300px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.rt-refempty { margin: 0; padding: 10px 12px; font-size: 0.82rem; }
.rt-refrow {
  display: flex; align-items: baseline; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; border-bottom: 1px solid var(--line);
  background: none; font: inherit; font-size: 0.85rem; text-align: left;
  cursor: pointer;
}
.rt-refrow:last-child { border-bottom: 0; }
.rt-refrow:hover:not(.disabled) { background: var(--bg); }
.rt-refrow.disabled { cursor: not-allowed; opacity: 0.5; }
.rt-refkind {
  flex: none; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); min-width: 68px;
}
.rt-refname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-refkey {
  flex: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem; color: var(--muted);
}

/* Preview pane: the same HTML the review page shows, so a writer sees exactly
   what a reviewer will. */
.rt-preview, .rt-rendered {
  border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; background: #fff; font-size: 0.92rem;
}
.rt-preview { margin-top: 6px; background: var(--bg); }
.rt-preview:empty { display: none; }
.rt-preview p, .rt-rendered p { margin: 0 0 0.6em; }
.rt-preview p:last-child, .rt-rendered p:last-child { margin-bottom: 0; }
.rt-preview ul, .rt-preview ol,
.rt-rendered ul, .rt-rendered ol { margin: 0 0 0.6em; padding-left: 1.4em; }
.rt-preview sup, .rt-rendered sup,
.rt-preview sub, .rt-rendered sub { font-size: 0.75em; line-height: 0; }

/* A cross-reference prints as a bare number in the PDF, which can't be known
   here — so on screen it shows what it points at instead. */
.rt-ref {
  background: #ede9fe; box-shadow: 0 0 0 1px #c4b5fd inset;
  border-radius: 3px; padding: 0 3px; font-size: 0.92em;
}
.rt-ref.broken {
  background: #fee2e2; box-shadow: 0 0 0 1px #fca5a5 inset; color: #991b1b;
}

/* Searchable value-picker field (FieldValuePicker), shown in Blockly's
   DropDownDiv when a Value block's field is clicked. */
.tv-picker { width: 280px; max-width: 90vw; display: flex; flex-direction: column; gap: 6px; }
.tv-search {
  font: inherit; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px;
  width: 100%; box-sizing: border-box;
}
.tv-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; }
.tv-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 5px 8px; border-radius: 4px; font: inherit;
}
.tv-item:hover { background: #eff6ff; }
.tv-item.tv-selected { background: #dbeafe; font-weight: 600; }
.tv-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-tag { flex-shrink: 0; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tv-empty { padding: 10px 8px; color: var(--muted); font-size: 0.85rem; }

/* Report block colour field: outline the swatch so it stays visible even when
   the chosen colour matches the canvas/background. The report_banner extension
   tags the colour field's group with .reportColourField; border its swatch rect
   (not every field's blocklyFieldRect). */
/* !important overrides Blockly's runtime-injected `... > rect { stroke: none }`
   (higher specificity than a plain class rule). */
.reportColourField .blocklyFieldRect { stroke: #57606a !important; stroke-width: 1.5px; }

/* ======================================================================== */
/* Banner sets (admin/banners.html)                                         */
/* ======================================================================== */
.banner-upload { display: flex; align-items: center; gap: 12px; margin: 8px 0 18px; flex-wrap: wrap; }
.banner-name-input {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  min-width: 260px;
}
.set-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.set-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 12px; display: flex; flex-direction: column; gap: 12px;
}
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.set-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-slots { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.slot { display: flex; flex-direction: column; gap: 6px; }
.slot-logo { align-items: center; }
.slot-label { font-size: 0.78rem; color: var(--muted); }
.slot-thumb-wrap {
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background: repeating-conic-gradient(#f3f4f6 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
}
.slot-banner .slot-thumb-wrap { height: 84px; }
.slot-logo .slot-thumb-wrap { width: 96px; height: 84px; }
.slot-thumb { width: 100%; height: 100%; object-fit: contain; display: block; }
.slot-empty {
  width: 100%; height: 100%; min-height: 84px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.8rem;
}
.slot-actions { display: flex; align-items: center; gap: 6px; }
.slot-actions .btn { margin: 0; }

/* Named images on a set (a Callout block picks these by name). */
.set-images {
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--line); padding-top: 10px;
}
.image-list { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.image-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px;
}
.image-cell .slot-thumb {
  width: 84px; height: 60px; border: 1px solid var(--line); border-radius: 6px;
  background: repeating-conic-gradient(#f3f4f6 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
}
.image-name {
  font-size: 0.75rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.image-add { display: flex; align-items: center; gap: 6px; }
.image-add .banner-name-input { min-width: 0; flex: 1; }
.image-add .btn { margin: 0; white-space: nowrap; }

/* --------------------------------------------------------------------------- */
/* Maps page (generate maps)                                                   */
/* --------------------------------------------------------------------------- */
.notice { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0 18px; background: var(--card); }
.notice-warn { border-color: #e7d3a1; background: #fdf7e6; color: #6b5416; }
.notice code { background: rgba(0,0,0,0.05); padding: 1px 5px; border-radius: 4px; }

.field-hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }

.map-form { max-width: 760px; }
.map-field { margin: 0 0 22px; }
.map-field > label { display: block; font-weight: 600; margin-bottom: 6px; }
.map-field input[type="text"],
.map-field input[type="file"] { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; }
.map-field input[type="file"] { padding: 7px 10px; background: var(--card); }
.map-add { position: relative; }

.selected-maps { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.map-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.map-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.map-card-title { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.map-card-group { font-weight: 500; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.map-card-main { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; padding: 12px; }
.map-card-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; flex: 1 1 300px; min-width: 0; }
.map-card-preview-wrap { flex: 0 0 auto; width: 148px; text-align: center; }
.map-card-preview { width: 148px; max-height: 130px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: block; }
.map-card-preview-cap { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.map-param { display: flex; flex-direction: column; gap: 4px; }
.map-param > label { font-size: 0.82rem; color: var(--muted); }
.map-param input[type="text"], .map-param input[type="number"], .map-param select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; width: 100%; box-sizing: border-box; }
.map-param-bool { flex-direction: row; align-items: center; gap: 8px; }
.map-param-bool > label { font-size: 0.9rem; color: var(--ink); }

.map-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }

/* Grouped picker popover */
.map-picker-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 240px; max-height: 320px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(47,15,65,0.18); }
.map-picker-option { display: block; width: 100%; text-align: left; padding: 7px 12px; background: none; border: 0; font: inherit; cursor: pointer; color: var(--ink); }
.map-picker-option:hover { background: #f3eef8; }
.map-picker-group { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: #faf8fc; border: 0; border-top: 1px solid var(--line); font: inherit; font-weight: 600; color: var(--brand); cursor: pointer; }
.map-picker-group:hover { background: #f3eef8; }
.map-picker-group .caret { color: var(--muted); }
.map-picker-group-body .map-picker-option { padding-left: 22px; }

/* Multi-map tile editor */
.map-multi { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.map-tiles { flex: 1 1 0; display: flex; flex-direction: column; gap: 8px; min-width: 230px; }
.map-tile { border: 1px solid var(--line); border-radius: 8px; background: #faf8fc; padding: 7px 9px; display: flex; flex-direction: column; gap: 7px; }
.map-tile-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* Compact param layouts inside a tile: two tight columns instead of the wide
   180px card grid (which forced a single tall column). Fields align to the
   bottom so a checkbox sits level with the Size dropdown on the same row, and
   free-text fields (title text) span the full width on their own row. */
/* Reset the base body's `flex: 1 1 300px` (a width basis for the standalone
   card's side-by-side layout) — inside a tile's vertical flex column it is read
   as a 300px HEIGHT, ballooning each block with empty space. */
.map-tile .map-card-body { flex: 0 0 auto; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px 8px; align-items: end; }
.map-tile .map-param-wide { grid-column: 1 / -1; }
.map-tile .map-param-bool { min-height: 24px; }
.map-tile-pos { grid-template-columns: repeat(4, minmax(42px, 1fr)); }
.map-tile .map-param > label { font-size: 0.74rem; }
.map-tile .map-param input, .map-tile .map-param select { padding: 4px 6px; }
.map-grid-preview { flex: 1 1 0; align-self: flex-start; display: grid; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 220px; max-width: 440px; }
.map-grid-tile { position: relative; overflow: hidden; border: 1px solid var(--brand); border-radius: 5px; background: #ece5f6; }
.map-grid-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.map-grid-label { position: absolute; left: 0; right: 0; bottom: 0; font-size: 0.6rem; line-height: 1.2; padding: 1px 3px; text-align: center; color: var(--brand); background: rgba(255, 255, 255, 0.82); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Job result */
.job-result { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 14px 16px; }
.job-result h2 { margin: 0 0 8px; font-size: 1.05rem; }
.job-status { font-weight: 600; margin: 4px 0; }
.job-status-done { color: #15803d; }
.job-status-error { color: var(--danger); }
.job-status-pending, .job-status-submitted { color: var(--accent); }
.job-dest code { background: rgba(0,0,0,0.05); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

/* Disabled button/link (e.g. "Download all" when nothing rendered) */
.btn.disabled, .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* Map requests page */
.req-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.req-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.req-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.req-main { flex: 1 1 260px; display: flex; align-items: center; gap: 10px; min-width: 0; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
.req-caret { color: var(--muted); flex: 0 0 auto; }
.req-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-meta { flex: 0 0 auto; font-size: 0.85rem; }
.req-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.req-counts { font-variant-numeric: tabular-nums; }
.req-badge { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 9px; border-radius: 999px; color: #fff; }
.req-badge-done { background: #15803d; }
.req-badge-partial { background: #b45309; }
.req-badge-failed { background: var(--danger); }
.req-badge-running { background: var(--accent); }
.req-detail { border-top: 1px solid var(--line); padding: 12px 14px; background: #faf8fc; }
.req-error { color: var(--danger); margin: 0 0 10px; font-weight: 600; }
.req-maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.req-map { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: var(--card); }
.req-map-missing { opacity: 0.85; }
.req-thumb-wrap { width: 100%; aspect-ratio: 4 / 3; border-radius: 4px; overflow: hidden; background: #eef1f8; display: flex; align-items: center; justify-content: center; }
.req-thumb { max-width: 100%; max-height: 100%; object-fit: contain; }
.req-thumb-missing { color: var(--danger); font-weight: 700; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
.req-map-label { font-weight: 600; word-break: break-word; }
.req-map-file { font-size: 0.78rem; word-break: break-all; }

/* --- Template preview panel (block editor) -------------------------------- */
.preview-panel { margin: 0 0 14px; }
.preview-panel h2 { margin: 0; font-size: 1.1rem; }
.preview-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 4px;
}
.preview-controls label { font-weight: 600; }
.preview-controls select { min-width: 260px; }
.preview-upload { margin: 10px 0 4px; }
.preview-upload summary { cursor: pointer; font-weight: 600; }
.preview-upload-form {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 6px;
}
.preview-frame {
  width: 100%; height: 70vh; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; margin-top: 10px;
}

/* --- LaTeX designs admin: author on the left, sample cover on the right ---- */
.designs-editor-row {
  display: flex; gap: 18px; align-items: flex-start; margin-bottom: 14px;
}
.designs-editor-row > .card { margin-bottom: 0; }
.design-form-card { flex: 1 1 55%; min-width: 0; }
.design-preview-card {
  flex: 1 1 45%; min-width: 0; position: sticky; top: 18px;
  display: flex; flex-direction: column;
}
.design-preview-card h2 { margin: 0; font-size: 1.1rem; }
.design-preview-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px;
}
.design-preview-controls select { flex: 1 1 200px; min-width: 0; }
.design-preview-empty { margin: 10px 0 0; }
.design-preview-frame {
  width: 100%; height: 62vh; min-height: 380px; margin-top: 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
/* Narrow screens: stack, and let the preview scroll with the page. */
@media (max-width: 900px) {
  .designs-editor-row { flex-direction: column; }
  .designs-editor-row > .card { width: 100%; }
  .design-preview-card { position: static; }
  .design-preview-frame { height: 70vh; }
}
.readonly-note {
  margin: 0 0 10px; padding: 8px 10px; border-radius: var(--radius);
  background: #f7f3fb; border: 1px solid var(--line); font-size: 0.85rem;
}
.readonly-note[hidden] { display: none; }
