@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=JetBrains+Mono:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --ink: #1a1a1a;
  --ink-soft: #3a3632;
  --muted: #8a8178;
  --paper: #f5f0e8;
  --paper-deep: #ebe4d8;
  --surface: #faf7f2;
  --line: #d4cbbf;
  --line-faint: #e8e1d5;
  --accent: #c4421a;
  --accent-hover: #a8350f;
  --accent-glow: rgba(196, 66, 26, 0.08);
  --teal: #2a7a6e;
  --teal-soft: rgba(42, 122, 110, 0.08);
  --focus: #c4421a;
  --shadow-sm: 0 1px 3px rgba(26, 26, 26, 0.06);
  --shadow-md: 0 8px 24px rgba(26, 26, 26, 0.08);
  --serif: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, output { font: inherit; }

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

button:hover { border-color: var(--accent); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* ─── TOPBAR ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 10px clamp(20px, 5vw, 56px);
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.topnav {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 3vw, 32px);
}

.topnav a {
  position: relative;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: color 0.15s;
}

.topnav a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.2s;
}

.topnav a:hover { color: var(--ink); }
.topnav a:hover::after { width: 100%; }

.reader-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  min-height: 40px;
  gap: 10px;
  border: 2px solid var(--ink);
  padding: 0 18px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toggle-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
  transition: background 0.2s;
}

.reader-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.reader-toggle[aria-pressed="true"] .toggle-dot {
  background: #5eea8d;
  box-shadow: 0 0 8px rgba(94, 234, 141, 0.5);
}

/* ─── MAIN GRID ─── */
.article-shell {
  display: grid;
  grid-template-columns: minmax(0, 740px) minmax(280px, 360px);
  gap: clamp(32px, 6vw, 80px);
  width: min(1200px, calc(100% - 40px));
  margin: 56px auto 140px;
  align-items: start;
}

.article { min-width: 0; }

.generator-shell {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 680px);
  gap: clamp(32px, 6vw, 72px);
  width: min(1180px, calc(100% - 40px));
  margin: 56px auto 120px;
  align-items: start;
}

.generator-controls {
  position: sticky;
  top: 88px;
}

.generator-form {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.generator-form label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.generator-input-row {
  display: grid;
  grid-template-columns: 1fr max-content;
  gap: 8px;
}

.generator-input-row input {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.generator-input-row button,
.route-action {
  min-height: 44px;
  border: 2px solid var(--ink);
  padding: 0 16px;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.route-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
}

.generated-article {
  min-width: 0;
}

.generated-sections {
  display: grid;
  gap: 8px;
}

/* ─── ARTICLE TYPOGRAPHY ─── */
.kicker {
  display: inline-block;
  margin: 0 0 20px;
  padding: 4px 12px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1, h2 { line-height: 1.05; letter-spacing: -0.03em; }

h1 {
  max-width: 13ch;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3.2rem, 9vw, 6.2rem);
  font-weight: 400;
  font-style: normal;
}

h2 {
  position: relative;
  margin: 80px 0 20px;
  padding-left: 20px;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3.6vw, 2.8rem);
  font-weight: 400;
}

h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  background: var(--accent);
}

.dek {
  max-width: 620px;
  margin: 28px 0 40px;
  color: var(--ink-soft);
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  line-height: 1.55;
}

p, blockquote, figcaption { font-size: 1.02rem; }

blockquote {
  position: relative;
  margin: 40px 0;
  padding: 24px 28px;
  background: var(--paper-deep);
  border-left: none;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.5;
}

blockquote::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
}

figure { margin: 0; }

img {
  display: block;
  max-width: 100%;
}

.hero-figure,
.inline-figure {
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.hero-figure img,
.inline-figure img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  filter: contrast(1.02) saturate(0.95);
}

#generatedThumbnail {
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

figcaption {
  padding: 12px 16px 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.01em;
  line-height: 1.5;
  border-top: 1px solid var(--line-faint);
}

.inline-figure { margin-top: 28px; }

/* ─── STATUS PANEL / SIDEBAR ─── */
.status-panel {
  position: sticky;
  top: 88px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink);
  background: var(--surface);
  padding: 24px 20px;
}

.status-panel h2 {
  margin: 0 0 20px;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.status-panel h2::before { display: none; }

.status-panel h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin: 0;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-faint);
}

dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

dd {
  margin: 3px 0 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

.live-narration {
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* ─── PANEL SECTIONS ─── */
.history-header,
.award-header,
.demo-script-header,
.submission-header,
.budget-header,
.runtime-header,
.image-receipt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 24px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-faint);
}

.history-header button,
.submission-header button {
  min-height: 28px;
  border: 1px solid var(--line);
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: transparent;
}

.history-header button:hover,
.submission-header button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.budget-header span,
.runtime-header span,
.image-receipt-header span,
.submission-header span,
.demo-script-header span {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal);
}

/* ─── TRANSCRIPT ─── */
.transcript-log {
  display: grid;
  gap: 8px;
  max-height: 320px;
  margin: 10px 0 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.transcript-log li {
  border: 1px solid var(--line-faint);
  padding: 10px 12px;
  background: var(--paper);
}

.transcript-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.transcript-text {
  margin: 6px 0 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ─── AWARD / DEMO / BULLET LISTS ─── */
.award-list,
.demo-script-list,
.demo-api-check-list,
.budget-list,
.runtime-list,
.image-receipt-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.demo-script-list { padding-left: 0; }

.award-list li,
.demo-script-list li,
.budget-list li,
.runtime-list li,
.image-receipt-list li {
  border: 1px solid var(--line-faint);
  padding: 10px 12px;
  background: var(--paper);
}

.demo-api-check-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  border: 1px solid var(--line-faint);
  padding: 10px 12px;
  background: var(--paper);
}

.demo-script-title,
.budget-row,
.runtime-row,
.image-receipt-row,
.award-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.budget-pill,
.runtime-pill,
.image-receipt-pill {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  letter-spacing: 0.04em;
}

.budget-pill {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(196, 66, 26, 0.2);
}

.runtime-pill {
  background: var(--teal-soft);
  color: var(--teal);
  border: 1px solid rgba(42, 122, 110, 0.2);
}

.status-pill {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-online {
  background: rgba(34, 140, 60, 0.12);
  color: #1d7a34;
  border: 1px solid rgba(34, 140, 60, 0.25);
}

.status-fallback {
  background: rgba(160, 140, 60, 0.1);
  color: #7a6a20;
  border: 1px solid rgba(160, 140, 60, 0.25);
}

.status-offline {
  background: rgba(180, 50, 50, 0.1);
  color: #a03030;
  border: 1px solid rgba(180, 50, 50, 0.25);
}

.image-receipt-pill {
  background: rgba(180, 150, 60, 0.1);
  color: #7a6520;
  border: 1px solid rgba(180, 150, 60, 0.2);
}

.award-status {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  background: var(--teal-soft);
  color: var(--teal);
  border: 1px solid rgba(42, 122, 110, 0.2);
}

.demo-script-title span:last-child {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  background: var(--teal-soft);
  color: var(--teal);
  border: 1px solid rgba(42, 122, 110, 0.2);
}

.demo-script-list p,
.budget-list p,
.runtime-list p,
.image-receipt-list p {
  margin: 6px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.award-evidence {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.demo-api-check-list span {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
}

.demo-api-check-list code {
  font-family: var(--mono);
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

.demo-api-check-list p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
}

.demo-api-command {
  grid-column: 1 / -1;
  display: block;
  padding: 8px 10px;
  background: var(--ink);
  color: #c8e6c9;
  font-family: var(--mono);
  font-size: 0.72rem;
  white-space: normal;
  line-height: 1.5;
}

/* ─── READER BAR ─── */
.reader-bar {
  position: fixed;
  bottom: clamp(16px, 3vw, 36px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  width: min(1200px, calc(100% - 32px));
  min-height: 64px;
  padding: 10px 16px;
  border: 2px solid var(--ink);
  background: var(--surface);
  box-shadow: 4px 4px 0 var(--ink);
}

.reader-bar[hidden] { display: none; }

.reader-bar button {
  min-width: 80px;
  min-height: 40px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.reader-bar button:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.reader-bar label {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reader-bar select {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.76rem;
  padding: 0 10px;
}

.reader-bar input[type="range"] {
  width: clamp(96px, 12vw, 160px);
  min-width: 80px;
}

.reader-bar output {
  min-width: 48px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink);
}

/* ─── SPEAKABLE / READER ACTIVE ─── */
.speakable {
  scroll-margin: 100px;
  transition: background 0.2s, outline-color 0.2s;
}

.reader-active {
  outline: 3px solid var(--accent);
  outline-offset: 6px;
  background: var(--accent-glow);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .topnav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .reader-toggle { width: 100%; }

  .article-shell {
    grid-template-columns: 1fr;
  }

  .generator-shell {
    grid-template-columns: 1fr;
  }

  .generator-controls {
    position: static;
  }

  .generator-input-row {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: 14ch;
    font-size: clamp(2.8rem, 15vw, 4.5rem);
  }

  .status-panel {
    position: static;
    border-top: 3px solid var(--ink);
  }

  .reader-bar {
    flex-wrap: wrap;
    justify-content: flex-start;
    box-shadow: 3px 3px 0 var(--ink);
    width: calc(100% - 32px);
  }

  .reader-bar button {
    min-width: 70px;
    flex: 1 1 28%;
  }
}
