:root {
  --bg: #f4f0e8;
  --ink: #17232e;
  --muted: #657384;
  --line: rgba(23, 35, 46, 0.12);
  --line-strong: rgba(23, 35, 46, 0.2);
  --paper: rgba(255, 252, 247, 0.9);
  --paper-strong: #fffdfa;
  --navy: #16324a;
  --forest: #1f4d4a;
  --sand: #b4864f;
  --shadow: 0 28px 72px rgba(23, 31, 41, 0.12);
  --shadow-soft: 0 18px 34px rgba(23, 31, 41, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: "Inter", "Avenir Next", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(22, 50, 74, 0.11), transparent 24%),
    radial-gradient(circle at top right, rgba(31, 77, 74, 0.08), transparent 18%),
    linear-gradient(180deg, #efe8dd 0%, #f8f4ed 42%, #fcfbf7 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.viewer-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent);
}

.viewer-shell {
  position: relative;
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 88px;
  min-width: 0;
}

.viewer-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

.viewer-kicker,
.viewer-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.viewer-context {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 600;
}

.viewer-hero-copy {
  max-width: 68ch;
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: var(--navy);
  color: #fff;
}

.button-secondary {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
}

.viewer-hero {
  margin-bottom: 24px;
  padding: 38px 40px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(19, 39, 58, 0.97), rgba(30, 61, 82, 0.94)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
  box-shadow: var(--shadow);
}

.viewer-label,
.viewer-subtitle {
  color: rgba(247, 245, 240, 0.78);
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
blockquote,
pre {
  margin-top: 0;
}

h1,
.report-content h1,
.report-content h2,
.report-content h3 {
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

h1 {
  margin-bottom: 14px;
  max-width: 16ch;
  color: #f7f5f0;
  font-size: clamp(2.4rem, 4vw, 4.2rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
}

.viewer-subtitle {
  max-width: 64ch;
  margin-bottom: 0;
  line-height: 1.65;
}

.viewer-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #f8f4ed;
  font-size: 0.82rem;
  font-weight: 700;
}

.meta-pill-soft {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(248, 244, 237, 0.84);
}

.viewer-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  min-width: 0;
}

.viewer-rail {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

.rail-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  min-width: 0;
}

.rail-card-accent {
  background: linear-gradient(135deg, rgba(22, 50, 74, 0.08), rgba(31, 77, 74, 0.06)), var(--paper);
}

.report-meta,
.rail-list {
  color: var(--muted);
  line-height: 1.66;
}

.report-meta,
.rail-callout,
.report-content,
.report-content p,
.report-content li,
.report-content code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.rail-callout {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--ink);
}

.rail-list {
  margin: 0;
  padding-left: 18px;
}

.report-paper {
  padding: 42px 46px;
  border: 1px solid rgba(23, 35, 46, 0.08);
  border-radius: 30px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
  min-width: 0;
}

.report-content {
  max-width: 900px;
  color: var(--ink);
  line-height: 1.85;
  min-width: 0;
}

.report-content h1,
.report-content h2,
.report-content h3,
.report-content h4 {
  margin-bottom: 12px;
  line-height: 1.15;
}

.report-content h1 {
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.report-content h2 {
  margin-top: 42px;
  font-size: clamp(1.5rem, 2vw, 1.95rem);
}

.report-content h3 {
  margin-top: 28px;
  font-size: 1.24rem;
}

.report-content p,
.report-content li,
.report-content blockquote {
  color: #283543;
}

.report-content p,
.report-content li {
  font-size: 1.03rem;
}

.report-content ul,
.report-content ol {
  padding-left: 22px;
}

.report-content code {
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  background: rgba(22, 50, 74, 0.06);
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.report-content pre {
  overflow-x: auto;
  padding: 18px;
  border-radius: 18px;
  background: #142538;
  color: #f6f8fb;
}

.report-content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.report-content .table-wrapper {
  overflow-x: auto;
}

.report-content table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  margin: 18px 0;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
}

.report-content th,
.report-content td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(23, 35, 46, 0.08);
  text-align: left;
  vertical-align: top;
}

.report-content th {
  color: var(--muted);
  background: rgba(22, 50, 74, 0.04);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.report-content blockquote {
  margin: 22px 0;
  padding: 16px 18px;
  border-left: 4px solid var(--sand);
  background: rgba(180, 134, 79, 0.08);
  border-radius: 0 14px 14px 0;
}

.report-content img {
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.report-content :is(h1, h2, h3, h4) + p {
  margin-top: 0.35rem;
}

.report-content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 30px 0;
}

.report-content a {
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

@media (min-width: 1280px) {
  .viewer-shell {
    width: min(1320px, calc(100% - 56px));
  }
}

@media (max-width: 1024px) {
  .viewer-layout {
    grid-template-columns: 1fr;
  }

  .viewer-rail {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .viewer-hero {
    padding: 32px 32px;
  }

  .report-paper {
    padding: 32px 32px;
  }
}

@media (max-width: 720px) {
  .viewer-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 14px;
    padding-bottom: 64px;
  }

  .viewer-topbar {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .viewer-kicker,
  .viewer-label {
    margin-bottom: 6px;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
  }

  .viewer-context {
    font-size: 0.9rem;
  }

  .viewer-actions {
    justify-content: flex-start;
    width: 100%;
    gap: 8px;
  }

  .viewer-hero-copy {
    max-width: none;
  }

  .button {
    width: 100%;
    min-height: 42px;
    padding: 0 14px;
    font-size: 0.94rem;
  }

  .viewer-hero,
  .rail-card,
  .report-paper {
    padding: 18px;
    border-radius: 24px;
  }

  .viewer-hero {
    margin-bottom: 18px;
  }

  .viewer-rail {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  h1 {
    max-width: none;
    font-size: clamp(1.95rem, 9.8vw, 2.7rem);
    line-height: 0.96;
  }

  .viewer-subtitle {
    font-size: 0.94rem;
    line-height: 1.58;
  }

  .viewer-subtitle,
  .report-meta,
  .rail-list,
  .report-content p,
  .report-content li {
    font-size: 0.94rem;
  }

  .report-content {
    max-width: none;
    line-height: 1.68;
  }

  .report-content h1 {
    font-size: 1.85rem;
  }

  .report-content h2 {
    margin-top: 28px;
    font-size: 1.34rem;
  }

  .report-content h3 {
    font-size: 1.04rem;
  }

  .report-content pre {
    padding: 12px;
    font-size: 0.84rem;
  }

  .report-content table {
    min-width: 480px;
  }

  .viewer-hero-meta {
    gap: 8px;
    margin-top: 12px;
  }

  .meta-pill {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .rail-list {
    padding-left: 16px;
  }

  .report-content ul,
  .report-content ol {
    padding-left: 18px;
  }
}
