/* Cookie Cutter Studio - mobile web app. Mobile-first; landscape / tablet / desktop via media queries. */
:root {
  /* Cookie Cutter Studio — slate neutrals + wine red accent (matches desktop) */
  --bg: #eef1f5; --panel: #ffffff; --panel2: #f4f6f9; --border: #d5dce8; --text: #1a2332; --muted: #5f6b7c;
  --accent: #8b1e3a; --accent2: #6e1730; --accent-soft: #f3e4e9; --ok: #1f8a5b; --warn: #b07a10; --err: #c0392b;
  --vp: #e8ecf2; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 2px 8px rgba(15,23,42,.06); --r: 14px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 44px;
  color-scheme: light;
}
:root.dark {
  --bg: #121419; --panel: #1b1e25; --panel2: #232730; --border: #2e333d; --text: #eceef2; --muted: #9ea5b3;
  --accent: #c45a76; --accent2: #a83f5c; --accent-soft: #3a1f2a; --vp: #16181e; --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 var(--font); overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { position: fixed; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input, select, textarea { font: inherit; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
svg { flex-shrink: 0; }

/* ---------- layout (portrait phone) ---------- */
#app { display: flex; flex-direction: column; height: 100%; height: 100dvh; padding-left: var(--sal); padding-right: var(--sar); }
#topbar { flex: none; display: flex; align-items: center; gap: 4px; padding: calc(var(--sat) + 4px) 8px 4px 14px; min-height: calc(48px + var(--sat)); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -.2px; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { width: 28px; height: 28px; border-radius: 7px; }
.tb-spacer { flex: 1; }
.icon-btn { width: var(--tap); height: var(--tap); display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; border-radius: 12px; color: var(--text); flex: none; }
.icon-btn:active { background: var(--panel2); }
.icon-btn.boxed { border: 1px solid var(--border); background: var(--panel); }
.icon-btn:disabled { opacity: .4; }

#stage { position: relative; flex: none; height: 40vh; height: clamp(220px, 40dvh, 520px); transition: height .22s ease; margin: 0 10px; border-radius: 18px; overflow: hidden; background: var(--vp); box-shadow: inset 0 0 0 1px var(--border); }
/* the 3D canvas stops above the size/watertight line (status: bottom 10px + ~26px pill + gap) so the
   width dimension label, which lives inside the canvas overlay, can never sit on top of it */
#viewport { position: absolute; inset: 0 0 44px 0; }
#viewport canvas { display: block; touch-action: none; }
/* 3D preview dimension callouts (wine-red theme) */
.dim-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.dim-overlay.hidden { display: none; }
.dim-label {
  position: absolute; transform: translate(-50%, -50%);
  padding: 3px 8px; border-radius: 8px;
  font: 600 12px/1.2 var(--font);
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  box-shadow: var(--shadow);
  white-space: nowrap;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.dim-label.dim-vert { transform: translate(-50%, -50%) rotate(-90deg); }
/* width label: centred on its guide line (JS places it 14px below the line) so it stays inside the canvas in every view */
#dimW { transform: translate(-50%, calc(-50% - 14px)); }
#vpTools { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 6px; }
.vp-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--text); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--shadow); }
.vp-btn:active { background: var(--accent-soft); }
.busy { position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px; border-radius: 99px; background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
.spin { width: 15px; height: 15px; border-radius: 50%; border: 2.2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { position: absolute; left: 10px; bottom: 10px; right: 60px; pointer-events: none; }
.status span#statusText { display: inline-block; max-width: 100%; padding: 5px 10px; border-radius: 99px; font-size: 12.5px; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.status .ok { color: var(--ok); font-weight: 600; } .status .bad { color: var(--err); font-weight: 600; }
.warn-chip { position: absolute; left: 10px; bottom: 44px; max-width: calc(100% - 70px); min-height: 32px; padding: 5px 12px; border: 0; border-radius: 99px; background: #fff4d6; color: #7a5200; font-size: 12.5px; font-weight: 600; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: var(--shadow); }
.warn-chip::after { content: ""; position: absolute; inset: -6px 0; }
:root.dark .warn-chip { background: #3b2e10; color: #ffd27a; }
.error { position: absolute; left: 10px; right: 10px; bottom: 44px; padding: 10px 12px; border-radius: 12px; background: #fbe4e2; color: #8c2019; font-size: 13.5px; }
:root.dark .error { background: #3b1c1a; color: #ffb4ad; }

.empty-state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(120% 90% at 50% 20%, color-mix(in srgb, var(--accent) 10%, var(--vp)), var(--vp)); }
.es-card { text-align: center; max-width: 340px; }
.es-ico img { width: 64px; height: 64px; border-radius: 16px; box-shadow: 0 6px 18px rgba(207,95,40,.25); }
.es-title { font-size: 20px; font-weight: 700; letter-spacing: -.3px; margin: 10px 0 4px; }
.es-sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.es-btns { display: flex; gap: 10px; justify-content: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-weight: 600; font-size: 15px; text-decoration: none; user-select: none; -webkit-user-select: none; }
.btn:active { background: var(--panel2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent2); }
.btn.primary:disabled { background: color-mix(in srgb, var(--accent) 40%, var(--panel2)); border-color: transparent; color: rgba(255,255,255,.85); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.big { min-height: 50px; padding: 0 20px; font-size: 16px; border-radius: 14px; }
.small-btn { min-height: var(--tap); padding: 0 12px; font-size: 14px; }

#actionbar { flex: none; display: flex; gap: 10px; padding: 10px 10px 8px; }
.product-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 12px; border: 1px solid var(--border); background: var(--panel); border-radius: 14px; text-align: left; box-shadow: var(--shadow); }
.product-btn:active { background: var(--panel2); }
.product-btn .pi { font-size: 24px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); border-radius: 10px; flex: none; }
.pb-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.pb-text small { color: var(--muted); font-size: 12px; }
.pb-text b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-btn .caret { margin-left: auto; color: var(--muted); }
.export-btn { min-height: 54px; border-radius: 14px; padding: 0 18px; font-size: 16px; box-shadow: 0 2px 8px rgba(207,95,40,.25); }

#panel { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 10px calc(16px + var(--sab)); }
.seg-wrap { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 0 0 10px; margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
.seg { display: flex; gap: 4px; padding: 4px; margin: 0; background: var(--panel2); border: 1px solid var(--border); border-radius: 13px; }
:root:not(.dark) .seg { background: #ebe6df; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.cbadge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.card-title { font-weight: 700; font-size: 16px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; min-height: 32px; }
.card-title .spacer { flex: 1; }
.badge { font-size: 11.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent2); padding: 2px 8px; border-radius: 99px; }
:root.dark .badge { color: #ffb48c; }
.row { display: flex; align-items: center; } .gap { gap: 10px; margin-top: 10px; }
.row .btn { flex: 1; }
.tip { margin: 8px 2px 0; }
.drop { position: relative; border: 1.5px dashed var(--border); border-radius: 12px; background: var(--panel2); aspect-ratio: 16 / 10; overflow: hidden; cursor: pointer; }
body:not(.has-design) .drop { display: none; }
body:not(.has-design) .row.gap { margin-top: 0; }
body.dragging .drop { border-color: var(--accent); background: var(--accent-soft); }
.drop canvas { width: 100%; height: 100%; display: block; }
.drop-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); pointer-events: none; }

/* settings */
.settings-head { padding: 0 0 10px; }
.search { display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 6px 0 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; height: 44px; -webkit-appearance: none; appearance: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search .clear { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--panel2); color: var(--muted); }
.profiles { display: flex; gap: 8px; margin-top: 8px; }
.profiles select { flex: 1; min-width: 0; }
.nomatch { padding: 18px 6px; text-align: center; }
.foot { text-align: center; margin: 14px 8px 4px; }

select, .sel { min-height: var(--tap); border: 1px solid var(--border); border-radius: 11px; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23887f76' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center; padding: 0 32px 0 12px; font-size: 16px; -webkit-appearance: none; appearance: none; max-width: 100%; }

.sec { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden; }
.sec > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 4px 10px 4px 14px; font-weight: 700; font-size: 16px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.sec > summary::-webkit-details-marker { display: none; }
.sec-icon { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--panel2); font-size: 16px; flex: none; }
.sec-title { flex: 1; min-width: 0; }
.sec-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent2); font-size: 12px; line-height: 20px; text-align: center; }
:root.dark .sec-count { color: #ffb48c; }
.chev { color: var(--muted); transition: transform .18s; }
.sec[open] > summary .chev { transform: rotate(90deg); }
.sec-body { padding: 0 14px 8px; border-top: 1px solid var(--border); }
.grp { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); padding: 14px 0 2px; }

.rst { display: none; position: relative; align-items: center; justify-content: center; gap: 6px; min-width: 34px; height: 34px; padding: 0 8px; border: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent2); flex: none; font-size: 13px; font-weight: 600; }
:root.dark .rst { color: #ffb48c; }
.rst.on { display: inline-flex; }
.rst::after { content: ""; position: absolute; inset: -5px; } /* 44px touch target */
.rst:active { filter: brightness(.95); }
.sec-rst span { white-space: nowrap; }
.sec > summary .sec-rst.on + .chev { margin-left: 0; }

.field { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.sec-body > .field:last-child, #traceFields > .field:last-child { border-bottom: 0; }
.field.wide { flex-wrap: wrap; }
.field.wide > .ctl { flex-basis: 100%; }
.lbl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; font-size: 15px; }
.lt { min-width: 0; overflow-wrap: anywhere; }
.field { position: relative; }
.field.changed .lt { font-weight: 600; }
.field.changed::before { content: ""; position: absolute; left: -10px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); }
.bar .field.changed::before { display: none; }
.q { width: 30px; height: 32px; flex: none; margin: -4px 0; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; padding: 0; position: relative; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.q::before { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor; opacity: .7; }
.q:active { color: var(--accent); }
.q::after { content: ""; position: absolute; inset: -6px -7px; } /* 44px touch target */
.ctl { display: flex; align-items: center; justify-content: flex-end; min-width: 0; }
.field.disabled .ctl, .field.disabled .lt { opacity: .45; }
.field.disabled .ctl { pointer-events: none; }
.field.hl { background: linear-gradient(90deg, var(--accent-soft), transparent 80%); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.warnmsg { flex-basis: 100%; font-size: 13px; color: var(--warn); margin-top: 2px; }
.readonly { font-weight: 600; font-variant-numeric: tabular-nums; }
/* Tracing: values chosen by Auto threshold */
.field.auto-val .ctl { opacity: .6; }
.field.auto-val .lt::after { content: "auto"; margin-left: 6px; padding: 1px 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent2); font-size: 11px; font-weight: 700; vertical-align: 1px; }
:root.dark .field.auto-val .lt::after { color: #ffb48c; }
.trace-status { padding: 8px 0 4px; font-size: 13px; color: var(--muted); }
.trace-status:empty { display: none; }
#traceFields > .field:nth-last-child(2) { border-bottom: 0; }

.num { display: flex; align-items: stretch; height: 46px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; flex: none; }
.num .step { width: 44px; border: 0; background: var(--panel2); font-size: 20px; font-weight: 500; color: var(--text); padding: 0; }
.num .step:active { background: var(--accent-soft); color: var(--accent2); }
.nbox { display: flex; align-items: center; padding: 0 7px 0 4px; gap: 3px; }
.num input { width: 48px; border: 0; background: transparent; text-align: right; font-size: 16px; outline: none; padding: 0; font-variant-numeric: tabular-nums; }
.num input.bad { color: var(--err); }
.num .unit { font-size: 13px; color: var(--muted); }
.num.compact .step { display: none; }
.num.compact input { width: 52px; }
.num:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.slider { display: flex; align-items: center; gap: 12px; width: 100%; }
.slider input[type=range] { flex: 1; min-width: 0; }
input[type=range] { -webkit-appearance: none; appearance: none; height: var(--tap); background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--border); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.3), 0 0 0 .5px rgba(0,0,0,.08); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--border); }
input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.txt { width: 100%; min-height: var(--tap); border: 1px solid var(--border); border-radius: 11px; background: var(--panel); padding: 10px 12px; font-size: 16px; resize: vertical; outline: none; }
.txt:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tog { display: flex; width: 100%; gap: 2px; padding: 2px; background: var(--panel2); border-radius: 12px; border: 1px solid var(--border); }
.tog button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); }
.tog button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.lockbtn { min-height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--panel); font-weight: 600; }
/* iOS style switch */
.sw { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.sw input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.sw span { position: absolute; inset: 0; border-radius: 99px; background: #d9d3cb; transition: background .18s; }
:root.dark .sw span { background: #3a3f4b; }
.sw span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .18s; }
.sw input:checked + span { background: var(--ok); }
.sw input:checked + span::after { transform: translateX(20px); }
.sw input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

.bars { width: 100%; }
.bar { border: 1px solid var(--border); border-radius: 12px; padding: 4px 12px; margin: 8px 0; background: var(--panel2); }
.bar .field { min-height: 50px; }
.bar .field:last-child { border-bottom: 0; }
.bar-head { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.bar-head .del { border: 0; background: transparent; color: var(--err); font-weight: 600; min-height: 40px; padding: 0 4px; }
.barline { display: flex; gap: 8px; align-items: center; padding: 4px 0 8px; }
.barline .addbar { flex: 1; }

.radio-opt { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); margin-bottom: 8px; text-align: left; cursor: pointer; }
.radio-opt .rtext { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.radio-opt .rtext .muted { font-size: 13px; }
.rdot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex: none; position: relative; }
.radio-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.radio-opt.on .rdot { border-color: var(--accent); }
.radio-opt.on .rdot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.radio-opt .sub { flex-basis: 100%; display: flex; gap: 8px; padding-left: 34px; }
.radio-opt .sub .sel { flex: 1; }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(20,14,8,.38); opacity: 0; transition: opacity .2s; }
.scrim.show { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: calc(100% - var(--sat) - 40px); display: flex; flex-direction: column; background: var(--panel); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.18); transform: translateY(105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); padding-bottom: var(--sab); padding-left: var(--sal); padding-right: var(--sar); }
.sheet.show { transform: translateY(0); }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; min-height: 48px; padding: 0 8px 0 18px; font-size: 17px; flex: none; touch-action: none; }
.sheet-head b { flex: 1; }
.sheet-close { width: var(--tap); height: var(--tap); border: 0; background: transparent; color: var(--muted); font-size: 17px; border-radius: 50%; position: relative; }
.sheet-close::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--panel2); z-index: -1; }
.sheet-close { z-index: 0; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 16px 16px; }
.hint-sheet .sheet-body p#hintText { white-space: pre-line; font-size: 16.5px; line-height: 1.5; margin: 0 0 8px; }
.hint-sheet #hintReset { width: 100%; margin-top: 6px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 12px; }
.sheet-actions .btn { flex: 1; }
.export-info { padding: 2px 4px; min-height: 20px; overflow-wrap: anywhere; }
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pgroup { font-size: 13px; font-weight: 700; margin: 16px 2px 8px; }
.pgroup span { font-weight: 400; color: var(--muted); }
.pcard { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 112px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); text-align: left; }
.pcard:active { background: var(--panel2); }
.pcard.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.pcard .pic { font-size: 26px; line-height: 1; margin-bottom: 4px; }
.pcard .pic sup { font-size: 11px; font-weight: 700; color: var(--accent2); margin-left: 2px; }
.pcard b { font-size: 15px; }
.pcard .d { font-size: 12.5px; color: var(--muted); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.menu-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 12px; }
.menu-list button { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border: 0; border-bottom: 1px solid var(--border); background: var(--panel); text-align: left; font-size: 16px; }
.menu-list button:last-child { border-bottom: 0; }
.menu-list button span { width: 24px; display: inline-flex; justify-content: center; color: var(--accent); }
.menu-list button b { margin-left: auto; color: var(--muted); font-weight: 500; }
.menu-list button:active { background: var(--panel2); }
.install-tip { padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); font-size: 14px; margin-bottom: 8px; }
.ios-share { vertical-align: -3px; color: #0a84ff; }

.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(20,14,8,.42); }
.modal-box { width: 100%; max-width: 340px; background: var(--panel); border-radius: 18px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-box p { margin: 6px 0 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(18px + var(--sab)); transform: translateX(-50%); z-index: 70; max-width: calc(100% - 24px); width: max-content; padding: 11px 16px; border-radius: 14px; background: #2a2521; color: #fff; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); display: flex; align-items: center; gap: 12px; }
:root.dark .toast { background: #eceef2; color: #16181e; }
.toast-act { border: 0; background: transparent; color: var(--accent); font-weight: 700; min-height: 36px; }

/* portrait: the preview shrinks while you scroll the settings, and grows back at the top */
body.compact #stage { height: 30vh; height: clamp(190px, 30dvh, 400px); }

/* ---------- landscape phones, tablets, desktop: side by side ---------- */
@media (orientation: landscape) and (min-width: 560px), (min-width: 820px) {
  #app { display: grid; grid-template-columns: 1fr minmax(340px, 400px); grid-template-rows: auto auto 1fr; }
  #topbar { grid-column: 1 / 3; }
  #stage, body.compact #stage { grid-column: 1; grid-row: 2 / 4; height: auto; min-height: 0; margin: 0 0 calc(10px + var(--sab)) 10px; }
  #actionbar { grid-column: 2; grid-row: 2; padding-top: 0; }
  #panel { grid-column: 2; grid-row: 3; }
}
@media (orientation: landscape) and (max-height: 500px) {
  #topbar { min-height: calc(44px + var(--sat)); padding-top: calc(var(--sat) + 2px); padding-bottom: 2px; }
  .brand { font-size: 15px; }
  #actionbar { padding-bottom: 6px; }
  .product-btn, .export-btn { min-height: 48px; }
}
@media (min-width: 820px) {
  #app { grid-template-columns: 1fr 420px; }
  .sheet { left: 50%; right: auto; width: 520px; transform: translate(-50%, 105%); }
  .sheet.show { transform: translate(-50%, 0); }
  .pgrid { grid-template-columns: 1fr 1fr 1fr; }
}
@media (hover: hover) {
  .btn:hover, .product-btn:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
  .pcard:hover { border-color: var(--accent); }
}
@media (prefers-reduced-motion: reduce) { .sheet, .scrim, .chev { transition: none; } }

/* ---------- undo / redo (topbar) ---------- */
.hist { display: inline-flex; gap: 0; }
.hist .icon-btn:disabled { opacity: .3; }
@media (max-width: 380px) { .brand-name { font-size: 15px; } }

/* ---------- ready-to-print check: summary pill on the preview + bottom sheet ---------- */
.vp-btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
/* the pill buttons are 44 px tall touch targets; the visible pill is the inner span */
.pc-pill, .estimate { position: absolute; left: 10px; max-width: calc(100% - 74px); min-height: 44px; padding: 0; border: 0; background: none; text-align: left; display: flex; align-items: center; z-index: 2; color: var(--text); }
.chip-in { display: block; max-width: 100%; padding: 6px 12px; border-radius: 99px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--shadow); }
.pc-pill { top: 3px; }
.pc-pill .chip-in { font-size: 13px; font-weight: 700; border: 1px solid var(--border); background: color-mix(in srgb, var(--panel) 92%, transparent); }
.pc-pill.pass { color: var(--ok); } .pc-pill.warn { color: var(--warn); }
:root.dark .pc-pill.warn { color: #ffd27a; }
.busy { z-index: 3; }
.pc-sub { margin: 0 0 8px; }
.pc-sum { font-weight: 700; padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; font-size: 15px; }
.pc-sum.pass { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pc-sum.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
:root.dark .pc-sum.warn { color: #ffd27a; }
.pc-row { display: flex; gap: 9px; padding: 9px 2px; line-height: 1.4; font-size: 15px; border-top: 1px solid var(--border); }
.pc-ico { flex: none; width: 18px; text-align: center; font-weight: 700; }
.pc-row.pass .pc-ico { color: var(--ok); } .pc-row.warn .pc-ico { color: var(--warn); }
.pc-off { width: 100%; margin-top: 12px; }

/* ---------- filament / time estimate chip (top-left of the preview; below the check pill when that is on) ---------- */
.estimate { top: 3px; }
.estimate .chip-in { padding: 4px 11px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 88%, transparent); }
body.has-pc .estimate { top: 45px; }
