/* DDV golden-app baseline. Mobile-first, CSS variables, dark mode via prefers-color-scheme. */
:root {
  --bg: #fafafa;
  --fg: #111;
  --muted: #555;
  --accent: #0066cc;
  --border: #ddd;
  --maxw: 760px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111; --fg: #f5f5f5; --muted: #aaa; --accent: #4ea1f7; --border: #333; }
}
[data-theme="dark"]  { --bg: #111; --fg: #f5f5f5; --muted: #aaa; --accent: #4ea1f7; --border: #333; }
[data-theme="light"] { --bg: #fafafa; --fg: #111; --muted: #555; --accent: #0066cc; --border: #ddd; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--fg);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
main { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1rem; flex: 1; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; text-decoration: none; color: var(--fg); }
nav { display: flex; gap: 1rem; align-items: center; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--fg); }
form.inline { display: inline; }
form.inline button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }
form.inline button:hover { color: var(--fg); }
footer { text-align: center; padding: 1rem; color: var(--muted); border-top: 1px solid var(--border); }

h1 { font-size: 1.6rem; margin: 0 0 0.5rem; }
.lede { color: var(--muted); margin-top: 0; }

.btn { display: inline-block; padding: 0.5rem 1rem; background: var(--accent); color: white; text-decoration: none; border-radius: 4px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button { padding: 0.5rem 1rem; background: var(--accent); color: white; border: none; border-radius: 4px; cursor: pointer; font: inherit; }
button:hover { filter: brightness(1.1); }

.auth label { display: block; margin: 0.75rem 0; }
.auth input { display: block; width: 100%; max-width: 360px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; background: var(--bg); color: var(--fg); }
.auth img { max-width: 240px; }

.announcement-banner { padding: 0.5rem 1rem; background: #ffd; color: #553; text-align: center; font-size: 0.95rem; border-bottom: 1px solid #ddd; }

.admin { max-width: 100%; }
.admin-nav { padding: 0.5rem 0; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.admin-stats { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 1rem 0; }
.admin-stats dt { color: var(--muted); }
.admin-stats dd { margin: 0; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th, .admin-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.admin-table.audit code { font-size: 0.8rem; color: var(--muted); word-break: break-all; }

.admin-table.checklist td { vertical-align: top; }
.cl-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.cl-pill.ok   { background: #cfe9d4; color: #1a5024; }
.cl-pill.warn { background: #fff1c2; color: #6a4d00; }
.cl-pill.fail { background: #fbd0d0; color: #8a1a1a; }
.cl-pill.na   { background: #e8e8e8; color: #555; }
@media (prefers-color-scheme: dark) {
  .cl-pill.ok   { background: #1f5e2c; color: #d6f3dd; }
  .cl-pill.warn { background: #6a5200; color: #fff2c2; }
  .cl-pill.fail { background: #6f1f1f; color: #fbd0d0; }
  .cl-pill.na   { background: #3a3a3a; color: #ccc; }
}

.legal { max-width: 56ch; }
.legal h1 { font-size: 1.4rem; }
.legal h2 { font-size: 1.1rem; margin-top: 1.5rem; }
.legal-draft-banner { padding: 0.75rem; margin-bottom: 1.5rem; border-left: 4px solid #c80; background: rgba(204, 136, 0, 0.08); font-size: 0.95rem; }

.contact textarea { width: 100%; max-width: 480px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; background: var(--bg); color: var(--fg); resize: vertical; }
.contact label { display: block; margin: 0.5rem 0; }
.contact input { display: block; width: 100%; max-width: 360px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; background: var(--bg); color: var(--fg); }

/* Respect the HTML `hidden` attribute even when display is set elsewhere.
   Without this, `display: flex` on #ddv-cookie-banner overrides the UA
   default `display: none` for [hidden], so the banner stays visible after
   accepting and clicking OK appears to do nothing. */
[hidden] { display: none !important; }
#ddv-cookie-banner { position: fixed; bottom: 0; left: 0; right: 0; padding: 1rem; background: var(--fg); color: var(--bg); display: flex; gap: 1rem; align-items: center; justify-content: center; flex-wrap: wrap; z-index: 1000; }
#ddv-cookie-banner p { margin: 0; }
#ddv-cookie-banner a { color: var(--bg); text-decoration: underline; }
#ddv-cookie-banner button { background: var(--accent); }

.skeleton { background: linear-gradient(90deg, var(--border), var(--bg), var(--border)); background-size: 200% 100%; animation: skeleton 1.5s infinite; }
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================================
   Homepage — signed-out marketing + signed-in dashboard
   ============================================================================ */

/* Break out of the 760px main container for the homepage. The marketing page
   needs a wider canvas for the pricing grid; the dashboard benefits too. */
.home-hero, .home-how, .home-templates, .home-pricing, .home-faq, .home-final-cta,
.home-dash, .home-upsell {
  max-width: 1080px;
  margin-left: auto; margin-right: auto;
  width: 100%;
}
main:has(.home-hero), main:has(.home-dash) { max-width: 1100px; }

/* Hero */
.home-hero { padding: 3rem 0 2rem; text-align: center; }
.home-hero h1 { font-size: clamp(1.8rem, 4vw, 3rem); margin: 0 0 0.75rem; line-height: 1.15; letter-spacing: -0.02em; }
.home-hero .lede { font-size: 1.15rem; max-width: 56ch; margin: 0 auto 1.5rem; }
.home-hero-cta { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.home-hero-cta .btn { padding: 0.7rem 1.4rem; font-size: 1rem; }
.home-hero-bullets { font-size: 0.9rem; }
.btn.primary { background: var(--accent); color: white; }
.btn.primary:hover { filter: brightness(1.1); }

/* How it works */
.home-how { padding: 2rem 0; }
.home-how h2 { text-align: center; margin: 0 0 1.5rem; }
.home-how-steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; counter-reset: step; }
.home-how-steps li { padding: 1.25rem; background: color-mix(in srgb, var(--fg) 4%, transparent); border-radius: 12px; counter-increment: step; position: relative; }
.home-how-steps li::before { content: counter(step); display: inline-block; width: 1.75rem; height: 1.75rem; line-height: 1.75rem; text-align: center; background: var(--accent); color: white; border-radius: 50%; font-weight: 600; margin-bottom: 0.5rem; font-size: 0.9rem; }

/* Template grid (used on home + dashboard empty state) */
.home-templates { padding: 2rem 0; }
.home-templates h2, .home-pricing h2, .home-faq h2, .home-final-cta h2, .home-empty h2, .home-upsell h2 { text-align: center; margin: 0 0 0.5rem; }
.home-templates .muted, .home-pricing > .muted, .home-empty > p { text-align: center; }
.tpl-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.tpl-card { padding: 1.25rem; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; }
.tpl-card h3 { margin: 0.75rem 0 0.25rem; }
.tpl-card p { flex: 1; margin: 0 0 0.75rem; font-size: 0.95rem; }
.tpl-card .btn { align-self: flex-start; }

/* CSS-painted thumbnails — no asset roundtrip, kept distinct per template id */
.tpl-thumb { width: 100%; aspect-ratio: 16/10; border-radius: 8px; border: 1px solid var(--border); position: relative; overflow: hidden; background: linear-gradient(135deg, #f0f4f9 0%, #e6ecf5 100%); }
@media (prefers-color-scheme: dark) { .tpl-thumb { background: linear-gradient(135deg, #1f2937 0%, #111827 100%); } }
.tpl-thumb::before, .tpl-thumb::after { content: ""; position: absolute; }
.tpl-thumb--landing-saas { background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); }
.tpl-thumb--landing-saas::before { left: 12%; right: 12%; top: 28%; height: 14%; background: rgba(255,255,255,0.85); border-radius: 4px; }
.tpl-thumb--landing-saas::after { left: 28%; right: 28%; top: 50%; height: 8%; background: rgba(255,255,255,0.55); border-radius: 4px; }
.tpl-thumb--link-bio { background: linear-gradient(180deg, #ec4899 0%, #db2777 100%); }
.tpl-thumb--link-bio::before { left: 50%; top: 16%; width: 22%; aspect-ratio: 1; transform: translateX(-50%); background: rgba(255,255,255,0.9); border-radius: 50%; }
.tpl-thumb--link-bio::after { left: 22%; right: 22%; top: 52%; height: 8%; background: rgba(255,255,255,0.7); border-radius: 4px; box-shadow: 0 16px 0 rgba(255,255,255,0.7), 0 32px 0 rgba(255,255,255,0.7); }
.tpl-thumb--personal-portfolio { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.tpl-thumb--personal-portfolio::before { left: 8%; top: 14%; width: 28%; aspect-ratio: 1; background: rgba(255,255,255,0.85); border-radius: 50%; }
.tpl-thumb--personal-portfolio::after { left: 42%; right: 8%; top: 18%; height: 8%; background: rgba(255,255,255,0.7); border-radius: 3px; box-shadow: 0 14px 0 rgba(255,255,255,0.55), 0 28px 0 rgba(255,255,255,0.4); }
.tpl-thumb--agency { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.tpl-thumb--agency::before { left: 10%; right: 10%; top: 20%; height: 12%; background: linear-gradient(90deg, #f59e0b, #ef4444); border-radius: 3px; }
.tpl-thumb--agency::after { left: 10%; right: 50%; top: 44%; height: 8%; background: rgba(255,255,255,0.7); border-radius: 3px; box-shadow: 0 14px 0 rgba(255,255,255,0.5); }
.tpl-thumb--consultant { background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%); }
.tpl-thumb--consultant::before { left: 10%; top: 18%; width: 22%; aspect-ratio: 1; background: rgba(255,255,255,0.9); border-radius: 6px; }
.tpl-thumb--consultant::after { left: 38%; right: 10%; top: 22%; height: 6%; background: rgba(255,255,255,0.7); border-radius: 3px; box-shadow: 0 12px 0 rgba(255,255,255,0.55), 0 24px 0 rgba(255,255,255,0.4), 0 36px 0 rgba(255,255,255,0.3); }
.tpl-thumb--event { background: linear-gradient(135deg, #f97316 0%, #db2777 100%); }
.tpl-thumb--event::before { left: 50%; top: 22%; width: 32%; aspect-ratio: 1; transform: translateX(-50%) rotate(45deg); background: rgba(255,255,255,0.85); border-radius: 6px; }
.tpl-thumb--event::after { left: 22%; right: 22%; bottom: 18%; height: 8%; background: rgba(255,255,255,0.7); border-radius: 3px; }

/* Pricing */
.home-pricing { padding: 2rem 0; }
.pricing-toggle { display: flex; gap: 0; justify-content: center; margin: 1rem 0 1.5rem; background: color-mix(in srgb, var(--fg) 6%, transparent); border-radius: 999px; padding: 4px; width: fit-content; margin-left: auto; margin-right: auto; }
.pricing-toggle-btn { background: transparent; color: var(--fg); border: 0; padding: 0.4rem 1rem; border-radius: 999px; cursor: pointer; font: inherit; font-size: 0.9rem; }
.pricing-toggle-btn.is-active { background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,0.08); font-weight: 600; }
.pricing-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.pricing-card { padding: 1.5rem 1.25rem; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; position: relative; }
.pricing-card--highlight { border-color: var(--accent); border-width: 2px; padding: calc(1.5rem - 1px) calc(1.25rem - 1px); }
.pricing-flag { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--accent); color: white; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.pricing-card h3 { margin: 0 0 0.25rem; font-size: 1.2rem; }
.pricing-blurb { margin: 0 0 1rem; font-size: 0.9rem; }
.pricing-price { margin: 0; }
.pricing-amount { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.02em; }
.pricing-period { color: var(--muted); font-size: 1rem; margin-left: 0.25rem; }
.pricing-annual-hint { font-size: 0.8rem; margin: 0.25rem 0 0; }
.pricing-features { list-style: none; padding: 0; margin: 1.25rem 0; flex: 1; font-size: 0.92rem; }
.pricing-features li { padding: 0.35rem 0 0.35rem 1.5rem; position: relative; }
.pricing-features li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.pricing-cta { width: 100%; text-align: center; }
.pricing-checkout { margin: 0; }
.pricing-checkout button { width: 100%; }
.pricing-cta-current { font-size: 0.9rem; text-align: center; padding: 0.5rem 0; margin: 0; }

/* FAQ */
.home-faq { padding: 2rem 0; max-width: 720px; }
.home-faq details { border-bottom: 1px solid var(--border); padding: 0.85rem 0; }
.home-faq summary { cursor: pointer; font-weight: 500; font-size: 1rem; list-style: none; }
.home-faq summary::-webkit-details-marker { display: none; }
.home-faq summary::after { content: " +"; color: var(--muted); float: right; font-weight: 400; }
.home-faq details[open] summary::after { content: " −"; }
.home-faq details p { margin: 0.6rem 0 0; color: var(--muted); }

.home-final-cta { text-align: center; padding: 2.5rem 0 3rem; }
.home-final-cta h2 { margin: 0 0 0.75rem; font-size: 1.6rem; }

/* ---- Signed-in dashboard ---- */
.home-dash { padding: 1.5rem 0; }
.home-dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.home-dash-head h1 { margin: 0; }
.home-dash-head .lede { margin: 0.25rem 0 0; }
.home-dash-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.home-empty { background: color-mix(in srgb, var(--fg) 4%, transparent); border-radius: 14px; padding: 2rem 1.5rem; text-align: center; }
.home-empty h2 { margin: 0 0 0.5rem; }
.site-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.site-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.85rem 1rem; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.site-row-main { flex: 1; min-width: 0; }
.site-row-host { display: block; font-weight: 600; color: var(--fg); text-decoration: none; word-break: break-all; }
.site-row-host:hover { color: var(--accent); }
.site-row-meta { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.25rem; font-size: 0.85rem; }
.site-row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.site-row-actions .btn { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.pill-ok { background: #cfe9d4; color: #1a5024; }
.pill-draft { background: #e8e8e8; color: #555; }
.pill-info { background: #dde8f6; color: #1c4480; text-transform: none; letter-spacing: normal; font-weight: 500; padding: 1px 6px; }
.pill-warn { background: #fff1c2; color: #6a4d00; }
@media (prefers-color-scheme: dark) {
  .pill-ok { background: #1f5e2c; color: #d6f3dd; }
  .pill-draft { background: #3a3a3a; color: #ccc; }
  .pill-info { background: #1e3a5f; color: #c7daf2; }
  .pill-warn { background: #6a5200; color: #fff2c2; }
}
.home-dash-foot { margin-top: 1.5rem; text-align: center; }
.home-limit-note { color: var(--muted); }
.home-upsell { padding: 2rem 0 1rem; margin-top: 2rem; border-top: 1px solid var(--border); }
.home-upsell h2 { margin: 0 0 0.25rem; }
.home-upsell > .muted { text-align: center; margin: 0 0 1rem; }

@media (max-width: 600px) {
  .site-row { flex-direction: column; align-items: stretch; }
  .site-row-actions { justify-content: flex-start; }
}

/* ============================================================================
   Editor — site builder UI
   ============================================================================ */

main:has(.editor) { max-width: 100%; padding: 0; }

.editor { max-width: 1400px; margin: 0 auto; padding: 0; }

/* Sticky toolbar */
.editor-toolbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); padding: 0.75rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.editor-toolbar-title { display: flex; align-items: baseline; gap: 0.75rem; min-width: 0; flex: 1; }
.editor-toolbar-title h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.editor-toolbar-title .editor-host { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; word-break: break-all; }
.editor-toolbar-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.editor-toolbar-actions .btn { padding: 0.5rem 1rem; font-size: 0.9rem; }
.editor-status { font-size: 0.85rem; color: var(--muted); min-width: 80px; text-align: right; }
.editor-status.ok { color: #1a7a3c; }
.editor-status.error { color: #c33; }
.editor-status.saving { color: var(--muted); }
@media (prefers-color-scheme: dark) { .editor-status.ok { color: #6ed68a; } }

/* Two-pane layout: left = sidebar + form, right = live preview */
.editor-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr) minmax(0, 480px); height: calc(100vh - 56px - 60px); }
@media (max-width: 1100px) { .editor-layout { grid-template-columns: 200px minmax(0, 1fr); } .editor-preview { display: none; } }
@media (max-width: 720px) { .editor-layout { grid-template-columns: 1fr; height: auto; } .editor-sidebar { flex-direction: row !important; overflow-x: auto; border-right: 0 !important; border-bottom: 1px solid var(--border); padding: 0.5rem !important; } }

/* Sidebar: tab nav */
.editor-sidebar { display: flex; flex-direction: column; gap: 2px; padding: 1rem 0.75rem; border-right: 1px solid var(--border); overflow-y: auto; }
.tab-btn { padding: 0.55rem 0.85rem; background: transparent; color: var(--fg); border: 0; border-radius: 6px; text-align: left; cursor: pointer; font: inherit; font-size: 0.92rem; white-space: nowrap; transition: background 120ms ease; }
.tab-btn:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); }
.tab-btn.active { background: var(--accent); color: white; font-weight: 500; }

/* Form pane */
.editor-pane { padding: 1.5rem 1.5rem 4rem; overflow-y: auto; max-width: 720px; width: 100%; }
.editor-pane h2 { margin: 0 0 0.5rem; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.editor-pane > section > .pane-lede { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.95rem; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* Field — the visual unit */
.field { margin-bottom: 1.25rem; }
.field-label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; color: var(--fg); }
.field-label .field-required { color: #c33; margin-left: 2px; }
.field-help { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.4rem; line-height: 1.4; }
.field-input,
.field input[type=text],
.field input[type=email],
.field input[type=tel],
.field input[type=url],
.field input[type=number],
.field textarea,
.field select { width: 100%; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 0.95rem; box-sizing: border-box; background: var(--bg); color: var(--fg); transition: border-color 120ms ease, box-shadow 120ms ease; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
.field input[type=color] { width: 60px; height: 36px; padding: 2px; cursor: pointer; }
.field-counter { color: var(--muted); font-size: 0.78rem; text-align: right; margin-top: 0.2rem; font-variant-numeric: tabular-nums; }
.field-counter.over { color: #c33; }

/* URL field: kind selector + value input */
.url-field { display: grid; grid-template-columns: 110px 1fr; gap: 0.5rem; }
.url-field select { padding: 0.5rem; }

/* List editor — the big one */
.list-editor { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; background: color-mix(in srgb, var(--fg) 3%, transparent); }
.list-editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.list-editor-head .field-help { margin: 0; }
.list-editor-meta { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.list-items { display: flex; flex-direction: column; gap: 0.75rem; }
.list-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.85rem; position: relative; }
.list-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; gap: 0.5rem; }
.list-item-handle { color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.list-item-actions { display: flex; gap: 0.25rem; }
.list-item-action { padding: 0.25rem 0.5rem; background: transparent; border: 1px solid var(--border); border-radius: 5px; color: var(--muted); cursor: pointer; font-size: 0.78rem; line-height: 1; }
.list-item-action:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); }
.list-item-action.danger:hover { background: #fee; color: #c33; border-color: #f99; }
@media (prefers-color-scheme: dark) { .list-item-action.danger:hover { background: #4a1f1f; color: #ff9999; border-color: #6f3030; } }
.list-item .field { margin-bottom: 0.75rem; }
.list-item .field:last-child { margin-bottom: 0; }
.list-item.list-item--primitive { display: flex; gap: 0.5rem; align-items: center; padding: 0.5rem; }
.list-item.list-item--primitive input { flex: 1; }
.list-add { margin-top: 0.75rem; width: 100%; padding: 0.55rem; background: transparent; border: 1px dashed var(--border); border-radius: 6px; color: var(--muted); cursor: pointer; font: inherit; font-size: 0.9rem; transition: border-color 120ms, color 120ms; }
.list-add:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); border-style: solid; }
.list-add:disabled { opacity: 0.5; cursor: not-allowed; }
.list-empty { color: var(--muted); text-align: center; padding: 1rem; font-style: italic; font-size: 0.9rem; }

/* Image uploader */
.image-uploader { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; background: color-mix(in srgb, var(--fg) 3%, transparent); }
.image-current { margin-bottom: 0.5rem; min-height: 0; }
.image-current img { max-width: 240px; max-height: 160px; border-radius: 6px; border: 1px solid var(--border); }
.image-uploader input[type=file] { display: none; }
.image-uploader-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.upload-status { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; }
.upload-status.ok { color: #1a7a3c; }
.upload-status.error { color: #c33; }

/* Theme/Palette/Density radio groups */
.choice-group { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.choice-group legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.4rem; padding: 0; width: 100%; }
.choice-pill { display: inline-flex; align-items: center; padding: 0.4rem 0.85rem; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 0.88rem; user-select: none; background: var(--bg); transition: all 120ms ease; }
.choice-pill:hover { border-color: var(--accent); }
.choice-pill input { display: none; }
.choice-pill.is-checked { background: var(--accent); color: white; border-color: var(--accent); }
.choice-pill input:checked + span { /* fallback if browser supports :has not */ }

/* Preview pane */
.editor-preview { border-left: 1px solid var(--border); display: flex; flex-direction: column; background: color-mix(in srgb, var(--fg) 3%, transparent); }
.editor-preview-bar { padding: 0.5rem 0.85rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--muted); flex-shrink: 0; }
.editor-preview-bar .btn { padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.editor-preview iframe { flex: 1; width: 100%; height: 100%; border: 0; background: var(--bg); }
.preview-stale { color: #c80; }

/* Inline buttons baseline (compact, used inside editor) */
.btn.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
button.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.btn.ghost:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* AI: inline ✨ button next to text labels, floating menu, variant chooser */
.ai-btn { background: transparent; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; padding: 0.05rem 0.45rem; font-size: 0.8rem; line-height: 1.2; margin-left: 0.4rem; vertical-align: middle; transition: all 120ms ease; opacity: 0.65; }
.ai-btn:hover { opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ai-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.ai-menu { position: absolute; z-index: 100; min-width: 200px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 0.3rem; display: flex; flex-direction: column; gap: 1px; }
.ai-menu button { background: transparent; border: 0; padding: 0.5rem 0.75rem; text-align: left; font: inherit; font-size: 0.9rem; cursor: pointer; border-radius: 5px; color: var(--fg); }
.ai-menu button:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.ai-menu button:focus-visible { background: color-mix(in srgb, var(--accent) 18%, transparent); outline: none; }

.ai-variants { position: absolute; z-index: 100; width: 420px; max-width: calc(100vw - 16px); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,0.14); padding: 0.85rem; }
.ai-variants-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.ai-variants ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.ai-variants li button { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.55rem 0.7rem; text-align: left; font: inherit; font-size: 0.92rem; cursor: pointer; color: var(--fg); transition: all 120ms ease; }
.ai-variants li button:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.editor-budget { font-size: 0.82rem; color: var(--muted); padding: 0.2rem 0.55rem; border: 1px solid var(--border); border-radius: 999px; font-variant-numeric: tabular-nums; }

/* ============================================================================
   Admin — polished surface for operator workflows
   ============================================================================ */

main:has(.admin) { max-width: 1200px; }
.admin h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 1rem; }
.admin h2 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }

/* Admin nav strip — tab-like horizontal bar */
.admin-nav { display: flex; gap: 0.25rem; padding: 0.4rem; margin: 0 0 1.25rem; background: color-mix(in srgb, var(--fg) 5%, transparent); border-radius: 10px; flex-wrap: wrap; font-size: 0; }
.admin-nav a { font-size: 0.9rem; padding: 0.45rem 0.85rem; border-radius: 6px; color: var(--fg); text-decoration: none; transition: background 120ms ease; }
.admin-nav a:hover { background: var(--bg); }
.admin-nav a.is-active { background: var(--accent); color: white; font-weight: 500; }

/* Stat cards (replaces dl visual) */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.5rem; padding: 0; background: transparent; border-radius: 0; }
.admin-stats dt { color: var(--muted); font-size: 0.8rem; padding: 0.85rem 0.85rem 0.2rem; background: color-mix(in srgb, var(--fg) 4%, transparent); border-radius: 10px 10px 0 0; }
.admin-stats dd { margin: 0; padding: 0 0.85rem 0.85rem; background: color-mix(in srgb, var(--fg) 4%, transparent); border-radius: 0 0 10px 10px; font-size: 1.4rem; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

/* Table polish */
.admin-table { background: var(--bg); border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px var(--border); }
.admin-table th { background: color-mix(in srgb, var(--fg) 4%, transparent); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.admin-table tr:hover td { background: color-mix(in srgb, var(--fg) 4%, transparent); }
.admin-table tr.muted-row { color: var(--muted); }
.admin-table td a { color: var(--accent); }

/* Section cards in admin */
.admin-card { padding: 1.25rem; background: color-mix(in srgb, var(--fg) 3%, transparent); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 1.25rem; }
.admin-card h2 { margin-top: 0; }

/* Readiness checklist row pill (already exists; reinforce) */
.checklist-summary { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; padding: 0.75rem 1rem; background: color-mix(in srgb, var(--fg) 4%, transparent); border-radius: 8px; margin-bottom: 1rem; font-size: 0.95rem; }
.checklist-summary a { color: var(--fg); text-decoration: none; }
.checklist-summary a:hover { color: var(--accent); }

/* ============================================================================
   Form group + form section helpers (used in onboarding-suggest etc.)
   ============================================================================ */

.form-card { background: color-mix(in srgb, var(--fg) 4%, transparent); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; margin-bottom: 1.5rem; }
.form-card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
