:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --border: #dedbd2;
  --accent: #1d3557;
  --accent-contrast: #ffffff;
  --accent-soft: #dbe4f0;
  --good: #1b7f3b;
  --good-soft: #dcf2e3;
  --bad: #b3261e;
  --bad-soft: #f9dedc;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  /* chart series, in this order (validated for colour-blind readers) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --surface: #1d1f23;
    --surface-2: #272a30;
    --text: #ececef;
    --muted: #9a9ca3;
    --border: #33363d;
    --accent: #8fb3e8;
    --accent-contrast: #0e1726;
    --accent-soft: #24344d;
    --good: #6fd08c;
    --good-soft: #1d3a27;
    --bad: #f28b82;
    --bad-soft: #452523;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.error { color: var(--bad); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { min-width: 0; }
.brand h1 { font-size: 1.25rem; }
.brand p { margin: 0; color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; flex-shrink: 0; }
.tabs button {
  border: 0;
  background: transparent;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-contrast); }
.switch-catalog { margin-left: auto; flex-shrink: 0; }
.tabs[hidden] { display: none; }
.lang-menu { margin-left: auto; flex-shrink: 0; }
.switch-catalog:not([hidden]) + .lang-menu { margin-left: 0; }
.lang-menu select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- catalog chooser ---------- */
.chooser { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.catalog-section { display: flex; flex-direction: column; gap: 12px; }
.catalog-section h2 { font-size: 1.25rem; margin: 0; }
.catalog-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
/* Compact rows: a small cover on the left, the text on the right. */
.catalog-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  grid-template-rows: auto;
  column-gap: 12px;
  row-gap: 2px;
  align-items: start;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
}
.catalog-card > :not(.catalog-cover) { grid-column: 2; min-width: 0; }
.catalog-cover {
  grid-column: 1;
  grid-row: 1 / span 4;
  display: block;
  width: 64px;
  height: 64px;
  border-radius: calc(var(--radius) / 2);
  overflow: hidden;
  background: var(--surface-2);
}
.catalog-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.catalog-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.catalog-name { font-weight: 700; font-size: 0.98rem; }
.catalog-desc { color: var(--muted); font-size: 0.85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.catalog-tags { color: var(--accent); font-size: 0.78rem; }
.catalog-categories { display: flex; flex-wrap: wrap; gap: 6px; }
.catalog-categories .chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.catalog-count { color: var(--muted); font-size: 0.75rem; }
.chooser form.edit-form { max-width: 420px; }
/* Personal catalogs: panels opening one at a time. */
.acc-group { display: flex; flex-direction: column; gap: 8px; }
.acc { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); }
.acc > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.acc[open] > summary::after { transform: rotate(180deg); }
.acc > summary:hover .acc-title { color: var(--accent); }
.acc[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.acc-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acc-title { font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.acc-sub { color: var(--muted); font-size: 0.85rem; }
.acc-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.acc-body > p { margin: 0; }
.acc-body .error:empty { display: none; }
.soon-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
}
.local-tools { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--border); }
.local-tools .nav-btn { display: inline-flex; align-items: center; gap: 6px; }
.local-tools .nav-btn .help-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
.local-tools .nav-btn[aria-expanded="true"] .help-btn { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.local-help { margin: 0; }
.local-help h3 { font-size: 0.92rem; margin: 6px 0 2px; }
.local-help h3:first-child { margin-top: 0; }
.local-help code { font-size: 0.85em; padding: 0 3px; border-radius: 4px; background: var(--surface-2); }
@media (max-width: 640px) {
  .acc > summary, .acc-body { padding-left: 12px; padding-right: 12px; }
  .acc-body .edit-actions .primary, .acc-body .edit-actions .nav-btn { padding: 8px 14px; }
  .local-tools .nav-btn { white-space: normal; font-size: 0.88rem; text-align: left; }
}

.conn-banner { background: var(--bad-soft); color: var(--bad); text-align: center; padding: 6px; font-size: 0.9rem; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }

/* ---------- buttons & form controls ---------- */
.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
}
.primary:disabled { opacity: 0.45; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; }
input[type="search"], select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
}

/* ---------- filters ---------- */
.filters { display: flex; flex-direction: column; gap: 14px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }
.search-row select { max-width: 45%; }
.chip-group { border: 0; margin: 0; padding: 0; }
.chip-group legend { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.9rem;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.filters-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.match-count { font-weight: 600; }
.search-mode { display: flex; align-items: center; gap: 8px; }
.search-mode-label { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.search-mode-btns { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.search-mode-btn { border: 0; background: var(--surface); padding: 4px 12px; font-size: 0.9rem; }
.search-mode-btn + .search-mode-btn { border-left: 1px solid var(--border); }
.search-mode-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }

/* ---------- explore ---------- */
.explore { display: grid; grid-template-columns: 1fr; gap: 16px; }
.explore-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.filter-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
}
.sidebar { display: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.sidebar.open { display: block; }

@media (min-width: 900px) {
  .explore { grid-template-columns: 300px 1fr; align-items: start; }
  .explore-top { display: none; }
  .sidebar { display: block; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
}

/* Explore items: one .card per item, laid out by the list's view-* class. */
.items.view-large, .items.view-small { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (min-width: 600px) { .items.view-large { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; } }
.items.view-small { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
@media (min-width: 600px) { .items.view-small { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; } }
.card {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  transition: transform 0.12s, box-shadow 0.12s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-img { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-img { color: var(--muted); font-size: 0.85rem; }
.card-body { min-width: 0; }
.card-title { margin: 8px 10px 10px; font-size: 0.9rem; font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-summary { display: none; }
.view-small .card { border-radius: 10px; }
.view-small .card-title { margin: 4px 6px 6px; font-size: 0.74rem; line-height: 1.25; }
.view-small .no-img { font-size: 0.7rem; }
.view-small .ss-btn, .view-lines .ss-btn, .view-lines .ss-counter { display: none; }
.view-small .ss-counter { right: 4px; bottom: 4px; padding: 1px 6px; font-size: 0.65rem; }
/* Lines and titles: a single bordered list, one row per item. */
.items.view-lines, .items.view-titles { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.view-lines .card, .view-titles .card { flex-direction: row; align-items: center; gap: 12px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; }
.view-lines .card:last-child, .view-titles .card:last-child { border-bottom: 0; }
.view-lines .card:hover, .view-titles .card:hover { transform: none; box-shadow: none; background: var(--surface-2); }
.view-lines .card { padding: 8px 12px; }
.view-lines .card-img { flex: none; width: 72px; aspect-ratio: 1; border-radius: 8px; }
.view-lines .no-img { font-size: 0.7rem; text-align: center; }
.view-lines .card-body { flex: 1; }
.view-lines .card-title { margin: 0; font-size: 1rem; font-weight: 600; }
.view-lines .card-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; font-size: 0.85rem; color: var(--muted); line-height: 1.35; }
.card-field { font-weight: 600; }
.view-titles .card { padding: 12px 14px; }
.view-titles .card-title { margin: 0; font-size: 1rem; font-weight: 400; display: block; }
@media (max-width: 480px) {
  .view-lines .card { padding: 8px 10px; gap: 10px; }
  .view-lines .card-img { width: 56px; }
  .view-lines .card-title { font-size: 0.95rem; }
  .view-lines .card-summary { font-size: 0.8rem; }
}
img.loading { opacity: 0; }
img { transition: opacity 0.2s; }
img.broken { opacity: 0.2; }

/* Above the items: item navigation, then the view switch at the right. */
.results-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.view-switch { display: inline-flex; margin-left: auto; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); padding: 2px; }
.view-btn { display: grid; place-items: center; width: 34px; height: 30px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); }
.view-btn .icon { fill: currentColor; }
.view-btn:hover { color: var(--text); }
.view-btn[aria-checked="true"] { background: var(--accent-soft); color: var(--text); }
.history-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 600;
  white-space: nowrap;
}
.nav-btn:not(:disabled):hover { border-color: var(--accent); }
.nav-btn:disabled { opacity: 0.4; }
.list-status { text-align: center; color: var(--muted); padding: 20px; min-height: 60px; }
.sentinel { height: 1px; }

/* ---------- details overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(0 0 0 / 60%);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade 0.15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.details {
  position: relative;
  width: min(1150px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.details-bar {
  position: sticky;
  top: -20px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -20px -20px 12px;
  padding: 12px 12px 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.details .close { margin-left: auto; flex-shrink: 0; }
.details .nav { position: fixed; top: 50%; transform: translateY(-50%); z-index: 51; background: rgb(255 255 255 / 90%); color: #111; border: 0; box-shadow: 0 2px 8px rgb(0 0 0 / 35%); }
.details .nav.prev { left: 8px; }
.details .nav.next { right: 8px; }
.details-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 900px) {
  .details-grid { grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); }
  .details-grid.no-media { grid-template-columns: 1fr; }
}
.stage { margin: 0; background: var(--surface-2); border-radius: var(--radius); overflow: hidden; }
.stage img { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.stage figcaption, .clue-images figcaption { font-size: 0.8rem; color: var(--muted); padding: 6px 10px; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumb { border: 2px solid transparent; background: var(--surface-2); border-radius: 8px; padding: 0; overflow: hidden; width: 96px; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.thumb span { display: block; font-size: 0.72rem; padding: 2px 4px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb.current { border-color: var(--accent); }
.info h2 { font-size: 1.35rem; margin: 0 0 14px; }
.info dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.info dt { color: var(--muted); font-size: 0.9rem; }
.info dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .overlay { padding: 0; }
  .details { border-radius: 0; height: 100%; padding: 12px 12px 72px; }
  .details-bar { top: -12px; margin: -12px -12px 12px; padding: 8px 8px 8px 12px; }
  .details-bar .nav-btn { padding: 6px 12px; }
  .details-bar .nav-label { display: none; }
  .details .nav { top: auto; bottom: 12px; transform: none; }
}

/* ---------- quiz ---------- */
.quiz-setup { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .quiz-setup { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.setup-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.setup-block h2 { font-size: 1.1rem; margin-bottom: 4px; }
.field { font-weight: 600; margin: 8px 0 0; }
.clue-list { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 8px; background: var(--surface); }
.check small { color: var(--muted); }
.check.disabled { opacity: 0.4; }
.setup-block .primary { align-self: flex-start; margin-top: 8px; }

.setup-block .hint { margin: 0; font-size: 0.9rem; }
.setup-block .error:empty { display: none; }
.text-input { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.quiz-notice { margin: 0; grid-column: 1 / -1; }
.quiz-setup > .challenge-block { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .challenge-block { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 16px; align-items: end; }
  .challenge-block > h2, .challenge-block > .hint, .challenge-block > .error { grid-column: 1 / -1; }
  .challenge-block > label { grid-row: 3; }
  .challenge-block > select, .challenge-block > input { grid-row: 4; }
  .challenge-block > .primary { grid-column: 1; justify-self: start; }
}

/* ---------- quiz: a quiz-show stage ---------- */
.quiz {
  /* The stage: same colours in light and dark mode. */
  --stage-a: #141c38;
  --stage-b: #0b1022;
  --stage-text: #f3f4f8;
  --stage-muted: rgb(243 244 248 / 68%);
  --stage-line: rgb(255 255 255 / 14%);
  --gold: #e8c46a;
  --hit: #3ccf91;
  --miss: #f0616d;
}
.quiz-play { max-width: 900px; margin: 0 auto; }
.play-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.play-bar .quit { flex-shrink: 0; }
.scoreboard { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.scoreboard > span {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
}
.scoreboard .points { background: var(--stage-a); color: var(--gold); border-color: var(--stage-a); }
.scoreboard .points.bump { animation: bump 0.5s ease-out; }
.scoreboard .timer { font-variant-numeric: tabular-nums; }
.scoreboard .timer.hurry { background: var(--miss); border-color: var(--miss); color: #fff; animation: pulse 1s infinite; }

.question-card, .show-screen {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: var(--stage-text);
  background:
    radial-gradient(120% 60% at 50% -12%, rgb(90 110 190 / 45%), transparent 62%),
    linear-gradient(180deg, var(--stage-a), var(--stage-b));
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 12px 32px rgb(8 12 30 / 35%);
}
/* Two spotlights slowly sweeping the stage from above. */
.question-card::before, .show-screen::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto;
  height: 120%;
  z-index: -1;
  pointer-events: none;
  background:
    conic-gradient(from 168deg at 28% 0%, transparent 0deg, rgb(255 236 190 / 20%) 12deg, transparent 24deg),
    conic-gradient(from 168deg at 72% 0%, transparent 0deg, rgb(170 200 255 / 18%) 12deg, transparent 24deg),
    radial-gradient(30% 45% at 28% 0%, rgb(255 236 190 / 30%), transparent 70%),
    radial-gradient(30% 45% at 72% 0%, rgb(170 200 255 / 26%), transparent 70%);
  filter: blur(8px);
  animation: sweep 9s ease-in-out infinite alternate;
}
/* A flash of light on an answer (see quiz.js). */
.question-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
}
.question-card.lit-good::after { background: radial-gradient(70% 60% at 50% 70%, rgb(60 207 145 / 38%), transparent 70%); animation: flash 1.1s ease-out; }
.question-card.lit-bad::after { background: radial-gradient(90% 80% at 50% 60%, transparent 40%, rgb(240 97 109 / 34%)); animation: flash 0.9s ease-out; }
.question-card.enter { animation: enter 0.35s ease-out; }
.question-card .muted, .loading-q { color: var(--stage-muted); margin: 0; }
.question-card .error { color: #ffb4b4; }
.question-card a { color: var(--gold); }
.q-head { display: flex; justify-content: center; margin-bottom: 10px; }
.q-number {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.clue-images { display: grid; gap: 10px; }
@media (min-width: 640px) {
  .clue-images.n2 { grid-template-columns: 1fr 1fr; }
  .clue-images.n3 { grid-template-columns: 1fr 1fr 1fr; }
}
.clue-images figure {
  margin: 0;
  background: rgb(0 0 0 / 30%);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 8%), 0 0 40px rgb(150 175 255 / 12%);
}
.clue-images img { display: block; width: 100%; max-height: 45vh; object-fit: contain; }
.clue-images figcaption { color: var(--stage-muted); }
/* Text clues: one block per clue, its name above; short texts are big
   (--fs, set per clue from its length and the number of clues) and
   shrink with narrow windows. */
.clue-text { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 32px; margin: 12px 0 0; }
.clue-text.alone { min-height: 24vh; align-content: center; padding: 8px 0; }
.clue { flex: 1 1 200px; min-width: 0; max-width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.clue.long { text-align: left; align-items: stretch; flex-basis: 100%; }
.clue.clue-links { flex-basis: 100%; }
.clue dt { color: var(--stage-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.clue dd {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, calc(var(--fs, 1) * 2.4vw), calc(var(--fs, 1) * 1rem));
  max-width: 100%;
}
.clue.long dd { font-weight: 400; line-height: 1.45; max-height: 40vh; overflow-y: auto; }

/* Where a clue would give the answer away: a blurred black bar. */
.hidden-answer {
  display: inline-block;
  width: 4.2em;
  height: 0.95em;
  vertical-align: -0.1em;
  border-radius: 4px;
  background: #05070d;
  box-shadow: 0 0 6px 3px rgb(5 7 13 / 85%);
  filter: blur(1.5px);
  margin: 0 0.15em;
}

/* Items listed by a links field: cards (picture and title), a row that
   scrolls sideways when there are several. */
.link-cards { display: inline-flex; max-width: 100%; }
.link-cards.many { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; scrollbar-width: thin; }
.link-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 10px;
  background: rgb(255 255 255 / 7%);
  border: 1px solid rgb(255 255 255 / 14%);
  min-width: 0;
  text-align: left;
}
.link-cards.many .link-card { flex: none; max-width: 300px; scroll-snap-align: start; }
.link-card img, .link-card-blank { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; background: rgb(255 255 255 / 6%); }
.link-card-title { font-weight: 600; font-size: 1rem; line-height: 1.25; overflow-wrap: anywhere; }
.link-cards.one .link-card { padding: 8px 16px 8px 8px; }
.link-cards.one .link-card img, .link-cards.one .link-card-blank { width: 96px; height: 96px; }
.link-cards.one .link-card-title { font-size: 1.25rem; }
.link-cards.small .link-card { padding: 3px 8px 3px 3px; gap: 8px; background: transparent; border-color: rgb(255 255 255 / 10%); }
.link-cards.small.one .link-card { padding: 0; gap: 10px; background: transparent; border: 0; }
.link-cards.small .link-card img, .link-cards.small .link-card-blank,
.link-cards.small.one .link-card img, .link-cards.small.one .link-card-blank { width: 40px; height: 40px; border-radius: 6px; }
.link-cards.small .link-card-title, .link-cards.small.one .link-card-title { font-size: 0.92rem; }
.link-cards.small.many .link-card { max-width: 220px; }
.option.with-links .label { flex: 1; min-width: 0; overflow: hidden; display: flex; }
.ask {
  font-size: 1.2rem;
  text-align: center;
  margin: 16px auto 10px;
  padding: 9px 18px;
  max-width: 34rem;
  border: 1px solid rgb(232 196 106 / 55%);
  border-radius: 999px;
  background: linear-gradient(100deg, transparent 35%, rgb(255 255 255 / 16%) 50%, transparent 65%) no-repeat, rgb(255 255 255 / 4%);
  background-size: 250% 100%, auto;
  background-position: 120% 0, 0 0;
  box-shadow: 0 0 22px rgb(232 196 106 / 12%);
  overflow-wrap: anywhere;
}
.question-card.enter .ask { animation: sheen 1.4s 0.2s ease-out both; }
.speed { height: 3px; border-radius: 999px; background: var(--stage-line); overflow: hidden; margin: 0 0 12px; }
.speed i { display: block; height: 100%; background: var(--gold); box-shadow: 0 0 8px var(--gold); transform-origin: left; animation: drain linear forwards; }
.speed.stopped i { animation-play-state: paused; }
.options { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .options { grid-template-columns: 1fr 1fr; } }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: var(--stage-text);
  border: 1px solid var(--stage-line);
  background: rgb(255 255 255 / 5%);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  min-height: 52px;
  min-width: 0;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.2s, opacity 0.2s;
}
.option .label { min-width: 0; overflow-wrap: anywhere; }
.option .letter {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgb(232 196 106 / 70%);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
}
.option:not(:disabled):hover { border-color: rgb(232 196 106 / 70%); background: rgb(255 255 255 / 9%); box-shadow: 0 0 18px rgb(232 196 106 / 18%); }
.option:not(:disabled):active { background: rgb(255 255 255 / 13%); }
.option:disabled { color: var(--stage-text); }
.option.right { border-color: var(--hit); background: rgb(60 207 145 / 22%); box-shadow: 0 0 24px rgb(60 207 145 / 35%); }
.option.right .letter { border-color: var(--hit); background: var(--hit); color: #06241a; }
.option.wrong { border-color: var(--miss); background: rgb(240 97 109 / 20%); }
.option.wrong .letter { border-color: var(--miss); color: var(--miss); }
.option.dim { opacity: 0.4; }
.field-group { display: flex; flex-direction: column; gap: 10px; }
.answer-form { display: flex; gap: 8px; }
.answer-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--stage-line);
  background: rgb(255 255 255 / 7%);
  color: var(--stage-text);
  border-radius: 12px;
  padding: 12px 14px;
}
.answer-input:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 16px rgb(232 196 106 / 20%); }
.answer-input.right { border-color: var(--hit); background: rgb(60 207 145 / 20%); }
.answer-input.wrong { border-color: var(--miss); background: rgb(240 97 109 / 20%); }
.question-card .primary, .show-screen .primary { background: var(--gold); color: #141c38; }
.question-card .link, .show-screen .link { color: var(--stage-muted); }
.verdict { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 14px 0 4px; animation: rise 0.35s ease-out; }
.verdict strong { font-size: 1.35rem; font-weight: 800; }
.verdict.good strong { color: var(--hit); text-shadow: 0 0 14px rgb(60 207 145 / 45%); }
.verdict.bad strong { color: var(--miss); }
.verdict .gain { font-size: 1.1rem; font-weight: 700; color: var(--gold); animation: rise 0.8s ease-out; }
.verdict .cheer { font-weight: 600; color: var(--stage-muted); font-size: 0.95rem; }
.feedback .detail { margin: 0 0 8px; font-weight: 600; color: var(--stage-muted); }
.feedback-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }

/* Challenge intro and results */
.show-screen { max-width: 640px; margin: 0 auto; text-align: center; padding: 32px 20px 26px; }
.show-body { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.show-screen p { margin: 0; }
.show-kicker { color: var(--gold); font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.8rem; }
.show-title { font-size: 1.5rem; }
.show-sub { color: var(--stage-muted); }
.show-limits { font-weight: 700; }
.show-target { border: 1px solid var(--stage-line); border-radius: 999px; padding: 6px 14px; }
.show-target strong, .show-points strong { color: var(--gold); }
.show-points { font-size: 1.1rem; font-weight: 600; }
.show-points strong { font-size: 2.8rem; font-weight: 800; text-shadow: 0 0 24px rgb(232 196 106 / 40%); }
.show-verdict { font-weight: 700; font-size: 1.1rem; }
.show-verdict.win { color: var(--hit); }
.show-actions, .show-share { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-top: 8px; }
.show-share .text-input { background: rgb(255 255 255 / 8%); border-color: var(--stage-line); color: var(--stage-text); width: 12rem; max-width: 100%; }
.show-share .text-input::placeholder { color: var(--stage-muted); }
.primary.big { padding: 12px 26px; font-size: 1.05rem; }
.ghost { border: 1px solid var(--stage-line); background: transparent; color: var(--stage-text); border-radius: 999px; padding: 9px 18px; font-weight: 600; }

/* Share sheet (where the system has none) */
.share-sheet { background: var(--surface); border-radius: 16px; padding: 20px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.share-sheet h2 { font-size: 1.15rem; }
.share-targets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-target { display: block; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; text-decoration: none; }
.share-target.whatsapp { background: #25d366; border-color: #25d366; color: #06301a; }
.share-url { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px; min-width: 0; font-size: 0.85rem; }
.share-sheet .link { align-self: flex-end; }
.share-sheet .muted:empty { display: none; }

@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
@keyframes bump { 40% { transform: scale(1.15); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pulse { 50% { opacity: 0.65; } }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes sweep { from { transform: translateX(-8%) rotate(-3deg); } to { transform: translateX(8%) rotate(3deg); } }
@keyframes flash { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sheen { from { background-position: 120% 0, 0 0; } to { background-position: -20% 0, 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .question-card::before, .show-screen::before, .question-card.enter, .question-card.enter .ask, .verdict, .verdict .gain,
  .scoreboard .points.bump, .scoreboard .timer.hurry { animation: none; }
}

/* Small phones (e.g. a Galaxy S10, 360 px wide): the question fits on one screen. */
@media (max-width: 480px) {
  .quiz-play { margin: -6px -6px 0; }
  .question-card { padding: 12px; border-radius: 14px; }
  .q-head { margin-bottom: 6px; }
  .clue-images img { max-height: 32vh; }
  .clue-text { gap: 8px 16px; margin-top: 8px; }
  .clue-text.alone { min-height: 18vh; }
  .options.with-links, .options.with-links.n2, .options.with-links.n3 { grid-template-columns: 1fr; }
  .link-cards.many .link-card { max-width: 240px; }
  .link-cards.one .link-card img, .link-cards.one .link-card-blank { width: 72px; height: 72px; }
  .link-cards.one .link-card-title { font-size: 1.05rem; }
  .link-card img, .link-card-blank { width: 52px; height: 52px; }
  .link-cards.small .link-card img, .link-cards.small .link-card-blank,
  .link-cards.small.one .link-card img, .link-cards.small.one .link-card-blank { width: 32px; height: 32px; }
  .link-cards.small .link-card-title, .link-cards.small.one .link-card-title { font-size: 0.84rem; }
  .ask { font-size: 1.05rem; margin: 10px auto 8px; padding: 7px 14px; }
  .speed { margin-bottom: 8px; }
  .options { grid-template-columns: 1fr 1fr; gap: 6px; }
  .options.n2, .options.n3 { grid-template-columns: 1fr; }
  .option { min-height: 46px; padding: 7px 8px; gap: 7px; font-size: 0.9rem; border-radius: 10px; }
  .option .letter { width: 24px; height: 24px; font-size: 0.8rem; }
  .verdict { margin-top: 10px; }
  .verdict strong { font-size: 1.3rem; }
  .scoreboard > span { padding: 2px 8px; font-size: 0.82rem; }
  .show-screen { padding: 22px 14px; }
  .show-title { font-size: 1.3rem; }
  .setup-block { padding: 12px; }
}

/* Small phones: the header's title, Catalogs and the tabs share one line. */
@media (max-width: 480px) {
  .topbar { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .brand h1 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand p { font-size: 0.78rem; }
  .switch-catalog { font-size: 0.9rem; }
  .tabs button { padding: 5px 11px; font-size: 0.9rem; }
}

/* ---------- item editing ---------- */
.edit-slot { display: contents; }
.details.editing .details-bar > :not(.close),
.details.editing .nav { display: none; }
.edit-form { max-width: 720px; display: flex; flex-direction: column; gap: 12px; }
.edit-form h2 { font-size: 1.25rem; }
.edit-form p { margin: 0; }
.edit-row { display: flex; flex-direction: column; gap: 4px; }
.edit-row label { font-weight: 600; font-size: 0.9rem; }
.edit-row label small { font-weight: 400; color: var(--muted); }
.edit-form input[type="text"], .edit-form input[type="password"], .edit-form textarea {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
.edit-form textarea { resize: vertical; }
.edit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 4px; }
.captcha-image { display: block; border-radius: 8px; background: #f4f1ea; }
.login-form #edit-answer { max-width: 120px; }
.edit-notice { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: var(--bad-soft); }
.edit-notice.ok { background: var(--good-soft); color: var(--good); }
.edit-tools { display: contents; }
.history { max-width: 760px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.history h2 { font-size: 1.25rem; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; align-self: stretch; }
.history-step { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; background: var(--surface); }
.history-step.undone { opacity: 0.6; }
.history-step p { margin: 0 0 6px; }
.history-step dl { margin: 0 0 8px; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.history-step dt { color: var(--muted); font-size: 0.9rem; }
.history-step dd { margin: 0; overflow-wrap: anywhere; }
.history-step del { color: var(--bad); }
.history-step ins { color: var(--good); text-decoration: none; font-weight: 600; }

/* ---------- links ---------- */
.info dd.links { display: flex; flex-wrap: wrap; gap: 6px; }
.link-chip {
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.88rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.link-chip:hover { border-color: var(--accent); }
.link-chip.unknown { background: transparent; color: var(--muted); border-style: dashed; }

/* ---------- links graph ---------- */
.graph-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(0 0 0 / 60%);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade 0.15s ease-out;
}
.graph-panel {
  width: min(1400px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.graph-head, .graph-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px 10px 20px;
}
.graph-head { border-bottom: 1px solid var(--border); }
.graph-head h2 { font-size: 1.15rem; margin-right: 8px; }
.graph-head .close { margin-left: auto; order: 2; }
.graph-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.graph-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px 3px 8px;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}
.graph-chip input { position: absolute; opacity: 0; pointer-events: none; }
.graph-chip-wrap { display: inline-flex; align-items: center; gap: 4px; }
.graph-color { width: 26px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.graph-color::-webkit-color-swatch-wrapper { padding: 2px; }
.graph-color::-webkit-color-swatch { border: 0; border-radius: 4px; }
.graph-color::-moz-color-swatch { border: 0; border-radius: 4px; }
.graph-start-box { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.graph-start-hint { font-size: 0.85rem; }
.graph-scope-text[hidden] { display: none; }
.graph-chip .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--c); }
.graph-chip:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.graph-chip:has(input:checked) .dot { background: var(--c); }
.graph-chip:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.graph-tools { padding-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.graph-scope { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.graph-scope-text { font-weight: 600; }
.graph-scope select, .graph-find input {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 8px;
}
.graph-find input { width: min(280px, 100%); }
.graph-start { position: relative; }
.graph-start input {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 8px;
  width: min(240px, 100%);
}
.graph-start-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 5;
  width: max(100%, 300px);
  max-width: calc(100vw - 24px);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.graph-stats { margin-left: auto; }
.graph-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--muted) 25%, transparent) 1px, transparent 0) 0 0 / 22px 22px,
    var(--surface);
}
.graph-canvas { position: absolute; inset: 0; overflow: hidden; }
.graph-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}
.graph-hint { margin: 0; padding: 6px 20px 8px; font-size: 0.8rem; border-top: 1px solid var(--border); }
/* force-graph's hover tooltip */
.graph-canvas .float-tooltip-kap {
  background: var(--text) !important;
  color: var(--surface) !important;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .graph-overlay { padding: 0; }
  .graph-panel { border-radius: 0; }
  .graph-head, .graph-tools { padding-left: 12px; }
  .graph-chips { order: 3; flex-basis: 100%; }
  .graph-stats { margin-left: 0; width: 100%; }
  .graph-hint { display: none; }
  .graph-tools { gap: 6px 8px; }
  .graph-scope { gap: 6px; }
  .graph-scope-text { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .graph-group { flex: 1 1 40%; min-width: 0; }
  .graph-group select { flex: 1; min-width: 0; }
  .graph-scope { flex-basis: 100%; min-width: 0; }
  .graph-scope select { flex: 1 1 35%; min-width: 0; }
  .graph-scope .nav-btn { padding: 5px 10px; }
  .graph-start, .graph-find { flex: 1 1 140px; min-width: 0; }
  .graph-start input, .graph-find input { width: 100%; }
}

/* ---------- settings rows with help (graph, analytics) ---------- */
.graph-head .head-end { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.graph-head .head-end .close { margin-left: 0; }
.settings-btn { padding: 5px 12px; }
.graph-tools.set-rows {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0;
  padding: 4px 20px;
  max-height: 55vh;
  overflow-y: auto;
}
.set-rows[hidden] { display: none; }
.set-row { display: contents; }
.set-row[hidden] { display: none; }
.set-label, .set-controls { padding: 7px 0; border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.set-row:first-child > .set-label, .set-row:first-child > .set-controls { border-top: 0; }
.set-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  padding-right: 16px;
  white-space: nowrap;
  align-self: stretch;
  align-items: flex-start;
}
.set-label > * { min-height: 32px; display: inline-flex; align-items: center; }
.set-label > .help-btn { min-height: 0; margin-top: 5px; justify-content: center; }
.set-controls .graph-scope { flex-basis: 100%; }
.set-controls .graph-scope-text { flex-basis: 100%; }
.set-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; min-width: 0; }
.set-sub { color: var(--muted); font-size: 0.88rem; margin-right: 2px; }
.help-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  flex: none;
  cursor: pointer;
}
.help-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.set-help {
  grid-column: 1 / -1;
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.45;
}
.set-help[hidden] { display: none; }
.set-help p { margin: 0 0 4px; }
.set-help ul { margin: 0 0 4px; padding-left: 18px; }
.set-help li { margin: 2px 0; }
.set-help > :last-child { margin-bottom: 0; }
.graph-matching { flex-basis: 100%; }
.graph-status { display: flex; align-items: center; padding: 4px 20px; border-bottom: 1px solid var(--border); font-size: 0.85rem; min-height: 1.6em; }
.graph-status .graph-stats { margin-left: 0; }
.an-tools .an-title-input { flex: 1 1 200px; order: 0; }
@media (max-width: 640px) {
  .graph-tools.set-rows { grid-template-columns: minmax(0, 1fr); padding: 2px 12px; max-height: 50vh; }
  .set-label > * { min-height: 24px; }
  .set-label > .help-btn { margin-top: 1px; }
  .set-label { padding-bottom: 2px; border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
  .set-controls { padding-top: 2px; border-top: 0; }
  .set-row:first-child > .set-label { border-top: 0; }
  .graph-status { padding: 4px 12px; }
  .graph-head .graph-chips { flex-basis: auto; }
}

/* ---------- analytics ---------- */
.analytics-panel .graph-head { row-gap: 6px; }
.nav-btn .icon { vertical-align: -2px; fill: currentColor; }
.an-saved { display: inline-flex; gap: 6px; align-items: center; order: 1; }
.an-saved[hidden] { display: none; }
.an-saved select, .an-title-input {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
}
.an-saved select { max-width: 220px; }
.an-title-input { order: 3; flex: 1 1 100%; }
.an-tools select, .an-tools input[type="number"] {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
}
.an-stats { order: 4; flex-basis: 100%; font-size: 0.85rem; }
.an-ys { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.an-y { display: inline-flex; gap: 4px; align-items: center; }
.an-y + .an-y { padding-left: 8px; border-left: 2px solid var(--border); }
.an-remove { width: 26px; height: 26px; font-size: 1rem; }
.an-add { padding: 4px 10px; }
.an-title { margin: 0; font-size: 1.1rem; text-align: center; }
.an-title[hidden] { display: none; }
.an-swatch-input {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}
.an-swatch-input::-webkit-color-swatch-wrapper { padding: 0; }
.an-swatch-input::-webkit-color-swatch { border: 0; border-radius: 3px; }
.an-swatch-input::-moz-color-swatch { border: 0; border-radius: 3px; }
.an-reset { font-size: 0.85rem; }
.an-signin {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 16px;
}
.an-signin[hidden] { display: none; }
.an-signin .signin-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; box-shadow: var(--shadow); max-width: 440px; width: 100%; }
.an-field { display: inline-flex; align-items: center; gap: 6px; }
.an-field[hidden], .an-check[hidden], .an-tools select[hidden] { display: none; }
.an-label { font-weight: 600; }
.an-check { display: inline-flex; align-items: center; gap: 4px; font-size: 0.9rem; }
.an-interval { width: 90px; }
.an-segs { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.an-seg { border: 0; background: var(--surface); padding: 5px 12px; }
.an-seg + .an-seg { border-left: 1px solid var(--border); }
.an-seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }
.an-actions { margin-left: auto; display: inline-flex; gap: 6px; }
.an-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 16px 12px; gap: 8px; overflow: auto; }
.an-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.88rem; }
.an-legend[hidden] { display: none; }
.an-key { display: inline-flex; align-items: center; gap: 6px; }
.an-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.an-plot { position: relative; flex: 1; min-height: 260px; }
.an-chart { position: absolute; inset: 0; }
.an-chart svg { display: block; }
.an-grid line { stroke: var(--border); stroke-width: 1; }
.an-grid line.an-zero { stroke: var(--muted); }
.an-grid text { fill: var(--muted); font-size: 11px; }
.an-grid .an-axis-title { fill: var(--text); font-size: 12px; font-weight: 600; }
.an-hover { fill: color-mix(in srgb, var(--muted) 14%, transparent); }
.an-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.an-dot { stroke: var(--surface); stroke-width: 2; }
.an-tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  min-width: 140px;
}
.an-tip[hidden] { display: none; }
.an-tip-row { display: flex; align-items: center; gap: 6px; }
.an-tip-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.an-table { max-height: 40%; overflow: auto; flex: none; }
.an-table[hidden] { display: none; }
.an-table table { border-collapse: collapse; font-size: 0.88rem; width: 100%; }
.an-table th, .an-table td { padding: 4px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.an-table td, .an-table thead th + th { text-align: right; font-variant-numeric: tabular-nums; }
.an-table thead th { position: sticky; top: 0; background: var(--surface); }
/* A setting never pushes the panel wider than the screen: its selects shrink instead. */
.an-field, .an-y { max-width: 100%; min-width: 0; }
.an-remove { flex: none; }
.an-tools select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }
@media (max-width: 640px) {
  /* Phones (e.g. 360 px wide): denser header and settings, so the chart keeps most of the height. */
  .analytics-panel .graph-head { padding: 6px 8px 6px 12px; gap: 6px 8px; }
  .analytics-panel .graph-head h2 { font-size: 1.05rem; margin-right: 0; }
  .analytics-panel .graph-head .close { width: 32px; height: 32px; font-size: 1rem; margin-left: 0; }
  .an-stats { order: 1; flex-basis: auto; margin-left: auto; font-size: 0.8rem; }
  .an-saved { order: 3; }
  .an-title-input { order: 4; }
  .an-title-input, .an-tools select, .an-tools input[type="number"] { padding: 4px 6px; }
  .analytics-panel .graph-tools { padding: 6px 8px 6px 12px; gap: 6px 8px; font-size: 0.85rem; }
  .an-seg { padding: 3px 10px; }
  .an-tools .nav-btn { padding: 3px 10px; }
  .an-y + .an-y { padding-left: 6px; }
  .an-actions { margin-left: 0; }
  .an-stage { padding: 4px 8px 8px; gap: 4px; }
  .an-plot { min-height: 220px; }
  .an-table { max-height: 35%; }
}

/* ---------- links picker (edit form) ---------- */
.picker { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.picker-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.picker-chip { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; }
.picker-chip button { border: 0; background: transparent; padding: 0 4px; font-size: 1rem; line-height: 1; color: var(--muted); }
.picker-chip button:hover { color: var(--bad); }
.edit-form .picker input[type="search"] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; border-radius: 8px; background: var(--surface-2); }
.picker-list li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; cursor: pointer; }
.picker-list li.empty { cursor: default; }
.picker-list li:not(.empty):hover, .picker-list li.active { background: var(--accent-soft); }
.picker-list li.on { font-weight: 600; }
.picker-list .tick { width: 1.2em; text-align: center; color: var(--muted); }
.picker-list li.on .tick { color: var(--good); }
.picker-list img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--surface); }
.picker-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-key { font-size: 0.8rem; flex-shrink: 0; }

/* Slideshow: an image cell listing several files */
.slideshow { position: relative; width: 100%; touch-action: pan-y; user-select: none; }
.slideshow > img { display: block; }
.card-img .slideshow { height: 100%; }
.card-img .slideshow > img { width: 100%; height: 100%; object-fit: cover; }
.ss-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.45); color: #fff;
  font-size: 1.6rem; line-height: 1; cursor: pointer; opacity: 0.85;
}
.ss-btn:hover { opacity: 1; background: rgba(0, 0, 0, 0.65); }
.ss-btn.prev { left: 8px; }
.ss-btn.next { right: 8px; }
.ss-counter {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 0.75rem; pointer-events: none;
}
.slideshow.compact .ss-btn { width: 28px; height: 28px; font-size: 1.2rem; }
.slideshow.compact .ss-btn.prev { left: 4px; }
.slideshow.compact .ss-btn.next { right: 4px; }
.slideshow.compact .ss-counter { right: 6px; bottom: 6px; font-size: 0.7rem; }
/* Thumbnails: arrows show on hover (always on touch screens). */
@media (hover: hover) {
  .slideshow.compact .ss-btn { opacity: 0; transition: opacity 0.15s; }
  .card:hover .slideshow.compact .ss-btn, .card:focus-visible .slideshow.compact .ss-btn { opacity: 0.85; }
  .card:hover .slideshow.compact .ss-btn:hover { opacity: 1; }
}

.image-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.image-preview:empty { display: none; }
.image-preview figure { margin: 0; width: 64px; height: 64px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.image-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.graph-group { display: flex; align-items: center; gap: 6px; }
.graph-group select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 8px;
}

/* ---------- field types, enum values, new fields ---------- */
.type-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
  vertical-align: 1px;
}
.label-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.link.small { font-size: 0.85rem; padding: 0; }
.edit-form select { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px; width: 100%; }
.edit-rows { display: flex; flex-direction: column; gap: 12px; }
.enum-editor, .add-field-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.add-field-box h3 { margin: 0; font-size: 1.05rem; }
.edit-form > .nav-btn { align-self: flex-start; }

/* ---------- fullscreen graph / chart (js/fullscreen.js) ---------- */
.fs-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 36px;
  height: 36px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  box-shadow: var(--shadow);
}
.fs-btn:hover { border-color: var(--accent); }
/* The chart panel scrolls (table): the button stays at the top, over the title and legend. */
.an-stage > .fs-btn { position: sticky; top: 0; flex: none; align-self: flex-end; margin-bottom: -36px; }
.an-title, .an-legend { padding-right: 44px; }
/* Covers the page when the browser has no fullscreen (iPhone, the Android app). */
.fs-on {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.fs-on > .fs-btn { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
.an-stage > .fs-btn { top: 0; }
.an-stage.fs-on { background: var(--surface); padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.an-stage.fs-on .an-plot { min-height: 0; }

/* Picture credit written over an image (images.watermark in the catalog config) */
.watermarked { position: relative; }
.watermarked > img { display: block; }
.watermark {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 90px);
  padding: 2px 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.5); color: rgba(255, 255, 255, 0.92);
  font-size: 0.7rem; line-height: 1.3; pointer-events: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.watermark[hidden] { display: none; }
