/* Neutral, documentation-style theme. One accent colour, used for actions and links only. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f6f7f8;
  --ink: #16171a;
  --muted: #565b63;
  --line: #e2e4e7;
  --accent: #1f4fd1;
  --on-accent: #ffffff;
  --focus: #1f4fd1;
  --error-bg: #fdecec;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1012;
    --surface: #17191c;
    --ink: #ececee;
    --muted: #a2a8b0;
    --line: #2b2e33;
    --accent: #8aa9ff;
    --on-accent: #0f1012;
    --focus: #8aa9ff;
    --error-bg: #3a1d1f;
  }
}

* { box-sizing: border-box; }

/* The hidden attribute must win over display rules like .actions { display: flex }. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--accent); text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  min-height: 56px;
}

.brand {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.site-header nav a {
  display: inline-block;
  padding: 10px 0; /* 44px tall tap target */
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
}

.site-header nav a:hover { color: var(--ink); }

/* ---------- headings and text ---------- */

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }

h1 { font-size: clamp(2rem, 6vw, 2.6rem); font-weight: 700; }

h2 { font-size: 1.35rem; font-weight: 600; margin-bottom: 12px; }

h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }

section { margin-top: 56px; }

section p { margin: 0 0 12px; }

.intro { margin-top: 48px; }

.lead {
  margin: 14px 0 28px;
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 40em;
}

/* ---------- key facts ---------- */

.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.facts div { padding: 14px 16px 14px 0; }

.facts dt {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.facts dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- demo panel ---------- */

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  min-height: 3.4em;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
  resize: vertical;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 12px 0 4px;
}

.examples-label { font-size: 0.85rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: 0.88rem/1.3 var(--sans);
  cursor: pointer;
  text-align: left;
}

.chip:hover { border-color: var(--muted); }

.advanced { margin: 10px 0 0; }

.advanced summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px 24px;
  padding: 4px 0 8px;
}

.slider label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 500;
}

.slider output { color: var(--muted); font-variant-numeric: tabular-nums; }

.slider input {
  width: 100%;
  height: 32px; /* taller hit area for thumbs on touch screens */
  accent-color: var(--accent);
}

.hint { margin: 0; font-size: 0.78rem; color: var(--muted); }

/* ---------- buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button.primary, button.secondary {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 6px;
  font: 600 0.95rem/1 var(--sans);
  cursor: pointer;
}

button.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

button.secondary:hover { border-color: var(--muted); }

button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- loading, status, errors ---------- */

.loading { margin-top: 18px; }

progress {
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
}

.status {
  margin: 8px 0 0;
  min-height: 1.6em;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.error {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 6px;
  background: var(--error-bg);
}

.error p { margin: 0 0 10px; }

/* ---------- generated story ---------- */

.story {
  margin-top: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.story p {
  margin: 0;
  font: 1.12rem/1.7 var(--serif);
  white-space: pre-wrap; /* keep the model's line breaks */
  overflow-wrap: anywhere; /* a long made-up word must not cause sideways scrolling */
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--ink);
  animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- results ---------- */

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  vertical-align: middle;
  letter-spacing: 0.02em;
}

.table-scroll { overflow-x: auto; margin: 8px 0 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

tbody tr:last-child td { font-weight: 600; }

.note { font-size: 0.85rem; color: var(--muted); }

/* ---------- method ---------- */

.columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.columns > div { padding-top: 12px; border-top: 1px solid var(--line); }

.columns p { font-size: 0.92rem; color: var(--muted); }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--line);
  padding: 16px 0 32px;
}

.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 24px; }

.site-footer a {
  display: inline-block;
  padding: 10px 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.noscript { padding: 16px; border-radius: 6px; background: var(--error-bg); }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .facts { grid-template-columns: repeat(2, 1fr); }
  .columns { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  .panel { padding: 18px 16px; }
  .story { padding: 18px 16px; }
  .actions button { flex: 1 1 auto; } /* full-width buttons are easier to tap */
  section { margin-top: 44px; }
  .step { display: none; } /* keep the results table inside the screen; time and total remain */
  th, td { padding-right: 8px; }
}
