:root {
  color-scheme: light;
  --ink: #171817;
  --muted: #61645f;
  --line: #dadcd3;
  --paper: #fbfbf7;
  --panel: #ffffff;
  --wash: #eff4ed;
  --brick: #a73e35;
  --cobalt: #255f9f;
  --moss: #447052;
  --gold: #b27b20;
  --shadow: 0 18px 55px rgba(32, 36, 31, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

svg {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(68, 112, 82, 0.08), rgba(255, 255, 255, 0) 280px),
    var(--paper);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid rgba(23, 24, 23, 0.08);
  background: rgba(251, 251, 247, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border: 1px solid rgba(23, 24, 23, 0.16);
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.95rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.1rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.icon-link {
  position: relative;
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid rgba(23, 24, 23, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-link:hover,
.icon-link:focus-visible {
  border-color: rgba(37, 95, 159, 0.42);
  background: #fff;
  outline: none;
  transform: translateY(-1px);
}

[data-tooltip]::after {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 50%;
  z-index: 30;
  padding: 0.28rem 0.45rem;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  content: attr(data-tooltip);
  font-size: 0.72rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -0.2rem);
  transition: opacity 140ms ease, transform 140ms ease;
  white-space: nowrap;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: clamp(1.25rem, 4vw, 3.2rem);
  align-items: end;
  min-height: 58vh;
  padding: clamp(3rem, 9vh, 6rem) 0 clamp(2rem, 6vh, 4rem);
}

.eyebrow {
  margin: 0 0 0.9rem;
  color: var(--brick);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.2rem, 8vw, 7.5rem);
  font-weight: 500;
  line-height: 0.92;
}

h1 span {
  display: block;
}

.lede {
  max-width: 40rem;
  margin: 1.25rem 0 0;
  color: #3d403b;
  font-size: clamp(1rem, 1.8vw, 1.22rem);
  line-height: 1.75;
}

.control-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid rgba(23, 24, 23, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.status-block {
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid rgba(23, 24, 23, 0.08);
  border-radius: 8px;
  background: var(--paper);
}

.status-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.status-block strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  min-height: 2.9rem;
  padding: 0.28rem;
  border: 1px solid rgba(23, 24, 23, 0.1);
  border-radius: 8px;
  background: #eef1e9;
}

.segment,
.refresh-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.segment {
  min-width: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 15px rgba(32, 36, 31, 0.09);
}

.refresh-button {
  display: inline-flex;
  min-height: 2.9rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.refresh-button:hover,
.refresh-button:focus-visible {
  background: var(--cobalt);
  outline: none;
  transform: translateY(-1px);
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(23, 24, 23, 0.1);
  border-radius: 8px;
  background: var(--line);
}

.summary-band > div {
  min-width: 0;
  padding: 1rem;
  background: #fff;
}

.summary-number,
.summary-label {
  display: block;
}

.summary-number {
  color: var(--moss);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
}

.summary-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.feed-section {
  padding: 1.5rem 0 4rem;
}

.state-message {
  margin: 0 0 1rem;
  color: var(--muted);
}

.state-message[hidden] {
  display: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.story-card {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  min-height: 540px;
  border: 1px solid rgba(23, 24, 23, 0.12);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(32, 36, 31, 0.08);
}

.card-media {
  position: relative;
  min-height: 185px;
  background:
    linear-gradient(135deg, rgba(167, 62, 53, 0.16), rgba(37, 95, 159, 0.16)),
    var(--wash);
}

.card-media img {
  width: 100%;
  height: 100%;
  max-height: 235px;
  object-fit: cover;
  display: block;
}

.card-media.fallback {
  display: grid;
  place-items: center;
  min-height: 185px;
}

.fallback-letter {
  display: grid;
  width: 5.4rem;
  height: 5.4rem;
  place-items: center;
  border: 1px solid rgba(23, 24, 23, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--cobalt);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
}

.card-body {
  display: grid;
  gap: 1rem;
  padding: 1.05rem;
}

.card-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.pill {
  display: inline-flex;
  min-height: 1.45rem;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: #edf2f7;
  color: var(--cobalt);
  font-weight: 800;
}

.story-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 2.4vw, 2.15rem);
  font-weight: 500;
  line-height: 1.05;
}

.holiday-name {
  margin: 0;
  color: var(--brick);
  font-size: 0.95rem;
  font-weight: 800;
}

.story-angle {
  margin: 0;
  color: #343730;
  line-height: 1.65;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.metric {
  min-width: 0;
  padding: 0.72rem;
  border: 1px solid rgba(23, 24, 23, 0.08);
  border-radius: 8px;
  background: #f8f8f2;
}

.metric span,
.metric small {
  display: block;
}

.metric span {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 900;
}

.metric small {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.2rem;
}

.insight-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.insight-list li {
  display: grid;
  gap: 0.22rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid rgba(23, 24, 23, 0.08);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.35;
}

.insight-list strong {
  color: var(--cobalt);
  font-size: 0.78rem;
}

.insight-list span {
  color: #30332f;
}

.insight-link {
  width: fit-content;
  color: var(--brick);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.empty-insights {
  padding: 0.75rem;
  border: 1px dashed rgba(23, 24, 23, 0.18);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem 2.4rem;
  border-top: 1px solid rgba(23, 24, 23, 0.08);
  color: var(--muted);
  font-size: 0.86rem;
}

.site-footer a {
  color: var(--ink);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(12, 14, 12, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(92vw, 390px);
  max-height: min(86vh, 620px);
  overflow: auto;
  padding: 1.15rem;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 2.6rem 1rem 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 500;
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid rgba(23, 24, 23, 0.12);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.modal-close:focus-visible {
  outline: 2px solid rgba(37, 95, 159, 0.45);
  outline-offset: 2px;
}

.qr-image {
  display: block;
  width: 100%;
  max-width: 310px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid rgba(23, 24, 23, 0.1);
}

.modal-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.modal-links a {
  color: var(--cobalt);
  font-weight: 800;
}

@media (max-width: 840px) {
  main {
    width: min(100% - 1rem, 680px);
  }

  .topbar {
    padding: 0.8rem 0.75rem;
  }

  .brand small {
    display: none;
  }

  .workbench {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 2.25rem;
  }

  h1 {
    max-width: 10ch;
    font-size: clamp(3.1rem, 15vw, 5rem);
  }

  .control-strip,
  .summary-band,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .summary-band {
    gap: 0;
  }

  .story-card {
    min-height: auto;
  }
}

@media (max-width: 480px) {
  .top-actions {
    gap: 0.3rem;
  }

  .icon-link {
    width: 2.05rem;
    height: 2.05rem;
  }

  .control-strip {
    padding: 0.7rem;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}
