/* GuestPage host app (sign-in, dashboard, editor). Operate mode: calm, precise, system fonts. */
:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --ink: #1c1c1a;
  --ink-2: #5f5d57;
  --line: #e1dfd8;
  --brand: #1f5c4f;
  --brand-ink: #ffffff;
  --ok: #2c6a45;
  --ok-bg: #e4f1e8;
  --warn: #8f4416;
  --warn-bg: #fbeadf;
  --danger: #a3271b;
  --focus: #2457c5;
  --radius: 12px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
/* Folded panels: one Phosphor caret (in the markup) instead of the browser's triangle; it turns when open. */
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
summary .caret { display: inline-grid; place-items: center; flex: none; color: var(--ink-2); transition: transform 0.15s; }
details[open] > summary .caret { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { summary .caret { transition: none; } }
.back-link { display: inline-flex; align-items: center; gap: var(--s-1); }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
::selection { background: var(--brand); color: var(--brand-ink); }
a { color: var(--brand); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2 { line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 var(--s-2); text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
h2 { font-size: 1.15rem; }
p { margin: 0 0 var(--s-3); }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) clamp(16px, 4vw, 32px); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 800; color: var(--ink); text-decoration: none; }
.brand svg { color: var(--brand); }
.bar nav { display: flex; align-items: center; gap: var(--s-4); }
.bar nav a { color: var(--ink); text-decoration: none; font-weight: 600; padding-block: 10px; }
.bar nav button.link { min-height: 44px; }
.bar nav form { margin: 0; }
main { max-width: 56rem; margin: 0 auto; padding: var(--s-6) clamp(16px, 4vw, 32px) var(--s-7); }
main.wide { max-width: 80rem; }

/* Controls */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4);
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 0.95rem system-ui, sans-serif; text-decoration: none; cursor: pointer;
}
button:hover, .button:hover { border-color: var(--ink-2); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover { background: color-mix(in srgb, var(--brand) 86%, black); }
button.small, .button.small { min-height: 36px; padding: 0 var(--s-3); font-size: 0.875rem; }
button.danger, .button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
button.link.danger { color: var(--danger); }
.stack { display: grid; gap: var(--s-4); }
label { display: grid; gap: var(--s-1); font-weight: 600; font-size: 0.92rem; }
label small { font-weight: 400; color: var(--ink-2); }
input, select, textarea { font: 400 1rem system-ui, sans-serif; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-height: 42px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
textarea { resize: vertical; line-height: 1.45; }
input[type='color'] { padding: 4px; width: 100%; height: 42px; cursor: pointer; }
label.check { display: flex; align-items: center; gap: var(--s-2); align-self: end; min-height: 42px; font-weight: 600; }
label.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: 0.92rem; padding: 0; margin-bottom: var(--s-2); }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--s-3); align-items: start; }

.chip { display: inline-flex; align-items: center; min-height: 24px; padding: 0 var(--s-2); border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: #ecebe6; color: var(--ink); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.quiet { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.alert, .notice { border-radius: var(--radius); padding: var(--s-3) var(--s-4); font-weight: 600; }
.alert { background: var(--warn-bg); color: var(--warn); }
.notice { background: var(--ok-bg); color: var(--ok); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-5); }

/* Auth */
.narrow { max-width: 26rem; margin: 6vh auto 0; }
.lede { color: var(--ink-2); font-size: 1.05rem; }

/* Dashboard */
.heading-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.guide-list { list-style: none; margin: 0 0 var(--s-6); padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.guide-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--s-2) var(--s-4); align-items: center; padding: var(--s-4) var(--s-5); }
.guide-row + .guide-row { border-top: 1px solid var(--line); }
.gr-main { display: grid; gap: 2px; min-width: 0; }
.gr-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.gr-title:hover { color: var(--brand); }
.gr-actions { display: flex; align-items: center; gap: var(--s-4); }
@media (max-width: 34rem) { .guide-row { grid-template-columns: 1fr auto; } .gr-actions { grid-column: 1 / -1; } }
.empty { text-align: center; padding: var(--s-7) var(--s-5); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: var(--s-6); }
.new-guide summary { cursor: pointer; font-weight: 700; }
.new-guide[open] summary { margin-bottom: var(--s-4); }

/* Editor */
.crumb { margin: 0 0 var(--s-1); font-size: 0.875rem; font-weight: 600; }
.crumb a { color: var(--ink-2); text-decoration: none; display: inline-block; padding-block: 4px; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin: 0; font-size: 0.9rem; }
.status-line a { overflow-wrap: anywhere; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--s-6); align-items: start; }
.editor-main { display: grid; gap: var(--s-5); }
.device { width: 390px; height: min(780px, calc(100vh - 6rem)); border-radius: 28px; border: 10px solid #23231f; background: #23231f; overflow: hidden; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05), 0 18px 40px -20px rgba(0, 0, 0, 0.35); }
.device iframe { width: 100%; height: 100%; border: 0; border-radius: 18px; background: #fff; }

.theme-option:hover .theme-card { border-color: var(--ink-2); }
.theme-option input:checked + .theme-card { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.theme-option input:focus-visible + .theme-card { outline: 3px solid var(--focus); outline-offset: 2px; }

.sections { display: grid; gap: var(--s-2); }
.section-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.section-card > summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-4); cursor: pointer; list-style: none; min-height: 52px; }
.section-card > summary::-webkit-details-marker { display: none; }
.section-card[open] > summary { border-bottom: 1px solid var(--line); }
.sc-title { font-weight: 700; flex: 1 1 11rem; min-width: 0; overflow-wrap: anywhere; }
.sc-meta { display: flex; gap: var(--s-2); align-items: center; font-size: 0.85rem; }
.section-card.is-hidden .sc-title { color: var(--ink-2); }
.section-card > form { padding: var(--s-4); }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.save-state { min-height: 1.5em; font-size: 0.875rem; color: var(--ink-2); }
.save-state.ok { color: var(--ok); font-weight: 600; animation: saved-fade 0.6s ease-out 2.4s both; }
@keyframes saved-fade { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .save-state.ok { animation: none; } }
.save-state.error { color: var(--danger); }
.save-state.error ul { margin: var(--s-1) 0 0; padding-left: 1.1em; }
.add-section { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s-2); margin-top: var(--s-3); padding-top: var(--s-4); border-top: 1px dashed var(--line); }
.add-section label { flex: 1 1 14rem; }

.rows { display: grid; gap: var(--s-3); }
.rows-list { display: grid; gap: var(--s-3); }
.row-item { display: grid; gap: var(--s-3); padding: var(--s-3); border: 1px solid var(--line); border-radius: 10px; background: var(--bg); justify-items: stretch; }
.row-item > button { justify-self: start; }
.rows > [data-add-row] { justify-self: start; }


/* Cover photo */
.sub { font-size: 0.95rem; margin: var(--s-5) 0 var(--s-2); }
.cover { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.cover.busy { opacity: 0.6; pointer-events: none; }
.cover-preview { aspect-ratio: 16 / 9; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; overflow: hidden; text-align: center; padding: var(--s-1); }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-actions { display: grid; gap: var(--s-2); justify-items: start; }
.cover-actions form { margin: 0; }
.cover-actions p { margin: 0; }
label.file { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s-4); border: 1px dashed var(--ink-2); border-radius: 10px; font-weight: 600; cursor: pointer; }
label.file:hover { border-color: var(--brand); color: var(--brand); }
label.file:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
label.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
@media (max-width: 30rem) { .cover { grid-template-columns: 1fr; } }

/* QR codes & signs */
.qr-list { display: grid; gap: var(--s-4); margin: var(--s-5) 0; }
.qr-card { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.qr-thumb { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.qr-thumb .qr { display: block; width: 100%; height: auto; }
.qr-info { display: grid; gap: var(--s-2); min-width: 0; }
.qr-info h3 { margin: 0; font-size: 1.1rem; }
.qr-info p { margin: 0; }
.qr-url a { font-weight: 700; overflow-wrap: anywhere; }
.scans { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.bars { width: 180px; height: 32px; display: block; }
.bars rect { fill: var(--brand); }
.qr-more { border-top: 1px solid var(--line); padding-top: var(--s-2); }
.qr-more summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; gap: var(--s-2); }
.qr-more[open] summary { margin-bottom: var(--s-3); }
.target-fields { border: 0; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.target-fields legend { font-weight: 700; margin-bottom: var(--s-1); }
.field-error { color: var(--danger); font-weight: 600; }
.nfc-url { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: var(--s-2) var(--s-3); overflow-wrap: anywhere; user-select: all; }
.nfc ol { margin: var(--s-2) 0 0; padding-left: 1.2em; display: grid; gap: var(--s-1); }
.printables { margin-top: var(--s-5); }
.printables .sub { margin-top: var(--s-5); }
.print-table { width: 100%; border-collapse: collapse; margin: var(--s-3) 0; }
.print-table th, .print-table td { text-align: left; padding: var(--s-2) var(--s-2) var(--s-2) 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.print-table thead th { font-size: 0.85rem; color: var(--ink-2); }
.print-table td a.small { margin-left: var(--s-2); }
.notice-page { max-width: 30rem; margin: 18vh auto 0; text-align: center; }
@media (max-width: 34rem) {
  .qr-card { grid-template-columns: 1fr; }
  .qr-thumb { width: 132px; }
  .print-table thead { display: none; }
  .print-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); padding: var(--s-2) 0; border-bottom: 1px solid var(--line); }
  .print-table th, .print-table td { border: 0; padding: 0; }
  .print-table th[scope='row'] { grid-column: 1 / -1; }
}
.head-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.head-actions form { margin: 0; }
.gr-qr { font-weight: 600; justify-self: start; }

/* Admin (operator) pages: orders and Etsy. */
.tabs { display: flex; gap: var(--s-5); margin-bottom: var(--s-4); border-bottom: 1px solid var(--line); }
.tabs a { padding: var(--s-2) 0; margin-bottom: -1px; color: var(--ink-2); font-weight: 700; text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current='page'] { color: var(--ink); border-bottom-color: var(--brand); }
/* Seven admin tabs don't fit a phone: the row scrolls on its own, the page doesn't. */
.admin-tabs { overflow-x: auto; scrollbar-width: none; border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line); }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs a { flex: none; margin-bottom: 0; }
.admin-section { margin-top: var(--s-7); }
.admin-section > h2 { margin-bottom: var(--s-1); }
.admin-table { width: 100%; border-collapse: collapse; margin: var(--s-3) 0; font-variant-numeric: tabular-nums; }
.admin-table th, .admin-table td { text-align: left; padding: var(--s-3) var(--s-3) var(--s-3) 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table thead th { font-size: 0.85rem; color: var(--ink-2); padding-top: 0; }
.admin-table .chip { margin-left: var(--s-2); }
.admin-table td:first-child .chip { margin-left: var(--s-2); }
.admin-table td > .chip:first-child { margin-left: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin: 0; }
.inline-form input, .inline-form select { width: auto; min-width: 12rem; flex: 1 1 12rem; }
.inline-form input[type=file] { min-width: 0; max-width: 100%; }
.panel.stack { grid-template-columns: minmax(0, 1fr); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.downloads { list-style: none; padding: 0; margin: var(--s-3) 0 0; display: grid; gap: var(--s-2); }
.downloads a { font-weight: 700; }
code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.9em; }
.building { margin-bottom: var(--s-5); }
.building h2 { margin-bottom: var(--s-1); }
.building p { margin: 0; font-weight: 400; }
@media (max-width: 40rem) {
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
  .admin-table td { border: 0; padding: var(--s-1) 0; }
}
.behalf { margin: var(--s-1) 0 var(--s-2); color: var(--warn); font-weight: 600; font-size: 0.9rem; }
.filters { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-end; margin: var(--s-3) 0 var(--s-4); }
.filters label { min-width: 11rem; }
.filters select { width: auto; }
.building p { margin: var(--s-1) 0 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); margin: var(--s-4) 0; }
.facts dt { color: var(--ink-2); font-weight: 600; }
.facts dd { margin: 0; }
.answers dt { font-weight: 700; margin-top: var(--s-4); }
.answers dd { margin: var(--s-1) 0 0; }
.pre { white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-1) var(--s-4); margin: var(--s-2) 0 0; }
.kv dt { color: var(--ink-2); font-size: 0.85rem; }
.kv dd { margin: 0; }
.kv ul, .draft-section ul { margin: 0; padding-left: 1.2em; }
.draft-section { padding: var(--s-4); }
.draft-section .check { margin-bottom: var(--s-2); }
.draft-notes { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: var(--s-4); margin: var(--s-4) 0; }
.draft-notes h2 { font-size: 1rem; }
.draft-notes p { margin: 0; color: var(--ink); }
.log { list-style: none; padding: 0; margin: var(--s-2) 0 0; display: grid; gap: var(--s-2); }
.create-guide { margin-top: var(--s-3); }
.narrow-form { max-width: 32rem; }
.metric-bars .bars { width: 100%; max-width: 40rem; height: 72px; }
.admin-table.compact { max-width: 36rem; }
.questionnaire textarea { min-height: 0; }
@media (max-width: 40rem) { .facts, .kv { grid-template-columns: 1fr; } }
.metric-bars { margin: var(--s-3) 0; max-width: 40rem; }
.axis { display: flex; justify-content: space-between; margin-top: var(--s-1); }
.request { margin-bottom: var(--s-3); }
.request .inline-form { margin-top: var(--s-3); }
.refs { margin: var(--s-2) 0 0; padding-left: 1.2em; }
form.inline { display: inline; margin: 0; }

/* Live signs (M6). */
.ico { flex: none; vertical-align: -0.15em; }
.sign-list { list-style: none; padding: 0; margin: var(--s-4) 0; display: grid; gap: var(--s-3); }
.sign-row { display: grid; grid-template-columns: minmax(0, 14rem) 1fr; gap: var(--s-4); align-items: center; }
.sign-row h2 { margin: 0 0 var(--s-1); }
.sign-row h2 a { color: var(--ink); text-decoration: none; }
.sign-thumb img, .sign-preview img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.sign-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); margin: var(--s-1) 0 var(--s-3); }
.add-sign { margin-top: var(--s-5); }
.sign-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--s-5); align-items: start; }
.sign-side { display: grid; gap: var(--s-4); min-width: 0; }
.sign-preview { margin: 0; }
.sign-preview img { transition: opacity 0.2s ease-out; }
.sign-preview.loading img { opacity: 0.55; }
.sign-draft-note { margin-top: var(--s-2); color: var(--warn); font-weight: 600; }
.sign-facts { grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-2) var(--s-4); margin: 0; font-size: 0.95rem; }
.sign-facts dd { overflow-wrap: anywhere; }
.sign-facts .inline-form { display: inline-flex; margin-left: var(--s-2); }
.sign-commands { border-top: 1px solid var(--line); padding-top: var(--s-4); display: grid; gap: var(--s-2); }
.sign-commands h3 { font-size: 1rem; margin: 0; }
.sign-commands p { margin: 0; }
.sign-command-row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0; }
.sign-pending { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-3); margin: 0; padding: var(--s-2) var(--s-3); border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-size: 0.9rem; }
.sign-preview figcaption { margin-top: var(--s-2); }
.sign-forms { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); min-width: 0; }
.layouts .check { align-items: baseline; }
.sensor-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-3); }
.sensor-list > li { border-top: 1px solid var(--line); padding-top: var(--s-3); }
.sensor-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-3); margin-bottom: var(--s-2); }
.pin-show { font-size: 1.1rem; letter-spacing: 0.08em; background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.pair .code { font: 800 2.6rem/1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: 0.18em; margin: var(--s-2) 0; color: var(--brand); }
.pair-steps { display: grid; gap: var(--s-3); margin: var(--s-4) 0; }
.pair-steps h2 { display: flex; align-items: center; gap: var(--s-2); }
.pair-steps ol { margin: 0; padding-left: 1.2em; display: grid; gap: var(--s-2); }
.waiting { font-weight: 600; color: var(--ink-2); }
.live-link { margin-bottom: var(--s-4); }
@media (max-width: 52rem) { .sign-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 30rem) { .sign-facts { grid-template-columns: 1fr; gap: 0; } .sign-facts dt { margin-top: var(--s-2); } }
@media (max-width: 34rem) { .sign-row { grid-template-columns: 1fr; } }

/* Etsy API Terms §6: the notice on every app page. */
.app-foot { max-width: 80rem; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px) var(--s-6); }
.app-foot p { text-wrap: pretty; margin: 0; padding-top: var(--s-4); border-top: 1px solid var(--line); color: var(--ink-2); font-size: 0.8rem; }

/* Guide pages: title, Guide | QR & signs, and the QR & signs row. */
.guide-tabs { margin: var(--s-3) 0 0; }
.guide-head .subtabs { margin: 0; }
.subtabs { display: flex; flex-wrap: wrap; gap: var(--s-1); margin: var(--s-4) 0 0; padding: var(--s-1); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; width: fit-content; max-width: 100%; }
.subtabs a { padding: 6px var(--s-3); border-radius: 7px; color: var(--ink-2); font-weight: 600; font-size: 0.92rem; text-decoration: none; }
.subtabs a:hover { color: var(--ink); }
.subtabs a[aria-current='page'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

/* Dialogs: confirmations (confirm.js) and New guide. */
dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(30rem, calc(100vw - 32px)); width: 100%; box-shadow: 0 12px 40px rgb(0 0 0 / 0.22); color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgb(20 20 20 / 0.45); }
dialog > form, dialog > .dialog-body { padding: var(--s-5); display: grid; gap: var(--s-3); }
dialog h2 { margin: 0; font-size: 1.15rem; }
.confirm-body p { margin: 0 0 var(--s-2); color: var(--ink-2); }
.confirm-actions, .dialog-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-2); }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger-solid:hover { background: color-mix(in srgb, var(--danger) 86%, black); }

/* A Live sign's page: back link, name, status; preview beside the tabbed settings. */
.sign-head { display: grid; gap: var(--s-1); margin: 0 0 var(--s-4); }
.sign-head .sign-title { margin: 0; font-size: 1.5rem; }
.sign-head .sign-status { margin: 0; }
.sign-tabs { display: flex; flex-wrap: wrap; gap: var(--s-5); border-bottom: 1px solid var(--line); margin: 0 0 var(--s-4); }
.sign-tabs a { padding: var(--s-2) 0; margin-bottom: -1px; color: var(--ink-2); font-weight: 700; text-decoration: none; border-bottom: 2px solid transparent; }
.sign-tabs a:hover { color: var(--ink); }
.sign-tabs a[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--brand); }
.sign-panel { gap: var(--s-4); }
.sign-panel + .sign-panel { margin-top: var(--s-5); }
.sign-tabs.js ~ .sign-panel + .sign-panel { margin-top: 0; }
@media (min-width: 52.01rem) { .sign-side { position: sticky; top: var(--s-4); } }
.qr-sign { display: inline-block; margin: 0 0 var(--s-2); }
.qr-delete { margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line); }
.qr-delete p { margin: 0; }

/* .stack (display: grid) must not override the hidden attribute (tab panels, dialogs). */
[hidden] { display: none !important; }

/* Phones: the header links and the sign tabs stay on one line. */
.bar nav a, .bar nav button { white-space: nowrap; }
.sign-tabs a { white-space: nowrap; }
@media (max-width: 30rem) {
  .bar nav { gap: var(--s-3); }
  .bar nav a, .bar nav button { font-size: 0.92rem; }
  .sign-tabs { flex-wrap: nowrap; gap: var(--s-4); overflow-x: auto; scrollbar-width: none; }
  .sign-tabs::-webkit-scrollbar { display: none; }
  .sign-tabs a { font-size: 0.95rem; }
}

/* Skip link: hidden until focused. */
.skip-link { position: absolute; left: var(--s-4); top: -100px; z-index: 50; padding: var(--s-2) var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: var(--s-3); }

/* With JavaScript, forms autosave: their Save buttons are for no-JS only (and vice versa). */
html.js [data-nojs] { display: none; }
html:not(.js) [data-jsonly] { display: none; }
@media (pointer: coarse) { button.small, .button.small { min-height: 44px; } }
.measure { max-width: 68ch; }

/* Editor: header with the publish bar; on narrow screens the bar sits at the bottom. */
/* Every guide page (Guide, QR codes, Printed signs, Live signs) has this same header. */
.guide-head { display: grid; gap: var(--s-2); margin-bottom: var(--s-5); }
.guide-head h1 { margin: 0; }
.guide-head .notice { margin: var(--s-1) 0 0; font-weight: 600; }
.guide-head .tabs { margin-bottom: 0; }
/* QR codes and Printed signs keep a reading width inside the wide frame. */
.guide-body { max-width: 60rem; }
.live-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin: 0; font-weight: 600; }
.live-line a { display: inline-flex; align-items: center; gap: var(--s-1); }
.publish-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pb-state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); margin: 0; font-size: 0.92rem; color: var(--ink-2); }
.pb-actions { display: flex; align-items: center; gap: var(--s-2); }
.pb-actions form { margin: 0; }
.pb-actions .primary { min-width: 9.5rem; }
.pb-actions .primary:disabled { opacity: 1; background: var(--ok-bg); border-color: var(--ok-bg); color: var(--ok); }
/* Wide screens: two independent columns. The right one (the phone) runs the full height of
   the left, so the phone stays in view while the host scrolls. */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--s-6); align-items: start; }
.ed-left { display: grid; gap: var(--s-5); min-width: 0; }
.ed-right { display: flex; flex-direction: column; gap: var(--s-5); align-self: stretch; min-width: 0; }
.editor-extra { display: grid; gap: var(--s-3); }
.editor-preview { flex: 1; }
.gv-sticky { position: sticky; top: var(--s-4); display: grid; gap: var(--s-2); justify-items: center; }
/* The preview at 85 %: still a 390 px wide page inside, so guests' layout is what the host sees. */
.editor-preview .device { width: 350px; height: min(680px, calc(100vh - 7rem)); border-width: 9px; border-radius: 26px; }
.editor-preview .device iframe { width: 390px; height: calc(100% / 0.85); transform: scale(0.85); transform-origin: 0 0; border-radius: 0; }
.gv-bar { display: none; }
.pb-guest { display: none; }
@media (max-width: 68rem) {
  /* Phones: one list in task order: readiness, Title and look, sections, then the rest. */
  .editor { display: flex; flex-direction: column; gap: var(--s-5); }
  .ed-left, .ed-right { display: contents; }
  .editor-main { order: 1; }
  .editor-extra { order: 2; }
  .gv-open .gv-sticky { position: static; display: block; }
  .gv-open .editor-preview .device iframe { width: 100%; height: 100%; transform: none; }
  .pb-guest { display: inline-flex; }
  .publish-bar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; border-width: 1px 0 0; padding: var(--s-2) clamp(16px, 4vw, 32px) calc(var(--s-2) + env(safe-area-inset-bottom)); box-shadow: 0 -6px 18px -12px rgb(0 0 0 / 0.25); }
  main:has(.publish-bar) { padding-bottom: 8rem; }
  .editor-preview { display: none; }
  .gv-open .editor-preview { display: grid; position: fixed; inset: 0; z-index: 30; align-content: start; justify-items: stretch; gap: 0; background: var(--bg); }
  .gv-open { overflow: hidden; }
  .gv-open .gv-bar { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2) clamp(16px, 4vw, 32px); background: var(--surface); border-bottom: 1px solid var(--line); }
  .gv-open .editor-preview .device { width: 100%; height: calc(100dvh - 61px); border: 0; border-radius: 0; box-shadow: none; }
  .gv-open .device iframe { border-radius: 0; }
  .gv-open .gv-sticky > p { display: none; }
}
@media (max-width: 34rem) {
  .pb-state > span:not(.chip) { display: none; }
  .pb-actions .primary { min-width: 0; }
}

/* Before guests arrive: one quiet list, one row per fact. */
.ready-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-1) var(--s-4); }
.ready-head h2 { margin: 0; }
.ready-head p { margin: 0; }
.ready-list { list-style: none; margin: var(--s-3) 0 0; padding: 0; }
.ready-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); min-height: 48px; padding: var(--s-1) 0; border-top: 1px solid var(--line); }
.ready-list li .ico { color: var(--ink-2); }
.ready-list li.done .ico { color: var(--ok); }
.ready-list li.done .ready-label { color: var(--ink-2); }
.ready-list li.todo .ready-label { font-weight: 600; }
.ready-go { font-weight: 700; padding-block: 10px; }
.ready-list form { margin: 0; }
.ready-next { display: flex; align-items: center; gap: var(--s-2); margin: var(--s-3) 0 0; padding-top: var(--s-3); border-top: 1px solid var(--line); }

/* Section rows: order on the left, Delete apart on the right. */
.sc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: 0 var(--s-4) var(--s-4); }
.sc-actions form { margin: 0; }
.sc-move { display: flex; gap: var(--s-1); }
.sc-actions .sc-delete { margin-left: auto; }
button.icon { width: 36px; padding: 0; }
@media (pointer: coarse) { button.icon { width: 44px; } }
.sc-meta .chip { gap: 4px; }
.inline-pin { margin: 0 var(--s-4) var(--s-4); padding: var(--s-3); border-radius: 10px; background: var(--warn-bg); color: var(--warn); display: grid; gap: var(--s-2); }
.inline-pin p { display: flex; gap: var(--s-2); align-items: flex-start; margin: 0; font-weight: 600; }
.inline-pin .ico { margin-top: 2px; }
.inline-pin input { background: var(--surface); }
.field-aside { margin: 0; }
.row-undo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border: 1px dashed var(--line); border-radius: 10px; font-weight: 600; color: var(--ink-2); }
.row-item > button[data-remove-row] { min-height: 36px; padding: 0 var(--s-2); }

/* Title and look: folded to one line until the host wants to change it. */
.look > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); cursor: pointer; list-style: none; }
.look > summary::-webkit-details-marker { display: none; }
.look-head { display: grid; gap: 2px; min-width: 0; }
.look-head h2 { margin: 0; }
.look-summary { display: flex; align-items: center; gap: var(--s-2); color: var(--ink-2); font-size: 0.9rem; }
.look-summary .dot { width: 12px; height: 12px; flex: none; }
.look .when-open, .look[open] .when-closed { display: none; }
.look[open] .when-open { display: inline; }
.look[open] > summary { padding-bottom: var(--s-4); margin-bottom: var(--s-4); border-bottom: 1px solid var(--line); }
.look-body { display: grid; gap: 0; }
.accent-row { display: flex; gap: var(--s-2); align-items: center; }
.accent-row input[type='color'] { width: 64px; flex: none; }
#accent-note { font-weight: 400; color: var(--ink-2); }

/* Theme picker: each card is the host's own guide in that theme. */
.themes { display: grid; grid-template-columns: repeat(auto-fill, 158px); gap: var(--s-3); }
.themes legend { grid-column: 1 / -1; }
.themes-note { grid-column: 1 / -1; margin: calc(-1 * var(--s-2)) 0 0; }
.theme-option { position: relative; display: block; font-weight: 400; }
.theme-option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; min-height: 0; }
.theme-card { display: grid; align-content: start; gap: 2px; height: 100%; padding: 0 0 var(--s-3); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; cursor: pointer; }
.theme-thumb { display: block; width: 156px; height: 208px; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--bg); margin-bottom: var(--s-2); }
.theme-thumb iframe { width: 390px; height: 520px; border: 0; transform: scale(0.4); transform-origin: 0 0; pointer-events: none; }
.theme-card strong, .theme-card small { padding: 0 var(--s-3); }
.theme-card small { color: var(--ink-2); font-size: 0.8rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.theme-option:hover .theme-card { border-color: var(--ink-2); }
.theme-option input:checked + .theme-card { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.theme-option input:checked + .theme-card strong { color: var(--brand); }
.theme-option input:focus-visible + .theme-card { outline: 3px solid var(--focus); outline-offset: 2px; }
.theme-custom { text-decoration: none; color: inherit; }
.theme-custom .theme-card { border-style: dashed; padding: var(--s-3); align-content: center; }
.theme-custom .theme-card strong, .theme-custom .theme-card small { padding: 0; }
@media (max-width: 22.5rem) { .themes { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }
.danger-zone { margin-top: var(--s-3); text-align: right; }
.look-body .sub { margin-top: var(--s-4); }
.ready-fold > summary { cursor: pointer; font-weight: 600; color: var(--brand); min-height: 44px; display: flex; align-items: center; gap: var(--s-2); width: fit-content; }
.ready-fold[open] > summary { margin-bottom: 0; }
@media (max-width: 34rem) {
  .publish-bar { flex-wrap: nowrap; }
  .pb-guest { width: 44px; padding: 0; }
  .pb-guest-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.cover-preview:not(:has(img)) { background: transparent; border-style: dashed; }

/* Custom section icon picker: the current icon, then a grid of choices. */
.icon-pick { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.icon-pick > summary { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); cursor: pointer; list-style: none; font-weight: 600; }
.icon-pick > summary::-webkit-details-marker { display: none; }
.icon-now { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--brand); }
.icon-change { margin-left: auto; }
.icon-pick[open] .icon-change { visibility: hidden; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: var(--s-1); margin: 0; padding: 0 var(--s-3) var(--s-3); border: 0; }
.icon-opt { position: relative; display: block; cursor: pointer; }
.icon-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; min-height: 0; cursor: pointer; }
.icon-face { display: grid; place-items: center; height: 44px; border-radius: 8px; border: 1px solid transparent; color: var(--ink-2); background: var(--surface); }
.icon-opt:hover .icon-face { color: var(--ink); border-color: var(--line); }
.icon-opt input:checked + .icon-face { color: var(--brand); border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.icon-opt input:focus-visible + .icon-face { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Motion. Operate mode: motion explains what changed and where, never makes the host wait.
   1. Guide tabs: the page changes under a header that stays put; the tab marker slides over.
   2. Things that open (dialogs, sections, the phone guest view) grow out of where they were.
   3. Feedback: a press, a save reaching the preview, a fact ticked off, a new code or section.
   Reduced motion keeps the fades and colour changes (they carry state) and drops the movement. */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: 0.3s; animation-timing-function: var(--ease-out); }
::view-transition-old(root) { animation-duration: 0.12s; }
::view-transition-new(root) { animation-duration: 0.2s; }
/* Named elements form their own stacking context: lift the header so its fixed publish bar (phones) stays above the content. */
.guide-head { view-transition-name: guide-head; position: relative; z-index: 10; }
.publish-bar { view-transition-name: publish-bar; }
.guide-tabs a, .subtabs a { position: relative; isolation: isolate; }
.guide-tabs a[aria-current='page'] { border-bottom-color: transparent; }
.tab-mark { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand); view-transition-name: tab-mark; }
.subtabs a[aria-current='page'] { background: none; box-shadow: none; }
/* While it slides, the pill passes under the header's labels (the row itself is see-through:
   it sits on the page background). */
.guide-head .subtabs { background: transparent; }
::view-transition-group(subtab-mark) { z-index: 1; }
::view-transition-group(guide-head) { z-index: 2; }
::view-transition-group(tab-mark), ::view-transition-group(publish-bar) { z-index: 3; }
.subtab-mark { position: absolute; inset: 0; z-index: -1; border-radius: 7px; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); view-transition-name: subtab-mark; }

button, .button { transition: transform 0.08s ease-out, background-color 0.15s, border-color 0.15s, color 0.15s; }
button:active:not(:disabled), .button:active { transform: translateY(1px); }

dialog { opacity: 0; transform: translateY(6px) scale(0.98); transition: opacity 0.14s ease-in, transform 0.14s ease-in, overlay 0.14s allow-discrete, display 0.14s allow-discrete; }
dialog[open] { opacity: 1; transform: none; transition-duration: 0.24s; transition-timing-function: var(--ease-out); }
@starting-style { dialog[open] { opacity: 0; transform: translateY(10px) scale(0.98); } }
dialog::backdrop { transition: background-color 0.24s, overlay 0.24s allow-discrete, display 0.24s allow-discrete; }
@starting-style { dialog[open]::backdrop { background-color: rgb(20 20 20 / 0); } }
/* Without JavaScript, New code is a link to the dialog: show it in the page instead. */
html:not(.js) dialog:target, html:not(.js) dialog[data-autoopen] { display: block; position: static; opacity: 1; transform: none; margin: var(--s-5) 0; border: 1px solid var(--line); }

@supports (interpolate-size: allow-keywords) {
  details { interpolate-size: allow-keywords; }
  details::details-content { block-size: 0; overflow: clip; overflow-clip-margin: 6px; transition: block-size 0.24s var(--ease-out), content-visibility 0.24s allow-discrete; }
  details[open]::details-content { block-size: auto; }
}

.notice[role='status'], .row-undo { animation: note-in 0.28s var(--ease-out) both; }
@keyframes note-in { from { opacity: 0; transform: translateY(-4px); } }

/* Where the host's attention should land: the code just created, the section just added or opened. */
.qr-card:target, .qr-card[data-arrive], .section-card.arrived { animation: arrive 1.6s var(--ease-out); }
@keyframes arrive { from { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent); background-color: color-mix(in srgb, var(--ok-bg) 80%, var(--surface)); } }

.editor-preview .device iframe { transition: opacity 0.2s; }
.editor-preview .device.is-loading iframe { opacity: 0.6; transition-duration: 0.1s; }

.ready-list li.just-done .ico { animation: tick 0.45s var(--ease-out); color: var(--ok); }
@keyframes tick { from { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } }
.publish-bar .chip.bump { animation: bump 0.4s var(--ease-out); }
@keyframes bump { from { transform: scale(0.88); filter: brightness(0.92); } }

@media (max-width: 68rem) {
  .gv-open .editor-preview { animation: sheet-in 0.32s var(--ease-out); }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*) { animation-duration: 0s; }
  button:active:not(:disabled), .button:active { transform: none; }
  dialog, dialog[open], html:not(.js) dialog:target { transform: none; }
  @starting-style { dialog[open] { transform: none; } }
  details::details-content { transition: none; }
  @keyframes note-in { from { opacity: 0; } }
  @keyframes tick { from { opacity: 0; } }
  @keyframes bump { from { filter: brightness(0.92); } }
  @keyframes sheet-in { from { opacity: 0; } }
}

/* Admin → Emails: each email in a frame at phone-to-desktop width, its text version folded below. */
.email-jump { display: flex; flex-wrap: wrap; gap: 0 var(--s-4); margin: 0 0 var(--s-6); }
.email-jump a { font-weight: 600; padding-block: 10px; }
.email-preview { margin: 0 0 var(--s-7); max-width: 44rem; scroll-margin-top: var(--s-5); }
.email-preview h2 { margin-bottom: var(--s-1); }
.email-preview > .muted { margin: 0 0 var(--s-2); }
.email-subject { margin: 0 0 var(--s-3); font-weight: 600; }
.email-subject .muted { font-weight: 400; margin-right: var(--s-2); }
.email-preview iframe { display: block; width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.email-preview details { margin-top: var(--s-3); }
.email-preview summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: var(--s-2); }
.email-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-4); margin: var(--s-2) 0 0; }
