/* ==========================================================================
   Emrooz Chi Shod — newsroom stylesheet
   --------------------------------------------------------------------------
   One stylesheet, two writing directions. Layout is driven by logical
   properties (inline-start/end, margin-inline, padding-inline) so the Persian
   RTL edition and the English LTR edition share every rule.

   Design intent: a wire-service desk. Hairline rules, small-caps labels,
   numbered stories, monogrammed source chips, one accent colour and one
   signal colour. Nothing decorative that does not carry information.
   ========================================================================== */

/* ---- fonts ------------------------------------------------------------- */

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---- tokens ------------------------------------------------------------ */

:root {
  color-scheme: light;

  --ink: #101418;
  --ink-soft: #39434c;
  --ink-mute: #6d7883;
  --ink-faint: #98a2ab;

  --paper: #fbfaf7;
  --paper-raised: #ffffff;
  --paper-sunken: #f4f2ec;

  --rule: #e4e1d9;
  --rule-strong: #cec9bd;
  --rule-ink: #101418;

  --accent: #0f5c4f;
  --accent-deep: #0a4438;
  --accent-soft: #e7f0ed;

  --signal: #a4161a;
  --signal-soft: #fbeceb;

  --ok: #1c7c54;
  --ok-soft: #e6f4ec;
  --warn: #a8690a;
  --warn-soft: #fdf3e2;
  --bad: #a4161a;
  --bad-soft: #fbeceb;

  --wrap: 78rem;
  --wrap-narrow: 46rem;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.375rem;
  --step-3: 1.75rem;
  --step-4: 2.25rem;
  --step-5: 3rem;
  --step-6: 3.75rem;

  --sans: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* --invert backs the few deliberately dark surfaces (footer, newsroom bar)
     that stay dark in both themes, so their light text never lands on light. */
  --invert: #101418;
  --invert-fg: #cfd6dc;
  --invert-fg-strong: #ffffff;

  --shadow-sm: 0 1px 2px rgba(16, 20, 24, 0.05);
  --shadow-md: 0 6px 24px -12px rgba(16, 20, 24, 0.18);
  --radius: 10px;
  --radius-sm: 7px;
}

/* ---- dark theme ---------------------------------------------------------
   Light is the default: the tokens above apply until the reader opts into
   dark, which the theme toggle (and a pre-paint script) records on the <html>
   element as data-theme="dark". Only tokens and the handful of surfaces that
   hard-code a colour are overridden. */

html[data-theme="dark"] {
  color-scheme: dark;

  --ink: #e9eef2;
  --ink-soft: #c2ccd5;
  --ink-mute: #93a0ab;
  --ink-faint: #74808b;

  --paper: #0f151b;
  --paper-raised: #161e26;
  --paper-sunken: #1b242d;

  --rule: #29343e;
  --rule-strong: #3b4854;
  --rule-ink: #cbd5de;

  --accent: #35b996;
  --accent-deep: #7fd6bd;
  --accent-soft: #13302b;

  --signal: #ff7a7a;
  --signal-soft: #3a1d1d;

  --ok: #58c68e;
  --ok-soft: #12301f;
  --warn: #e0a94f;
  --warn-soft: #33280f;
  --bad: #ff7a7a;
  --bad-soft: #3a1d1d;

  --invert: #070b0f;
  --invert-fg: #cfd6dc;
  --invert-fg-strong: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px -12px rgba(0, 0, 0, 0.65);
}

/* ---- reset ------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; }

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-inline-start: 1.4rem; }

a {
  color: var(--accent-deep);
  text-decoration: none;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--paper-sunken);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.05em 0.35em;
  direction: ltr;
  display: inline-block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
}
.skip-link:focus { inset-inline-start: 0; }

/* ---- header ------------------------------------------------------------ */

.site-header {
  background: var(--paper-raised);
  border-block-end: 1px solid var(--rule);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8125rem;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.brand:hover { text-decoration: none; }

.brand-mark-img {
  display: block;
  inline-size: 2.375rem;
  block-size: 2.375rem;
  flex: 0 0 auto;
}

/* In dark mode the tile edge needs a faint rim to stay a crisp shape against
   the dark header; against paper the green edge is already strong. */
html[data-theme="dark"] .brand-mark-img {
  filter: drop-shadow(0 0 0.8px rgba(233, 238, 242, 0.4));
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-name {
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.brand-tagline {
  font-size: var(--step--1);
  color: var(--ink-mute);
  line-height: 1.4;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.site-nav {
  display: flex;
  gap: 1.1rem;
  font-size: var(--step--1);
  font-weight: 500;
}
.site-nav a { color: var(--ink-soft); }
.site-nav a:hover { color: var(--accent-deep); }

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper-sunken);
}
.lang-option {
  padding: 0.3rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  text-decoration: none;
}
.lang-option:hover { color: var(--ink); text-decoration: none; }
.lang-option.is-active { background: var(--ink); color: var(--paper); }

/* ---- switching editions ------------------------------------------------ */
/* Every edition has its own canonical URL, so a switch is a full document
   load. A cross-document view transition cross-fades the old edition into the
   new one and morphs the header between them, instead of showing a blank frame
   and resetting the reader's eye. Browsers without support simply navigate the
   way they always did, and readers who ask for less motion are left alone. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .site-header { view-transition-name: site-header; }
  .chipbar { view-transition-name: chipbar; }
}

/* ---- section chips ----------------------------------------------------- */

.chipbar {
  border-block-start: 1px solid var(--rule);
  background: var(--paper-raised);
  position: sticky;
  top: 0;
  z-index: 20;
}

.chipbar-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-block: 0.65rem;
}
.chipbar-inner::-webkit-scrollbar { display: none; }

.edition-switch {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  padding: 0.2rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 4%, var(--paper));
  gap: 0.15rem;
}
.edition-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.edition-option:hover { color: var(--ink); text-decoration: none; }
.edition-option.is-active {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 35%, transparent);
}
.chipbar-sep {
  width: 1px;
  align-self: stretch;
  background: var(--rule-strong);
  flex: 0 0 auto;
  margin-block: 0.25rem;
}
.desk-switch {
  display: inline-flex;
  gap: 0.45rem;
  flex: 0 0 auto;
}
/* The category area is filled in by category-bar.js from the availability
   payload; display:contents lets the injected chips take part in the desk
   row's own flex layout without adding a nested gap. */
.desk-categories {
  display: contents;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  padding: 0.42rem 0.95rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: var(--ink); color: var(--ink); text-decoration: none; }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip-icon { font-size: 0.7rem; opacity: 0.75; }
.chip.is-active .chip-icon { opacity: 1; color: #7fd1bd; }

/* The active edition and language are rendered as plain elements rather than
   links to the page you are already on: re-clicking the edition you are reading
   used to reload it and throw the reader back to the top. */
.edition-option.is-active,
.chip.is-active,
.lang-option.is-active { cursor: default; }

@media (max-width: 40rem) {
  .edition-option { min-width: 0; padding: 0.38rem 0.7rem; }
  .chipbar-inner { gap: 0.55rem; }
}

/* ---- briefing layout --------------------------------------------------- */

.briefing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
  padding-block: 2.5rem 4rem;
}

@media (min-width: 64rem) {
  .briefing-grid {
    grid-template-columns: minmax(0, 1fr) 18.5rem;
    gap: 3.5rem;
  }
}

.masthead {
  padding-block-end: 1.75rem;
  border-block-end: 3px solid var(--rule-ink);
  margin-block-end: 2.25rem;
}

.masthead-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-size: var(--step--1);
  color: var(--ink-mute);
  margin-block-end: 0.9rem;
}

.eyebrow-desk {
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.rule-dot { color: var(--ink-faint); }

.masthead-title {
  font-size: clamp(2rem, 5.2vw, var(--step-6));
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin-block-end: 0.9rem;
}

html[lang="en"] .masthead-title { font-family: var(--serif); letter-spacing: -0.015em; }

.masthead-subtitle {
  font-size: var(--step-1);
  color: var(--ink-soft);
  max-width: 46ch;
  margin-block-end: 1.1rem;
}

.masthead-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-size: var(--step--1);
  color: var(--ink-mute);
}

.meta-item { white-space: nowrap; }
.meta-time { font-variant-numeric: tabular-nums; }

/* ---- stories ----------------------------------------------------------- */

.stories { display: flex; flex-direction: column; }

.story { padding-block: 2rem; border-block-end: 1px solid var(--rule); }
.story:first-child { padding-block-start: 0.5rem; }
.story-lead { border-block-end: 1px solid var(--rule); }

.story-head {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-block-end: 0.85rem;
}

.story-number {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-faint);
  padding-block-start: 0.5rem;
  min-inline-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}

.story-headings { min-width: 0; }

.story-flag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
  border-block-end: 2px solid var(--signal);
  padding-block-end: 0.1rem;
  margin-block-end: 0.5rem;
}

.story-headline {
  font-size: clamp(1.3rem, 2.6vw, var(--step-4));
  line-height: 1.24;
  letter-spacing: -0.022em;
  /* A story link lands here; the flag and some air stay visible above it. */
  scroll-margin-top: 1.75rem;
}

/* The story a link pointed at, briefly marked so the reader sees which one. */
.story.is-linked {
  border-radius: var(--radius-sm, 2px);
  animation: story-linked 3s ease-out 0.3s both;
}

@keyframes story-linked {
  from { background-color: var(--accent-soft); box-shadow: 0 0 0 0.75rem var(--accent-soft); }
  to { background-color: transparent; box-shadow: 0 0 0 0.75rem transparent; }
}

html[lang="en"] .story-headline { font-family: var(--serif); font-weight: 700; }

.story-lead .story-headline { font-size: clamp(1.55rem, 3.2vw, 2.6rem); }

.story-desk {
  display: inline-block;
  margin-block-start: 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
html[lang="fa"] .story-desk,
html[lang="fa-IR"] .story-desk {
  letter-spacing: 0.02em;
  text-transform: none;
}

.story-figure {
  margin: 0.85rem 0 1.1rem;
  overflow: hidden;
  border-radius: var(--radius-sm, 2px);
  background: var(--wash, #f2efe8);
  aspect-ratio: 16 / 9;
}

.story-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-quick {
  padding-block: 0.7rem;
}

.story-quick .story-summary,
.story-quick .why {
  display: none;
}

.story-summary {
  font-size: var(--step-1);
  line-height: 1.85;
  color: var(--ink-soft);
  margin-block-end: 1.1rem;
}
.story-lead .story-summary { font-size: 1.2rem; color: var(--ink); }

.why {
  border-inline-start: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.85rem 1.1rem;
  margin-block-end: 1.1rem;
}
html[dir="rtl"] .why { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

.why-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-block-end: 0.35rem;
}

.why-text { margin: 0; font-size: var(--step-0); line-height: 1.8; color: var(--ink-soft); }

/* ---- source chips ------------------------------------------------------ */

.story-sources {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sources-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.source-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.7rem 0.35rem 0.4rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
html[dir="rtl"] .source-chip { padding: 0.35rem 0.4rem 0.35rem 0.7rem; }
.source-chip:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); text-decoration: none; }

.source-monogram {
  display: grid;
  place-items: center;
  inline-size: 1.7rem;
  block-size: 1.7rem;
  border-radius: 5px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.66rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.source-body { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.source-publisher { font-size: 0.8rem; font-weight: 600; color: var(--ink); }
.source-host { font-size: 0.68rem; color: var(--ink-faint); direction: ltr; unicode-bidi: embed; }

/* ---- rail -------------------------------------------------------------- */

.briefing-rail { display: flex; flex-direction: column; gap: 1.25rem; }

@media (min-width: 64rem) {
  .briefing-rail {
    position: sticky;
    top: 4.5rem;
    align-self: start;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
  }
}

.rail-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 1.1rem 1.2rem;
}

.rail-heading {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-block-end: 0.6rem;
  border-block-end: 1px solid var(--rule);
  margin-block-end: 0.8rem;
}

.rail-desk { font-size: var(--step-1); font-weight: 700; line-height: 1.3; }

.rail-tagline { font-size: var(--step--1); color: var(--ink-mute); margin-block: 0.35rem 0.9rem; }

.rail-list { margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.rail-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: var(--step--1);
}
.rail-list dt { color: var(--ink-mute); margin: 0; }
.rail-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.rail-publishers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: var(--step--1);
  color: var(--ink-soft);
}
.rail-publishers li { padding-inline-start: 0.85rem; position: relative; }
.rail-publishers li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.62em;
  inline-size: 0.3rem;
  block-size: 0.3rem;
  border-radius: 50%;
  background: var(--accent);
}

.rail-section-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.rail-section-list a {
  display: block;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: var(--step--1);
  font-weight: 500;
  text-decoration: none;
}
.rail-section-list a:hover { background: var(--paper-sunken); text-decoration: none; }
.rail-section-list a.is-active { background: var(--ink); color: var(--paper); font-weight: 600; }

/* ---- briefing foot ----------------------------------------------------- */

.briefing-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block-start: 1.75rem;
  margin-block-start: 1rem;
  border-block-start: 1px solid var(--rule);
}

.foot-note { font-size: var(--step--1); color: var(--ink-mute); max-width: 60ch; }

.back-to-top {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--accent-deep);
  white-space: nowrap;
}

.empty-edition {
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  padding: 2rem;
  background: var(--paper-raised);
}
.empty-edition h2 { font-size: var(--step-2); margin-block-end: 0.6rem; }
.empty-edition p { color: var(--ink-mute); }

/* ---- section head (archive, pages, notices) ---------------------------- */

.section-head {
  padding-block: 3rem 1.5rem;
  border-block-end: 3px solid var(--rule-ink);
  margin-block-end: 2rem;
}

.section-title { font-size: clamp(1.9rem, 4.5vw, var(--step-5)); letter-spacing: -0.03em; }

.section-intro {
  font-size: var(--step-1);
  color: var(--ink-mute);
  max-width: 52ch;
  margin-block-start: 0.75rem;
  margin-block-end: 0;
}

.page-wrap { max-width: var(--wrap-narrow); }

.page-body {
  font-size: var(--step-1);
  line-height: 1.9;
  color: var(--ink-soft);
  padding-block-end: 4rem;
}
.page-body h2 { font-size: var(--step-2); color: var(--ink); margin-block: 2rem 0.75rem; }
.page-body h2:first-child { margin-block-start: 0; }
.page-body ol,
.page-body ul { padding-inline-start: 1.5rem; }
.page-body li { margin-block-end: 0.35rem; }
.page-body strong { color: var(--ink); }

.notice-body { font-size: var(--step-1); color: var(--ink-mute); max-width: 54ch; }
.notice-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-block-start: 1.5rem; }

/* ---- archive ----------------------------------------------------------- */

.archive-list {
  list-style: none;
  margin: 0;
  padding: 0 0 4rem;
  border-block-start: 1px solid var(--rule);
}

.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: 1rem;
  border-block-end: 1px solid var(--rule);
}

.archive-link {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.archive-link:hover { color: var(--accent-deep); text-decoration: none; }

.archive-date { font-size: var(--step-1); font-weight: 600; letter-spacing: -0.015em; }
.archive-weekday { font-size: var(--step--1); color: var(--ink-faint); }

.archive-sections { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.archive-section {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-mute);
  text-decoration: none;
}
.archive-section:hover { border-color: var(--accent); color: var(--accent-deep); text-decoration: none; }

.archive-empty { color: var(--ink-mute); padding-block-end: 4rem; }

/* ---- footer ------------------------------------------------------------ */

.site-footer {
  background: var(--invert);
  color: var(--invert-fg);
  padding-block: 3rem;
  margin-block-start: 2rem;
}
.site-footer a { color: #e8edf1; }
.site-footer a:hover { color: #fff; }

.footer-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; }
@media (min-width: 52rem) {
  .footer-grid { grid-template-columns: 1.6fr 1fr 1fr; gap: 3rem; }
}

.footer-brand { font-size: var(--step-2); font-weight: 700; color: #fff; margin-block-end: 0.75rem; }

.footer-heading {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8e9aa5;
  margin-block-end: 0.9rem;
}

.footer-note { font-size: var(--step--1); line-height: 1.85; color: #a8b3bc; margin-block-end: 0.6rem; }

.footer-links { display: flex; flex-direction: column; gap: 0.45rem; font-size: var(--step--1); margin-block-end: 1rem; }

.footer-sources {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: var(--step--1);
  color: #a8b3bc;
  direction: ltr;
}

.footer-copyright { color: #8e9aa5; }

.footer-notice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  margin-block-start: 2.25rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
}
.footer-notice-text { margin: 0; font-size: var(--step--1); line-height: 1.9; color: #d5dce2; }
.site-footer a.footer-notice-email {
  display: inline-block;
  max-width: 100%;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: #fff;
  color: var(--invert);
  font-weight: 700;
  font-size: var(--step-0);
  letter-spacing: 0.01em;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.site-footer a.footer-notice-email:hover,
.site-footer a.footer-notice-email:focus-visible { background: #e8edf1; color: var(--invert); text-decoration: underline; }
@media (min-width: 52rem) {
  .footer-notice { flex-direction: row; align-items: center; justify-content: space-between; gap: 1.5rem; }
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-block-start: 1.75rem;
  padding-block-start: 1.25rem;
  border-block-start: 1px solid rgba(255, 255, 255, 0.12);
}
.footer-bottom p { margin: 0; }
.pireno { display: inline-flex; align-items: center; gap: 0.5rem; }
.pireno-logo { display: block; block-size: 24px; inline-size: auto; }

/* ---- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.05rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-family: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover {
  background: color-mix(in srgb, var(--ink) 85%, var(--paper));
  border-color: color-mix(in srgb, var(--ink) 85%, var(--paper));
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-update-content {
  font-size: 1.05rem;
  padding: 0.85rem 1.6rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 28%, transparent);
}
.btn-update-content:disabled {
  opacity: 0.7;
  cursor: wait;
  box-shadow: none;
}
.admin-update-panel {
  margin: 1.25rem 0 1.75rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
  border-radius: 1rem;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent) 10%, var(--paper)),
      color-mix(in srgb, var(--paper-raised) 80%, var(--paper)));
}
.admin-update-form { display: flex; flex-direction: column; align-items: flex-start; gap: 0.65rem; }
.admin-update-hint {
  margin: 0;
  max-width: 40rem;
  color: var(--ink-soft);
  font-size: var(--step--1);
  line-height: 1.55;
}
.btn-quiet { background: var(--paper-raised); border-color: var(--rule-strong); color: var(--ink-soft); }
.btn-quiet:hover { background: var(--paper-sunken); border-color: var(--ink-mute); color: var(--ink); }

.btn-danger { background: var(--paper-raised); border-color: #e3b6b7; color: var(--bad); }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.75rem; }
.btn-block { inline-size: 100%; }

/* ---- admin ------------------------------------------------------------- */

.admin-bar { background: var(--invert); color: var(--invert-fg); }

.admin-bar-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding-block: 0.7rem;
}

.admin-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8e9aa5;
}

.admin-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.admin-nav a {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--step--1);
  font-weight: 600;
  color: #cfd6dc;
  text-decoration: none;
}
.admin-nav a:hover { background: #1d252c; color: var(--invert-fg-strong); text-decoration: none; }
.admin-nav a.is-active { background: var(--accent); color: var(--invert-fg-strong); }

.admin-bar-tools { display: flex; align-items: center; gap: 0.6rem; margin-inline-start: auto; }
.admin-bar-tools form { margin: 0; }
.admin-site-link { font-size: var(--step--1); color: #cfd6dc; }
.admin-bar .btn-quiet { background: transparent; border-color: #39434c; color: #cfd6dc; }
.admin-bar .btn-quiet:hover { background: #1d252c; border-color: #55606a; color: #fff; }

.admin-wrap { padding-block: 2rem 5rem; display: flex; flex-direction: column; gap: 2.5rem; }

.admin-section {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 1.4rem 1.5rem 1.6rem;
  box-shadow: var(--shadow-sm);
}

.admin-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-block-end: 1.1rem;
}
.admin-section-head h2 { font-size: var(--step-2); }

.admin-section-tools { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.admin-subhead { font-size: var(--step-1); margin-block-end: 0.9rem; }

.admin-hint {
  font-size: var(--step--1);
  color: var(--ink-mute);
  line-height: 1.8;
  max-width: 90ch;
  margin-block: 0.5rem 1rem;
}

.flash {
  margin-block-start: 1.25rem;
  padding: 0.7rem 1rem;
  border: 1px solid #b9d9c9;
  border-radius: var(--radius-sm);
  background: var(--ok-soft);
  color: #14503a;
  font-size: var(--step--1);
  font-weight: 500;
}
.flash-error { border-color: #e3b6b7; background: var(--bad-soft); color: #7d1114; }

.alert {
  border: 1px solid var(--rule-strong);
  border-inline-start: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  padding: 0.85rem 1.1rem;
  font-size: var(--step--1);
  line-height: 1.8;
  margin-block-end: 1.25rem;
}
.alert code { background: rgba(255, 255, 255, 0.7); }
.alert-bad { border-inline-start-color: var(--bad); background: var(--bad-soft); }

/* Flash regeneration: the awaiting-approval state must be unmistakable. */
.flash-pending { border-inline-start-width: 5px; font-size: var(--step-0); }
.flash-pending strong:first-child { display: block; color: var(--warn); }
.flash-stale { margin: 0.5rem 0 0; }
.flash-panel .admin-table { margin-block-end: 1rem; }

/* Editor-only preview of unpublished content. */
.preview-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--warn-soft);
  border-block-end: 2px solid var(--warn);
  color: var(--ink);
  font-weight: 700;
  font-size: var(--step--1);
  padding-block: 0.6rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-block-end: 1.5rem;
}
.stat { background: var(--paper-raised); padding: 0.9rem 1.1rem; display: flex; flex-direction: column; gap: 0.2rem; }
.stat-value { font-size: var(--step-2); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.72rem; color: var(--ink-mute); }

/* ---- admin tables ------------------------------------------------------ */

.admin-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
  margin-block-end: 1rem;
}
.admin-table thead th {
  text-align: start;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0.5rem 0.65rem;
  border-block-end: 2px solid var(--rule-strong);
  white-space: nowrap;
}
.admin-table tbody td { padding: 0.6rem 0.65rem; border-block-end: 1px solid var(--rule); vertical-align: top; }
.admin-table tbody tr:hover { background: var(--paper-sunken); }

.admin-table-forms tbody tr:hover { background: transparent; }
.admin-table-forms td { padding: 0; border-block-end: 1px solid var(--rule); }

.cell-strong { font-weight: 600; }
.cell-mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.cell-muted { color: var(--ink-mute); font-size: 0.75rem; }
.cell-error { color: var(--bad); font-size: 0.78rem; word-break: break-word; }
.cell-empty { color: var(--ink-faint); text-align: center; padding-block: 1.5rem; }
.cell-title { max-width: 34rem; }
.cell-title a { color: var(--ink); }
.cell-title a:hover { color: var(--accent-deep); }
.cell-actions { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.cell-actions form { margin: 0; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe0ce; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: #e3b6b7; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: #ecd4a8; }
.pill.idle { background: var(--paper-sunken); color: var(--ink-mute); border-color: var(--rule-strong); }

.lang-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  color: var(--ink-mute);
}

.date-nav { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.date-current { font-size: var(--step-1); font-weight: 700; }

.public-link { font-size: var(--step--1); font-weight: 600; }

.pager { display: flex; align-items: center; gap: 1rem; padding-block-start: 0.75rem; }
.pager-current { font-size: var(--step--1); color: var(--ink-mute); }

.filter-form { display: flex; gap: 0.5rem; align-items: center; }

/* ---- admin forms ------------------------------------------------------- */

.admin-form { margin: 0; }
.admin-form-inline {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block-start: 0.75rem;
  border-block-start: 1px solid var(--rule);
}

.admin-form label,
.login-form label,
.event-editor label,
.source-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-soft);
}

.admin-form input[type="text"],
.admin-form input[type="password"],
.admin-form input[type="number"],
.admin-form select,
.login-form input,
.event-editor input[type="text"],
.event-editor textarea,
.source-form input[type="text"],
.source-form input[type="number"],
.source-form select,
.filter-form select {
  font-family: inherit;
  font-size: var(--step-0);
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  inline-size: 100%;
  min-inline-size: 0;
}
.admin-form input:focus,
.admin-form select:focus,
.login-form input:focus,
.event-editor input:focus,
.event-editor textarea:focus,
.source-form input:focus,
.source-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.event-editor textarea { resize: vertical; line-height: 1.7; }
.source-form input[dir="ltr"] { direction: ltr; text-align: left; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.form-wide { grid-column: 1 / -1; }

.admin-form .checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}
.admin-form .checkbox input { inline-size: auto; }

.field-hint { font-size: 0.72rem; color: var(--ink-faint); font-weight: 400; }

.form-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding-block-start: 1.1rem; }
.form-actions-sticky {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  border-block-start: 1px solid var(--rule);
  padding-block: 0.9rem;
  margin-block-start: 1rem;
  z-index: 5;
}

.event-editor {
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem 1.2rem;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--paper);
}
.event-editor legend {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: var(--step--1);
  font-weight: 700;
  padding-inline: 0.4rem;
}
.event-editor-no {
  display: grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.72rem;
}

/* ---- source editor ----------------------------------------------------- */

.source-editor-cell { padding: 1rem 1.1rem !important; }

.source-form { display: flex; flex-direction: column; gap: 0.65rem; }

.source-form-row { display: flex; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; }
.source-form-row .grow { flex: 1 1 20rem; }
.source-form-row input[type="text"],
.source-form-row select { inline-size: auto; min-inline-size: 8rem; }
.source-form-row input[type="number"] { inline-size: 5.5rem; }

.source-slug {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
  padding-block-end: 0.5rem;
  min-inline-size: 7rem;
}

.source-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-block-start: 0.85rem;
  padding-block-start: 0.75rem;
  border-block-start: 1px dashed var(--rule);
}
.source-meta form { margin: 0; }

/* ---- login ------------------------------------------------------------- */

.login-page { padding-block: 4rem 6rem; }
.login-wrap { max-width: 26rem; }

.login-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-block-end: 1.25rem;
  border-block-end: 1px solid var(--rule);
  margin-block-end: 1.25rem;
}
.login-title { font-size: var(--step-2); font-weight: 700; line-height: 1.2; }
.login-sub { font-size: var(--step--1); color: var(--ink-mute); }

.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-note {
  font-size: var(--step--1);
  color: var(--ink-faint);
  margin-block: 1.25rem 0;
  text-align: center;
}

/* ---- theme toggle ------------------------------------------------------ */

.theme-toggle {
  display: inline-grid;
  place-items: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper-sunken);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--ink); color: var(--ink); }
.theme-toggle svg { inline-size: 1.05rem; block-size: 1.05rem; display: block; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.admin-bar .theme-toggle { background: transparent; border-color: #39434c; color: var(--invert-fg); }
.admin-bar .theme-toggle:hover { background: #1d252c; color: var(--invert-fg-strong); }

/* ---- confirmation dialog ----------------------------------------------- */

.confirm-dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  max-inline-size: min(30rem, calc(100vw - 2rem));
  inline-size: 100%;
}
.confirm-dialog::backdrop {
  background: rgba(9, 12, 15, 0.52);
  backdrop-filter: blur(2px);
}
.confirm-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "mark title" "body body" "actions actions";
  gap: 0.85rem 0.9rem;
  padding: 1.5rem 1.5rem 1.25rem;
  border: 1px solid var(--rule-strong);
  border-radius: calc(var(--radius) + 4px);
  background: var(--paper-raised);
  box-shadow: 0 28px 70px -28px rgba(16, 20, 24, 0.5);
  animation: confirm-in 0.16s ease-out;
}
.confirm-mark {
  grid-area: mark;
  display: grid;
  place-items: center;
  inline-size: 2.15rem;
  block-size: 2.15rem;
  border: 1px solid color-mix(in srgb, var(--warn) 38%, var(--rule));
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--step-1);
  font-weight: 700;
  line-height: 1;
}
.confirm-title {
  grid-area: title;
  align-self: center;
  margin: 0;
  font-size: var(--step-1);
  font-weight: 700;
  line-height: 1.4;
}
.confirm-body {
  grid-area: body;
  color: var(--ink-soft);
  font-size: var(--step--1);
  line-height: 1.9;
}
.confirm-body p { margin: 0 0 0.6rem; }
.confirm-body p:last-child { margin-block-end: 0; }
.confirm-body strong { color: var(--ink); font-weight: 700; }
.confirm-body ul {
  display: grid;
  gap: 0.35rem;
  margin: 0.4rem 0 0.7rem;
  padding-inline-start: 1.15rem;
}
.confirm-body li { padding-inline-start: 0.15rem; }
.confirm-actions {
  grid-area: actions;
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-block-start: 0.35rem;
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--rule);
}
@keyframes confirm-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 40rem) {
  .confirm-card { padding: 1.25rem 1.15rem 1rem; }
  .confirm-actions { flex-direction: column-reverse; }
  .confirm-actions .btn { inline-size: 100%; }
}

/* ---- toasts ------------------------------------------------------------ */

.toast-wrap {
  position: fixed;
  inset-block-start: 0.9rem;
  inset-inline-end: 0.9rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  inline-size: min(26rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: var(--step--1);
  font-weight: 500;
  line-height: 1.6;
  animation: toast-in 0.18s ease-out;
}
.toast-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--rule)); background: var(--ok-soft); color: var(--ok); }
.toast-error { border-color: color-mix(in srgb, var(--bad) 45%, var(--rule)); background: var(--bad-soft); color: var(--bad); }
.toast-text { flex: 1 1 auto; word-break: break-word; }
.toast-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0 0.1rem;
  cursor: pointer;
  opacity: 0.7;
}
.toast-close:hover { opacity: 1; }
.toast.is-leaving { opacity: 0; transform: translateY(-0.35rem); transition: opacity 0.2s ease, transform 0.2s ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to { opacity: 1; transform: none; }
}

/* ---- update-content button -------------------------------------------- */

.btn-spinner {
  display: none;
  inline-size: 1rem;
  block-size: 1rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}
.btn.is-loading .btn-spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.admin-update-title { font-size: var(--step-2); margin-block-end: 0.4rem; }
.admin-update-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.admin-update-status {
  margin: 0;
  font-size: var(--step--1);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
/* `display: flex` above outranks the UA `[hidden] { display: none }`, which
   would leave the "update in progress" line permanently on screen and make the
   panel look busy when nothing is running. */
.admin-update-status[hidden] { display: none; }

/* ---- update task list (✓ ⟳ ☐ ✕ per stage) ------------------------------ */

.stage-task-list {
  list-style: none;
  margin: 0.75rem 0 0.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 24rem;
}
.stage-task {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: var(--step--1);
}
.stage-task.is-current { border-color: var(--accent); }
.stage-symbol {
  inline-size: 1.25rem;
  text-align: center;
  font-weight: 700;
}
.stage-task.is-current .stage-symbol { animation: spin 1.2s linear infinite; display: inline-block; }
.stage-label { font-weight: 600; }
.stage-state { margin-inline-start: auto; color: var(--ink-soft); font-size: 0.75rem; }
.stage-ok .stage-symbol { color: var(--ok); }
.stage-bad .stage-symbol { color: var(--bad); }
.stage-running .stage-symbol { color: var(--accent); }
.stage-partial .stage-symbol { color: var(--warn); }
.stage-pending .stage-symbol { color: var(--ink-mute); }
.stage-idle .stage-symbol { color: var(--ink-mute); }
.stage-partial-note { margin: 0.25rem 0 0; font-size: var(--step--1); color: var(--warn); }

.verification-issues {
  margin: 0.5rem 0 0;
  padding-inline-start: 1.25rem;
  font-size: var(--step--1);
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ---- dark-theme surface fixes ------------------------------------------ */

html[data-theme="dark"] .flash { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--rule)); }
html[data-theme="dark"] .flash-error { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--rule)); }
html[data-theme="dark"] .alert code,
html[data-theme="dark"] .page-body code { background: rgba(255, 255, 255, 0.06); }
html[data-theme="dark"] .pill.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--rule)); }
html[data-theme="dark"] .pill.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--rule)); }
html[data-theme="dark"] .pill.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--rule)); }
html[data-theme="dark"] .story-figure { background: var(--paper-sunken); }
/* A plain .btn fills with --ink and labels with --paper, so it already reads
   correctly in dark mode and needs no override. Only the filled variants whose
   light-theme background turns light in dark mode need a darker label:
   .btn-primary (.btn-primary { color: #fff }) and .btn-danger:hover, plus
   .btn-danger's light-theme pink border. Do NOT repaint .btn here: a
   `html[data-theme="dark"] .btn { color: var(--paper) }` rule outranks
   .btn-quiet/.btn-danger and paints their labels with the dark --paper, which
   makes the لغو and مشاهده نسخه امروز ↗ buttons invisible. */
html[data-theme="dark"] .btn-primary { color: #04110d; }
html[data-theme="dark"] .btn-danger {
  border-color: color-mix(in srgb, var(--bad) 45%, var(--rule-strong));
}
html[data-theme="dark"] .btn-danger:hover { background: var(--bad); border-color: var(--bad); color: #1a0d0d; }

/* ---- first-party advertisement (see static/ads.js) -----------------------
   The same unit as Porabzar: a full-height carousel in a rail on each side
   of the page on wide screens, a thin swipeable banner on the bottom edge
   everywhere else. */

.emrooz-ad-rail,
.emrooz-ad-banner {
  --ad-accent: var(--accent);
  --ad-accent-deep: var(--accent-deep);
  --ad-accent-soft: var(--accent-soft);
}

.emrooz-ad-banner__cta--legal {
  --ad-accent: #1d4ed8;
  --ad-accent-soft: rgba(29, 78, 216, 0.14);
}

.emrooz-ad-banner__cta--child {
  --ad-accent: #15803d;
  --ad-accent-soft: rgba(21, 128, 61, 0.14);
}

.emrooz-ad-banner__cta--sports {
  --ad-accent: #b91c1c;
  --ad-accent-soft: rgba(185, 28, 28, 0.14);
}

html[data-theme="dark"] .emrooz-ad-banner__cta--legal { --ad-accent: #93b4ff; }
html[data-theme="dark"] .emrooz-ad-banner__cta--child { --ad-accent: #6fd39a; }
html[data-theme="dark"] .emrooz-ad-banner__cta--sports { --ad-accent: #ff8f8f; }

/* --- desktop rail carousel ------------------------------------------------ */

.emrooz-ad-rail {
  display: none;
}

@media (min-width: 1500px) {
  :root {
    --ad-rail-w: 224px;
    --ad-rail-edge: 16px;
  }

  html.has-ad-rails body {
    padding-inline: calc(var(--ad-rail-w) + 2 * var(--ad-rail-edge));
  }

  .emrooz-ad-rail {
    position: fixed;
    top: var(--ad-rail-edge);
    bottom: var(--ad-rail-edge);
    z-index: 15;
    display: flex;
    flex-direction: column;
    width: var(--ad-rail-w);
  }

  .emrooz-ad-rail--left { left: var(--ad-rail-edge); }
  .emrooz-ad-rail--right { right: var(--ad-rail-edge); }

  .emrooz-ad-rail .emrooz-ad__carousel {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
  }

  .emrooz-ad-rail .emrooz-ad__viewport {
    flex: 1 1 auto;
    min-height: 150px;
  }

  .emrooz-ad-rail .emrooz-ad__track,
  .emrooz-ad-rail .emrooz-ad__card {
    height: 100%;
  }

  .emrooz-ad-rail .emrooz-ad__hero {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  .emrooz-ad-rail .emrooz-ad__body {
    flex: 0 0 auto;
  }

  /* The rails take over on wide screens; the thin banner would be redundant. */
  .emrooz-ad-banner {
    display: none !important;
  }
}

.emrooz-ad__viewport {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  outline: none;
  cursor: grab;
  /* Horizontal drags drive the carousel; vertical gestures keep scrolling. */
  touch-action: pan-y;
}

.emrooz-ad__viewport:active { cursor: grabbing; }
.emrooz-ad__viewport:focus-visible { box-shadow: 0 0 0 3px var(--ad-accent-soft); }

.emrooz-ad__track {
  display: flex;
  flex-direction: row;
  height: 100%;
  will-change: transform;
  transition: transform 520ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.emrooz-ad__card {
  position: relative;
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.emrooz-ad__card:hover,
.emrooz-ad__card:focus-visible {
  border-color: var(--ad-accent);
  color: var(--ink);
  text-decoration: none;
}

.emrooz-ad__card:focus-visible {
  outline: 2px solid var(--ad-accent);
  outline-offset: 2px;
}

.emrooz-ad__hero {
  position: relative;
  display: block;
  flex: 0 0 94px;
  height: 94px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--ad-accent-deep), var(--ad-accent));
}

.emrooz-ad__media {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.emrooz-ad__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(9, 12, 18, 0.78), rgba(9, 12, 18, 0.08) 72%);
}

.emrooz-ad__icon {
  position: absolute;
  inset-inline-start: 9px;
  bottom: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: #0a4438;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.emrooz-ad__icon svg { width: 18px; height: 18px; }

.emrooz-ad__label {
  position: absolute;
  inset-inline-end: 8px;
  top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(9, 12, 18, 0.58);
  color: #f2f4f7;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  backdrop-filter: blur(4px);
}

.emrooz-ad__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 10px 12px 12px;
}

.emrooz-ad__eyebrow {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ad-accent);
}

.emrooz-ad__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 3px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
}

.emrooz-ad__desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--ink-mute);
}

.emrooz-ad__more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ad-accent);
}

.emrooz-ad__arrow { display: inline-flex; align-items: center; }
.emrooz-ad__arrow svg { width: 14px; height: 14px; }

.emrooz-ad__dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 9px;
}

.emrooz-ad__dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--rule-strong);
  cursor: pointer;
  transition: width 0.2s ease, background 0.2s ease;
}

.emrooz-ad__dot[aria-selected="true"] {
  width: 18px;
  background: var(--ad-accent);
}

.emrooz-ad__dot:focus-visible {
  outline: 2px solid var(--ad-accent);
  outline-offset: 2px;
}

/* --- mobile / responsive rotating banner ---------------------------------- */

.emrooz-ad-banner {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 60;
  display: block;
  background: var(--paper-raised);
  border-top: 1px solid var(--rule-strong);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.22);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* A swipe slides the creative past the edge; clip it without hiding the
     «تبلیغ» chip that overhangs the top border. */
  overflow-x: clip;
  transform: translateY(100%);
  transition: transform 0.25s ease, opacity 0.22s ease;
}

.emrooz-ad-banner.is-ready { transform: translateY(0); }

.emrooz-ad-banner__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
  /* Horizontal swipes move between creatives; vertical gestures still scroll. */
  touch-action: pan-y;
  will-change: transform;
}

.emrooz-ad-banner__item:hover { color: var(--ink); text-decoration: none; }

.emrooz-ad-banner__media {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--paper-sunken);
}

.emrooz-ad-banner__text {
  min-width: 0;
  flex: 1 1 auto;
}

.emrooz-ad-banner__title {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emrooz-ad-banner__desc {
  display: block;
  font-size: 0.74rem;
  line-height: 1.6;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emrooz-ad-banner__cta {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ad-accent-soft);
  color: var(--ad-accent);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.emrooz-ad-banner__label {
  position: absolute;
  inset-inline-start: 6px;
  top: -9px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--paper-sunken);
  border: 1px solid var(--rule);
  color: var(--ink-mute);
  font-size: 0.62rem;
}

/* While the banner is mounted, the page (footer included) needs room above
   it; ads.js measures the banner and sets the clearance. */
@media (max-width: 1499.98px) {
  html.has-bottom-ad body {
    padding-bottom: var(--ad-foot-clearance, 56px);
  }
}

/* ---- motion preferences ------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---- print ------------------------------------------------------------- */

@media print {
  .site-header, .site-footer, .briefing-rail, .skip-link, .chipbar,
  .emrooz-ad-rail, .emrooz-ad-banner { display: none !important; }
  body { background: #fff; padding: 0 !important; }
  .briefing-grid { display: block; padding: 0; }
  .story { break-inside: avoid; }
}
