/* ==========================================================================
   Skimtide UI tokens & layout
   ========================================================================== */

:root {
  --ink:            #1b1f29;
  --ink-muted:      #546171;
  /* `--ink-dim` used to be #7a8694 which failed WCAG AA on --bg-elev-2
   * (contrast ~3.9:1). Darkened to pass AA for non-large text while
   * preserving a visible hierarchy step below --ink-muted. */
  --ink-dim:        #5c6775;
  --bg:             #fbfaf7;
  --bg-elev-1:      #ffffff;
  --bg-elev-2:      #f1eee7;
  --border:         #e3dfd4;
  --border-strong:  #c8c2b2;
  --accent:         #c8231f;
  --accent-soft:    rgba(200, 35, 31, 0.10);
  --warm:           #d98700;
  --warm-soft:      rgba(217, 135, 0, 0.14);
  --link:           #1a5fb4;
  --map-land:       #dcd6c6;
  --map-land-stroke:#fbfaf7;
  --map-hover:      var(--warm);
  --map-selected:   var(--accent);
  --map-sphere:     radial-gradient(ellipse at center, #eeeae0 0%, #fbfaf7 100%);
  /* Continent tints (very low saturation pastels) — light theme */
  --map-tint-na:    hsl(18  22% 86%);
  --map-tint-sa:    hsl(130 16% 85%);
  --map-tint-eu:    hsl(255 18% 88%);
  --map-tint-as:    hsl(45  28% 85%);
  --map-tint-af:    hsl(28  30% 85%);
  --map-tint-oc:    hsl(170 18% 86%);
  --map-tint-an:    hsl(200  8% 88%);
  --tag-topic:      #9b5a00;
  --tag-sector:     #1a5fb4;
  --tag-religion:   #6b46c1;
  --mark-bg:        rgba(217, 135, 0, 0.35);
  --mark-fg:        var(--ink);
  --masthead-bg:    rgba(251, 250, 247, 0.82);
  --shadow-1:       0 1px 2px rgba(17, 24, 39, 0.06), 0 0 0 1px var(--border) inset;
  --shadow-2:       0 10px 30px rgba(17, 24, 39, 0.08);

  --font-serif:     "Source Serif 4", "Source Serif Pro", "Iowan Old Style",
                    "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans:      "Inter", "Noto Sans KR", "Noto Sans JP", "Noto Sans SC",
                    "Noto Sans TC", -apple-system, BlinkMacSystemFont,
                    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Display wordmark font for the "Skimtide" logotype and its tagline.
     Playfair Display is an elegant high-contrast serif that ships with a
     true 700 weight on Google Fonts — important because the wordmark is
     rendered bold, and faux-bolding a thin display serif looks smeared.
     Georgia fallback keeps the silhouette consistent if the webfont
     hasn't loaded yet. */
  --font-wordmark:  "Playfair Display", "Source Serif 4", Georgia,
                    "Palatino Linotype", serif;

  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-md:   1.0625rem;
  --text-lg:   1.3125rem;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* Horizontal gutter for the full-width header/banner and the 1480px
     content column. Uses 8% of viewport width so the page breathes on
     large monitors; clamp() keeps it sane on phones and ultra-wide. */
  --sp-page-x: clamp(20px, 8vw, 160px);

  --r-sm: 4px; --r-md: 8px; --r-lg: 14px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light;
}

/* ----- Theme toggle — dip-to-black overlay ---------------------------------
   toggleTheme() drops a full-viewport black overlay into the page and fades
   its opacity 0→1 (≈900ms), swaps data-theme while the overlay is opaque,
   then fades the overlay 1→0 (≈900ms). We animate ONLY opacity, which the
   compositor handles on the GPU — so no jank even on slow machines, unlike
   the previous approach of transitioning per-element background/colour.
   ----------------------------------------------------------------------- */
.theme-fade-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;      /* never blocks clicks */
  z-index: 9999;
  transition: opacity 900ms ease;
  /* Hint to the compositor so the layer is prepared once, up-front. */
  will-change: opacity;
}
.theme-fade-overlay.is-active { opacity: 1; }

[data-theme="dark"] {
  --ink:            #f2efe8;
  --ink-muted:      #a8a79e;
  /* Dark-mode parallel to the light-mode dim darken: the old value lost
   * contrast against --bg-elev-2 for stats/labels/placeholders. */
  --ink-dim:        #949489;
  --bg:             #0b0f17;
  --bg-elev-1:      #121826;
  --bg-elev-2:      #1a2235;
  --border:         #232c44;
  --border-strong:  #30405f;
  --accent:         #e63946;
  --accent-soft:    rgba(230, 57, 70, 0.16);
  --warm:           #f5b547;
  --warm-soft:      rgba(245, 181, 71, 0.22);
  --link:           #8ab4ff;
  --map-land:       #1f2841;
  --map-land-stroke:#0b0f17;
  --map-sphere:     radial-gradient(ellipse at center, #1a2235 0%, #0b0f17 100%);
  /* Continent tints (low saturation, deep tone) — dark theme */
  --map-tint-na:    hsl(18  14% 20%);
  --map-tint-sa:    hsl(130 12% 19%);
  --map-tint-eu:    hsl(255 14% 22%);
  --map-tint-as:    hsl(45  16% 20%);
  --map-tint-af:    hsl(28  18% 20%);
  --map-tint-oc:    hsl(170 12% 19%);
  --map-tint-an:    hsl(200  8% 20%);
  --tag-topic:      var(--warm);
  --tag-sector:     var(--link);
  --tag-religion:   #c5a8ff;
  --mark-bg:        rgba(245, 181, 71, 0.35);
  --mark-fg:        var(--ink);
  --masthead-bg:    rgba(11, 15, 23, 0.82);
  --shadow-1:       0 1px 2px rgba(0,0,0,0.35), 0 0 0 1px var(--border) inset;
  --shadow-2:       0 6px 24px rgba(0,0,0,0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
a { color: var(--link); text-decoration: none; }
/* Hover affordances are only meaningful with a pointer. On touch devices
 * they get "stuck" after a tap, which this media gate prevents. */
@media (hover: hover) {
  a:hover { text-decoration: underline; text-underline-offset: 3px; }
}
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: var(--r-sm); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
mark { background: var(--mark-bg); color: var(--mark-fg); padding: 0 2px; border-radius: 2px; }

.masthead {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--sp-5);
  padding: var(--sp-3) var(--sp-page-x);
  background: var(--masthead-bg);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.masthead__brand {
  display: flex; align-items: baseline; gap: var(--sp-3);
  /* Wordmark uses the display serif (Playfair Display) in bold (700). */
  font-family: var(--font-wordmark);
  font-size: calc(var(--text-lg) * 1.15);
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1;
  /* When the wordmark is wrapped in <a href="/">, kill the default link
     chrome and inherit the ink colour. Hover gets a soft fade to signal
     interactivity without a full underline rule. */
  color: var(--ink);
  text-decoration: none;
}
a.masthead__brand { cursor: pointer; }
a.masthead__brand:hover,
a.masthead__brand:focus-visible { color: var(--ink); opacity: 0.78; }
a.masthead__brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
.masthead__tagline {
  /* Tagline shares the wordmark font for visual unity with the logo, at
     a lighter weight so it reads as secondary text. Uppercased + wider
     letter-spacing so it sits as a label, not a headline. */
  color: var(--ink-muted);
  font-family: var(--font-wordmark);
  font-weight: 500;
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.masthead__search { flex: 1 1 auto; max-width: 560px; margin-left: auto; position: relative; }
.masthead__search input {
  width: 100%; padding: var(--sp-2) 34px var(--sp-2) 38px;
  background: var(--bg-elev-1); border: 1px solid var(--border);
  color: var(--ink); border-radius: var(--r-md); font-size: var(--text-sm);
  transition: border-color 120ms var(--ease), background-color 120ms var(--ease);
}
/* Hide native browser UI for <input type="search"> — we render our own × so
 * the control is consistent across Chromium, Firefox and Safari. */
.masthead__search input::-webkit-search-cancel-button,
.masthead__search input::-webkit-search-decoration { appearance: none; }
.search-clear {
  position: absolute; top: 50%; right: 8px;
  transform: translateY(-50%);
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-dim);
  display: grid; place-items: center;
  cursor: pointer; line-height: 1;
  font-size: 16px;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.search-clear:hover { background: var(--bg-elev-2); color: var(--ink); }
.search-clear:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px;
}
.search-clear.is-hidden { display: none; }
.masthead__search input::placeholder { color: var(--ink-dim); }
.masthead__search input:hover { border-color: var(--border-strong); }
.masthead__search input:focus { outline: none; border-color: var(--link); background: var(--bg-elev-2); }
.masthead__search::before {
  content: ""; position: absolute; top: 50%; left: 14px;
  width: 14px; height: 14px; margin-top: -7px; opacity: 0.7;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'><circle cx='11' cy='11' r='7'/><path d='M21 21l-4.3-4.3'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'><circle cx='11' cy='11' r='7'/><path d='M21 21l-4.3-4.3'/></svg>") center/contain no-repeat;
}
.masthead__actions { display: flex; align-items: center; gap: var(--sp-3); }

.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-elev-1); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--ink); font-size: var(--text-sm);
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.btn:hover { border-color: var(--link); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--bg-elev-1);
  border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--ink); font-size: var(--text-xs);
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.icon-btn:hover { border-color: var(--link); }
.icon-btn__glyph { display: inline-grid; place-items: center; width: 16px; height: 16px; color: var(--ink-muted); }

.lang-select {
  appearance: none; -webkit-appearance: none;
  padding: 6px 28px 6px 12px;
  background: var(--bg-elev-1); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: var(--text-xs); cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%237a8694' stroke-width='1.5'><path d='M3 4.5l3 3 3-3'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 10px 10px;
}
.lang-select:hover { border-color: var(--link); }

.stats { color: var(--ink-muted); font-size: var(--text-xs); letter-spacing: 0.02em; }

/* ----- User menu (masthead) ---------------------------------------------- */

.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Anonymous state: two compact links */
.user-menu[data-auth-state="anon"] .user-menu__link {
  padding: 6px 10px;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
}
.user-menu[data-auth-state="anon"] .user-menu__link:hover {
  color: var(--ink);
  border-color: var(--border);
}
.user-menu[data-auth-state="anon"] .user-menu__cta {
  padding: 6px 12px;
  font-size: var(--text-xs);
  text-decoration: none;
  background: var(--ink);
  color: var(--bg-elev-1);
  border-color: var(--ink);
}
.user-menu[data-auth-state="anon"] .user-menu__cta:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Authenticated state: avatar + email + caret */
.user-menu__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 10px 4px 4px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink);
  font-size: var(--text-xs);
  cursor: pointer;
  max-width: 260px;
  transition: border-color 120ms var(--ease);
}
.user-menu__toggle:hover { border-color: var(--link); }
.user-menu__toggle[aria-expanded="true"] { border-color: var(--link); }
.user-menu__avatar {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-elev-1));
  color: var(--accent);
  border-radius: 50%;
  font-weight: 600;
  font-size: var(--text-xs);
  flex: none;
}
.user-menu__email {
  max-width: 170px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink-muted);
}
.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: var(--sp-2);
  z-index: 40;
}
.user-menu__dropdown.is-hidden { display: none; }
.user-menu__dropdown-header {
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-2);
}
.user-menu__dropdown-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--ink-dim);
  margin-bottom: 2px;
}
.user-menu__dropdown-email {
  display: block;
  font-size: var(--text-sm);
  color: var(--ink);
  word-break: break-all;
}
.user-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: var(--text-sm);
  cursor: pointer;
}
.user-menu__item:hover,
.user-menu__item:focus-visible {
  background: var(--bg-elev-2);
}

/* ----- Anonymous banner -------------------------------------------------- */

.anon-banner {
  max-width: 1480px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-page-x);
  background: color-mix(in srgb, var(--warm) 10%, var(--bg-elev-1));
  border-bottom: 1px solid color-mix(in srgb, var(--warm) 35%, var(--border));
  color: var(--ink);
  font-size: var(--text-sm);
  text-align: center;
}
.anon-banner.is-hidden { display: none; }
.anon-banner__link {
  color: var(--link);
  text-decoration: underline;
  font-weight: 500;
}
.anon-banner__link:hover { color: var(--accent); }

/* ----- Preset bar (saved filter bundles) --------------------------------- */

.preset-bar {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elev-1); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-1);
}
.preset-bar.is-hidden { display: none; }

.preset-bar__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
}
.preset-bar__title {
  font-size: var(--text-xs); color: var(--ink-dim);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin: 0;
}
.preset-bar__actions {
  display: flex; gap: var(--sp-2); flex-wrap: wrap;
}
.preset-bar__btn {
  font-size: var(--text-xs);
  padding: 6px 10px;
}
.preset-bar__btn--primary {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.preset-bar__btn--primary:hover {
  background: var(--accent); border-color: var(--accent);
  filter: brightness(1.05);
}

/* The chip row is a flex wrap; empty state shows the hint instead. */
.preset-chips {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  min-height: 28px; align-items: center;
}
.preset-chips__empty {
  font-size: var(--text-xs); color: var(--ink-dim);
  font-style: italic;
}

.preset-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 4px 4px 10px;
  background: var(--bg-elev-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: var(--text-sm);
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.preset-chip__apply {
  background: transparent; border: 0; color: inherit;
  font: inherit; cursor: pointer; padding: 2px 4px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.preset-chip:hover { border-color: var(--link); }
.preset-chip__apply:hover { color: var(--link); }
.preset-chip__apply:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px;
  border-radius: 4px;
}
.preset-chip__delete {
  width: 22px; height: 22px; border-radius: 50%;
  background: transparent; border: 0; color: var(--ink-muted);
  display: grid; place-items: center;
  font-size: 15px; line-height: 1; cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.preset-chip__delete:hover {
  background: var(--accent-soft); color: var(--accent);
}
.preset-chip__delete:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px;
}

/* When a preset's filters exactly match the current state, highlight it. */
.preset-chip--active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.preset-chip--active .preset-chip__apply { color: var(--accent); font-weight: 500; }

/* Transient toast used by showToast() for save/default confirmations. */
.toast {
  position: fixed; left: 50%; bottom: var(--sp-5);
  transform: translateX(-50%);
  padding: var(--sp-2) var(--sp-4);
  background: var(--ink); color: var(--bg-elev-1);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  opacity: 0;
  transition: opacity 160ms var(--ease);
  pointer-events: none;
}
.toast.is-visible { opacity: 1; }

.page { max-width: 1480px; margin: 0 auto; padding: var(--sp-5) var(--sp-page-x) var(--sp-8); }

.geo-panel {
  background: var(--bg-elev-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5);
  margin-bottom: var(--sp-5); box-shadow: var(--shadow-1);
}
.geo-panel__header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-4);
}
.geo-panel__heading { display: flex; align-items: baseline; gap: var(--sp-3); }
.geo-panel__title {
  font-family: var(--font-serif); font-size: var(--text-md); font-weight: 600;
  margin: 0; letter-spacing: -0.01em;
}
.geo-panel__subtitle { color: var(--ink-muted); font-size: var(--text-sm); }
.geo-panel__toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: transparent;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--ink-muted); font-size: var(--text-xs);
  transition: all 120ms var(--ease);
}
.geo-panel__toggle:hover { color: var(--ink); border-color: var(--border-strong); }
.geo-panel__toggle .caret {
  display: inline-block; width: 10px; height: 10px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  /* Expanded: caret points UP (click to collapse / hide). */
  transform: rotate(-135deg) translate(-2px, -2px);
  transition: transform 180ms var(--ease);
}
.geo-panel.is-collapsed .geo-panel__toggle .caret {
  /* Collapsed: caret points DOWN (click to expand / reveal). */
  transform: rotate(45deg) translate(-2px, -2px);
}

.chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); align-items: center; }
.chip-row__label {
  display: inline-flex; align-items: center;
  font-size: var(--text-xs); color: var(--ink-dim);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-right: var(--sp-2); padding: 4px 0;
}
.chip {
  padding: 5px 12px; background: transparent;
  color: var(--ink-muted); border: 1px solid var(--border);
  border-radius: 999px; font-size: var(--text-sm);
  transition: all 120ms var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--border-strong); background: var(--bg-elev-2); }
.chip--active { color: #fff; background: var(--accent); border-color: var(--accent); }
.chip--active:hover { background: var(--accent); color: #fff; }
.chip--group { font-weight: 600; letter-spacing: 0.03em; }

.geo-panel__map-wrap {
  overflow: hidden; max-height: 900px; opacity: 1;
  transition: max-height 260ms var(--ease), opacity 200ms var(--ease), margin 200ms var(--ease);
}
.geo-panel.is-collapsed .geo-panel__map-wrap { max-height: 0; opacity: 0; margin-top: 0; }

.map-frame {
  position: relative; overflow: hidden;
  border-radius: var(--r-md);
  background: var(--map-sphere);
  border: 1px solid var(--border); min-height: 320px;
}
.map-frame svg { display: block; width: 100%; height: auto; }
.map-frame .country.continent-na { fill: var(--map-tint-na); }
.map-frame .country.continent-sa { fill: var(--map-tint-sa); }
.map-frame .country.continent-eu { fill: var(--map-tint-eu); }
.map-frame .country.continent-as { fill: var(--map-tint-as); }
.map-frame .country.continent-af { fill: var(--map-tint-af); }
.map-frame .country.continent-oc { fill: var(--map-tint-oc); }
.map-frame .country.continent-an { fill: var(--map-tint-an); }

.map-frame .country {
  fill: var(--map-land); stroke: var(--map-land-stroke); stroke-width: 0.5;
  /* Matched to body's 160ms so light/dark theme toggle feels like one
   * coordinated shift rather than two staggered transitions. */
  transition: fill 160ms var(--ease); cursor: pointer;
}
.map-frame .country:hover { fill: var(--map-hover); }
.map-frame .country.highlighted {
  fill: var(--map-selected); opacity: 0.62;
}
.map-frame .country.selected { fill: var(--map-selected); opacity: 1; }
.map-frame .country.in-group { fill: var(--map-selected); opacity: 0.78; }
.map-frame .country:focus-visible { outline: 2px solid var(--link); }
/* The svg itself is the single tabstop — give it a clear focus ring so
 * keyboard users can see they've landed on the map. */
.map-frame svg:focus { outline: none; }
.map-frame svg:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px; border-radius: var(--r-md);
}
.map-frame .graticule { fill: none; stroke: var(--border); stroke-width: 0.3; stroke-opacity: 0.55; }
.map-frame .sphere { fill: none; stroke: var(--border-strong); stroke-width: 0.8; }

.map-tooltip {
  position: absolute; pointer-events: none;
  padding: 6px 10px; background: var(--bg-elev-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: var(--text-xs); color: var(--ink); white-space: nowrap;
  opacity: 0; transform: translate(-50%, -120%);
  transition: opacity 100ms var(--ease); z-index: 2;
  box-shadow: var(--shadow-2);
}
.map-tooltip.visible { opacity: 1; }

/* --- Map zoom/pan toolbar & hint ---------------------------------- */

.map-toolbar {
  display: flex; justify-content: flex-end;
  margin-bottom: var(--sp-2);
}
.map-toolbar__reset {
  font: inherit; font-size: var(--text-xs); font-weight: 500;
  padding: 6px 12px; border-radius: 999px;
  color: var(--ink-muted); background: var(--bg-elev-1);
  border: 1px solid var(--border); cursor: pointer;
  transition: color 120ms var(--ease),
              background-color 120ms var(--ease),
              border-color 120ms var(--ease),
              opacity 120ms var(--ease);
}
.map-toolbar__reset:hover:not(:disabled) {
  color: var(--ink); background: var(--bg-elev-2);
  border-color: var(--border-strong);
}
.map-toolbar__reset:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px;
}
.map-toolbar__reset:disabled { opacity: 0.45; cursor: default; }

/* Grab cursor so users discover drag-to-pan. d3-zoom applies its own
 * inline cursor during an active drag, but this gives the correct idle
 * state. */
.map-frame svg { cursor: grab; }
.map-frame svg:active { cursor: grabbing; }

/* Centred pill shown briefly when the user wheels over the map without
 * holding Ctrl. Pointer-events:none so it never eats map interactions. */
.map-zoom-hint {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 16px; border-radius: 999px;
  background: rgba(15, 18, 24, 0.82); color: #fff;
  font-size: var(--text-sm); font-weight: 500;
  pointer-events: none; z-index: 3;
  opacity: 0; transition: opacity 200ms var(--ease);
  box-shadow: var(--shadow-2);
  white-space: nowrap;
}
.map-zoom-hint.is-visible { opacity: 1; }
.map-zoom-hint.is-hidden { display: none; }

.map-legend {
  display: flex; align-items: center; gap: var(--sp-4);
  margin-top: var(--sp-3); font-size: var(--text-xs); color: var(--ink-muted);
}
.map-legend__dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 6px; vertical-align: -1px;
}

.active-filters {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center;
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm); color: var(--ink-muted); min-height: 32px;
}
.active-filters__label { color: var(--ink-dim); margin-right: var(--sp-2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 10px; background: var(--accent-soft);
  color: var(--ink); border-radius: 999px; font-size: var(--text-xs);
}
.pill__x {
  /* Enlarged to 24×24 so it's comfortably above the 24px touch-target
   * minimum on mobile; hover picks up the accent colour instead of a grey
   * swatch so the affordance reads as "destructive". */
  width: 24px; height: 24px; border-radius: 50%;
  background: transparent; color: inherit;
  display: grid; place-items: center; font-size: 16px; line-height: 1;
  border: 0; cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.pill__x:hover { background: var(--accent-soft); color: var(--accent); }
.pill__x:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.filter-rail {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg-elev-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-1);
}
.filter-rail__primary,
.filter-rail__advanced-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
}
.filter-rail__advanced {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
}
.filter-rail__advanced[open] { padding-bottom: 0; }
.filter-rail__advanced-summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--text-xs); color: var(--ink-dim);
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 6px; border-radius: var(--r-sm);
  user-select: none;
  transition: color 120ms var(--ease), background 120ms var(--ease);
}
.filter-rail__advanced-summary::-webkit-details-marker { display: none; }
.filter-rail__advanced-summary::marker { content: ""; }
.filter-rail__advanced-summary::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translate(1px, -1px);
  transition: transform 160ms var(--ease);
}
.filter-rail__advanced[open] .filter-rail__advanced-summary::before {
  transform: rotate(45deg) translate(-1px, -1px);
}
.filter-rail__advanced-summary:hover { color: var(--ink); }
.filter-rail__advanced-summary:focus-visible {
  outline: 2px solid var(--link); outline-offset: 2px;
}
.filter-rail__advanced-badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  background: var(--accent); color: #fff;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0;
  text-transform: none;
}
.filter-rail__advanced-badge.is-hidden { display: none; }
.filter-rail__advanced-grid { margin-top: var(--sp-3); }
.filter-rail__group { display: flex; flex-direction: column; gap: 4px; position: relative; }
.filter-rail__label {
  font-size: var(--text-xs); color: var(--ink-dim);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.filter-rail select {
  appearance: none; -webkit-appearance: none; width: 100%;
  padding: 8px 32px 8px 12px;
  background: var(--bg-elev-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: var(--text-sm);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%237a8694' stroke-width='1.5'><path d='M3 4.5l3 3 3-3'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  background-size: 12px 12px; cursor: pointer;
  transition: border-color 120ms var(--ease);
}
.filter-rail select:hover { border-color: var(--border-strong); }
.filter-rail select:focus { outline: none; border-color: var(--link); }

/* ---- Multi-select checkbox dropdown --------------------------------------
   A minimal custom combobox: `msel__summary` looks like a `<select>`, and
   when `.is-open` is added to `.msel`, a panel with a scrollable checkbox
   list floats underneath.                                                  */
.msel { position: relative; }
.msel__summary {
  appearance: none; width: 100%;
  padding: 8px 32px 8px 12px; text-align: left;
  background: var(--bg-elev-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: var(--text-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%237a8694' stroke-width='1.5'><path d='M3 4.5l3 3 3-3'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  background-size: 12px 12px;
  transition: border-color 120ms var(--ease);
}
.msel__summary:hover { border-color: var(--border-strong); }
.msel__summary:focus-visible { outline: none; border-color: var(--link); }
.msel.is-open > .msel__summary { border-color: var(--link); }
.msel__summary-text {
  flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msel__summary-text--placeholder { color: var(--ink-dim); }
.msel__badge {
  flex: 0 0 auto;
  display: inline-grid; place-items: center; min-width: 20px; height: 18px;
  padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
}
.msel__panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--bg-elev-1); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  display: none; flex-direction: column; max-height: 340px;
  padding: var(--sp-2);
}
.msel.is-open > .msel__panel { display: flex; }
.msel__search {
  flex: 0 0 auto; width: 100%; margin-bottom: var(--sp-2);
  padding: 6px 10px; font-size: var(--text-sm);
  background: var(--bg-elev-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.msel__search::placeholder { color: var(--ink-dim); }
.msel__search:focus { outline: none; border-color: var(--link); }
.msel__actions {
  display: flex; gap: 6px; margin-bottom: var(--sp-2);
  justify-content: space-between; align-items: center;
}
.msel__action {
  padding: 2px 8px; font-size: var(--text-xs); color: var(--link);
  border-radius: var(--r-sm);
}
.msel__action:hover { background: var(--bg-elev-2); }
.msel__action:disabled { opacity: 0.4; cursor: not-allowed; }
.msel__list {
  flex: 1 1 auto; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px;
  min-height: 0;
}
.msel__option {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 8px; border-radius: var(--r-sm);
  color: var(--ink); font-size: var(--text-sm);
  cursor: pointer; user-select: none;
}
.msel__option:hover { background: var(--bg-elev-2); }
.msel__option input[type="checkbox"] {
  width: 14px; height: 14px; flex: 0 0 auto; accent-color: var(--accent);
}
.msel__option-label {
  flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msel__empty { padding: var(--sp-3); text-align: center; color: var(--ink-dim); font-size: var(--text-xs); }

.results-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.results-header__title {
  font-family: var(--font-serif); font-size: var(--text-lg);
  font-weight: 600; letter-spacing: -0.01em; margin: 0;
}
.results-header__count { color: var(--ink-muted); font-size: var(--text-sm); }

.headline-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 0; }
.article {
  display: grid; grid-template-columns: 140px 1fr;
  gap: var(--sp-5); padding: var(--sp-5) 0;
  border-top: 1px solid var(--border);
}
.article:last-child { border-bottom: 1px solid var(--border); }
.article__meta-col {
  display: flex; flex-direction: column; gap: var(--sp-2);
  font-size: var(--text-xs); color: var(--ink-muted);
}
.article__outlet { display: flex; align-items: flex-start; gap: var(--sp-2); }

/* ---- Outlet logo tile ----------------------------------------------------
   Previously a rigid 44x44 square. Now: the logo keeps its native aspect
   ratio (capped at 120x44 so wordmarks don't overrun the meta column), and
   the outlet name renders as a caption underneath.                         */
.outlet-logo-tile {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; width: 100%; min-width: 0;
}
.outlet-logo-tile__logo {
  display: grid; place-items: center;
  width: 100%; max-width: 120px; min-height: 24px; max-height: 48px;
  padding: 4px 6px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden;
}
.outlet-logo-tile__logo img {
  max-width: 100%; max-height: 40px;
  width: auto; height: auto; display: block;
  object-fit: contain;
}
.outlet-logo-tile__logo .outlet-initials {
  font-family: var(--font-serif); font-size: 13px; font-weight: 600;
  color: var(--ink); letter-spacing: -0.02em; text-align: center; line-height: 1;
}
.outlet-logo-tile__name {
  font-family: var(--font-sans); font-size: 11px; font-weight: 500;
  color: var(--ink); text-align: center; line-height: 1.25;
  letter-spacing: 0.01em; max-width: 120px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.article__section {
  text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 10px; color: var(--ink-dim);
}
.article__time { color: var(--ink-muted); }
.article__title {
  font-family: var(--font-serif); font-size: var(--text-md);
  font-weight: 600; line-height: 1.32; letter-spacing: -0.01em;
  color: var(--ink); margin: 0;
}
.article__title a { color: inherit; text-decoration: none; }
.article__title a:hover {
  color: var(--warm);
  /* Colour-only hover cues fail WCAG 1.4.1; underline makes the link
   * affordance robust against low-vision and B/W printouts. */
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--warm) 60%, transparent);
}
.article__summary {
  margin-top: var(--sp-2); color: var(--ink-muted);
  font-size: var(--text-sm); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.article__tags { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--ink-muted); letter-spacing: 0.02em;
  background: var(--bg-elev-1);
}
.tag--topic    { color: var(--tag-topic);    border-color: color-mix(in srgb, var(--tag-topic) 32%, transparent); }
.tag--sector   { color: var(--tag-sector);   border-color: color-mix(in srgb, var(--tag-sector) 32%, transparent); }
.tag--religion { color: var(--tag-religion); border-color: color-mix(in srgb, var(--tag-religion) 32%, transparent); }
.tag--more {
  color: var(--ink-dim); cursor: default;
  font-variant-numeric: tabular-nums;
}

/* Mentioned-countries row — sits between the summary and the tag row.
 * Visually lighter than .tag to keep the primary story pulls dominant. */
.article__mentions {
  margin-top: var(--sp-2);
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px;
  font-size: 11px;
}
.article__mentions-label {
  color: var(--ink-dim);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-right: 2px;
}
.article__mention-chip {
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 11px;
}
.article__mention-more {
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.pager {
  display: flex; align-items: center; gap: var(--sp-3);
  justify-content: center; margin-top: var(--sp-6);
  color: var(--ink-muted); font-size: var(--text-sm);
}
.empty, .loading { padding: var(--sp-7) var(--sp-5); text-align: center; color: var(--ink-muted); }
.empty__title { font-family: var(--font-serif); font-size: var(--text-lg); color: var(--ink); margin-bottom: var(--sp-2); }

@media (max-width: 900px) {
  .masthead { flex-wrap: wrap; gap: var(--sp-3); padding: var(--sp-3); }
  .masthead__search { order: 3; max-width: none; width: 100%; }
  .page { padding: var(--sp-4); }
  .article { grid-template-columns: 1fr; gap: var(--sp-3); }
  .article__meta-col { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0ms !important; animation: none !important; }
  html { scroll-behavior: auto; }
  .geo-panel__map-wrap { transition: none; }
}

/* Touch-only devices shouldn't keep a hover style after a tap. The easiest
 * fix without refactoring every rule is to neutralise hover visuals for the
 * small set of controls where sticky hover would actually be noticeable. */
@media (hover: none) {
  .btn:hover,
  .icon-btn:hover,
  .lang-select:hover,
  .chip:hover,
  .geo-panel__toggle:hover,
  .masthead__search input:hover,
  .filter-rail select:hover,
  .msel__summary:hover,
  .msel__option:hover,
  .msel__action:hover,
  .pill__x:hover {
    border-color: inherit;
    background: inherit;
    color: inherit;
  }
  .article__title a:hover { color: inherit; text-decoration: none; }
  .map-frame .country:hover { fill: var(--map-land); }
}

/* ---- Skeleton loading rows ------------------------------------------------
 * Match .article layout so the shift is imperceptible when real data lands.
 * The shimmer is a moving gradient; reduced-motion users get a static swatch
 * via the prefers-reduced-motion block above (which zeroes out animations). */
.article--skeleton {
  pointer-events: none;
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elev-1) 0%,
    color-mix(in srgb, var(--ink) 6%, var(--bg-elev-1)) 50%,
    var(--bg-elev-1) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}
.skeleton--logo  { width: 60px; height: 40px; margin-bottom: var(--sp-2); border-radius: var(--r-md); }
.skeleton--line  { height: 12px; margin-bottom: 8px; }
.skeleton--title { height: 18px; width: 82%; }
.skeleton--short { height: 10px; width: 50%; }
.skeleton--medium{ width: 66%; }
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Empty-state "Clear all filters" affordance -------------------------- */
.empty__clear {
  margin-top: var(--sp-4);
}
.btn--link {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.btn--link:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

/* ---- Refresh button spinner ---------------------------------------------- */
#refresh-btn.is-loading {
  position: relative;
  padding-right: 32px;
}
#refresh-btn.is-loading::after {
  content: "";
  position: absolute; top: 50%; right: 10px;
  width: 12px; height: 12px; margin-top: -6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: refresh-spin 0.7s linear infinite;
  opacity: 0.8;
}
@keyframes refresh-spin {
  to { transform: rotate(360deg); }
}

/* ---- Accessibility helper ------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ==========================================================================
   Auth pages (login.html, register.html)
   Minimal standalone layout — no map, no filters, just a centred card.
   Reuses the same tokens so dark/light themes work out of the box.
   ========================================================================== */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-6) var(--sp-5);
  box-shadow: var(--shadow-2);
}
.auth-card__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  margin-bottom: var(--sp-5);
  text-align: center;
}
.auth-card__brand-title {
  font-family: var(--font-wordmark);
  font-size: calc(var(--text-lg) * 1.45);
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1;
  color: var(--ink);
  margin: 0;
}
/* Wordmark on auth pages wraps in <a href="/"> so every brand click
   returns home. Neutralise default anchor chrome. */
a.auth-card__brand-title { text-decoration: none; cursor: pointer; }
a.auth-card__brand-title:hover,
a.auth-card__brand-title:focus-visible { color: var(--ink); opacity: 0.78; }
a.auth-card__brand-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
.auth-card__brand-tagline {
  font-family: var(--font-wordmark);
  font-weight: 500;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.auth-card h1 {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  margin: 0 0 var(--sp-5);
  text-align: center;
  color: var(--ink);
}
.auth-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-form__group { display: flex; flex-direction: column; gap: 6px; }
.auth-form__label {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}
.auth-form__input {
  padding: 10px 12px;
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.auth-form__input:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 20%, transparent);
}
.auth-form__hint {
  font-size: var(--text-xs);
  color: var(--ink-dim);
}
.auth-form__submit {
  margin-top: var(--sp-1);
  padding: 10px;
  font-size: var(--text-base);
  font-weight: 500;
  background: var(--ink);
  color: var(--bg-elev-1);
  border: 1px solid var(--ink);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.auth-form__submit:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}
.auth-form__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.auth-form__error {
  padding: var(--sp-2) var(--sp-3);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: var(--text-sm);
  text-align: center;
}
.auth-form__error.is-hidden { display: none; }
.auth-card__footer {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}
.auth-card__footer a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}
.auth-card__footer a:hover { text-decoration: underline; }
.auth-card__back {
  display: block;
  margin-top: var(--sp-3);
  font-size: var(--text-xs);
  color: var(--ink-dim);
  text-decoration: none;
  text-align: center;
}
.auth-card__back:hover { color: var(--ink-muted); }

/* ==========================================================================
   Settings / admin pages (account.html, admin.html)
   Cards + tables sharing the same tokens as the main app so theme
   switching Just Works.
   ========================================================================== */

.settings-page,
.admin-page {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.settings-card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-1);
}
.settings-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.settings-card__title {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  margin: 0 0 6px;
  color: var(--ink);
}
.settings-card__subtitle {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}
.auth-form__row {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

/* Account page & admin use the shared auth-form styling, but the buttons
   there should stretch less than the centred auth-card version. */
.settings-card .auth-form__submit {
  align-self: flex-start;
  padding-left: var(--sp-5);
  padding-right: var(--sp-5);
}

/* Tiny sibling of .btn used inside the admin row action column. */
.btn--sm {
  padding: 4px 10px;
  font-size: var(--text-xs);
}
.btn--danger {
  color: #fff;
  background: #c0392b;
  border-color: #c0392b;
}
.btn--danger:hover { background: #a93226; border-color: #a93226; }

/* Admin toggle (checkbox + label stacked horizontally). */
.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--ink);
  cursor: pointer;
}
.admin-toggle input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--link);
  cursor: pointer;
}

.admin-table-wrap {
  overflow-x: auto;
  margin: calc(-1 * var(--sp-2)) 0;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.admin-table th,
.admin-table td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 600;
  background: var(--bg);
}
.admin-table tbody tr:hover { background: var(--bg); }
.admin-table__admin {
  color: var(--link);
  font-weight: 600;
}
.admin-table__empty {
  text-align: center;
  padding: var(--sp-5);
  color: var(--ink-dim);
}

.admin-feedback {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.admin-feedback__empty {
  padding: var(--sp-5);
  text-align: center;
  color: var(--ink-dim);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
}
.admin-feedback__row {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.admin-feedback__head {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
  flex-wrap: wrap;
}
.admin-feedback__who  { font-weight: 600; color: var(--ink); }
.admin-feedback__meta { font-size: var(--text-xs); color: var(--ink-muted); }
.admin-feedback__msg  { white-space: pre-wrap; line-height: 1.55; }
.admin-feedback__tail {
  margin-top: var(--sp-2);
  display: flex;
  gap: var(--sp-3);
  font-size: var(--text-xs);
  color: var(--ink-dim);
  flex-wrap: wrap;
}

/* ==========================================================================
   Generic modal (admin user-edit dialog, potentially others).
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
}
.modal.is-hidden { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.modal__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.modal__title {
  font-family: var(--font-serif);
  font-size: var(--text-md);
  margin: 0;
  color: var(--ink);
}
.modal__close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.modal__close:hover { color: var(--ink); }
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.modal__foot {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   Floating feedback widget (index.html).
   Pinned bottom-right so it doesn't compete with the pager, and tucked
   under --sp-5 of inset so it sits comfortably on small screens too.
   ========================================================================== */

.fb-button {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 16px 10px 14px;
  background: var(--ink);
  color: var(--bg-elev-1);
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-2);
  transition: transform 120ms var(--ease), background 120ms var(--ease);
}
.fb-button:hover {
  transform: translateY(-1px);
  background: var(--accent);
  border-color: var(--accent);
}
.fb-button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}
.fb-button__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 520px) {
  .fb-button__label { display: none; }
  .fb-button { padding: 10px; }
}

.fb-dialog {
  position: fixed;
  right: var(--sp-5);
  bottom: calc(var(--sp-5) + 56px);
  z-index: 950;
  width: min(360px, calc(100vw - (var(--sp-5) * 2)));
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.fb-dialog.is-hidden { display: none; }
.fb-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
}
.fb-dialog__title {
  font-family: var(--font-serif);
  font-size: var(--text-md);
  margin: 0;
  color: var(--ink);
}
.fb-dialog__close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.fb-dialog__close:hover { color: var(--ink); }
.fb-dialog__hint {
  margin: 0 0 var(--sp-2);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.fb-dialog__form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fb-dialog__label {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  margin-top: 4px;
}
.fb-dialog__input,
.fb-dialog__textarea {
  padding: 8px 10px;
  font-size: var(--text-sm);
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit;
}
.fb-dialog__textarea {
  resize: vertical;
  min-height: 80px;
}
.fb-dialog__input:focus,
.fb-dialog__textarea:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 20%, transparent);
}
.fb-dialog__error,
.fb-dialog__ok {
  margin-top: var(--sp-2);
  padding: 6px var(--sp-2);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  text-align: center;
}
.fb-dialog__error {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  color: var(--accent);
}
.fb-dialog__ok {
  background: color-mix(in srgb, var(--link) 12%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--link) 30%, var(--border));
  color: var(--link);
}
.fb-dialog__error.is-hidden,
.fb-dialog__ok.is-hidden { display: none; }
.fb-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.fb-dialog__submit {
  padding: 8px 16px;
  background: var(--ink);
  color: var(--bg-elev-1);
  border: 1px solid var(--ink);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}
.fb-dialog__submit:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}
.fb-dialog__submit:disabled { opacity: 0.6; cursor: not-allowed; }
