:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #4a5160;
  --line: #d5d9e0;
  --field-line: #7b8392;
  --accent: #1f3a8a;
  --accent-hover: #182e6e;
  --accent-soft: #e8edfb;
  --warn-bg: #fff6e0;
  --warn-line: #b7791f;
}

*, *::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; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

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

main { padding-top: 20px; padding-bottom: 40px; }
h1 { margin: 0 0 6px; font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.01em; }
h2 { margin: 0 0 8px; font-size: 1.15rem; line-height: 1.3; }
h3 { margin: 0 0 4px; font-size: 1rem; }
p { margin: 0 0 12px; }
code {
  padding: 0 4px;
  background: var(--accent-soft);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.lead { max-width: 72ch; color: var(--muted); }
.crumbs { margin-bottom: 8px; color: var(--muted); font-size: 0.875rem; }

/* Builder */
.builder { margin: 4px 0 32px; }
.picker { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
.picker > legend, .task-links > h2 { margin-bottom: 8px; padding: 0; font-size: 1.15rem; font-weight: 700; }
.picker-details > summary {
  display: block;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.picker-groups { display: grid; gap: 10px; margin-top: 10px; }
.picker-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.picker-group > legend { margin-bottom: 4px; padding: 0; color: var(--muted); font-size: 0.875rem; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px 6px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.task-line { margin-bottom: 14px; }
.task-links ul { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; list-style: none; }
.task-links h3 { margin-top: 8px; color: var(--muted); font-size: 0.875rem; }

.cols { display: grid; gap: 20px; }
.fill, .copy {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.task-intro { color: var(--muted); font-size: 0.9375rem; }
.field { margin-bottom: 14px; }
.field label, .copy label { display: block; margin-bottom: 4px; font-weight: 600; }
.req { color: var(--muted); font-weight: 400; }
input[type="text"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--field-line);
  border-radius: 8px;
  color: inherit;
  font: inherit;
}
textarea { line-height: 1.45; resize: vertical; }
#acp-output {
  min-height: calc(12 * 1.45em + 18px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
}
.help { margin: 4px 0 0; color: var(--muted); font-size: 0.875rem; }
.note, .dirty, .noscript, .fallback-note {
  margin: 6px 0 0;
  padding: 6px 10px;
  background: var(--warn-bg);
  border-left: 3px solid var(--warn-line);
  font-size: 0.875rem;
}
.note:empty { display: none; }
.dirty { margin-top: 8px; }
.fallback-note { margin-bottom: 12px; }
.actionbar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.msgs { flex: 1; min-width: 0; font-size: 0.9rem; }
.msgs p { margin: 0; }
#acp-status { font-weight: 600; }
.more-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
button {
  min-height: 44px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--accent-soft); }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
.d3, .storage-note { color: var(--muted); font-size: 0.8125rem; }
.d3 { margin-bottom: 10px; }
.storage-note { margin: 12px 0 0; }
.task-guide { margin: 8px 0 0; font-size: 0.9375rem; }

/* Guides and lists */
.howto, .guide section, .category, .choosing, main > section {
  margin-top: 28px;
}
.guide { max-width: 80ch; }
.guide ul, .howto ol, .choosing ul { padding-left: 1.25rem; }
.guide li, .howto li, .choosing li { margin-bottom: 6px; }
.sample dt { margin-top: 8px; font-weight: 600; }
.sample dd { margin: 4px 0 0; }
.sample pre {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cards { display: grid; gap: 12px; padding: 0; list-style: none; }
.card { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.card p { margin: 4px 0 0; }
.need { color: var(--muted); font-size: 0.875rem; }

.site-footer { padding: 20px 0 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 4px; }
.site-footer nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px 0 0; }

@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)); }
}

@media (min-width: 1024px) {
  .picker-group { display: flex; align-items: center; gap: 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)); }
}

@media (max-width: 639px) {
  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; }
  .msgs { font-size: 0.8125rem; line-height: 1.3; }
  .actionbar button.primary { padding: 8px 12px; }
  main { padding-top: 14px; }
  h1 { font-size: 1.4rem; }
  .lead { font-size: 0.9375rem; }
  .fill, .copy { padding: 12px; }
  #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: 6px 16px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  }
}
