:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1f1d1a; --ink2: #4f4a44; --muted: #625d56; --line: #e4e0d7; --line2: #8a8377; --line-soft: #d6d1c6;
  --accent: #c2410c; --accent-ink: #9a3412; --ok: #276738; --warn-bg: #fdf3e2; --warn-ink: #5c3808; --err-bg: #fbe7e4; --err-ink: #7a1d10;
  --focus: #1f5fbf; --radius: 12px; --cta-h: 0px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 80px; scroll-padding-bottom: var(--cta-pad, 24px); }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 900; }
.skip:focus { left: 12px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* header */
.top { display: flex; align-items: center; gap: 28px; padding: 12px 32px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 800; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font: 600 22px var(--serif); }
.brand-name em { font-style: normal; color: var(--muted); font-weight: 400; }
.brand-sub { font-size: 12px; color: var(--muted); }
.steps { display: flex; gap: 10px; list-style: none; margin: 0; padding: 0; align-items: center; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 550; }
.step + .step::before { content: ""; width: 20px; height: 1px; background: var(--line-soft); margin-right: 2px; }
.step .n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #e7e2d8; color: var(--ink2); font-size: 13px; font-weight: 650; }
.step.current { color: var(--ink); }
.step.current .n { background: var(--ink); color: #fff; }
.step.done { color: var(--ink); }
.step.done .n { background: var(--ok); color: #fff; }
.step.done .n::after { content: "✓"; position: absolute; }
.step.done .n { position: relative; color: transparent; }
.step.done .n::after { color: #fff; }
.step.stale .n { background: #f1d9a8; color: #3b2a07; }
.top .link { margin-left: auto; }

main { max-width: 1320px; margin: 0 auto; padding: 16px 32px 60px; }
.intro { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin: 2px 0 14px; }
.intro h1 { font: 500 28px/1.15 var(--serif); margin: 0; letter-spacing: -0.01em; }
.lede { margin: 0; color: var(--ink2); font-size: 15px; max-width: 820px; }
.label { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); margin: 0 0 8px; }
.label.small { font-size: 11.5px; margin: 16px 0 8px; }
.label .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* template cards */
.template-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.template-help { margin: 8px 0 0; }
.tcard { display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; padding: 12px 6px 10px; min-height: 84px; background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius); cursor: pointer; }
.tcard:hover { border-color: #5f594f; }
.tcard[aria-checked="true"] { border: 2px solid var(--ink); padding: 11px 5px 9px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.tcard .ticon { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; background: #f0ece3; display: grid; place-items: center; color: var(--ink); }
.tcard[aria-checked="true"] .ticon { background: var(--ink); color: #fff; }
.tcard .tname { font-weight: 700; font-size: 16px; display: block; }
.tcard .tblurb { display: none; }

/* source */
.source-row { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.combo { position: relative; flex: 1 1 240px; }
.combo .icon { position: absolute; left: 18px; top: 50%; width: 20px; height: 20px; margin-top: -10px; color: var(--muted); }
.combo input { width: 100%; height: 54px; padding: 0 84px 0 50px; border: 1px solid var(--line2); border-radius: 999px; background: var(--card); font-size: 16px; }
.combo input:focus { border-color: var(--ink); outline: 3px solid var(--focus); outline-offset: 2px; }
.combo .clear { position: absolute; right: 10px; top: 50%; margin-top: -20px; width: 40px; height: 40px; border: 0; background: transparent; font-size: 24px; color: var(--muted); cursor: pointer; border-radius: 50%; }
.combo .clear:hover { background: #f1eee7; }
.spinner { position: absolute; right: 54px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border: 2px solid #d9d3c7; border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#search-list { position: absolute; left: 0; right: 0; top: 60px; z-index: 700; margin: 0; padding: 6px; list-style: none; background: var(--card); border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.14); max-height: 380px; overflow: auto; }
#search-list li[role="option"] { padding: 10px 12px; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-height: 44px; }
#search-list li[role="option"][aria-selected="true"], #search-list li[role="option"]:hover { background: #efebe3; }
#search-list li .name { font-weight: 600; }
#search-list li .name mark { background: none; color: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
#search-list li .sub { color: var(--muted); font-size: 13px; text-align: right; }
#search-list li.group { cursor: default; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 12px 4px; }
#search-list li.note { cursor: default; color: var(--muted); padding: 10px 12px; }
.source-extra { display: flex; gap: 10px; align-items: center; }
.selected { min-height: 22px; margin: 8px 4px 0; color: var(--ink2); }
.selected strong { color: var(--ink); }
.holes { margin-top: 6px; }
.hole-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.hole-grid .chip { min-width: 48px; padding: 6px 10px; flex-direction: column; gap: 0; line-height: 1.15; }
.hole-grid .chip small { font-size: 11px; font-weight: 500; color: var(--muted); }
.hole-grid .chip[aria-checked="true"] small { color: #e8e4dc; }

/* workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(360px, 1fr); gap: 28px; align-items: start; }
.mobile-top { display: contents; }
.preview { position: sticky; top: 76px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #e9e4da; border-radius: 999px; padding: 4px; }
.seg button { border: 0; background: transparent; padding: 8px 18px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--ink2); min-height: 44px; position: relative; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.dot-new { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: 2px; }
.panel { position: relative; isolation: isolate; width: 100%; aspect-ratio: 1 / 1; max-height: calc(100vh - 170px); border-radius: 18px; overflow: hidden; background: #e8e4db; border: 1px solid var(--line); }
#map { position: absolute; inset: 0; z-index: 0; background: #e8e4db; }
#map:focus-visible { outline-offset: -4px; }
.frame-box { position: absolute; z-index: 450; pointer-events: none; border: 2px solid var(--ink); border-radius: 2px; box-shadow: 0 0 0 4000px rgba(246, 244, 239, .58); }
.frame-pill { position: absolute; left: -2px; top: calc(100% + 8px); background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 8px; white-space: nowrap; }
/* handles: corners resize, the knob on a stem above the top edge turns the tile (they turn with the frame) */
.frame-box .fh { position: absolute; width: 16px; height: 16px; background: #fff; border: 2px solid var(--ink); border-radius: 4px; pointer-events: auto; touch-action: none; box-sizing: border-box; }
.frame-box .fh.nw { left: -9px; top: -9px; cursor: nwse-resize; } .frame-box .fh.se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.frame-box .fh.ne { right: -9px; top: -9px; cursor: nesw-resize; } .frame-box .fh.sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.frame-box .fh.rot { left: calc(50% - 10px); top: -46px; width: 20px; height: 20px; border-radius: 50%; cursor: grab; }
.frame-box .rot-stem { position: absolute; left: calc(50% - 1px); top: -28px; width: 2px; height: 26px; background: var(--ink); pointer-events: none; }
.frame-box.dragging { border-style: dashed; } .frame-box.dragging .fh.rot { cursor: grabbing; }
@media (pointer: coarse) { .frame-box .fh { width: 24px; height: 24px; } .frame-box .fh.nw, .frame-box .fh.sw { left: -13px; } .frame-box .fh.ne, .frame-box .fh.se { right: -13px; }
  .frame-box .fh.nw, .frame-box .fh.ne { top: -13px; } .frame-box .fh.sw, .frame-box .fh.se { bottom: -13px; } .frame-box .fh.rot { width: 26px; height: 26px; left: calc(50% - 13px); top: -52px; } }
.map-tools { position: absolute; right: 12px; bottom: 36px; z-index: 460; display: grid; grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); gap: 2px; }
.map-tools .mt { width: 40px; height: 40px; border: 1px solid var(--line2); background: rgba(255,255,255,.96); border-radius: 10px; cursor: pointer; font-size: 13px; color: var(--ink); }
.map-tools .mt:disabled { display: none; }
.map-tools .up { grid-column: 2; grid-row: 1; } .map-tools .left { grid-column: 1; grid-row: 2; } .map-tools .center { grid-column: 2; grid-row: 2; }
.map-tools .right { grid-column: 3; grid-row: 2; } .map-tools .down { grid-column: 2; grid-row: 3; }
.map-note { position: absolute; left: 12px; bottom: 28px; right: 150px; z-index: 460; margin: 0; background: rgba(255,255,255,.95); padding: 7px 11px; border-radius: 10px; font-size: 13px; color: var(--ink2); box-shadow: 0 1px 4px rgba(0,0,0,.12); width: fit-content; max-width: calc(100% - 170px); }
.panel-msg { position: absolute; inset: 0; z-index: 470; display: grid; place-content: center; text-align: center; padding: 30px; background: rgba(246,244,239,.9); color: var(--ink2); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 11px; }
.hole-pin { background: var(--card); border: 2px solid var(--ink); color: var(--ink); border-radius: 50%; display: grid !important; place-items: center; font: 700 12px var(--sans); box-shadow: 0 1px 3px rgba(0,0,0,.3); cursor: pointer; }
.hole-pin.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pin-mark { width: 22px !important; height: 22px !important; border-radius: 50% 50% 50% 0; background: var(--accent); transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.end-mark { border-radius: 50%; border: 3px solid var(--ink); background: #fff; }
.end-mark.finish { background: var(--ink); }
#viewer, #viewer-still { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #f3f1ec; }
#viewer-still { object-fit: cover; }
.viewer-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 30px; }
.viewer-empty p { margin: 4px 0; }
.badge { position: absolute; left: 12px; top: 12px; z-index: 5; background: rgba(31,29,26,.88); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 999px; }
.viewer-tools { position: absolute; right: 12px; top: 12px; z-index: 5; display: flex; gap: 6px; }
.caption { font-size: 13.5px; margin: 8px 2px 0; color: var(--muted); }

/* settings */
.settings { display: flex; flex-direction: column; gap: 22px; outline: none; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.block-head .value { font-weight: 650; font-size: 14px; }
details.block { border-top: 1px solid var(--line); padding-top: 10px; }
details.block > summary { cursor: pointer; list-style: none; padding: 6px 0; min-height: 44px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; display: inline-block; }
details.block[open] > summary::before { transform: rotate(90deg); }
details.block > summary .label { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line2); background: var(--card); border-radius: 12px; cursor: pointer; font-weight: 600; position: relative; text-align: center; }
.chip.small { min-height: 36px; padding: 4px 12px; font-size: 13px; }
.chip:hover { border-color: #5f594f; }
.chip[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.stack { flex-direction: column; gap: 2px; line-height: 1.15; }
.chip .rec { font-size: 10px; font-weight: 750; letter-spacing: .07em; color: var(--accent-ink); text-transform: uppercase; }
.chip[aria-checked="true"] .rec { color: #ffd2bd; }
.chip[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.swatch { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px; border: 1px solid var(--line2); border-radius: 14px; background: var(--card); cursor: pointer; text-align: left; position: relative; }
.swatch:hover { border-color: #5f594f; }
.swatch[aria-checked="true"] { border: 2px solid var(--ink); padding: 9px 11px; }
.swatch[aria-checked="true"]::after { content: "✓"; position: absolute; right: 10px; top: 8px; font-weight: 800; font-size: 13px; }
.swatch .sw { display: inline-flex; border-radius: 7px; overflow: hidden; border: 1px solid rgba(0,0,0,.35); flex: 0 0 auto; }
.swatch .sw i { width: 14px; height: 32px; display: block; }
.swatch .sname { font-weight: 650; }
.dot { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.45); display: inline-block; flex: 0 0 auto; }
.chip[aria-checked="true"] .dot { border-color: #fff; }
.help { font-size: 13.5px; color: var(--muted); margin: 8px 0 0; }
.help strong { color: var(--ink2); }
.help.center { text-align: center; }
.help.fine { font-size: 12.5px; }
.notes { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.notes li { font-size: 13px; padding: 7px 10px; border-radius: 9px; background: #eeeae2; color: var(--ink2); }
.notes li.warn { background: var(--warn-bg); color: var(--warn-ink); }
.field { position: relative; margin-top: 12px; }
.field label { display: block; font-weight: 650; font-size: 14px; margin-bottom: 4px; }
.field input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--line2); border-radius: 10px; background: var(--card); letter-spacing: .02em; }
.field input:focus { border-color: var(--ink); }
.field .count { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.field .count.warn { color: var(--warn-ink); font-weight: 600; }
.plate-preview { margin: 14px 0 0; padding: 18px 14px; background: #ebe7df; border-radius: 12px; }
#plate-preview { display: flex; justify-content: center; min-height: 36px; }
#plate-preview svg { width: 100%; max-width: 440px; height: auto; filter: drop-shadow(0 3px 6px rgba(0,0,0,.22)); }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 10px; cursor: pointer; }
.switch.small { font-size: 13.5px; margin: 0; min-height: 40px; }
.switch input { width: 20px; height: 20px; accent-color: var(--ink); flex: 0 0 auto; }
.reset-row { margin: 18px 0 0; }

/* CTA */
.cta { position: sticky; bottom: 16px; z-index: 600; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 12px; box-shadow: 0 12px 34px rgba(0,0,0,.12); }
.cta-status { font-size: 14px; color: var(--ink2); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 22px; }
.cta-status .state { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--ink); }
.cta-status .state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #b5afa3; }
.cta-status .state.ok::before { background: var(--ok); }
.cta-status .state.busy::before { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.cta-status .state.err::before { background: #b42318; }
.cta-status .state.stale::before { background: #d49a2a; }
@keyframes pulse { 50% { opacity: .35; } }
.primary { width: 100%; min-height: 54px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font-size: 17px; font-weight: 700; cursor: pointer; }
.primary.small { width: auto; min-height: 44px; padding: 0 22px; font-size: 15px; }
.primary[aria-disabled="true"] { background: #8a857c; cursor: not-allowed; }
.secondary { min-height: 44px; padding: 0 18px; border: 1px solid var(--ink); border-radius: 999px; background: var(--card); font-weight: 650; cursor: pointer; }
.secondary.small { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.link { border: 0; background: none; color: #1d4f99; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 40px; padding: 0 4px; font-weight: 600; }
.link.subtle { color: var(--muted); font-weight: 500; }
.link.light { color: #cfe0ff; }
.cta-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.cta-main { display: flex; gap: 8px; align-items: center; }
.cta-main .secondary { flex: 0 0 auto; min-height: 54px; }
.code-wrap { display: inline-flex; align-items: center; gap: 6px; }
.code-chip { font: 600 13px ui-monospace, Menlo, monospace; letter-spacing: .08em; background: #efebe3; padding: 4px 8px; border-radius: 6px; }
.alerts { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.alerts:empty { display: none; }
.alerts li { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; }
.alerts li.err { background: var(--err-bg); color: var(--err-ink); }
.alerts li.info { background: #eeeae2; color: var(--ink2); }
.alerts li .fix { margin-left: 6px; min-height: 32px; color: inherit; }
.log { margin: 0 0 10px; font-size: 13px; }
.log pre { max-height: 180px; overflow: auto; background: #f6f4ef; border-radius: 8px; padding: 8px; font-size: 11.5px; white-space: pre-wrap; }
.progress { margin-bottom: 10px; }
.bar { height: 8px; border-radius: 99px; background: #e9e4da; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
.progress-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 13.5px; margin-top: 4px; }

/* results + recent */
.results { margin-top: 30px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; outline: none; }
.results h3 { font-size: 15px; margin: 14px 0 6px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.files a, .files button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line2); border-radius: 10px; background: #faf9f6; color: var(--ink); text-decoration: none; font-weight: 600; cursor: pointer; }
.files a.primary-file { background: var(--ink); color: #fff; border-color: var(--ink); }
.files a small { font-weight: 500; color: var(--muted); }
.files a.primary-file small { color: #ddd; }
.result-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.result-grid img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.recent { margin-top: 34px; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.rcard { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.rcard:hover { border-color: #b9b2a5; box-shadow: 0 6px 18px rgba(0,0,0,.07); }
.rcard .rmain { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; width: 100%; height: 100%; }
.rcard .rmain:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: 12px; }
.rcard .thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: linear-gradient(180deg, #f8f7f4, #e4e2dc); }
.rcard .thumb.blank { display: grid; place-items: center; color: #b3ab9d; }
.rcard .thumb.blank svg { width: 36px; height: 36px; }
.rcard .rcap { padding: 10px 12px 12px; font-size: 12.5px; line-height: 1.4; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.rcard .rcap b { font-size: 13.5px; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard .rmeta { display: flex; align-items: center; gap: 6px; }
.rcard .state-dot { width: 7px; height: 7px; border-radius: 50%; background: #c9c2b5; flex: 0 0 auto; }
.rcard .state-dot.ok { background: var(--ok); }
.rcard .rremove { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); color: var(--ink2);
  font-size: 18px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.rcard:hover .rremove, .rcard .rremove:focus-visible { opacity: 1; }
@media (hover: none) { .rcard .rremove { opacity: .85; } }
.viewer-placeholder { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; z-index: 1; pointer-events: none; background: linear-gradient(180deg, #f8f7f4, #e4e2dc); }
.pill { position: fixed; left: 50%; bottom: calc(var(--cta-h) + 20px); transform: translateX(-50%); z-index: 850; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 14px; white-space: nowrap; box-shadow: 0 8px 24px rgba(0,0,0,.25); cursor: pointer; min-height: 44px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--cta-h) + 24px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 900; box-shadow: 0 8px 24px rgba(0,0,0,.25); display: flex; gap: 10px; align-items: center; max-width: calc(100vw - 32px); }
dialog { border: 0; border-radius: 16px; padding: 22px; width: min(420px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(31, 29, 26, .45); }
dialog h2 { font: 500 22px var(--serif); margin: 0 0 12px; }
dialog label { font-weight: 650; }
dialog input { width: 100%; height: 48px; border: 1px solid var(--line2); border-radius: 10px; padding: 0 12px; margin-top: 6px; font: 600 18px ui-monospace, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  #mobile-top .block { margin-bottom: 18px; }
  .preview { position: static; }
  .panel { max-height: 52vh; aspect-ratio: auto; height: min(52vh, 100vw); }
  .cta { position: fixed; left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(0,0,0,.12); }
  .cta .cta-sub { display: none; }
  .primary { min-height: 48px; font-size: 16px; }
  .cta-main .secondary { min-height: 48px; }
  main { padding-bottom: calc(var(--cta-h) + 24px); }
}
@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px 14px; padding: 10px 16px; position: static; }
  .steps { order: 3; width: 100%; font-size: 13px; gap: 6px; }
  .step + .step::before { width: 10px; }
  .top .link { font-size: 14px; }
  main { padding: 10px 16px calc(var(--cta-h) + 24px); }
  .intro h1 { font-size: 28px; }
  .lede { font-size: 15.5px; }
  .tcard { min-height: 76px; }
  .lede { display: none; }
  .source-extra { display: none; }
  .map-note { font-size: 12px; padding: 5px 8px; bottom: 26px; }
  .chips.grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .swatches { grid-template-columns: 1fr; }
  .map-note { right: auto; max-width: calc(100% - 150px); font-size: 12px; }
  .result-grid { grid-template-columns: 1fr; }
  .cta-status { font-size: 13px; margin-bottom: 6px; }
  .recent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---- v4: rotation, plate position picker, map layers, buildings check ---- */
.rotation { margin-top: 14px; }
.rot-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.rot-step { display: inline-flex; align-items: center; gap: 6px; }
.chip.icon { width: 44px; min-width: 44px; padding: 0; font-size: 20px; }
.rot-value { min-width: 52px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos-wrap { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.pos-grid { position: relative; width: 196px; height: 196px; flex: 0 0 auto; border-radius: 10px; border: 2px solid var(--ink);
            background: var(--pos-bg, #e3d8c2); box-shadow: inset 0 0 0 7px rgba(31, 29, 26, .22); }
.pos-grid .spot { position: absolute; width: 54px; height: 26px; border-radius: 6px; border: 2px dashed rgba(31, 29, 26, .55);
                  background: rgba(255, 255, 255, .55); cursor: pointer; padding: 0; display: grid; place-items: center; }
.pos-grid .spot:hover { background: rgba(255, 255, 255, .85); }
.pos-grid .spot[aria-checked="true"] { border: 2px solid var(--ink); background: #1f1d1a; }
.pos-grid .spot .sd { width: 10px; height: 10px; border-radius: 50%; background: #2f7a45; box-shadow: 0 0 0 2px #fff; }
.pos-grid .spot.warn .sd { background: #d49a2a; }
.pos-grid .spot.bad .sd { background: #b42318; }
.pos-grid .spot.unknown .sd { background: #9a948a; }
.pos-grid .spot[aria-checked="true"] .sd { box-shadow: 0 0 0 2px #1f1d1a; }
.pos-grid .spot.top-left { left: 12px; top: 12px; } .pos-grid .spot.top { left: calc(50% - 27px); top: 12px; } .pos-grid .spot.top-right { right: 12px; top: 12px; }
.pos-grid .spot.bottom-left { left: 12px; bottom: 12px; } .pos-grid .spot.bottom { left: calc(50% - 27px); bottom: 12px; } .pos-grid .spot.bottom-right { right: 12px; bottom: 12px; }
.pos-grid .spot[aria-checked="true"] .sd { box-shadow: 0 0 0 2px #fff; }
.pos-wrap .help { flex: 1 1 160px; margin-top: 0; }
details.sub { margin-top: 12px; }
details.sub > summary { cursor: pointer; font-weight: 650; min-height: 40px; display: flex; align-items: center; gap: 6px; }
.check-row { margin: 10px 0 0; }
.layer-toggle { position: absolute; top: 12px; right: 12px; z-index: 460; background: rgba(233, 228, 218, .95); }
.seg.small button { min-height: 36px; padding: 4px 12px; font-size: 13px; }
.bldg-foot { font-size: 12.5px; }
dialog.wide { width: min(980px, 94vw); }
#bldg-body img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
#bldg-body .verdict { font-size: 15px; margin: 0 0 10px; }
#bldg-body table { border-collapse: collapse; margin: 12px 0 4px; font-size: 13.5px; }
#bldg-body td { padding: 3px 14px 3px 0; }
#bldg-body td:first-child { color: var(--muted); }
.bldg-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 720px) { .bldg-grid { grid-template-columns: 1fr; } .pos-grid { width: 176px; height: 176px; } .pos-grid .spot { width: 46px; } .pos-grid .spot.top, .pos-grid .spot.bottom { left: calc(50% - 23px); } }

/* ---- v6: tile size + cost, print package, no CTA overlap ---- */
.settings-scroll { display: flex; flex-direction: column; gap: 22px; }
.chip .sub { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.chip[aria-checked="true"] .sub { color: #e8e4dc; }
.costs { margin: 12px 0 0; display: grid; gap: 6px; }
.costs > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 12px; background: #faf9f6; border: 1px solid var(--line); border-radius: 10px; font-size: 14.5px; }
.costs dt { color: var(--muted); font-weight: 600; white-space: nowrap; }
.costs dd { margin: 0; text-align: right; }
.costs .help { margin: 2px 2px 0; }
.warn-text { color: #8a4b08; font-size: 13.5px; margin: 6px 0; }
.files button[aria-disabled="true"] { opacity: .65; cursor: progress; }
.results details.sub { margin-top: 14px; }
.results details.sub > summary { cursor: pointer; font-weight: 650; min-height: 40px; display: flex; align-items: center; }
/* Desktop: the settings column scrolls inside itself and the action card sits under it — it used to float over the
   Map area / Rotation controls. Phones keep the fixed bottom bar. */
@media (min-width: 1081px) {
  .settings { position: sticky; top: 76px; max-height: calc(100vh - 176px); gap: 12px; }   /* fits from where it starts (under the intro) */
  .settings-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 14px 4px; margin: -4px -12px 0 -4px; scroll-padding: 12px; }
  .cta { position: static; flex: 0 0 auto; box-shadow: 0 4px 18px rgba(0,0,0,.08); }
}

/* ---------------------------------------------------------------- start from scratch, then three steps (09-29) --- */
.steps, .intro { display: none; }                            /* the numbered steps below carry the progress now */
.start { display: none; max-width: 640px; margin: 12vh auto 0; padding: 0 20px 80px; text-align: center; }
body[data-stage="start"] .start { display: block; }
body[data-stage="start"] .workspace, body[data-stage="start"] .results, body[data-stage="start"] #pill,
body[data-stage="start"] #mobile-top { display: none !important; }
.start h1 { font: 500 40px/1.12 var(--serif); letter-spacing: -0.015em; margin: 0 0 10px; }
.start-sub { font-size: 17px; color: var(--ink2); margin: 0 0 28px; }
.start-search .block.source { text-align: left; }
.start-search #s-label, .start-search #source-selected, .start-search #holes { display: none !important; }
.start-search .combo input { height: 62px; font-size: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.08); border-color: var(--line2); }
.start-search .combo .icon { left: 22px; }
.start-search .combo input { padding-left: 56px; }
.start-search #search-hint { text-align: center; margin-top: 12px; }
.start-steps { list-style: none; counter-reset: s; display: flex; justify-content: center; gap: 22px; flex-wrap: wrap;
               margin: 34px 0 0; padding: 0; color: var(--muted); font-size: 14px; }
.start-steps li { counter-increment: s; display: flex; align-items: center; gap: 8px; }
.start-steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line2);
                          display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--ink2); }
.start-steps li:first-child::before { background: var(--ink); border-color: var(--ink); color: #fff; }

/* numbered steps in the design column; the one to do next is marked */
.step-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff;
          font-size: 12px; font-weight: 700; letter-spacing: 0; margin-right: 8px; vertical-align: 1px; }
.step-title { margin-bottom: 12px; }
.step-group { display: flex; flex-direction: column; gap: 18px; }
.step-group .block.sub .label { font-size: 11.5px; }
.dstep { border-radius: 14px; transition: background .2s, box-shadow .2s; }
.dstep.is-next { background: var(--card); box-shadow: 0 0 0 2px var(--accent) inset; padding: 14px 14px 12px; margin: -14px -14px -12px; }
.dstep.is-next .step-n { background: var(--accent); }
.next-tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: #fff;
            font-size: 11px; font-weight: 700; letter-spacing: .06em; vertical-align: 2px; }
.cta-status .state.next { color: var(--accent-ink); }
.cta-status .state.next::before { background: var(--accent); }

/* quieter map: arrow buttons only for keyboard use (the map drags), no caption under it */
.map-tools { display: none; }
#panel-frame:focus-within .map-tools { display: grid; }
.caption:empty { display: none; }

/* recent designs live in the Open-a-design dialog */
#code-dialog { width: min(760px, calc(100vw - 32px)); }
.dialog-recent { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 18px; max-height: 52vh; overflow: auto; }
.dialog-recent .muted { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .start { margin-top: 7vh; }
  .start h1 { font-size: 31px; }
  .start-sub { font-size: 16px; margin-bottom: 20px; }
  .start-steps { gap: 12px; font-size: 13px; }
}

/* once a course, race or place is chosen, its search box says so: no second heading, no library hint */
body[data-stage="design"] #search-hint { display: none; }
#step-frame #holes-label { display: none; }                  /* the step is called Hole already */
#step-frame #holes { margin: 2px 0 12px; }

/* the 3D layer sits over the map (same box): the map → 3D hand-off crossfades instead of swapping tabs */
.stage-box { position: relative; }
#panel-3d { position: absolute; inset: 0; z-index: 2; transition: opacity .3s cubic-bezier(.2, 0, 0, 1); }
#panel-3d.enter { opacity: 0; }
#panel-frame.under { visibility: hidden; }

/* the build shows where the tile will appear: a pill centred in the framed square, and the square breathes */
.frame-build { position: absolute; z-index: 455; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px;
               background: rgba(31, 29, 26, .88); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
               white-space: nowrap; pointer-events: none; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.fb-ring { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: fbspin .9s linear infinite; }
@keyframes fbspin { to { transform: rotate(360deg); } }
.frame-box.building { animation: fbpulse 1.6s ease-in-out infinite; }
@keyframes fbpulse { 50% { border-color: var(--accent); } }

/* ---------------------------------------------------------------- one stage, stepper, one button per step (09-29) --- */
.preview-head { display: none; }                               /* no Frame / 3D tabs: the step decides what the stage shows */
.stepper ol { list-style: none; display: flex; gap: 6px; margin: 0 0 18px; padding: 0; flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; }
.stepper li + li::before { content: ""; width: 18px; height: 1px; background: var(--line-soft); margin: 0 6px 0 2px; }
.stepper button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 999px;
                  font-weight: 600; font-size: 14px; color: var(--muted); min-height: 32px; }
.stepper button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.stepper .sn { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #e7e2d8; color: var(--ink2); font-size: 12.5px; }
.stepper button[aria-current="step"] { color: var(--ink); background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.stepper button[aria-current="step"] .sn { background: var(--ink); color: #fff; }
.stepper button.done .sn { background: var(--ok); color: transparent; position: relative; }
.stepper button.done .sn::after { content: "✓"; position: absolute; color: #fff; font-size: 13px; }
.stepper button[disabled] { cursor: default; opacity: .55; }
.subject { margin: 0 0 14px; font-size: 15px; }
.subject #subject-name { font-weight: 650; }
/* what each step shows (body[data-step]) */
body[data-step="frame"] #step-look, body[data-step="frame"] #details { display: none !important; }
body[data-step="look"] #step-frame { display: none !important; }
body[data-stage="design"] #step-find, #step-frame > .block-head { display: none !important; }   /* the stepper names the step; search = start screen */
.dstep.is-next { box-shadow: none; background: none; padding: 0; margin: 0; }
.next-tag { display: none; }
/* 3D stage: the way back to the map, and rebuilds shown on the model itself */
.edit-area { position: absolute; left: 12px; top: 12px; z-index: 6; background: rgba(255, 255, 255, .94); }
#panel-3d.updating #viewer { opacity: .5; transition: opacity .2s; }
.stage-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7; }
.stage-bar { position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 7; background: transparent; }
.stage-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
#pill, #tab-3d-dot { display: none !important; }

#step-look > .step-title { display: none; }                   /* the stepper says Customise */
@media (max-width: 720px) {
  .stepper ol { flex-wrap: nowrap; margin-bottom: 14px; gap: 2px; }
  .stepper li + li::before { width: 10px; margin: 0 3px 0 1px; }
  .stepper button { padding: 4px 8px 4px 4px; font-size: 13.5px; gap: 6px; }
  .stepper .sn { width: 22px; height: 22px; font-size: 12px; }
}

/* the framed square looks like the product from above: the tile's frame ring, the rest of the map set back */
.frame-box { border-color: var(--ring-c, var(--ink)); box-shadow: 0 0 0 var(--ring, 0px) var(--ring-c, var(--ink)), 0 0 0 4000px rgba(246, 244, 239, .64); }

/* ---------------------------------------------------------------- customers and admin (09-30) --- */
/* header actions: Open a design · Our Etsy shop (customers) / Customer view (admin) */
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }
.top .top-actions .link { margin-left: 0; }
a.link { display: inline-flex; align-items: center; }
/* the order step: design code → Etsy listing → personalization box */
a.primary { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
#order-dialog { width: min(540px, calc(100vw - 32px)); }
.order-summary { margin: 0 0 14px; color: var(--ink2); }
.order-code { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 12px 14px; background: #faf9f6; border: 1px solid var(--line); border-radius: 12px; }
.order-code-label { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
.order-code .code-chip { font-size: 22px; padding: 6px 12px; }
.order-steps { margin: 16px 0 6px; padding-left: 22px; display: grid; gap: 6px; }
.order-status:empty { display: none; }
.order-status { color: var(--ink); font-weight: 600; }
.order-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
