/* editor.css — dark "studio" surface for the editor.
 * See docs/design-system.md for tokens and rationale.
 */

:root {
  --bg:        #161410;
  --panel:     #1c1a16;
  --panel-2:   #221f1a;
  --line:      #2c2924;
  --line-2:    #3a362f;
  --ink:       #ece6d6;
  --ink-2:     #b3ad9e;
  --ink-3:     #948e81;   /* 5.3:1 on --panel (WCAG AA) */
  --accent:    #ff7a3a;
  --accent-2:  #ffb43a;
  --good:      #6ec074;
  --pad:       18px;
  --radius:    10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 "Inter", "Inter Fallback", -apple-system, system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

/* ── Shell ────────────────────────────────────────────────────────────── */

.shell {
  display: grid; grid-template-rows: 48px 1fr;
  height: 100vh;
  /* dvh excludes the mobile browser URL bar — 100vh crops the stage bottom */
  height: 100dvh;
}
.body  { display: grid; grid-template-columns: 340px 1fr; min-height: 0; }

/* ── Topbar ───────────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  z-index: 4;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: "Playfair Display", "Playfair Fallback", Georgia, serif;
  font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none;
}
.brand .mark { width: 22px; height: 22px; display: grid; place-items: center; color: var(--ink); }
.brand sup { font-size: 9px; color: var(--ink-3); margin-left: 4px; vertical-align: super; }

.topbar .doc {
  display: flex; align-items: center; gap: 10px;
  margin-left: 18px;
  color: var(--ink-2);
  font-size: 12.5px;
  min-width: 0;
}
.topbar .doc .name {
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .grow { flex: 1; }
/* ── Sidebar ──────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: 4px;
  border: 2px solid transparent; background-clip: content-box;
}

.sect { padding: 16px var(--pad) 6px; }
.sect h3 {
  margin: 0 0 10px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  display: flex; justify-content: space-between; align-items: baseline;
}
.sect h3 .meta { color: var(--ink-3); font-weight: 500; letter-spacing: 0.04em; }
.sect + .sect { border-top: 1px solid var(--line); margin-top: 4px; }
details.sect { border-top: 1px solid var(--line); margin-top: 4px; }
details.sect > summary {
  list-style: none;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; user-select: none; margin-bottom: 0;
  min-height: 32px;
}
details.sect > summary::-webkit-details-marker { display: none; }
details.sect > summary::after {
  content: '›';
  font-size: 15px; font-weight: 300; color: var(--ink-3);
  display: inline-block; transition: transform .15s;
}
details.sect[open] > summary::after { transform: rotate(90deg); }
details.sect[open] > summary { margin-bottom: 10px; }

/* Location button */
.locbtn {
  width: 100%; text-align: left; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  transition: border-color .12s, background .12s;
  color: inherit;
}
.locbtn:hover { border-color: var(--line-2); }
.locbtn .pin { color: var(--accent); display: grid; place-items: center; }
.locbtn .city { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
.locbtn .country { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.locbtn .kbd {
  font: 11px "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, monospace; color: var(--ink-3);
  border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 6px;
}

/* Zoom slider */
.zoomrow {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11.5px; color: var(--ink-3);
}
.zoom-track { position: relative; height: 30px; display: flex; align-items: center; }
.zoom-track input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 999px;
  background: var(--line); outline: none; margin: 0;
}
.zoom-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line-2);
  cursor: grab;
}
.zoom-track input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line-2);
}
.zoom-ticks {
  position: absolute; left: 0; right: 0; top: 22px;
  display: flex; justify-content: space-between;
  pointer-events: none;
  font: 10px "JetBrains Mono", "JetBrains Mono Fallback", monospace;
  color: var(--ink-3);
}

/* Card grids (palette / layout) */
.cardgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.styleCard {
  position: relative; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2); padding: 10px;
  transition: border-color .12s;
  text-align: left;
  color: inherit;
}
.styleCard:hover { border-color: var(--line-2); }
.styleCard[data-on="1"] {
  border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset;
}
.styleCard .thumb {
  height: 64px; border-radius: 5px; margin-bottom: 8px;
  overflow: hidden; position: relative;
  display: grid; place-items: center;
}
.styleCard .thumb svg { display: block; width: 100%; height: 100%; }
.styleCard .name { font-size: 12px; font-weight: 600; letter-spacing: -0.005em; }
.styleCard .desc { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; line-height: 1.3; }
.styleCard .pill {
  position: absolute; top: 6px; right: 6px;
  font: 600 9px "JetBrains Mono", "JetBrains Mono Fallback", monospace; letter-spacing: 0.1em;
  color: var(--bg); background: var(--accent);
  padding: 2px 6px; border-radius: 999px;
}

/* Frame grid — 5 squat tiles */
.framegrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.frameCard {
  position: relative; cursor: pointer;
  border: 1px solid var(--line); border-radius: 7px;
  padding: 6px; padding-bottom: 4px;
  background: var(--panel-2);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  text-align: center; color: inherit;
  transition: border-color .12s;
}
.frameCard:hover { border-color: var(--line-2); }
.frameCard[data-on="1"] {
  border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset;
}
.frameCard .swatch {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}
.frameCard .name { font: 600 9.5px "Inter", "Inter Fallback", sans-serif; color: var(--ink-2); }
.frameCard[data-on="1"] .name { color: var(--ink); }

.swatch.f-none    { background: transparent; border: 1px dashed var(--line-2); }
.swatch.f-white   { background: linear-gradient(135deg, #f7f3e7, #c9bf9f); }
.swatch.f-black   { background: linear-gradient(135deg, #2a241e, #0d0b09); }
.swatch.f-natural { background: linear-gradient(135deg, #d9b886, #a78048); }
.swatch.f-brown   { background: linear-gradient(135deg, #6b4a2a, #3a2614); }

/* Form rows */
.fieldrow { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.fieldrow:first-child { margin-top: 0; }
.fieldrow label {
  font-size: 11px; color: var(--ink-2); letter-spacing: 0.02em;
  display: flex; justify-content: space-between; align-items: baseline;
}
.fieldrow label .meta-inline {
  font: 500 10px "JetBrains Mono", "JetBrains Mono Fallback", monospace; color: var(--ink-3);
}
.field {
  appearance: none; width: 100%;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 10px; font-size: 13px;
  color: var(--ink); outline: none;
}
.field:focus { border-color: var(--accent); background: #25221c; }
.field::placeholder { color: var(--ink-3); }

.toggle {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px;
}
.toggle .lbl { color: var(--ink-2); font-size: 12px; }
.sw {
  position: relative; width: 36px; height: 20px;
  border-radius: 999px; background: var(--line); border: 0;
  cursor: pointer; transition: background .15s;
  padding: 0;
}
.sw[data-on="1"] { background: var(--accent); }
.sw::before { content: ''; position: absolute; inset: -12px -6px; }  /* 48×44 hit area */
.sw i {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--ink);
  transition: transform .15s;
}
.sw[data-on="1"] i { transform: translateX(16px); }

.orient-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px;
}
.orient-row .lbl { color: var(--ink-2); font-size: 12px; }
.orient-seg {
  display: inline-flex; padding: 2px;
  border: 1px solid var(--line); border-radius: 8px; gap: 1px;
}
.orient-btn {
  appearance: none; background: transparent; border: 0; padding: 7px 10px; min-width: 36px; min-height: 32px;
  border-radius: 6px; color: var(--ink-3); cursor: pointer;
  display: grid; place-items: center;
  transition: background .12s, color .12s;
}
.orient-btn[data-on="1"] { background: var(--panel-2); color: var(--ink); }
.orient-btn:hover:not([data-on="1"]) { color: var(--ink-2); background: var(--line); }

.seg-btn {
  appearance: none; background: transparent; border: 0; padding: 6px 10px; min-height: 32px;
  border-radius: 6px; color: var(--ink-3); cursor: pointer;
  font-size: 12px; font-weight: 500;
  transition: background .12s, color .12s;
}
.seg-btn[data-on="1"] { background: var(--panel-2); color: var(--ink); }
.seg-btn:hover:not([data-on="1"]) { color: var(--ink-2); background: var(--line); }
.seg-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* Status line */
#status {
  margin-top: 8px;
  font: 11px "JetBrains Mono", "JetBrains Mono Fallback", monospace;
  color: var(--ink-3);
  min-height: 1.2em;
}

/* Buttons */
.btn {
  appearance: none; cursor: pointer;
  height: 38px; border-radius: 8px; padding: 0 14px;
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, transform .04s;
  width: 100%;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .styleCard:focus-visible, .frameCard:focus-visible, .locbtn:focus-visible,
.orient-btn:focus-visible, .sw:focus-visible, .search-region-card:focus-visible, .searchsheet .result:focus-visible,
details.sect > summary:focus-visible, .brand:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn.secondary {
  background: transparent; border-color: var(--line-2); color: var(--ink);
}
.btn.secondary:hover:not(:disabled) { background: var(--panel-2); }
.btn.primary {
  background: var(--ink); color: #1a0f08;
}
.btn.primary:hover:not(:disabled) { background: #fff; }
.btn.ghost {
  background: transparent; color: var(--ink-2); border: 0; width: auto; height: 32px;
}
.btn.ghost:hover { color: var(--ink); }

/* Generate button — accent so it stands out */
#btn-generate {
  background: var(--accent); color: #1a0f08; border-color: var(--accent);
  margin-top: 12px;
}
#btn-generate:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }

/* Action bar — Buy + downloads, always visible at the bottom of the sidebar */
.actionbar {
  position: sticky; bottom: 0; z-index: 2;
  margin-top: auto;
  padding: 12px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: var(--panel);
  display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px;
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 20px rgba(0,0,0,0.25);
}
.actionbar .btn { margin: 0; }
.actionbar .iconbtn { padding: 0; }
.buysect { grid-column: 1 / -1; }
.buysect[hidden] { display: none; }
.btn.buy {
  background: var(--accent); color: #1a0f08; border-color: var(--accent);
  height: 42px; font-size: 13.5px;
}
.btn.buy:hover:not(:disabled) {
  background: var(--accent-2); border-color: var(--accent-2);
}

/* ── Stage ────────────────────────────────────────────────────────────── */

.stage {
  position: relative; min-width: 0; min-height: 0;
  background:
    radial-gradient(1200px 800px at 50% 35%, #ece5d2 0%, #d6cfbc 75%);
  display: grid;
  grid-template-rows: 1fr;
  grid-template-columns: 1fr;
  overflow: hidden;
}
.stage-credit {
  position: absolute; right: 10px; bottom: 6px; margin: 0; z-index: 1;
  font-size: 10.5px; color: #5d5647;
}
.stage-credit a { color: inherit; }

/* Preview zoom (view-only) */
.stageInner { touch-action: pan-y; }
.stageInner.zoomed { touch-action: none; cursor: grab; }
.stageInner.zoomed:active { cursor: grabbing; }
.poster-mount { transform-origin: 50% 50%; will-change: transform; }
.view-zoom {
  position: absolute; left: 10px; bottom: 10px; z-index: 2;
  display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px;
  background: rgba(20,18,14,0.78); overflow: hidden;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.view-zoom button {
  all: unset; box-sizing: border-box; cursor: pointer;
  min-width: 32px; height: 30px; padding: 0 8px; text-align: center; line-height: 30px;
  font: 12px "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, monospace;
  color: var(--ink);
}
.view-zoom button:hover { background: rgba(255,255,255,0.1); }
.view-zoom button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
#view-zoom-reset { min-width: 54px; border-inline: 1px solid var(--line-2); }
.order-note a { color: var(--ink); }
.stageInner {
  position: relative; min-height: 0; min-width: 0;
  display: grid; place-items: center;
  padding: 36px;
}

/* The poster mount + frame moulding wraps the print */
.poster-mount {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  min-height: 0; min-width: 0;
}
.frame-shell {
  --moulding: 0px;
  --matt: 0px;
  /* width/height set by fitFrameToStage() in JS — supports all aspect ratios */
  flex-shrink: 0;
  padding: var(--moulding);
  border-radius: 1px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04),
    0 30px 60px rgba(0,0,0,0.55),
    0 8px 18px rgba(0,0,0,0.4);
  transition: width .3s ease, height .3s ease, padding .25s ease, background .25s ease;
}
.frame-shell .matt {
  width: 100%; height: 100%;
  padding: var(--matt);
  background: var(--matt-bg, transparent);
  transition: padding .25s ease, background .25s ease;
}

/* Frame variants */
.frame-shell[data-frame="none"]    { --moulding: 0px;  --matt: 0px;  background: transparent; }
.frame-shell[data-frame="white"]   { --moulding: 14px; --matt: 22px; background: linear-gradient(135deg, #f7f3e7, #d8cfb8); --matt-bg: #f4efe2; }
.frame-shell[data-frame="black"]   { --moulding: 14px; --matt: 22px; background: linear-gradient(135deg, #2a241e, #0d0b09); --matt-bg: #f4efe2; }
.frame-shell[data-frame="natural"] { --moulding: 14px; --matt: 22px; background: linear-gradient(135deg, #d9b886, #a78048); --matt-bg: #f4efe2; }
.frame-shell[data-frame="brown"]   { --moulding: 14px; --matt: 22px; background: linear-gradient(135deg, #6b4a2a, #3a2614); --matt-bg: #f4efe2; }

.poster-frame {
  position: relative;
  width: 100%; height: 100%;
  aspect-ratio: var(--ar, 2 / 3);
  overflow: hidden;
  background: #fff;
}
.map-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.chrome {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* Generating chip */
.genchip {
  position: absolute; top: 14px; right: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 8px;
  /* No backdrop-filter: blurring the canvas while it redraws every frame is
     needless GPU work on phones. */
  background: rgba(20,18,14,0.9);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font: 11px "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, monospace;
  color: var(--ink);
  letter-spacing: 0.02em;
  z-index: 5;
  pointer-events: none;
}
.genchip[hidden] { display: none; }

/* Error / slow-load notice shown on the poster */
.stage-notice {
  position: absolute; left: 14px; right: 14px; bottom: 14px;
  padding: 10px 12px;
  background: rgba(20,18,14,0.88);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font: 500 13px/1.45 "Inter", "Inter Fallback", system-ui, sans-serif;
  color: var(--ink);
  z-index: 6;
}
.stage-notice[hidden] { display: none; }
.stage-notice .notice-actions { display: flex; gap: 8px; margin-top: 8px; }
.stage-notice .notice-actions .btn { width: auto; height: 30px; padding: 0 12px; font-size: 12px; }
.genchip .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(255,122,58,.6);
  animation: pulse 1.1s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,122,58,.6); }
  70%  { box-shadow: 0 0 0 8px rgba(255,122,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,122,58,0); }
}

/* ── Location picker overlay ─────────────────────────────────────────── */

dialog.sheet {
  padding: 0; border: 0; background: transparent; color: inherit;
  margin: 10vh auto auto; max-height: 80vh; overflow: visible;
}
dialog.sheet::backdrop { background: rgba(8,7,5,0.55); animation: fadein .14s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.searchsheet {
  width: min(580px, 94vw);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
}

/* Region cards row */
.search-regions {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.search-regions::-webkit-scrollbar { display: none; }

.search-region-card {
  flex-shrink: 0; width: 84px;
  background: #0f0e0c; border: 2px solid var(--line-2);
  border-radius: 8px; overflow: hidden; cursor: pointer;
  padding: 0; text-align: center;
  box-sizing: border-box;
  appearance: none; -webkit-appearance: none;
  transition: border-color .12s, transform .12s;
  outline: none;
}
.search-region-card:hover { border-color: var(--line); transform: translateY(-1px); }
.search-region-card:focus-visible { border-color: var(--accent); }
.search-region-card.is-active { border-color: var(--accent); transform: translateY(-1px); }
.search-region-card.is-active span { color: var(--accent); }

.search-region-card object,
.search-region-card img,
.search-region-card .search-region-placeholder {
  display: block; width: 100%; height: 56px;
  object-fit: cover;
  pointer-events: none;
}
.search-region-card .search-region-placeholder {
  background: linear-gradient(135deg, #1a1a2e, #2e2a4e);
}

.search-region-card span {
  display: block; padding: 4px 3px 5px;
  font: 600 9.5px "JetBrains Mono", "JetBrains Mono Fallback", monospace;
  letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--ink-3); line-height: 1.2;
}

/* Input row */
.search-inputrow {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.search-inputrow .search-pin { color: var(--accent); flex-shrink: 0; }
.search-inputrow input {
  flex: 1; background: transparent; border: 0; outline: none;
  padding: 15px 0; font-size: 16px; color: var(--ink);
}
.search-inputrow input::placeholder { color: var(--ink-3); }
.search-inputrow input::-webkit-search-cancel-button { display: none; }
.search-close {
  background: none; border: 0; color: var(--ink-3); cursor: pointer;
  width: 44px; height: 44px; margin-right: -10px; font-size: 16px;
}
.search-close:hover { color: var(--ink); }

/* Results list */
.searchsheet ul { list-style: none; margin: 0; padding: 6px; max-height: 44vh; overflow-y: auto; }
.searchsheet .result {
  width: 100%; min-height: 44px; text-align: left;
  background: none; border: 0; color: inherit; font: inherit;
  padding: 9px 12px; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px;
}
.searchsheet .result:hover, .searchsheet .result:focus-visible { background: var(--panel-2); }
.searchsheet .result .name { font-size: 14px; }
.searchsheet .result .country { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }
.searchsheet .pin { color: var(--accent); flex-shrink: 0; }

/* Geocode result — stacked name + full address */
.searchsheet .result.geocode-result { align-items: flex-start; }
.result-stack { display: flex; flex-direction: column; gap: 2px; }
.result-stack .name { font-size: 14px; font-weight: 600; }
.result-stack .full-address { font-size: 11.5px; color: var(--ink-3); line-height: 1.4; }

/* Feedback line */
.search-feedback {
  padding: 10px 16px 12px;
  font: 12px "JetBrains Mono", "JetBrains Mono Fallback", monospace;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--line);
}
.search-feedback[hidden] { display: none; }
.search-feedback.err  { color: #e06060; }
.search-feedback.err::before  { content: '✕  '; }

/* SVG icon defaults */
.icon-svg {
  width: 16px; height: 16px; flex-shrink: 0;
  stroke: currentColor; fill: none; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ── Order a print modal ────────────────────────────────────────────── */
.ordersheet {
  width: min(360px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  display: flex; flex-direction: column;
}
.ordersheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.ordersheet-title { font-size: 15px; font-weight: 700; margin: 0; }
.ordersheet-close {
  background: none; border: none; color: var(--ink-3); cursor: pointer;
  font-size: 18px; line-height: 1; width: 44px; height: 44px; margin: -10px -12px -10px 0;
}
.ordersheet-close:hover { color: var(--ink); }
.ordersheet-body { padding: 20px 18px; }
.order-status { font-size: 13px; color: var(--ink-3); margin: 0; }
.order-note { font-size: 12px; line-height: 1.5; color: var(--ink-2); margin: 10px 0 0; }
.ordersheet-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.order-error { font-size: 12px; color: #e06060; margin: 0; }
.order-error[hidden] { display: none; }
.order-checkout { width: 100%; justify-content: center; }
.order-checkout:disabled { opacity: 0.45; cursor: not-allowed; }

/* Toast (link copied, errors) */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 60;
  padding: 10px 16px; border-radius: 999px;
  background: var(--ink); color: #1a0f08;
  font-weight: 600; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  animation: fadein .14s;
}
.toast[hidden] { display: none; }

/* Desktop: the split handle only exists on phones */
.split-handle { display: none; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .stageInner { padding: 18px; }
}

/* Touch devices: the ⌘K hint is meaningless; bigger targets; 16px text
   fields so iOS Safari doesn't zoom in on focus. */
@media (pointer: coarse) {
  .locbtn .kbd { display: none; }
  .field { font-size: 16px; padding: 10px 12px; }
  .orient-btn { min-width: 44px; min-height: 40px; }
  .seg-btn { min-height: 40px; padding: 6px 12px; }
  .btn { height: 44px; }
}

/* Phones: stack — preview on top (as big as the poster needs, capped),
 * controls scroll below. --poster-hw (h/w ratio) is set from JS on
 * orientation change so the stage hugs the poster's aspect. */
@media (max-width: 600px) {
  .body {
    grid-template-columns: 1fr;
  }
  .stage {
    grid-row: 1; grid-column: 1;
    height: var(--stage-h, min(
      calc((100vw - 28px - var(--frame-pad, 0px)) * var(--poster-hw, 1.414) + 28px + var(--frame-pad, 0px)),
      calc((100dvh - 48px) * 0.4)
    ));
  }
  .body { grid-template-rows: auto auto minmax(0, 1fr); }
  .sidebar { grid-row: 3; }
  .split-handle {
    grid-row: 2; grid-column: 1;
    display: flex; align-items: center; justify-content: center;
    height: 20px; cursor: ns-resize; touch-action: none; user-select: none;
    background: var(--panel); border-top: 1px solid var(--line);
    -webkit-tap-highlight-color: transparent;
  }
  .split-handle .grip {
    width: 44px; height: 5px; border-radius: 3px; background: var(--line-2);
    transition: background .12s, width .12s;
  }
  .split-handle:hover .grip, .split-handle:focus-visible .grip,
  .split-handle.dragging .grip { background: var(--ink); width: 56px; }
  .split-handle:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

  .sidebar {
    grid-column: 1;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .stageInner { padding: 14px; }
  .stage-credit { display: none; }

  /* Give the controls room: tighter sections, swipeable card strips */
  .sect { padding: 12px 14px 4px; }
  .sect h3 { margin-bottom: 8px; }
  .locbtn { padding: 8px 12px; }
  .cardgrid {
    display: flex; gap: 8px; overflow-x: auto;
    margin: 0 -14px; padding: 0 14px 8px;
    scroll-snap-type: x proximity; scrollbar-width: none;
  }
  .cardgrid::-webkit-scrollbar { display: none; }
  .cardgrid .styleCard { flex: 0 0 112px; scroll-snap-align: start; padding: 8px; }
  .styleCard .thumb { height: 52px; margin-bottom: 6px; }
  .styleCard .desc { display: none; }
  .actionbar { padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); }
  .btn.buy { height: 44px; }

  /* Location picker: full-screen sheet so the keyboard doesn't hide results */
  dialog#search-scrim { margin: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; }
  dialog#search-scrim .searchsheet {
    width: 100%; height: 100%; border-radius: 0; border: 0;
    display: flex; flex-direction: column;
  }
  dialog#search-scrim ul { max-height: none; flex: 1; }
  .toast { bottom: calc(120px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .genchip .pulse, .export-spin-ring { animation: none; }
  dialog.sheet::backdrop, .toast { animation: none; }
  .frame-shell, .frame-shell .matt, .sw, .sw i, .styleCard, .search-region-card { transition: none; }
}

/* ── Export spinner ────────────────────────────────────────────────── */
.export-spin-ring {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
