/* frontend-design pre-emit critique: P5 H5 E5 S5 R5 V5 */
:root {
  --paper: oklch(96% 0.012 86);
  --paper-raised: oklch(99% 0.006 86);
  --paper-muted: oklch(92% 0.014 86);
  --ink: oklch(22% 0.018 72);
  --ink-soft: oklch(42% 0.018 72);
  --ink-faint: oklch(58% 0.014 72);
  --line: oklch(82% 0.016 78);
  --line-strong: oklch(68% 0.02 78);
  --accent: oklch(46% 0.09 150);
  --accent-soft: oklch(91% 0.045 150);
  --adapted: oklch(49% 0.09 232);
  --adapted-soft: oklch(92% 0.035 232);
  --optional: oklch(48% 0.035 76);
  --optional-soft: oklch(91% 0.02 76);
  --warning: oklch(52% 0.12 53);
  --warning-soft: oklch(93% 0.045 70);
  --focus: oklch(52% 0.13 244);
  --shadow: oklch(24% 0.02 72 / 8%);
  --body: "IBM Plex Sans", Verdana, sans-serif;
  --display: "Source Serif 4", Georgia, serif;
  --step-0: 0.8rem;
  --step-1: 1rem;
  --step-2: 1.25rem;
  --step-3: 1.563rem;
  --step-4: 1.953rem;
  --step-5: 2.441rem;
  --step-6: 3.052rem;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step-1);
  line-height: 1.65;
}

button, input { font: inherit; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code { padding: 0.1em 0.35em; border-radius: 4px; background: var(--paper-muted); font-size: 0.92em; overflow-wrap: anywhere; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-160%);
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper-raised);
}
.skip-link:focus { transform: translateY(0); }

.document-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  padding: 8px max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--paper) 94%, transparent);
  backdrop-filter: blur(12px);
}
.document-name { color: var(--ink); font-family: var(--display); font-size: var(--step-2); font-weight: 650; text-decoration: none; }
.document-actions { display: flex; gap: 8px; }
.document-actions button, .prompt-block button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.document-actions button:hover, .prompt-block button:hover { border-color: var(--accent); background: var(--accent-soft); }
.document-actions button:active, .prompt-block button:active { transform: translateY(1px); }

.page-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 760px);
  gap: 72px;
  width: min(100% - 48px, 1080px);
  margin: 0 auto;
  padding: 64px 0 96px;
}

.contents { position: sticky; top: 96px; align-self: start; max-height: calc(100vh - 120px); overflow-y: auto; padding-right: 8px; }
.contents-title { margin: 0 0 12px; color: var(--ink-faint); font-size: var(--step-0); font-weight: 600; letter-spacing: 0.04em; }
.contents nav { display: grid; }
.contents nav a { padding: 5px 0 5px 12px; border-left: 2px solid var(--line); color: var(--ink-soft); font-size: var(--step-0); line-height: 1.4; text-decoration: none; }
.contents nav a:hover, .contents nav a.is-current { border-color: var(--accent); color: var(--accent); }
.progress-panel { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.progress-copy { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-soft); font-size: var(--step-0); }
.progress-copy strong { color: var(--ink); }
.progress-track { height: 6px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: var(--paper-muted); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 220ms ease; }

.guide { min-width: 0; }
.guide-intro { padding: 24px 0 64px; border-bottom: 1px solid var(--line); }
.overline { margin: 0 0 16px; color: var(--accent); font-size: var(--step-0); font-weight: 600; letter-spacing: 0.04em; }
h1, h2, h3 { font-family: var(--display); overflow-wrap: anywhere; }
h1 { max-width: 14ch; margin: 0; font-size: clamp(var(--step-5), 6vw, var(--step-6)); line-height: 1.05; letter-spacing: -0.025em; }
.lead { max-width: 62ch; margin: 24px 0 0; color: var(--ink-soft); font-size: var(--step-2); line-height: 1.55; }
.summary-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin: 40px 0 0; }
.summary-list div { padding-top: 12px; border-top: 2px solid var(--ink); }
.summary-list dt { color: var(--ink-faint); font-size: var(--step-0); }
.summary-list dd { margin: 4px 0 0; font-size: var(--step-0); font-weight: 600; line-height: 1.5; }

.guide-section { scroll-margin-top: 96px; padding: 64px 0; border-bottom: 1px solid var(--line); }
.guide-section h2 { max-width: 22ch; margin: 0 0 24px; font-size: var(--step-4); line-height: 1.15; letter-spacing: -0.015em; }
.guide-section h3 { max-width: 28ch; margin: 32px 0 12px; font-size: var(--step-2); line-height: 1.3; }
.guide-section > p, .guide-section > ul, .guide-section > ol { max-width: 65ch; }
.guide-section > p { color: var(--ink-soft); }

.legend { display: grid; gap: 12px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.legend p { display: grid; grid-template-columns: 144px 1fr; gap: 12px; align-items: start; margin: 0; color: var(--ink-soft); font-size: var(--step-0); }
.label { display: inline-flex; width: fit-content; align-items: center; min-height: 26px; padding: 3px 8px; border-radius: 4px; font-family: var(--body); font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.label-used { background: var(--accent-soft); color: var(--accent); }
.label-adapted { background: var(--adapted-soft); color: var(--adapted); }
.label-optional { background: var(--optional-soft); color: var(--optional); }

.process-list { margin: 32px 0 0; padding: 0; list-style: none; counter-reset: process; }
.process-list li { display: grid; grid-template-columns: 32px 152px 1fr; gap: 16px; align-items: baseline; padding: 16px 0; border-top: 1px solid var(--line); counter-increment: process; }
.process-list li::before { content: counter(process, decimal-leading-zero); color: var(--accent); font-size: var(--step-0); font-weight: 600; }
.process-list span { font-weight: 600; }
.process-list small { color: var(--ink-soft); font-size: var(--step-0); }

.table-wrap { max-width: 100%; margin-top: 32px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); }
table { width: 100%; border-collapse: collapse; font-size: var(--step-0); line-height: 1.5; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--paper-muted); color: var(--ink-soft); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td:first-child { width: 22%; font-weight: 600; }
td:nth-child(3) { width: 28%; color: var(--ink-soft); }

.step-section.is-complete { margin-inline: -24px; padding-inline: 24px; background: linear-gradient(to right, var(--accent-soft), transparent 62%); }
.step-heading { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.step-heading > p { margin: 0; color: var(--ink-faint); font-size: var(--step-0); font-weight: 600; }
.instruction-list { padding-left: 24px; }
.instruction-list li { padding: 5px 0 5px 8px; }
.check-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; padding: 0; list-style: none; }
.check-list li { position: relative; padding-left: 24px; }
.check-list li::before { content: "□"; position: absolute; left: 0; color: var(--accent); }
.check-list.compact { grid-template-columns: 1fr; }

.note, .result { max-width: 65ch; margin: 32px 0; padding: 20px 24px; border-left: 3px solid var(--accent); background: var(--paper-raised); box-shadow: 0 8px 24px var(--shadow); }
.note p, .result p { margin: 4px 0 0; color: var(--ink-soft); font-size: var(--step-0); }
.note-important { background: var(--accent-soft); }
.note-warning { border-left-color: var(--warning); background: var(--warning-soft); }
.result { border: 1px solid var(--line); border-left: 3px solid var(--accent); box-shadow: none; }

.prompt-block { max-width: 65ch; margin: 32px 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); }
.prompt-block p { margin: 0; color: var(--ink); font-family: var(--display); font-size: var(--step-1); line-height: 1.65; }
.prompt-block button { margin-top: 20px; color: var(--accent); }
.complete { display: flex; gap: 10px; align-items: center; width: fit-content; margin-top: 40px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-raised); cursor: pointer; font-size: var(--step-0); font-weight: 600; }
.complete:hover { border-color: var(--accent); }
.complete input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.alternative { max-width: 65ch; margin: 32px 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); }
.alternative h3 { margin-top: 16px; }
.alternative p { margin-bottom: 0; color: var(--ink-soft); }
.references ul { padding-left: 20px; }
.references li { max-width: 65ch; padding: 4px 0; color: var(--ink-soft); }
.last-updated { margin-top: 32px; color: var(--ink-faint); font-size: var(--step-0); }
.guide-footer { padding: 64px 0 24px; font-family: var(--display); font-size: var(--step-2); }
.guide-footer p { max-width: 34ch; margin: 0 0 8px; }
.guide-footer p:last-child { color: var(--accent); font-family: var(--body); font-size: var(--step-0); }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; padding: 10px 14px; border-radius: var(--radius); background: var(--ink); color: var(--paper-raised); font-size: var(--step-0); font-weight: 600; transform: translateY(140%); transition: transform 180ms ease; }
.toast.is-visible { transform: translateY(0); }

button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

@media (max-width: 900px) {
  .page-shell { grid-template-columns: 1fr; gap: 32px; width: min(100% - 40px, 760px); padding-top: 32px; }
  .contents { position: static; max-height: none; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); }
  .contents nav { grid-template-columns: 1fr 1fr; }
  .contents nav a { border-left: 0; border-bottom: 1px solid var(--line); }
  .progress-panel { margin-top: 16px; }
}

@media (max-width: 620px) {
  .document-header { min-height: 56px; padding-inline: 16px; }
  .document-actions button:first-child { display: none; }
  .document-actions button { min-height: 36px; padding: 6px 8px; font-size: 0.72rem; }
  .page-shell { width: min(100% - 32px, 760px); }
  .contents nav { grid-template-columns: 1fr; }
  .guide-intro { padding-top: 16px; }
  h1 { font-size: clamp(2.35rem, 12vw, var(--step-6)); }
  .lead { font-size: var(--step-1); }
  .summary-list { grid-template-columns: 1fr; gap: 16px; }
  .guide-section { padding: 48px 0; }
  .guide-section h2 { font-size: var(--step-3); }
  .legend p { grid-template-columns: 1fr; gap: 6px; }
  .process-list li { grid-template-columns: 28px 1fr; gap: 4px 12px; }
  .process-list small { grid-column: 2; }
  .check-list { grid-template-columns: 1fr; }
  .step-section.is-complete { margin-inline: -16px; padding-inline: 16px; }
  .note, .result, .prompt-block, .alternative { padding: 18px; }
  .complete { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms; }
}

@media print {
  .document-header, .contents, .complete, .prompt-block button, .toast { display: none; }
  body { background: white; color: black; }
  .page-shell { display: block; width: 100%; padding: 0; }
  .guide-intro { padding-top: 0; }
  .guide-section { break-inside: avoid; }
  .step-section.is-complete { margin-inline: 0; padding-inline: 0; background: transparent; }
  a { color: black; text-decoration: underline; }
  .note, .result, .prompt-block, .alternative, .table-wrap { box-shadow: none; }
}
