/* Design tokens (CR-009). Spacing uses only 4/8/12/16/24/32/48 px, radii
   8/12/16 px, type 12–30 px. Light theme only; text meets AA on its
   background. Accent: indigo-violet. */
:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --text: #111827;
  --muted: #4b5563;
  --subtle: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --field-line: #868e9c;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-ink: #3730a3;
  --accent-soft: #eef2ff;
  --accent-line: #c7d2fe;
  --ok: #047857;
  --ok-line: #10b981;
  --ok-soft: #d1fae5;
  --warn-bg: #fffbeb;
  --warn-line: #d97706;
  --warn-border: #fde68a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow-1: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-2: 0 2px 4px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: anywhere;
}

[hidden] { display: none !important; }

/* Side padding only: main.wrap keeps its own top and bottom padding. */
.wrap { max-width: 1200px; margin: 0 auto; padding-right: 16px; padding-left: 16px; }

/* Visually hidden, still read by assistive tech. */
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon { flex: none; }

/* Links in prose keep their underline; interface links are styled as controls. */
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip {
  position: absolute;
  left: 8px;
  top: -64px;
  z-index: 10;
  padding: 8px 16px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 8px;
}
.skip:focus { top: 8px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 56px;
}
.brand { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; margin: 0; font-weight: 700; line-height: 1.25; }
.brand a { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.mark { flex: none; color: var(--accent); }
.badge {
  padding: 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
}
.site-nav { display: flex; flex: none; gap: 4px; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

main { padding-top: 16px; padding-bottom: 48px; }
h1 { margin: 0 0 8px; font-size: 1.875rem; line-height: 1.2; letter-spacing: -0.02em; }
h2 { margin: 0 0 8px; font-size: 1.25rem; line-height: 1.3; letter-spacing: -0.01em; }
h3 { margin: 0 0 4px; font-size: 1rem; line-height: 1.4; }
p { margin: 0 0 12px; }
code {
  padding: 0 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.875em;
}
.lead { max-width: 72ch; margin-bottom: 12px; color: var(--muted); }
.crumbs { margin-bottom: 8px; color: var(--subtle); font-size: 0.875rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

/* Step markers: "1." keeps its "." for assistive tech. */
.picker > legend, .task-links > h2, .fill-head h2, .copy > h2 { display: flex; align-items: center; gap: 8px; }
.step {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent-soft);
  border-radius: 50%;
  color: var(--accent-ink);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0;
}

/* Builder */
.builder { margin: 0 0 32px; }
.picker { position: relative; min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
.picker > legend, .task-links > h2 { margin-bottom: 8px; padding: 0; font-size: 1.125rem; font-weight: 700; }
.picker-details > summary {
  display: block;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-1);
  font-weight: 600;
  cursor: pointer;
}
.picker-groups { display: grid; gap: 8px; margin-top: 8px; }
.picker-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.picker-group > legend, .more-head, .family-label, .jump-title {
  padding: 0;
  color: var(--subtle);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.picker-group > legend { margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* The native radio stays (keyboard, screen readers) but is drawn invisibly
   over its chip; the chip shows the state. */
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--surface);
  /* The chip stands in for the radio: its boundary needs 3:1 (WCAG 1.4.11). */
  border: 1px solid var(--field-line);
  border-radius: 999px;
  box-shadow: var(--shadow-1);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
}
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 999px;
  opacity: 0;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip:has(input:checked) {
  padding: 8px 12px 8px 28px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.chip:has(input:checked)::before, .step::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}
.chip:has(input:checked)::before { left: 11px; top: 50%; margin-top: -5px; }
.step::after { display: none; color: #fff; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.picker-search { position: relative; max-width: 28rem; }
.picker-search .icon { position: absolute; top: 14px; left: 12px; color: var(--subtle); pointer-events: none; }
#acp-template-search { padding-left: 36px; }
.search-empty { margin: 0; }
/* Empty, the live region takes no room (it stays rendered for announcements). */
.search-empty:empty { margin-bottom: -8px; }
.more-head { margin: 0 0 4px; }
.more-links, .task-links ul, .jump ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.more-links a, .task-links ul a, .more-all a, .more-rest a, .jump-item, .jump a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}
.more-links a, .task-links ul a, .jump-item {
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
}
.more-links a:hover, .task-links ul a:hover, .jump-item:hover { border-color: var(--accent); color: var(--accent-ink); }
.more-all a, .more-rest a { gap: 4px; font-weight: 600; }
.more-all a::after, .more-rest a::after {
  content: "";
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 2px 2px 0 0;
  transform: rotate(45deg);
}
.more-all a:hover, .more-rest a:hover { text-decoration: underline; }
.more-all { margin: 0; font-size: 0.9375rem; }
.more-rest { margin: 0; color: var(--muted); font-size: 0.875rem; }

/* Template pages: where the prompt goes, then the way back. */
.task-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
.paste {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  color: var(--accent-ink);
  font-size: 0.875rem;
}
.task-line > a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; }
.task-line > a:hover { text-decoration: underline; }
.task-links h3 { margin: 16px 0 8px; color: var(--subtle); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* Panels: fields, and the result. */
.cols { display: grid; gap: 24px; }
.fill, .copy {
  min-width: 0;
  padding: 0 16px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-1);
}
.fill-head, .copy > h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-height: 52px;
  margin: 0 -16px 12px;
  padding: 4px 16px;
  border-bottom: 1px solid var(--line);
  border-radius: 11px 11px 0 0;
}
.fill-head h2 { margin: 0; }
.copy > h2 { justify-content: flex-start; background: var(--surface-2); }
/* All required fields filled: step 3 turns into a green check and the
   result panel's border follows (Go to field is hidden exactly then). */
.copy:has(#acp-goto[hidden]) { border-color: var(--ok-line); box-shadow: 0 0 0 3px var(--ok-soft); }
.copy:has(#acp-goto[hidden]) .step { background: var(--ok); color: transparent; }
.copy:has(#acp-goto[hidden]) .step::after { display: block; top: 9px; left: 9px; }
.copy:has(#acp-goto[hidden]) #acp-missing { color: var(--ok); font-weight: 600; }
.task-intro { color: var(--muted); font-size: 0.9375rem; }
.field { margin-bottom: 16px; scroll-margin-top: 12px; }
.field label, .copy label { display: block; margin-bottom: 4px; font-size: 0.9375rem; font-weight: 600; }
.req { color: var(--subtle); font-size: 0.8125rem; font-weight: 500; }
input[type="text"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--field-line);
  border-radius: 8px;
  color: inherit;
  font: inherit;
}
input[type="text"]:hover, input[type="search"]:hover, select:hover, textarea:hover { border-color: var(--muted); }
input[type="text"]:focus-visible, input[type="search"]:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 0 5px var(--accent-line);
}
::placeholder { color: var(--subtle); opacity: 1; }
textarea { line-height: 1.45; resize: vertical; }
#acp-output {
  min-height: calc(12 * 1.45em + 18px);
  background: #fbfbfc;
  font-family: var(--mono);
  font-size: 0.875rem;
}
.help { margin: 4px 0 0; color: var(--subtle); font-size: 0.875rem; }
.note, .dirty, .noscript, .fallback-note, .search-empty:not(:empty), .confirm {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left: 3px solid var(--warn-line);
  border-radius: 8px;
  font-size: 0.875rem;
}
.note:empty { display: none; }
.fallback-note { margin: 0 0 12px; }
.actionbar { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.msgs { flex: 1; min-width: 0; color: var(--muted); font-size: 0.875rem; }
.msgs p { margin: 0; }
.missing-line { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; }
#acp-status { color: var(--text); font-weight: 600; }
/* A complete copy gets a check before its message. */
#acp-status.ok { position: relative; padding-left: 20px; color: var(--ok); }
#acp-status.ok::before {
  content: "";
  position: absolute;
  top: 0.35em;
  left: 2px;
  width: 10px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}
.more-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px -12px 0; }
.confirm { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.confirm p { flex-basis: 100%; margin: 0; }
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-1);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--surface-2); border-color: var(--field-line); }
button.primary {
  padding: 8px 24px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(55, 48, 163, 0.3);
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
/* Quiet actions: Clear, Discard, Go to field. */
.more-actions button, button.text-button {
  padding: 0 12px;
  background: none;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
  font-weight: 500;
}
.more-actions button:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
button.text-button { padding: 0 4px; color: var(--accent); font-size: inherit; font-weight: 600; }
button.text-button:hover { background: none; border-color: transparent; text-decoration: underline; }
.d3, .storage-note { color: var(--subtle); font-size: 0.8125rem; }
.d3 { margin-bottom: 12px; }
.storage-note { margin: 12px 0 0; }
.task-guide { margin: 8px 0 0; font-size: 0.9375rem; }

/* Guides and lists */
.howto, .category, .choosing, main > section { margin-top: 32px; }
.guide { max-width: 72ch; margin-top: 48px; }
.guide section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.guide section:first-child { margin-top: 0; }
.guide ul, .howto ol, .choosing ul { padding-left: 24px; }
.guide li, .howto li, .choosing li { margin-bottom: 8px; }
.sample dt { margin-top: 12px; font-size: 0.9375rem; font-weight: 600; }
.sample dd { margin: 4px 0 0; }
.sample pre {
  margin: 0;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* /prompts/: group pills, cards, the Claude Code block. */
.jump { margin-top: 24px; }
.jump-title { margin: 0 0 8px; }
.jump-item { position: relative; gap: 8px; }
.jump a { color: inherit; }
.jump a::after { content: ""; position: absolute; inset: 0; border-radius: 999px; }
.jump-family { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex-basis: 100%; margin-top: 4px; color: var(--subtle); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.jump-family .jump-item { color: var(--text); font-size: 0.9375rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.jump .count {
  padding: 0 8px;
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
}
.cards { display: grid; gap: 12px; padding: 0; list-style: none; }
.card {
  position: relative;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-1);
}
.card:hover, .card:has(a:focus-visible) { border-color: var(--accent-line); box-shadow: var(--shadow-2); }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.card:hover h3 a { color: var(--accent-ink); }
.card p { margin: 4px 0 0; color: var(--muted); font-size: 0.9375rem; }
.card .need { margin-top: 12px; color: var(--subtle); font-size: 0.8125rem; }
.need-label {
  margin-right: 4px;
  padding: 0 8px;
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
}
.family {
  margin-top: 48px;
  padding: 0 16px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.family-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0 -16px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  border-radius: 15px 15px 0 0;
}
.family-label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 0.875rem; }
.family-label .icon { color: var(--accent); }
.family .paste { background: var(--surface); }
.family .category { margin-top: 24px; }
.family .card { background: var(--bg); box-shadow: none; }

.site-footer { padding: 24px 0 32px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 0.875rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 16px; }
.site-footer nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); text-decoration: none; }
.site-footer nav a:hover { color: var(--accent); text-decoration: underline; }

@media (min-width: 640px) {
  @supports selector(::details-content) {
    .picker-details > summary { display: none; }
    .picker-details::details-content { content-visibility: visible; }
    .picker-groups { margin-top: 0; }
  }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .family { padding: 0 24px 24px; }
  .family-head { margin: 0 -24px; padding: 12px 24px; }
}

/* Mouse-sized task chips and links on wide screens, so the whole loop fits
   1440×900; touch screens keep 44 px targets. */
@media (min-width: 1024px) and (pointer: fine) {
  .chip { min-height: 36px; padding-top: 4px; padding-bottom: 4px; }
  .more-all a { min-height: 36px; }
}

@media (min-width: 1024px) {
  h1 { font-size: 1.875rem; }
  .picker-group { display: flex; align-items: center; gap: 12px; }
  .picker-more, .more-all { padding-left: calc(8.5rem + 12px); }
  .picker-group > legend { float: left; width: 8.5rem; margin: 0; }
  .cols { grid-template-columns: 11fr 9fr; align-items: start; }
  .copy { position: sticky; top: 16px; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* The search shares the "1. Choose a task" row: the fieldset's padding box
     starts below the legend (44 px) and its 8 px margin. */
  @supports selector(::details-content) {
    .picker > legend { min-height: 44px; }
    .picker-search { position: absolute; top: -52px; right: 0; width: 22rem; }
  }
}

/* Narrow phones: the badge goes under the name, so the header stays one row. */
@media (max-width: 479px) {
  .brand { flex-direction: column; align-items: flex-start; gap: 2px; font-size: 0.875rem; }
  .mark { width: 22px; height: 22px; }
  .badge { margin-left: 30px; }
}

@media (max-width: 639px) {
  /* One header row: About and Privacy are in the footer. */
  .site-nav a + a { display: none; }
  .site-nav a { padding: 0 8px; }
  .jump-item { padding: 0 12px; }
  .picker-details > summary { font-size: 0.875rem; }
  html { scroll-padding-bottom: 72px; }
  body { padding-bottom: 72px; }
  /* A status message can make the bar several lines tall; keep focused fields clear of it. */
  html:has(#acp-status:not(:empty)) { scroll-padding-bottom: 136px; }
  body:has(#acp-status:not(:empty)) { padding-bottom: 136px; }
  /* Phones keep the bar to one row: Go to field joins it with a status
     message (after Copy, Clear or Try example), when it is needed. */
  .msgs:not(:has(#acp-status:not(:empty))) #acp-goto { display: none; }
  html:has(#acp-status:not(:empty)):has(#acp-goto:not([hidden])) { scroll-padding-bottom: 184px; }
  body:has(#acp-status:not(:empty)):has(#acp-goto:not([hidden])) { padding-bottom: 184px; }
  /* First screen on phones: the task, Try example (beside the heading from
     about 375 px) and the first required field above the Copy bar. */
  main { padding-top: 12px; }
  h1 { font-size: 1.5rem; }
  .lead { margin-bottom: 12px; font-size: 0.9375rem; line-height: 1.5; }
  .picker { margin-bottom: 8px; }
  .picker > legend { margin-bottom: 8px; font-size: 1rem; }
  .step { width: 24px; height: 24px; font-size: 0.8125rem; }
  .copy:has(#acp-goto[hidden]) .step::after { top: 7px; left: 7px; }
  .fill-head, .copy > h2 { gap: 4px 8px; min-height: 52px; margin: 0 -12px 8px; padding: 4px 12px; }
  .fill-head h2, .copy > h2 { font-size: 1.0625rem; }
  .fill-head button { padding: 8px 12px; }
  .task-intro { margin-bottom: 8px; font-size: 0.8125rem; line-height: 1.4; }
  .msgs { font-size: 0.8125rem; line-height: 1.3; }
  .actionbar button.primary { padding: 8px 16px; }
  .fill, .copy { padding: 0 12px 12px; }
  .more-actions { margin: 8px -8px 0; }
  #acp-output { min-height: calc(10 * 1.45em + 18px); }
  .actionbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    min-height: 56px;
    margin: 0;
    padding: 4px 16px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 8px rgba(17, 24, 39, 0.06);
  }
}
