:root {
  --frame-margin: 14px;
  --wine-950: #4e0602;
  --wine-900: #650800;
  --wine-800: #7f0c03;
  --source-burgundy: #700b06;
  --gold-500: #ffcc3d;
  --gold-300: #ffe08a;
  --cream-100: #fff6d8;
  --cream-300: #edcf80;
  --paper: #fffaf0;
  --ink: #24100c;
  --muted: #704834;
  --line: #d4a84e;
  --shadow: 0 18px 44px rgba(89, 43, 8, 0.13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--cream-100);
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}
button, a { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
h1, h2, h3, p, li, dd { overflow-wrap: anywhere; }

.page-header {
  margin: 8px var(--frame-margin) 0;
  min-height: 302px;
  padding: 8px;
  background: var(--source-burgundy);
  border-radius: 14px;
  overflow: hidden;
}
.image-banner {
  display: grid;
  place-items: center start;
  min-height: 286px;
  background: var(--source-burgundy);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
}
.image-banner img {
  display: block;
  width: min(1120px, 100%);
  height: auto;
  max-width: 1120px;
}

.app-layout {
  min-height: calc(100vh - 390px);
  margin: 18px var(--frame-margin) 24px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--cream-100);
  box-shadow: var(--shadow);
}
.side-panel {
  padding: 22px;
  color: var(--cream-100);
  background: linear-gradient(180deg, var(--wine-900), var(--wine-950));
  box-shadow: inset -1px 0 0 rgba(255, 231, 163, 0.18);
}
.side-title {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 224, 138, 0.25);
}
.side-title span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: var(--gold-500);
  border-radius: 6px;
  font-weight: 900;
}
.section-tabs {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}
.tab-button {
  display: block;
  padding: 12px 10px;
  color: var(--cream-100);
  text-align: left;
  background: transparent;
  border-left: 3px solid transparent;
  border-radius: 4px;
  font-weight: 800;
}
.tab-button:hover {
  color: var(--gold-300);
  background: rgba(255, 246, 216, 0.08);
  border-left-color: rgba(255, 224, 138, 0.42);
}
.tab-button.is-active {
  color: var(--gold-500);
  background: rgba(255, 204, 61, 0.13);
  border-left-color: var(--gold-500);
}

.content-stage {
  min-width: 0;
  padding: 24px;
  background: linear-gradient(90deg, rgba(112, 11, 6, 0.06), rgba(112, 11, 6, 0) 96px), var(--cream-100);
}
.stage-top { margin-bottom: 18px; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--wine-800);
  font-size: 0.77rem;
  font-weight: 900;
  text-transform: uppercase;
}
.stage-top h1 {
  margin: 0;
  color: var(--wine-950);
  font-size: clamp(1.7rem, 3vw, 2.55rem);
}
.article-subtitle {
  max-width: none;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 1.35;
}
.article-authors {
  display: block;
  margin-top: 3px;
  color: var(--wine-800);
}
.article-authors strong { font-weight: 900; }
.publication-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 18px;
  width: 100%;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--cream-300);
  font-size: .82rem;
  line-height: 1.6;
  color: var(--wine-800);
}
.publication-details p {
  margin: 0;
  white-space: nowrap;
}
.publication-details span { margin: 0 6px; }
.publication-details a { color: var(--wine-800); text-underline-offset: 3px; }

.content-panel { display: none; }
.content-panel.is-visible { display: block; }
.inside-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--cream-300);
  border-radius: 8px;
  background: #efdfb5;
  overflow-x: auto;
}
.inside-nav button {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: .81rem;
  line-height: 1.3;
  color: var(--wine-950);
  background: transparent;
  font-weight: 800;
}
.inside-nav button:hover { background: var(--paper); }
.inside-nav button[aria-pressed=true] {
  color: var(--cream-100);
  background: linear-gradient(135deg, var(--wine-800), var(--wine-950));
  border-color: var(--wine-900);
  box-shadow: inset 0 -2px var(--gold-500);
}

.paper-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  min-height: 310px;
  overflow: hidden;
  color: #fff8dc;
  background: linear-gradient(120deg, rgba(255, 204, 61, 0.18), transparent 42%), linear-gradient(135deg, var(--wine-900), var(--wine-950));
  border: 1px solid var(--cream-300);
  border-radius: 8px;
}
.hero-copy {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 30px;
}
.hero-copy h2 {
  margin: 0;
  max-width: 820px;
  color: #fff8dc;
  font-size: clamp(1.45rem, 2.35vw, 2.2rem);
  line-height: 1.12;
}
.hero-copy p {
  margin: 0;
  max-width: 780px;
  color: #f5d9a0;
  font-size: 1.04rem;
  line-height: 1.48;
}
.template-source-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.article-link-button, .primary {
  display: inline-block;
  padding: 10px 13px;
  color: var(--wine-950);
  background: var(--gold-500);
  border: 1px solid var(--gold-300);
  border-radius: 6px;
  font-size: .83rem;
  font-weight: 900;
  text-decoration: none;
}
.hero-facts {
  padding: 22px;
  border-left: 1px solid #ffe08a38;
  background: #fff6d817;
}
.hero-facts dl { display: grid; gap: 12px; margin: 0; }
.hero-facts div {
  padding: 13px;
  border: 1px solid #ffe08a3d;
  background: #fff6d821;
  border-radius: 7px;
}
.hero-facts dt {
  color: var(--gold-300);
  font-size: .75rem;
  font-weight: 900;
  text-transform: uppercase;
}
.hero-facts dd {
  margin: 5px 0 0;
  color: #fff8dc;
  font-size: 1rem;
  line-height: 1.35;
}

.overview-section {
  margin-top: 22px;
  border: 1px solid var(--cream-300);
  border-radius: 8px;
  background: rgba(255, 241, 197, 0.55);
}
.compact-section, .visual-section, .section-card { padding: 18px; }
.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.overview-section > .section-heading,
.section-card > .section-heading {
  padding: 10px 12px;
  background:
    linear-gradient(90deg, var(--wine-900) 0%, var(--wine-950) 18%, #b78242 52%, var(--wine-950) 84%, var(--wine-900) 100%);
  border: 1px solid rgba(101, 8, 0, 0.18);
  border-radius: 7px;
}
.section-heading span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  color: var(--wine-950);
  background: var(--gold-500);
  border-radius: 6px;
  font-weight: 900;
}
.section-heading h2 {
  margin: 0;
  color: #fff8dc;
  font-size: 1.35rem;
}
.small-heading { margin-bottom: 10px; }
.small-heading span { width: 30px; height: 30px; font-size: .85rem; }
.lens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.lens-card, .finding-card, .burden-card, .concept-card, .data-grid > div {
  padding: 16px;
  background: #fffdf7;
  border: 1px solid #e4cf9b;
  border-radius: 8px;
}
.lens-card h3, .finding-card h3, .burden-card h3, .concept-card h3 {
  margin: 0 0 9px;
  color: var(--wine-900);
  font-size: 1.08rem;
}
.lens-card p, .finding-card p, .burden-card p, .concept-card dd, .section-card li {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.43;
}
.keyword-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.keyword-row span, .finding-card > span, .concept-card > span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 7px 10px;
  color: var(--wine-950);
  background: #f4e3b6;
  border: 1px solid #e3c47b;
  border-radius: 5px;
  font-size: .76rem;
  font-weight: 900;
  text-transform: uppercase;
}
.finding-card > span {
  margin-bottom: 10px;
}
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.data-grid strong {
  display: block;
  color: var(--wine-900);
  margin-bottom: 6px;
}
.data-grid span {
  color: var(--muted);
  line-height: 1.45;
}
.burden-grid, .finding-grid, .concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 14px;
}
.burden-card strong {
  display: block;
  color: var(--wine-900);
  font-size: 2rem;
  font-weight: 500;
}
.finding-card { border-top: 6px solid var(--wine-800); }
.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  border: 0;
  background: transparent;
}
.section-card {
  border: 1px solid var(--cream-300);
  border-radius: 8px;
  background: var(--paper);
}
.section-card ul { margin: 0; padding-left: 20px; }
.section-card li + li { margin-top: 10px; }
.conclusion-section {
  padding: 18px;
}
.conclusion-section .section-card {
  width: 100%;
}
.template-abstract {
  color: var(--muted);
  font-size: .97rem;
  line-height: 1.6;
}

.evidence-stack {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
}
.figure-selector {
  display: grid;
  align-content: start;
  gap: 10px;
}
.figure-choice {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 70px;
  padding: 11px;
  text-align: left;
  color: var(--wine-950);
  background: var(--paper);
  border: 1px solid var(--cream-300);
  border-radius: 8px;
}
.figure-choice[aria-pressed=true] {
  color: var(--cream-100);
  background: linear-gradient(135deg, var(--wine-800), var(--wine-950));
  border-color: var(--wine-900);
  box-shadow: inset 3px 0 var(--gold-500);
}
.figure-number {
  display: grid;
  place-items: center;
  height: 38px;
  background: #f4e3b6;
  border-radius: 5px;
  color: var(--wine-950);
  font-weight: 900;
}
.figure-choice[aria-pressed=true] .figure-number { background: var(--gold-500); }
.figure-choice-copy strong {
  font-size: .8rem;
  line-height: 1.28;
}
.evidence-card {
  overflow: hidden;
  border: 1px solid var(--cream-300);
  border-radius: 8px;
  background: var(--paper);
}
.evidence-visual {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 24px;
  background: #fffdf7;
}
.evidence-visual img {
  display: block;
  width: 100%;
  max-height: none;
  object-fit: contain;
}
.figure-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  padding: 18px 22px;
  border-top: 1px solid var(--cream-300);
}
.figure-heading { flex: 1; }
.figure-heading h3 {
  margin: 0 0 6px;
  color: var(--wine-900);
  font-size: 1.06rem;
}
.figure-heading p, #dialogCaption {
  margin: 0;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.6;
}

.concept-card dl { margin: 14px 0 0; }
.concept-card div + div { margin-top: 12px; }
.concept-card dt {
  color: var(--wine-900);
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
}
.concept-card dd { margin: 4px 0 0; }

.site-footer {
  margin: 0 var(--frame-margin) 18px;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--wine-900), var(--wine-950));
  color: #fff8dc;
  text-align: center;
  padding: 14px 18px;
  font-size: .82rem;
}
.site-footer p { margin: 0; }

dialog {
  width: min(1100px, 94vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: #24100caa; }
.dialog-top {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  color: var(--wine-900);
  margin-bottom: 14px;
}
.dialog-top button {
  padding: 9px 13px;
  color: var(--cream-100);
  background: var(--wine-900);
  border-radius: 5px;
}
#dialogFigure img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

@media (max-width: 980px) {
  .app-layout { grid-template-columns: 1fr; }
  .side-panel { padding: 18px 22px; }
  .section-tabs { display: flex; margin-top: 16px; }
  .tab-button { flex: 1; }
  .paper-hero, .bottom-grid, .evidence-stack { grid-template-columns: 1fr; }
  .hero-facts { border-left: 0; border-top: 1px solid #ffe08a38; }
}
@media (max-width: 680px) {
  .page-header { min-height: 0; }
  .image-banner { min-height: 0; }
  .app-layout { margin-top: 12px; }
  .content-stage { padding: 16px; }
  .section-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .inside-nav { display: grid; grid-template-columns: 1fr 1fr; }
  .paper-hero { min-height: 0; }
  .hero-copy { padding: 22px; }
  .hero-copy h2 { font-size: 1.45rem; }
  .figure-header { grid-template-columns: 1fr; }
  .evidence-visual { min-height: 240px; padding: 12px; }
  .publication-details p { white-space: normal; }
}
