/* Tee Studio — print-shop workbench: order ticket on the left, print bed on the right.
   No inline styles anywhere (CSP style-src 'self'); colours are tokens. */

:root {
  --paper: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #151922;
  --graphite: #586072;
  --rule: #d8dce4;
  --rule-strong: #b9c0cc;
  --accent: #2b44d6;
  --accent-hover: #2236b4;
  --accent-ink: #ffffff;
  --accent-soft: #e8ecfd;
  --ok: #1d7748;
  --ok-soft: #e2f2e9;
  --hand: #1d7748;
  --warn: #8f5400;
  --warn-soft: #fbefd9;
  --bad: #b42318;
  --bad-soft: #fbe8e5;
  --checker-a: #d9dce2;
  --checker-b: #ffffff;
  --radius-s: 6px;
  --radius-m: 10px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1217;
    --surface: #171b22;
    --surface-2: #1c212a;
    --ink: #e8ebf1;
    --graphite: #9aa3b3;
    --rule: #2a313c;
    --rule-strong: #3b4452;
    --accent: #8396ff;
    --accent-hover: #a3b1ff;
    --accent-ink: #0f1217;
    --accent-soft: #1f2748;
    --ok: #63c992;
    --ok-soft: #15301f;
    --hand: #63c992;
    --warn: #e6a94e;
    --warn-soft: #33270f;
    --bad: #ff8172;
    --bad-soft: #3a1915;
    --checker-a: #2b3038;
    --checker-b: #3a404a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0f1217;
  --surface: #171b22;
  --surface-2: #1c212a;
  --ink: #e8ebf1;
  --graphite: #9aa3b3;
  --rule: #2a313c;
  --rule-strong: #3b4452;
  --accent: #8396ff;
  --accent-hover: #a3b1ff;
  --accent-ink: #0f1217;
  --accent-soft: #1f2748;
  --ok: #63c992;
  --ok-soft: #15301f;
  --hand: #63c992;
  --warn: #e6a94e;
  --warn-soft: #33270f;
  --bad: #ff8172;
  --bad-soft: #3a1915;
  --checker-a: #2b3038;
  --checker-b: #3a404a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
.muted { color: var(--graphite); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ------------------------------------------------------------ top bar */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; position: relative; flex: none; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; }
.brand-mark::before { inset: 3px; border: 2px solid var(--accent); border-radius: 50%; }
.brand-mark::after { left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); box-shadow: 0 0 0 0 transparent; }
.bar-right { display: flex; align-items: center; gap: 14px; }
.budget { font-size: 13px; color: var(--graphite); font-variant-numeric: tabular-nums; }
.lang { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius-s); overflow: hidden; }
.lang button { font: inherit; font-size: 13px; font-weight: 650; border: 0; background: var(--surface); color: var(--graphite); padding: 4px 10px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.link-btn { font: inherit; font-size: 14px; border: 0; background: none; color: var(--graphite); cursor: pointer; padding: 4px 2px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--ink); }

main { flex: 1 0 auto; width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 24px 40px; }
.loading { color: var(--graphite); padding: 60px 0; text-align: center; }

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: 15px; line-height: 1.2;
  padding: 10px 16px; border-radius: var(--radius-s); border: 1px solid var(--rule-strong);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.big { padding: 13px 26px; font-size: 16px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.field-label { font-weight: 650; font-size: 14px; padding: 0; }
.hint { font-size: 13px; color: var(--graphite); }
input[type="text"], input[type="number"], textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-s); padding: 9px 11px;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--graphite) 75%, transparent); }
input:focus-visible, textarea:focus-visible { border-color: var(--accent); }
.form-error { color: var(--bad); font-size: 14px; }

/* ------------------------------------------------------------ gate */
.gate { display: flex; justify-content: center; padding: 6vh 0; }
.gate-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.gate-card .field { margin: 0; }
#gate-code { font-size: 20px; letter-spacing: 0.08em; text-align: center; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ studio layout */
.studio { display: grid; grid-template-columns: minmax(300px, 430px) minmax(0, 1fr); gap: 40px; align-items: start; }
.order { min-width: 0; }
.work { min-width: 0; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 76px; }

/* drop zone + reference list */
.drop {
  border: 1.5px dashed var(--rule-strong); border-radius: var(--radius-m); padding: 16px; text-align: center;
  color: var(--graphite); background: var(--surface); cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }
.drop-pick { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.refs { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.refs:empty { display: none; }
.ref { position: relative; width: 84px; }
.ref img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--rule); display: block; background: var(--surface-2); }
.ref .ref-x {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); font: 700 14px/1 var(--font); cursor: pointer;
}
.ref .ref-name { font-size: 11px; color: var(--graphite); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; margin-top: 3px; }
.ref.first img { border-color: var(--accent); }

/* mode options */
.option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface); cursor: pointer; }
.option + .option { margin-top: 6px; }
.option input { margin-top: 3px; accent-color: var(--accent); }
.option span { display: flex; flex-direction: column; gap: 2px; }
.option small { color: var(--graphite); font-size: 13px; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* style chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 6px 12px; border: 1px solid var(--rule-strong); border-radius: 999px; font-size: 14px; background: var(--surface); }
.chip input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip input:focus-visible + span { box-shadow: var(--focus); }
/* KREKLI-W6 hand-drawn styles: a 2 px green border (5.5:1 on white, 8.5:1 on the dark surface; thicker than the grey one,
   so colour is not the only cue); selected = the usual ink fill plus a green ring around it */
.chip.hand span { border: 2px solid var(--hand); padding: 5px 11px; }
.chip.hand input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--hand); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--hand); }
.chip.hand input:checked:focus-visible + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--hand), 0 0 0 7px color-mix(in srgb, var(--accent) 35%, transparent); }
.chips .preset-hint { flex: 1 0 100%; margin: 2px 0 6px; padding: 2px 0 2px 10px; border-left: 3px solid var(--hand); color: var(--ink); }
.brief .meta b::after { content: ":"; }

/* garments */
.garments { display: flex; gap: 10px; flex-wrap: wrap; }
.garment { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px 8px 8px; border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--surface); cursor: pointer; position: relative; }
.garment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.garment-dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--rule-strong); }
.garment-dot.light { background: #ffffff; }
.garment-dot.dark { background: #16181d; }
.garment:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.garment:has(input:focus-visible) { box-shadow: var(--focus); }

/* model rows */
.models { display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); overflow: hidden; }
.model { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start; padding: 12px 14px; cursor: pointer; border-left: 3px solid transparent; position: relative; }
.model + .model { border-top: 1px solid var(--rule); }
.model input { margin: 3px 0 0; accent-color: var(--accent); }
.model .m-name { font-weight: 650; }
.model .m-best { grid-column: 2 / 3; font-size: 13px; color: var(--graphite); }
.model .m-cost { text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.model .m-time { grid-column: 3 / 4; text-align: right; font-size: 12px; color: var(--graphite); }
.model .m-tag { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--accent); }
.model .m-off { grid-column: 2 / 4; font-size: 13px; color: var(--warn); }
.model:has(input:checked) { border-left-color: var(--accent); background: var(--accent-soft); }
.model.off { cursor: not-allowed; opacity: .55; }

/* quality segmented */
.segmented { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius-s); overflow: hidden; align-self: flex-start; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 8px 16px; background: var(--surface); font-size: 14px; }
.segmented label + label span { border-left: 1px solid var(--rule-strong); }
.segmented input:checked + span { background: var(--ink); color: var(--surface); }
.segmented input:focus-visible + span { box-shadow: inset var(--focus); }

.go { position: sticky; bottom: 0; z-index: 5; background: var(--paper); border-top: 1px solid var(--rule); padding: 12px 0 10px; display: flex; flex-direction: column; gap: 10px; }
.cost-line { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink); }
.cost-line.nomoney { color: var(--bad); }

/* ------------------------------------------------------------ panels */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 18px 20px; }
.panel h2 { margin-bottom: 10px; }

/* brief */
.brief .brief-lv { font-size: 16px; line-height: 1.55; }
.brief .meta { display: flex; flex-wrap: wrap; gap: 14px 22px; margin-top: 12px; font-size: 14px; }
.brief .meta b { font-weight: 650; margin-right: 6px; }
.palette { display: inline-flex; gap: 4px; vertical-align: middle; }
.palette i { width: 16px; height: 16px; border-radius: 3px; border: 1px solid var(--rule-strong); display: inline-block; }
.callout { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-s); font-size: 14px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.bad { background: var(--bad-soft); color: var(--bad); }
.callout ul { margin: 4px 0 0; padding-left: 18px; }
.check-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-weight: 600; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }
details.more { margin-top: 12px; }
details.more summary { cursor: pointer; color: var(--graphite); font-size: 14px; }
details.more textarea { margin-top: 8px; min-height: 120px; font-size: 14px; }
.fix-box { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.brief .btn-row { margin-top: 14px; }

/* progress: a real sequence of steps */
.progress ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; counter-reset: step; }
.progress li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px; padding: 6px 0; color: var(--graphite); }
.progress li::before {
  counter-increment: step; content: counter(step);
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--rule-strong);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.progress li.run { color: var(--ink); font-weight: 600; }
.progress li.run::before { border-color: var(--accent); color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.progress li.done { color: var(--ink); }
.progress li.done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.progress li.skip { opacity: .55; }
.progress li.skip::before { content: "–"; }
.progress li.fail::before { content: "!"; background: var(--bad); border-color: var(--bad); color: #fff; }
.progress .t { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--graphite); }
.progress .p-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.progress .note { font-size: 13px; color: var(--warn); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { .progress li.run::before { animation: none; } }

/* ------------------------------------------------------------ print bed (the hero) */
.bed { margin: 0; }
.bed-frame {
  position: relative; width: min(100%, calc((100vh - 190px) * 0.75)); aspect-ratio: 3 / 4; margin: 14px auto;
  border: 1px solid var(--rule-strong); background: var(--checker-b);
}
.bed-frame[data-bg="checker"] {
  background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 18px 18px;
}
.bed-frame[data-bg="white"] { background: #ffffff; }
.bed-frame[data-bg="black"] { background: #111214; }
.bed-frame[data-bg="heather"] { background: #9ea2a2; }
.bed-frame[data-bg="navy"] { background: #1f2a44; }
.bed-frame[data-bg="red"] { background: #b3202a; }
.bed-frame img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.bed-margin { position: absolute; inset: 1%; border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); pointer-events: none; }
.bed-frame.has-img .bed-margin { display: none; }
.bed-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; color: var(--ink); }
.bed-empty p { font-size: 17px; font-weight: 600; background: var(--surface); padding: 4px 10px; border-radius: 4px; }
.spec { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.spec li { font-size: 14px; background: var(--surface); padding: 2px 8px; border-radius: 4px; color: var(--graphite); font-variant-numeric: tabular-nums; }
/* registration marks at the corners of the print area */
.reg { position: absolute; width: 18px; height: 18px; border: 1.5px solid var(--ink); border-radius: 50%; opacity: .55; }
.reg::before, .reg::after { content: ""; position: absolute; background: var(--ink); }
.reg::before { left: 50%; top: -6px; bottom: -6px; width: 1.5px; margin-left: -.75px; }
.reg::after { top: 50%; left: -6px; right: -6px; height: 1.5px; margin-top: -.75px; }
.reg.tl { top: -24px; left: -24px; }
.reg.tr { top: -24px; right: -24px; }
.reg.bl { bottom: -24px; left: -24px; }
.reg.br { bottom: -24px; right: -24px; }

.swatches { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--rule-strong); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch input:focus-visible + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent), var(--focus); }
.swatch .sw-checker { background: repeating-conic-gradient(#cfd3da 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.swatch .sw-white { background: #ffffff; }
.swatch .sw-black { background: #111214; }
.swatch .sw-heather { background: #9ea2a2; }
.swatch .sw-navy { background: #1f2a44; }
.swatch .sw-red { background: #b3202a; }

/* ------------------------------------------------------------ result */
.result .saved { font-weight: 600; word-break: break-all; }
.result .saved small { display: block; font-weight: 400; color: var(--graphite); }
.badges { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 13px; padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.error { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--surface-2); color: var(--graphite); border-color: var(--rule); }
.ai-review { margin-top: 12px; font-size: 14px; }
.ai-review ul { margin: 6px 0 0; padding-left: 18px; }
table.costs { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
table.costs th, table.costs td { padding: 6px 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
table.costs td.num, table.costs th.num { text-align: right; white-space: nowrap; }
table.costs .src { font-size: 12px; color: var(--graphite); }
table.costs .src.exact { color: var(--ok); }
table.costs tfoot td { font-weight: 700; border-bottom: 0; }
table.costs tfoot .eur { font-weight: 400; color: var(--graphite); font-size: 13px; }
.result .btn-row { margin-top: 16px; }

/* ------------------------------------------------------------ gallery */
.gallery { margin-top: 48px; border-top: 1px solid var(--rule); padding-top: 24px; }
.gallery h2 { margin-bottom: 6px; }
.gallery-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.g-item { display: flex; flex-direction: column; gap: 6px; }
.g-item .g-img { aspect-ratio: 3 / 4; border: 1px solid var(--rule); background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 12px 12px; }
.g-item img { width: 100%; height: 100%; display: block; }
.g-item .g-name { font-size: 12px; color: var(--graphite); word-break: break-all; }

/* ------------------------------------------------------------ footer + toast */
.foot { padding: 18px 24px 28px; color: var(--graphite); font-size: 13px; text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.foot p { max-width: 70ch; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--radius-s); font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); }
.toast.error { background: var(--bad); color: #fff; }

/* ------------------------------------------------------------ owner page */
.owner-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--graphite); }
.owner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-bottom: 24px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 8px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
table.data th { font-weight: 650; color: var(--graphite); background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); }
.jobs td.brief { max-width: 360px; white-space: pre-wrap; color: var(--graphite); }
.jobs .lines { color: var(--graphite); }
.code-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 12px 0; }
.code-form .field { margin: 0; }
.code-form input[type="number"] { width: 110px; }
.new-code { margin: 10px 0; padding: 12px; border: 1px dashed var(--accent); border-radius: var(--radius-s); background: var(--accent-soft); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.new-code code { font-size: 20px; font-weight: 700; letter-spacing: .08em; }
.revoked { color: var(--graphite); text-decoration: line-through; }
.cap-input { width: 90px; }

/* ------------------------------------------------------------ narrow screens */
@media (max-width: 920px) {
  .studio { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .work { position: static; }
  .bed-frame { width: min(100%, 520px); }
}
@media (max-width: 480px) {
  main { padding: 18px 16px 32px; }
  .bar { padding: 10px 16px; }
  .budget { display: none; }
  h1 { font-size: 22px; }
  .panel { padding: 14px; }
  .model { grid-template-columns: auto 1fr; }
  .model .m-cost, .model .m-time { grid-column: 2 / 3; text-align: left; }
  .bed-frame { margin: 22px auto; width: calc(100% - 40px); }
  .gate-card { padding: 20px; }
  .btn.big { width: 100%; }
}

/* owner page spacing */
.section-gap { margin: 28px 0 10px; }
.settings-title { margin-top: 22px; }
#owner section > h2 { margin-bottom: 10px; }

/* ------------------------------------------------------------ shared: spinner, danger buttons, confirm dialog */
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--rule); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex: none; }
.spinner.small { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--rule-strong); } }
.btn.danger-quiet { color: var(--bad); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 85%, black); }
dialog.confirm { border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); color: var(--ink); padding: 20px 22px; max-width: min(440px, calc(100vw - 32px)); }
dialog.confirm::backdrop { background: rgb(15 18 23 / 45%); }
dialog.confirm h2 { margin-bottom: 8px; }
dialog.confirm p { margin-bottom: 10px; }
dialog.confirm .confirm-name { font-size: 13px; color: var(--graphite); word-break: break-all; }
dialog.confirm .btn-row { justify-content: flex-end; margin-top: 6px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
/* pictures never leave the page by dragging (KREKLI-W3 bug fix; see js/app/guards.js) */
img { -webkit-user-drag: none; }

/* ------------------------------------------------------------ mockups (W3: compact panel) */
.mockups { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 76px; }
.mockups h2 { margin: 0; }
.mk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mk-loading { display: flex; align-items: center; gap: 10px; }
.mk-for { font-size: 13px; color: var(--graphite); word-break: break-all; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.mk-cost { word-break: normal; }
.mk-error { display: flex; flex-direction: column; gap: 10px; color: var(--bad); }

.mk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.mk-progress { font-size: 13px; color: var(--graphite); }

/* KREKLI-W4: 18 cards; a group wraps its cards, small groups share a row */
.mk-groups { display: flex; flex-wrap: wrap; gap: 18px 34px; align-items: flex-start; }
.mk-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; max-width: 100%; }
.mk-group h3 { font-size: 13px; font-weight: 650; color: var(--graphite); letter-spacing: 0; }
.mk-cards { display: flex; flex-wrap: wrap; gap: 16px 14px; }

.mk-card { width: 200px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mk-thumb { position: relative; display: block; width: 200px; height: 200px; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface-2); overflow: hidden; cursor: zoom-in; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.mk-thumb:hover { border-color: var(--rule-strong); }
.mk-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; pointer-events: none; }
.mk-thumb.loading img { opacity: .55; }
.mk-state { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 8px; padding: 12px; text-align: center; font-size: 12px; }
.mk-state.busy, .mk-state.error { display: flex; }
.mk-state.error { background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--bad); }
.mk-retry { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 600; }
.mk-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.mk-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-dl { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: none; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); cursor: pointer; }
.mk-dl:hover { background: var(--surface-2); }
.mk-dl:disabled { cursor: progress; }
.mk-dl.busy .ico { animation: mk-pulse 1s ease-in-out infinite; }
@keyframes mk-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .mk-dl.busy .ico { animation: none; opacity: .5; } }

/* colour dropdown (KREKLI-W4): the button shows the colour, the list holds the 18 palette colours */
.mk-chip { display: inline-block; width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1px solid var(--rule-strong); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 6%); }
.mk-chip.heather { background-image: radial-gradient(rgb(255 255 255 / 28%) 0.6px, transparent 0.9px), radial-gradient(rgb(0 0 0 / 22%) 0.6px, transparent 0.9px); background-size: 3px 3px, 4px 4px; background-position: 0 0, 1px 2px; }
.mk-pick { display: flex; align-items: center; gap: 7px; width: 100%; min-width: 0; height: 32px; padding: 0 28px 0 8px; position: relative; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.mk-pick:hover { background: var(--surface-2); border-color: var(--rule-strong); }
.mk-pick:focus-visible { outline: none; box-shadow: var(--focus); }
.mk-pick::after { content: ""; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-70%) rotate(45deg); opacity: .7; }
.mk-pick[aria-expanded="true"]::after { transform: translateY(-20%) rotate(-135deg); }
.mk-pick-sw { display: inline-flex; flex: none; }
.mk-pick-sw:empty { display: none; }
.mk-pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-same { display: inline-flex; align-items: center; gap: 6px; }
.mk-same .mk-pick-sw { display: none; }
.mk-same::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.mk-same[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }
.mk-list { position: fixed; z-index: 60; overflow-y: auto; overscroll-behavior: contain; padding: 4px; margin: 0; background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong); border-radius: var(--radius-m); box-shadow: 0 12px 32px rgb(15 18 23 / 24%); outline: none; }
.mk-list[hidden] { display: none; }
.mk-opt { display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 4px 26px 4px 8px; position: relative; border-radius: var(--radius-s); font-size: 14px; white-space: nowrap; cursor: pointer; -webkit-user-select: none; user-select: none; }
.mk-opt .mk-chip { width: 20px; height: 20px; }
.mk-opt.active { background: var(--accent-soft); }
.mk-opt[aria-selected="true"] { font-weight: 650; }
.mk-opt[aria-selected="true"]::after { content: ""; position: absolute; right: 10px; top: 50%; width: 5px; height: 10px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: translateY(-60%) rotate(45deg); }
.mk-list.dark { background: #1b1f27; color: #e9edf3; border-color: #3b4452; box-shadow: 0 12px 32px rgb(0 0 0 / 50%); }
.mk-list.dark .mk-opt.active { background: #2a3350; }
.mk-list.dark .mk-opt[aria-selected="true"]::after { border-color: #8396ff; }
.mk-list.dark .mk-chip { border-color: #4a5466; }
.mk-kind-note { margin: 0; min-height: 32px; display: flex; align-items: center; font-size: 13px; color: var(--graphite); }
.mk-inc { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--graphite); cursor: pointer; white-space: nowrap; }
.mk-inc input { margin: 0; accent-color: var(--accent); }
.mk-warn { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-s); padding: 6px 8px; font-size: 12px; line-height: 1.35; }
.mk-warn .link-btn { color: inherit; font-weight: 600; font-size: 12px; padding: 0; }

/* hover preview: the whole photo next to the card (fixed: no layout jump) */
.mk-pop { position: fixed; z-index: 40; padding: 6px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); box-shadow: 0 10px 30px rgb(15 18 23 / 22%); pointer-events: none; }
.mk-pop img { display: block; border-radius: var(--radius-s); max-width: none; }

/* viewer (lightbox) */
html.mk-lock, html.mk-lock body { overflow: hidden; }
dialog.mk-viewer { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0d0f13; color: #e9edf3; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
dialog.mk-viewer:not([open]) { display: none; }
dialog.mk-viewer::backdrop { background: #0d0f13; }
.mkv-top, .mkv-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #14171d; }
.mkv-head { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.mkv-title { font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #f4f6fa; }
.mkv-count { font-size: 13px; color: #9aa3b3; font-variant-numeric: tabular-nums; }
.mkv-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.mkv-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid #2c323d; border-radius: var(--radius-s); background: #1b1f27; color: #e9edf3; font: inherit; font-size: 13px; cursor: pointer; }
.mkv-btn:hover { background: #252b35; }
.mkv-btn:disabled { opacity: .5; cursor: progress; }
.mkv-btn:focus-visible { box-shadow: 0 0 0 3px rgb(131 150 255 / 55%); }
.mkv-zoom { min-width: 64px; font-variant-numeric: tabular-nums; }
.mkv-stage { position: relative; overflow: hidden; touch-action: none; cursor: zoom-in; outline: none; }
.mkv-stage.zoomed { cursor: grab; }
.mkv-stage.zoomed:active { cursor: grabbing; }
.mkv-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; image-rendering: auto; }
.mkv-status { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgb(20 23 29 / 88%); color: #e9edf3; padding: 6px 12px; border-radius: var(--radius-s); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.mkv-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.mkv-dots { display: flex; gap: 8px; min-height: 36px; align-items: center; }
.mkv-pick { width: 240px; max-width: 70vw; height: 36px; background: #1b1f27; color: #e9edf3; border-color: #2c323d; font-size: 14px; }
.mkv-pick:hover { background: #252b35; border-color: #3b4452; }
.mkv-pick:focus-visible { box-shadow: 0 0 0 3px rgb(131 150 255 / 55%); }
.mkv-pick .mk-chip { width: 20px; height: 20px; border-color: #4a5466; }
.mkv-note { font-size: 12px; color: #9aa3b3; text-align: center; }
.mkv-retry { height: 28px; }

@media (max-width: 920px) {
  .mk-group { flex: 1 1 100%; }
}
@media (max-width: 480px) {
  .mockups { padding: 14px; }
  .mk-groups { gap: 12px; }
  .mk-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
  .mk-card, .mk-thumb { width: 100%; }
  .mk-thumb { height: auto; aspect-ratio: 1 / 1; }
  .mk-pick { padding-left: 6px; gap: 5px; font-size: 12.5px; }
  .mk-row { flex-wrap: wrap; row-gap: 4px; }
  .mkv-title { font-size: 14px; }
  .mkv-tools [data-act="out"], .mkv-tools [data-act="in"] { display: none; }
  .mkv-dl-label { display: none; }
  .mkv-top, .mkv-bottom { padding: 8px 10px; }
}
