:root {
  --bg: #f3efe5;
  --ink: #1f2933;
  --ink-soft: #51606f;
  --panel: rgba(255, 255, 255, 0.9);
  --line: #c9d3dc;
  --accent: #124e66;
  --accent-strong: #0b3a4c;
  --ok: #1f6d45;
  --error: #9f1239;
  --rendering: #8a5300;
  --callout-bg: #fffdf7;
  --callout-border: #d4a96a;
  --callout-accent: #8b2020;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(18, 78, 102, 0.1) 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(173, 107, 77, 0.12) 0%, transparent 32%),
    var(--bg);
}

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  overflow-x: hidden;
}

/* ── Hero ── */

.hero {
  margin-bottom: 1.4rem;
}

.kicker {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

h1 {
  margin: 0.3rem 0 0.5rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(1.7rem, 3.6vw, 2.6rem);
  line-height: 1.12;
  max-width: none;
}

.lede {
  margin: 0 0 0.5rem;
  color: var(--ink-soft);
  max-width: none;
}

.back-link {
  display: inline-block;
  margin-top: 0.2rem;
  color: var(--accent);
  font-size: 0.88rem;
  text-decoration-thickness: 2px;
}

/* ── Panels ── */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  backdrop-filter: blur(2px);
}

.controls-panel {
  margin-bottom: 0.8rem;
}

.status-panel {
  margin-top: 0;
  margin-bottom: 0.9rem;
  justify-content: space-between;
}

/* ── Toolbar ── */

.toolbar {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: stretch;
}

.fixture-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.scale-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.35rem 0.2rem 0.72rem;
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.fixture-picker select {
  min-width: 260px;
  max-width: 380px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.48rem 0.82rem;
  background: #fff;
  color: var(--ink);
  font: 500 1rem/1.2 "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  height: 100%;
}

.scale-picker select {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 500 0.98rem/1.2 "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
}

.fixture-picker select:focus-visible {
  outline: 2px solid rgba(18, 78, 102, 0.33);
  outline-offset: 1px;
}

.scale-picker select:focus-visible {
  outline: none;
}

.fixture-picker[data-loading="true"]::after {
  content: "Loading\2026";
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.fixture-picker select:disabled {
  cursor: wait;
  opacity: 0.75;
}

/* ── Dispatch callout ── */

.dispatch-callout {
  display: flex;
  gap: 0;
  margin-bottom: 0.9rem;
  background: var(--callout-bg);
  border: 1px solid var(--callout-border);
  border-left: none;
  border-radius: 10px;
  overflow: hidden;
}

.dispatch-callout[hidden] {
  display: none;
}

.callout-accent {
  width: 5px;
  flex-shrink: 0;
  background: var(--callout-accent);
  border-radius: 10px 0 0 10px;
}

.callout-body {
  flex: 1;
  min-width: 0;
  padding: 0.9rem 1rem;
}

.callout-eyebrow {
  margin: 0 0 0.35rem;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--callout-accent);
}

.callout-text {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
  max-width: none;
}

.callout-text:last-child {
  margin-bottom: 0;
}

/* ── Buttons ── */

button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.48rem 0.88rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
}

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

button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.copy-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}

.copy-btn:hover {
  color: var(--accent);
}

#upload-json {
  display: none;
}

/* ── Status row ── */

.field-label {
  display: block;
  margin-bottom: 0.42rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
}

.metrics-row {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.metrics-row p {
  margin: 0;
}

#status,
#page-count {
  margin: 0;
}

#status[data-state="idle"] {
  color: var(--ink-soft);
}

#status[data-state="rendering"] {
  color: var(--rendering);
}

#status[data-state="success"] {
  color: var(--ok);
}

#status[data-state="error"] {
  color: var(--error);
}

/* ── Workspace ── */

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 1rem;
  align-items: start;
}

.editor-panel,
.preview-shell {
  min-width: 0;
  min-height: 0;
}

/* ── Editor panel ── */

.panel-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.panel-heading-left {
  display: flex;
  flex: 1;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: baseline;
  min-width: 0;
}

.panel-heading-left h2,
.panel-heading-left p {
  margin: 0;
}

.panel-heading-left h2 {
  font-size: 1.05rem;
  color: var(--accent-strong);
  white-space: nowrap;
}

.panel-heading-left p {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

textarea {
  width: 100%;
  height: min(66vh, 720px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.84rem;
  resize: vertical;
  font: 500 0.88rem/1.5 "Cascadia Code", "Consolas", monospace;
  background: #f9fafb;
  color: #111827;
}

textarea:focus-visible {
  outline: 2px solid rgba(18, 78, 102, 0.33);
  outline-offset: 1px;
}

.inline-error {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.7rem;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  color: var(--error);
  font-size: 0.85rem;
  line-height: 1.45;
}

/* ── Preview shell ── */

.preview-shell {
  background: rgba(18, 78, 102, 0.07);
  border: 1px solid rgba(18, 78, 102, 0.16);
  border-radius: 18px;
  padding: 0.95rem;
  position: sticky;
  top: 1rem;
}

.preview-header {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  align-items: baseline;
  margin-bottom: 0.8rem;
}

.preview-header h2,
.preview-header p {
  margin: 0;
}

.preview-header h2 {
  font-size: 1.05rem;
  color: var(--accent-strong);
}

.preview-header p {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.preview-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.current-page {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  flex: 1;
  text-align: center;
}

.preview-stage {
  display: flex;
  justify-content: center;
}

.preview-canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.08);
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.08),
    0 4px 12px rgba(15, 23, 42, 0.06);
}

code {
  font-family: "Cascadia Code", "Consolas", monospace;
}

/* ── About section ── */

.about-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.about-intro {
  max-width: 64ch;
  margin-bottom: 1.6rem;
}

.about-intro h2 {
  margin: 0 0 0.6rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: normal;
  color: var(--ink);
}

.about-intro p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem 1.4rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.feature-grid li {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink-soft);
  padding-left: 0.9rem;
  border-left: 2px solid var(--line);
}

.feature-grid li strong {
  display: block;
  color: var(--ink);
  margin-bottom: 0.15rem;
  font-size: 0.92rem;
}

.feature-grid a {
  color: var(--accent);
}

/* ── Responsive ── */

@media (max-width: 760px) {
  .shell {
    padding: 1.2rem 0.7rem 1.8rem;
  }

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

  .status-panel {
    justify-content: flex-start;
  }

  .preview-shell {
    position: static;
  }

  .preview-nav {
    flex-wrap: wrap;
  }

  textarea {
    height: 52vh;
  }

  .scale-picker {
    width: fit-content;
  }

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

@media (max-width: 480px) {
  .feature-grid {
    grid-template-columns: 1fr;
  }
}
