/* Designer: fixed control sidebar left, canvas stage right; stacks on phones */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --soft: #f6f5f2;
  --line: #e8e4dd;
  --fg: #1f1d1a;
  --muted: #6b665e;
  --accent: #e0592a;
  --accent-ink: #b8431a;
  --accent-soft: #fdeee7;
  --ok: #18794e;
  --stage: #efece6;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 var(--body); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--fg); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }

.dz-top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--line); background: var(--bg); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; text-decoration: none; color: inherit; }
.brand b { color: var(--accent); }
.mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: var(--display); }
.dz-title { font-family: var(--display); font-weight: 700; font-size: 1.1rem; padding-left: 16px; border-left: 1px solid var(--line); }
.dz-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tool { border: 1px solid var(--line); background: var(--bg); border-radius: 9px; height: 36px; min-width: 36px; display: inline-grid; place-items: center; padding: 0 10px; font-weight: 700; font-size: .84rem; transition: background .15s, border-color .15s; }
.tool:hover:not(:disabled) { background: var(--soft); border-color: #d6d0c6; }
.tool:disabled { opacity: .4; cursor: default; }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool[aria-pressed="true"] { background: var(--fg); color: #fff; border-color: var(--fg); }
.tool.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.tool.primary:hover { background: var(--accent-ink); }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 42px; z-index: 20; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .14); padding: 6px; min-width: 240px; display: grid; }
.menu button { text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.menu button:hover, .menu button:focus-visible { background: var(--soft); }

.dz { flex: 1; display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 0; }
.side { border-right: 1px solid var(--line); overflow-y: auto; padding: 4px 18px 40px; background: var(--bg); }
.grp { padding: 16px 0; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.grp:last-child { border: 0; }
.grp h2 { margin: 0; font: 800 .72rem var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.field-label { font-weight: 700; font-size: .84rem; margin-top: 4px; }

.templates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tpl { border: 2px solid transparent; background: none; padding: 0; border-radius: 12px; overflow: hidden; text-align: left; position: relative; transition: border-color .15s, transform .15s; }
.tpl:hover { transform: translateY(-1px); }
.tpl canvas { width: 100%; aspect-ratio: 16 / 10; display: block; border-radius: 10px; background: var(--soft); }
.tpl span { display: block; padding: 5px 4px 2px; font-weight: 700; font-size: .8rem; }
.tpl[aria-checked="true"] { border-color: var(--accent); }
.tpl[aria-checked="true"]::after { content: '✓'; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .72rem; display: grid; place-items: center; font-weight: 800; }
.tpl-desc { margin: 0; color: var(--muted); font-size: .84rem; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset { border: 1px solid var(--line); background: var(--soft); border-radius: 99px; padding: 6px 12px; font-weight: 700; font-size: .8rem; transition: background .15s; }
.preset:hover { background: var(--accent-soft); border-color: #f3c7b4; }

.schemes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.scheme { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px; display: grid; gap: 6px; font-weight: 700; font-size: .78rem; text-align: left; transition: border-color .15s; }
.scheme i { display: flex; height: 14px; border-radius: 4px; overflow: hidden; }
.scheme i b { flex: 1; }
.scheme[aria-checked="true"] { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line); transition: transform .12s; }
.sw:hover { transform: scale(1.1); }
.sw[aria-checked="true"] { box-shadow: 0 0 0 2px var(--fg); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 7px 11px; font-weight: 600; font-size: .82rem; transition: background .15s, border-color .15s; }
.opt:hover { background: var(--soft); }
.opt[aria-checked="true"] { background: var(--fg); color: #fff; border-color: var(--fg); }

.range { display: grid; gap: 4px; font-weight: 700; font-size: .84rem; }
.range span { display: flex; justify-content: space-between; }
.range output { font-variant-numeric: tabular-nums; color: var(--accent-ink); }
.range input { width: 100%; accent-color: var(--accent); }
.hint { margin: 0; font-size: .8rem; color: var(--muted); }
.hint.warn { color: #b45309; }
.text { display: grid; gap: 4px; font-weight: 700; font-size: .84rem; }
.text input { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: 500 .9rem var(--body); color: var(--fg); background: var(--bg); }
.text input:focus { border-color: var(--fg); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.saved { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.saved li { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.saved img { width: 56px; height: 35px; object-fit: cover; border-radius: 6px; flex: none; }
.saved .nm { flex: 1; min-width: 0; font-weight: 700; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; text-align: left; padding: 0; }
.saved .nm small { display: block; color: var(--muted); font-weight: 500; }
.saved .del { border: 0; background: none; color: var(--muted); font-size: .78rem; font-weight: 700; }
.saved .del:hover { color: #b91c1c; }
.saved .none { border: 1px dashed var(--line); color: var(--muted); font-size: .82rem; justify-content: center; padding: 12px; }

.stage { background: var(--stage); display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; padding: 20px; min-width: 0; min-height: 0; }
.canvas-box { position: relative; align-self: center; justify-self: center; width: 100%; max-width: 1400px; aspect-ratio: 16 / 10; max-height: calc(100vh - 150px); border-radius: 16px; overflow: hidden; box-shadow: 0 2px 4px rgba(0, 0, 0, .06), 0 20px 50px rgba(0, 0, 0, .14); background: #ddd; }
@supports (aspect-ratio: 1) { .canvas-box { width: min(100%, calc((100vh - 150px) * 1.6)); } }
.canvas-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#view { transition: opacity .25s; }
.split .tag { position: absolute; top: 12px; z-index: 3; background: rgba(0, 0, 0, .6); color: #fff; font-weight: 800; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px; }
.split .l { left: 12px; } .split .r { right: 12px; }
.split input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; z-index: 4; margin: 0; }
.split-line { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; z-index: 2; transform: translateX(-50%); box-shadow: 0 0 10px rgba(0, 0, 0, .35); pointer-events: none; }
.split-line::after { content: '⟷'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 38px; height: 38px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; color: var(--fg); box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }
.split input:focus-visible + .split-line::after { outline: 3px solid var(--accent); }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: var(--soft); font-weight: 700; color: var(--muted); z-index: 5; transition: opacity .3s; }
.loading.done { opacity: 0; pointer-events: none; }
.spin { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.summary { text-align: center; color: var(--muted); font-size: .86rem; font-weight: 600; }
.summary b { color: var(--fg); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: calc(100% - 32px); }
.print-sheet { display: none; }

.tool.block { width: 100%; height: 40px; }
.vendors { display: grid; gap: 8px; }
.vrow { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 6px; transition: border-color .15s; }
.vrow.on { border-color: var(--accent); background: var(--accent-soft); }
.vrow img, .vrow .ph { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; background: var(--soft); }
.vrow label { display: grid; gap: 2px; font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); min-width: 0; }
.vrow select { border: 0; background: transparent; font: 700 .88rem var(--body); color: var(--fg); padding: 0; text-transform: none; letter-spacing: 0; width: 100%; text-overflow: ellipsis; }
.vrow small { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: .76rem; }
.vrow small a { color: var(--accent-ink); }
.estimate { display: grid; gap: 4px; font-size: .84rem; font-variant-numeric: tabular-nums; }
.estimate div { display: flex; justify-content: space-between; gap: 8px; }
.estimate .tot { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 800; }
/* photo button */
.tool.photo { display: inline-flex; align-items: center; background: var(--fg); color: #fff; border-color: var(--fg); }
.tool.photo::before { content: '✦'; margin-right: 6px; color: #ffcf8a; }
.tool.photo:hover { background: #3a362f; }
.switch { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: .84rem; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .8rem; }
.pmodal { position: fixed; inset: 0; z-index: 70; background: rgba(20, 16, 12, .6); display: grid; place-items: center; padding: 16px; }
.psheet { background: var(--bg); border-radius: 18px; width: min(1100px, 100%); max-height: calc(100vh - 32px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.phead { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.phead h2 { margin: 0; font-family: var(--display); font-size: 1.2rem; }
.phead .tool { margin-left: auto; }
.pbody { position: relative; background: var(--stage); min-height: 0; display: grid; place-items: center; }
.pbody canvas { width: 100%; height: auto; max-height: calc(100vh - 170px); object-fit: contain; display: block; }
.pwait { display: grid; justify-items: center; gap: 10px; padding: 80px 24px; text-align: center; color: var(--muted); width: 100%; aspect-ratio: 16 / 10; align-content: center; }
.pwait b { color: var(--fg); }
.pbar { width: min(320px, 80%); height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.pbar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s linear; }
.perr { margin: 0; padding: 60px 24px; text-align: center; font-weight: 600; color: #b45309; }
.pfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pact { display: flex; gap: 8px; }

@media (max-width: 1100px) {
  .dz { grid-template-columns: 290px minmax(0, 1fr); }
  .dz-title { display: none; }
}
@media (max-width: 760px) {
  body { height: auto; }
  .dz { grid-template-columns: 1fr; }
  .stage { order: -1; padding: 12px; position: sticky; top: 0; z-index: 10; }
  .canvas-box { width: 100%; max-height: none; border-radius: 12px; }
  .summary { display: none; }
  .side { border: 0; padding-inline: 16px; overflow: visible; }
  .dz-top { padding-inline: 16px; }
  .dz-tools { margin-left: 0; width: 100%; }
  .sep { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block !important; padding: 0; color: #000; font-family: var(--body); }
  .print-sheet img { width: 100%; border-radius: 0; }
  .print-sheet h1 { font-family: var(--display); margin: 0 0 4px; }
  .print-sheet table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 11pt; }
  .print-sheet td { border-bottom: 1px solid #ccc; padding: 6px 4px; }
  .print-sheet td:first-child { font-weight: 700; width: 30%; }
  @page { size: landscape; margin: 12mm; }
}
