/* ============================================================
   Scenario Library — "Midnight Platform" design system
   Palette: violet ink night, parchment text, brass lamplight,
   wisteria interactive. Type: Fraunces / Alegreya Sans / IBM Plex Mono.
   ============================================================ */

:root {
  --bg: #141021;
  --bg-2: #1a142e;
  --surface: #211a3a;
  --surface-2: #292050;
  --surface-3: #322861;
  --line: #3a2f63;
  --line-soft: #2c2450;
  --text: #efe7d8;
  --text-dim: #a99dcb;
  --text-faint: #7e73a1;
  --brass: #e0a83f;
  --brass-soft: #f2c86e;
  --brass-deep: #a9761f;
  --wist: #a08bff;
  --wist-soft: #c9bcff;
  --danger: #ff7d6b;
  --ok: #7fd6a4;
  --shadow: 0 18px 50px -18px rgba(6, 3, 18, 0.85);
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;
  --max: 1280px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(160, 139, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(224, 168, 63, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(224, 168, 63, 0.35); }

a { color: var(--wist-soft); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

/* grid/flex children may never force the page wider than the viewport */
.hero-grid > *, .explore-layout > *, .detail-layout > *, .wizard-layout > *,
.card-grid > *, .search-bar > * { min-width: 0; }
svg, img { max-width: 100%; }

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

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(20, 16, 33, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.site-header .wrap {
  display: flex; align-items: center; gap: 26px;
  height: 64px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 1.18rem; font-weight: 600;
  color: var(--text); letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand svg { flex: 0 0 auto; }

.main-nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }

.main-nav a {
  color: var(--text-dim);
  padding: 8px 13px; border-radius: 8px;
  font-size: 0.95rem;
}
.main-nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.main-nav a[aria-current="page"] { color: var(--brass-soft); }

.main-nav .nav-cta {
  color: #1c1226;
  background: var(--brass);
  font-weight: 600;
  margin-left: 6px;
}
.main-nav .nav-cta:hover { background: var(--brass-soft); color: #1c1226; }

/* ---------- Hero ---------- */

.hero { padding: 58px 0 30px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 48px; align-items: center;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem; letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 14px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1.04;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}
.hero h1 em {
  font-style: italic;
  color: var(--brass-soft);
}

.hero-sub {
  color: var(--text-dim);
  font-size: 1.12rem;
  max-width: 46ch;
  margin: 0 0 26px;
}

.search-bar {
  display: flex; gap: 10px;
  max-width: 560px;
}
.search-bar input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  padding: 13px 22px;
}
.search-bar input::placeholder { color: var(--text-faint); }
.search-bar input:focus { border-color: var(--brass); outline: none; }

.search-bar button {
  border: 0; border-radius: 999px;
  background: var(--brass); color: #1c1226;
  font: inherit; font-weight: 700;
  padding: 0 26px; cursor: pointer;
}
.search-bar button:hover { background: var(--brass-soft); }

.search-hint {
  margin: 12px 2px 0;
  font-size: 0.85rem;
  color: var(--text-faint);
}
.search-hint button {
  background: none; border: 0; padding: 0;
  color: var(--wist); cursor: pointer;
  font: inherit; font-size: 0.85rem;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.search-hint button:hover { color: var(--wist-soft); }

/* --- Signature: the specimen ticket. A live fill-in-the-blank sentence. --- */

.specimen[hidden] { display: none; }
.hero-grid:has(.specimen[hidden]) { grid-template-columns: minmax(0, 1fr); }

.specimen {
  position: relative;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px 22px;
  box-shadow: var(--shadow);
}
.specimen::before,
.specimen::after {
  /* ticket punch notches */
  content: "";
  position: absolute; top: 50%;
  width: 18px; height: 18px; margin-top: -9px;
  background: var(--bg); border-radius: 50%;
  border: 1px solid var(--line);
}
.specimen::before { left: -10px; }
.specimen::after { right: -10px; }

.specimen-label {
  font-family: var(--font-mono);
  font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-faint);
  display: flex; justify-content: space-between;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 10px; margin-bottom: 16px;
}

.specimen-sentence {
  font-family: var(--font-display);
  font-size: 1.45rem;
  line-height: 1.65;
  margin: 0 0 18px;
}

.ph-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--brass-soft);
  background: rgba(224, 168, 63, 0.08);
  border: 1px dashed rgba(224, 168, 63, 0.55);
  border-radius: 7px;
  padding: 0.05em 0.5em;
  white-space: nowrap;
  transition: opacity 220ms ease;
}
.ph-chip.is-swapping { opacity: 0; }

.specimen-foot {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-faint);
}
.specimen-foot code { color: var(--wist); font-family: inherit; }

/* ---------- Toolbar: tabs + time ---------- */

.toolbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line-soft);
  margin-top: 26px;
}

.tabs { display: flex; gap: 2px; }

.tab {
  appearance: none; background: none; border: 0;
  color: var(--text-dim); cursor: pointer;
  font: inherit; font-size: 1.02rem;
  padding: 10px 16px 14px;
  position: relative;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--brass-soft); font-weight: 600; }
.tab[aria-selected="true"]::after {
  /* twin rails under the active tab */
  content: "";
  position: absolute; left: 12px; right: 12px; bottom: 4px;
  height: 5px;
  border-top: 2px solid var(--brass);
  border-bottom: 1px solid var(--brass-deep);
}

.time-filters { display: flex; gap: 6px; padding-bottom: 10px; }

.time-btn {
  background: none; border: 1px solid transparent;
  color: var(--text-faint); cursor: pointer;
  font: inherit; font-size: 0.85rem;
  padding: 5px 12px; border-radius: 999px;
}
.time-btn:hover { color: var(--text); }
.time-btn[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

/* ---------- Layout: sidebar + results ---------- */

.explore-layout {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  gap: 36px;
  /* padding-block only — this class shares an element with .wrap,
     and a padding shorthand would wipe out .wrap's side padding */
  padding-block: 30px 80px;
  align-items: start;
}

.filters {
  position: sticky; top: 84px;
  display: flex; flex-direction: column; gap: 26px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}

.filter-group h3 {
  font-family: var(--font-mono);
  font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}

.filter-options { display: flex; flex-direction: column; gap: 2px; }

.filter-check {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 8px; border-radius: 7px;
  color: var(--text-dim); cursor: pointer;
  font-size: 0.94rem;
  user-select: none;
}
.filter-check:hover { background: var(--surface); color: var(--text); }
.filter-check input {
  accent-color: var(--brass);
  width: 15px; height: 15px; margin: 0;
  cursor: pointer;
}
.filter-check .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
}

.filter-select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit; font-size: 0.92rem;
  padding: 8px 10px;
}

.filters .clear-filters {
  align-self: flex-start;
  background: none; border: 0; cursor: pointer;
  color: var(--wist);
  font: inherit; font-size: 0.88rem;
  padding: 4px 8px;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.filters .clear-filters:hover { color: var(--wist-soft); }

.results-head {
  display: flex; align-items: baseline; gap: 14px;
  margin: 2px 0 18px;
}
.results-head .count-line {
  color: var(--text-faint);
  font-size: 0.9rem;
}
.results-head .active-query {
  font-family: var(--font-mono); font-size: 0.85rem;
  color: var(--brass-soft);
}

/* ---------- Cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

.scenario-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.scenario-card:hover, .scenario-card:focus-within {
  transform: translateY(-3px);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-2);
}
.card-cover svg { display: block; width: 100%; height: 100%; }

.card-cover .rating-badge {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--font-mono); font-size: 0.78rem;
  color: var(--brass-soft);
  background: rgba(16, 11, 30, 0.78);
  border: 1px solid rgba(224, 168, 63, 0.35);
  border-radius: 999px;
  padding: 3px 10px;
  backdrop-filter: blur(4px);
}

.card-cover .cw-badge {
  position: absolute; top: 10px; left: 10px;
  font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: #ffd9d2;
  background: rgba(90, 22, 22, 0.82);
  border: 1px solid rgba(255, 125, 107, 0.45);
  border-radius: 999px;
  padding: 3px 9px;
}

.is-cw .card-cover svg { filter: saturate(0.75) brightness(0.85); }

.card-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 18px 14px;
  flex: 1;
}

.card-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--wist);
  margin: 0;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.card-eyebrow .mode { color: var(--brass); }

.card-title {
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 600;
  line-height: 1.18;
  margin: 0;
}
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--brass-soft); text-decoration: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; }
.scenario-card { position: relative; }
.scenario-card .card-actions, .scenario-card .card-author a { position: relative; z-index: 2; }

.card-hook {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-author {
  font-size: 0.84rem; color: var(--text-faint);
  margin: 0;
}
.card-author a { color: var(--text-faint); }
.card-author a:hover { color: var(--wist-soft); }

.card-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: auto; padding-top: 8px;
}

.meta-chip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
}
.meta-chip.hot { color: var(--brass-soft); border-color: rgba(224, 168, 63, 0.5); }

.card-foot {
  display: flex; align-items: center; gap: 14px;
  border-top: 1px solid var(--line-soft);
  padding: 11px 18px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-faint);
}
.card-foot .stat { display: inline-flex; align-items: center; gap: 5px; }
.card-foot .stat.star { color: var(--brass-soft); }

.preview-btn {
  margin-left: auto;
  font: inherit; font-size: 0.76rem;
  color: var(--wist-soft);
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 12px;
  cursor: pointer;
}
.preview-btn:hover { border-color: var(--wist); background: rgba(160, 139, 255, 0.08); }

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 60px 30px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state h3 { font-family: var(--font-display); font-size: 1.4rem; margin: 0 0 8px; color: var(--text); }
.empty-state p { margin: 0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 0.98rem;
  border-radius: 10px;
  padding: 11px 20px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 140ms ease, border-color 140ms ease;
}
.btn-primary { background: var(--brass); color: #1c1226; }
.btn-primary:hover { background: var(--brass-soft); }
.btn-secondary {
  background: var(--surface-2); color: var(--text);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--wist); }
.btn-ghost { background: none; color: var(--text-dim); border-color: var(--line-soft); }
.btn-ghost:hover { color: var(--text); border-color: var(--line); }
.btn-danger { background: none; color: var(--danger); border-color: rgba(255, 125, 107, 0.35); }
.btn-danger:hover { background: rgba(255, 125, 107, 0.08); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.is-active { border-color: var(--brass); color: var(--brass-soft); }

/* ---------- Detail page ---------- */

.detail-hero {
  position: relative;
  border-bottom: 1px solid var(--line-soft);
  overflow: hidden;
}
.detail-hero .backdrop {
  position: absolute; inset: 0; z-index: -1;
  opacity: 0.35;
}
.detail-hero .backdrop svg { width: 100%; height: 100%; }
.detail-hero .backdrop::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20,16,33,0.55), var(--bg) 92%);
}

.detail-hero-inner { padding-block: 64px 34px; }

.crumb {
  font-family: var(--font-mono); font-size: 0.76rem;
  color: var(--text-faint);
  margin-bottom: 20px; display: inline-block;
}

.detail-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3.1rem);
  font-weight: 580;
  line-height: 1.05;
  margin: 6px 0 12px;
  max-width: 20ch;
}

.detail-byline { color: var(--text-dim); margin: 0 0 16px; }
.detail-byline .follow-btn {
  font: inherit; font-size: 0.82rem;
  margin-left: 10px;
  background: none; border: 1px solid var(--line);
  border-radius: 999px; color: var(--wist-soft);
  padding: 3px 12px; cursor: pointer;
}
.detail-byline .follow-btn:hover { border-color: var(--wist); }
.detail-byline .follow-btn.is-following { color: var(--ok); border-color: rgba(127, 214, 164, 0.4); }

.tag-row { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  font-family: var(--font-mono); font-size: 0.72rem;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 3px 11px;
}
.tag.mode-tag { color: var(--brass-soft); border-color: rgba(224, 168, 63, 0.4); }

.detail-stats-row {
  display: flex; flex-wrap: wrap; gap: 26px;
  margin-top: 26px;
  font-family: var(--font-mono); font-size: 0.82rem;
  color: var(--text-dim);
}
.detail-stats-row strong { color: var(--brass-soft); font-weight: 600; }

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 44px;
  padding-block: 40px 90px;
  align-items: start;
}

.detail-main section + section { margin-top: 42px; }

.detail-main h2 {
  font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 600;
  margin: 0 0 6px;
}
.section-note { color: var(--text-faint); font-size: 0.88rem; margin: 0 0 16px; }

.prose { color: var(--text-dim); max-width: 68ch; }
.prose p { margin: 0 0 1em; }

.prompt-preview {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--brass-deep);
  border-radius: var(--radius-sm);
  padding: 24px 28px 44px;
  font-family: var(--font-display);
  font-size: 1.06rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow: hidden;
}
.prompt-preview .ph-chip { font-size: 0.78em; }
.prompt-preview::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 90px;
  background: linear-gradient(180deg, transparent, var(--surface));
  pointer-events: none;
}
.prompt-hidden-note {
  font-family: var(--font-mono); font-size: 0.76rem;
  color: var(--text-faint);
  margin-top: 10px;
}

.custom-preview {
  display: grid; gap: 14px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
}
.custom-field label {
  display: block;
  font-size: 0.92rem; color: var(--text);
  margin-bottom: 5px;
}
.custom-field .q { color: var(--text-faint); font-size: 0.82rem; margin-left: 6px; }
.custom-field input, .custom-field select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit; font-size: 0.95rem;
  padding: 9px 12px;
}
.custom-field input:focus, .custom-field select:focus { border-color: var(--brass); outline: none; }

.materials-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 8px;
  max-width: 460px;
}
.materials-list li {
  display: flex; gap: 10px; align-items: baseline;
  color: var(--text-dim); font-size: 0.97rem;
}
.materials-list li::before {
  content: "✓";
  color: var(--ok);
  font-weight: 700;
}
.materials-list li.missing { color: var(--text-faint); }
.materials-list li.missing::before { content: "—"; color: var(--text-faint); }

.settings-table {
  border-collapse: collapse;
  font-family: var(--font-mono); font-size: 0.8rem;
  color: var(--text-dim);
}
.settings-table td { padding: 6px 22px 6px 0; border-bottom: 1px solid var(--line-soft); }
.settings-table td:first-child { color: var(--text-faint); }

/* sidebar action card */
.action-card {
  position: sticky; top: 88px;
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: grid; gap: 10px;
  box-shadow: var(--shadow);
}
.action-card .btn { width: 100%; }
.action-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-note {
  font-size: 0.8rem; color: var(--text-faint);
  margin: 4px 0 0; text-align: center;
}

/* ---------- Dialog (placeholder form) ---------- */

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  width: min(560px, 92vw);
  box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 0.9);
}
dialog::backdrop { background: rgba(10, 7, 20, 0.72); backdrop-filter: blur(3px); }

.dialog-head {
  padding: 22px 26px 0;
}
.dialog-head h2 { font-family: var(--font-display); margin: 0 0 4px; font-size: 1.4rem; }
.dialog-head p { color: var(--text-faint); margin: 0; font-size: 0.9rem; }

.dialog-body { padding: 20px 26px; display: grid; gap: 15px; }
.dialog-foot {
  /* row-reverse keeps "Begin story" first in the DOM (the form's default
     button, so Enter starts the story) while rendering it on the right */
  display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 10px;
  padding: 4px 26px 24px;
}

/* ---------- Reader overlay ---------- */

.reader {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  overflow-y: auto;
}
.reader-inner {
  max-width: 720px; margin: 0 auto;
  padding: 46px 26px 120px;
}
.reader-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 40px;
  font-family: var(--font-mono); font-size: 0.78rem;
  color: var(--text-faint);
}
.reader h1 {
  font-family: var(--font-display); font-weight: 580;
  font-size: 2rem; margin: 0 0 30px;
}
.reader-prose {
  font-family: var(--font-display);
  font-size: 1.18rem; line-height: 1.85;
  white-space: pre-wrap;
  color: var(--text);
}
.reader-prose .filled {
  color: var(--brass-soft);
  border-bottom: 1px dashed rgba(224, 168, 63, 0.4);
}
.reader-continue {
  margin-top: 46px;
  border-top: 1px dashed var(--line);
  padding-top: 26px;
  color: var(--text-faint);
  font-size: 0.92rem;
}
.reader textarea {
  width: 100%; min-height: 120px;
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-display); font-size: 1.05rem; line-height: 1.7;
  padding: 16px;
  resize: vertical;
}

/* ---------- Create wizard ---------- */

.wizard-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 44px;
  padding-block: 46px 90px;
  align-items: start;
}

.wizard-steps {
  position: sticky; top: 88px;
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 2px;
  counter-reset: step;
}
.wizard-steps li {
  counter-increment: step;
  display: flex; gap: 12px; align-items: center;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text-faint);
  font-size: 0.92rem;
  cursor: pointer;
}
.wizard-steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--text-faint);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 2px 6px;
}
.wizard-steps li:hover { background: var(--surface); color: var(--text-dim); }
.wizard-steps li.is-current { color: var(--text); background: var(--surface); }
.wizard-steps li.is-current::before { color: var(--brass-soft); border-color: var(--brass-deep); }
.wizard-steps li.is-done { color: var(--text-dim); }
.wizard-steps li.is-done::before { content: "✓"; color: var(--ok); border-color: rgba(127, 214, 164, 0.35); }

.wizard-panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 32px 34px;
}
.wizard-panel h2 { font-family: var(--font-display); font-size: 1.6rem; margin: 0 0 4px; }
.wizard-panel .step-sub { color: var(--text-faint); margin: 0 0 24px; font-size: 0.95rem; }

.form-grid { display: grid; gap: 18px; }
.form-field label { display: block; font-size: 0.94rem; margin-bottom: 6px; color: var(--text); }
.form-field .hint { color: var(--text-faint); font-size: 0.8rem; margin-left: 6px; }
.form-field input[type="text"], .form-field select, .form-field textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit; font-size: 0.95rem;
  padding: 10px 13px;
}
.form-field textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
.form-field textarea.code, textarea.code {
  font-family: var(--font-mono); font-size: 0.85rem;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--brass); outline: none;
}

.radio-cards { display: grid; gap: 10px; }
.radio-card {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
}
.radio-card:hover { border-color: var(--line); }
.radio-card input { accent-color: var(--brass); margin-top: 4px; }
.radio-card strong { display: block; font-size: 0.98rem; }
.radio-card span { color: var(--text-faint); font-size: 0.85rem; }
.radio-card:has(input:checked) { border-color: var(--brass-deep); background: rgba(224, 168, 63, 0.05); }

.wizard-nav {
  display: flex; justify-content: space-between;
  margin-top: 30px; padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}

.lint-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lint-item {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  font-size: 0.92rem;
  color: var(--text-dim);
}
.lint-item::before { font-size: 1rem; line-height: 1.3; }
.lint-item.warn { border-color: rgba(224, 168, 63, 0.4); }
.lint-item.warn::before { content: "⚠"; color: var(--brass-soft); }
.lint-item.error { border-color: rgba(255, 125, 107, 0.4); }
.lint-item.error::before { content: "✕"; color: var(--danger); }
.lint-item.ok { border-color: rgba(127, 214, 164, 0.35); }
.lint-item.ok::before { content: "✓"; color: var(--ok); }
.lint-item code { font-family: var(--font-mono); font-size: 0.8em; color: var(--wist-soft); }

.ph-editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr auto;
  gap: 8px; align-items: center;
  margin-bottom: 8px;
}
.ph-editor-row input {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 7px; color: var(--text);
  font-family: var(--font-mono); font-size: 0.8rem;
  padding: 7px 9px; min-width: 0;
}
.ph-editor-row .rm {
  background: none; border: 0; color: var(--text-faint);
  cursor: pointer; font-size: 1rem; padding: 4px 8px;
}
.ph-editor-row .rm:hover { color: var(--danger); }

.test-preview {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 22px 26px;
  font-family: var(--font-display);
  font-size: 1.02rem; line-height: 1.75;
  white-space: pre-wrap;
  max-height: 340px; overflow-y: auto;
}

/* ---------- Toast ---------- */

.toast-region {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 80;
  display: grid; gap: 8px;
  width: min(420px, 90vw);
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  animation: toast-in 240ms ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line-soft);
  padding: 34px 0 44px;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.site-footer .wrap {
  display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.site-footer nav { display: flex; gap: 18px; }
.site-footer a { color: var(--text-faint); }
.site-footer a:hover { color: var(--text-dim); }

/* ---------- Library page ---------- */

.page-head { padding: 52px 0 8px; }
.page-head h1 { font-family: var(--font-display); font-weight: 580; font-size: 2.4rem; margin: 0 0 8px; }
.page-head p { color: var(--text-dim); margin: 0; }

.section-block { padding: 26px 0 10px; }
.section-block h2 {
  font-family: var(--font-mono); font-size: 0.74rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--brass); margin: 0 0 16px;
}

.story-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 10px;
}
.story-row .t { font-family: var(--font-display); font-size: 1.06rem; }
.story-row .d { color: var(--text-faint); font-size: 0.8rem; font-family: var(--font-mono); margin-left: auto; }

/* ---------- Responsive ---------- */

@media (max-width: 1040px) {
  .hero-grid { grid-template-columns: 1fr; gap: 34px; }
  .specimen { max-width: 620px; }
  .detail-layout { grid-template-columns: 1fr; }
  .action-card { position: static; }
  .wizard-layout { grid-template-columns: 1fr; gap: 26px; }
  .wizard-steps {
    position: static;
    display: flex; flex-wrap: wrap; gap: 6px;
  }
  .wizard-steps li { padding: 6px 10px; }
}

@media (max-width: 860px) {
  .explore-layout { grid-template-columns: 1fr; gap: 10px; }
  .filters {
    position: static; max-height: none;
    flex-direction: row; flex-wrap: wrap; gap: 18px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    margin-bottom: 18px;
  }
  .filter-group { min-width: 150px; }
}

@media (max-width: 620px) {
  body { font-size: 16px; overflow-x: clip; }
  .site-header .wrap { gap: 8px 12px; height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .main-nav { flex-wrap: wrap; }
  .main-nav a:not(.nav-cta) { padding: 8px 8px; font-size: 0.88rem; }
  .search-bar input { min-width: 0; }
  .specimen-sentence { font-size: 1.22rem; }
  .ph-chip { white-space: normal; }
  .hero { padding-top: 38px; }
  .toolbar { gap: 8px; }
  .tab { padding: 8px 10px 14px; font-size: 0.95rem; }
  .card-grid { grid-template-columns: 1fr; }
  .wizard-panel { padding: 22px 20px; }
  .ph-editor-row { grid-template-columns: 1fr 1fr; }
  .ph-editor-row input:nth-child(3) { grid-column: 1 / -1; }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
