/* Peelpress — one visual system: neutral surfaces, one indigo accent, 8px rhythm. */
:root {
  --bg: #f4f5f8;
  --panel: #ffffff;
  --line: #e6e8ee;
  --line-2: #d7dbe3;
  --text: #171a21;
  --text-2: #4a5160;
  --muted: #7a8292;
  --accent: #4f46e5;
  --accent-2: #4338ca;
  --accent-soft: #eef0ff;
  --accent-line: #c9ccfb;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #15803d;
  --stage: #eceef3;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 13.5px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.i { display: inline-flex; flex: none; }
.i svg { display: block; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; margin-right: 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #4338ca); display: grid; place-items: center; box-shadow: 0 2px 6px rgba(79, 70, 229, .35); }
.steps-nav { display: flex; align-items: center; gap: 4px; }
.tab { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 7px 12px 7px 8px; border-radius: 999px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.tab:hover { background: var(--bg); color: var(--text); }
.tab .num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-2); font-size: 11.5px; font-weight: 700; background: #fff; }
.tab em { font-style: normal; font-weight: 500; color: var(--muted); font-size: 11.5px; margin-left: 2px; }
.tab.active { background: var(--accent-soft); color: var(--accent-2); }
.tab.active .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-sep { width: 18px; height: 1.5px; background: var(--line-2); border-radius: 1px; }
.tab .short { display: none; }
.spacer { flex: 1; }
.save-status { color: var(--muted); font-size: 12px; margin-right: 4px; white-space: nowrap; }
.save-status.bad { color: var(--danger); font-weight: 600; }
.icon-group { display: flex; gap: 2px; }
.reset-btn { color: var(--text-2); }
.reset-btn:hover { color: var(--danger); background: #fef2f2; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-2); background: #fff; padding: 7px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap; font-weight: 500; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s; }
.btn:hover { background: #f8f9fb; border-color: #c5cad4; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: #eef0f4; }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.icon { padding: 7px; }
.btn.block { width: 100%; margin-top: 10px; padding: 9px 12px; }
.zoom-pct { min-width: 52px; font-variant-numeric: tabular-nums; }

/* ---------- workspace ---------- */
.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr) 320px; min-height: 0; }
.panel { background: var(--panel); overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-bar { height: 46px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 10px 0 14px; background: rgba(255, 255, 255, .7); border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); }
.stage-info { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.stage-info strong { color: var(--text); font-weight: 600; }
.muted-sm { color: var(--muted); font-size: 12px; }
.zoom { display: flex; align-items: center; gap: 2px; flex: none; }
.canvas-wrap { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 24px; background: var(--stage) radial-gradient(circle, #d6dae2 1px, transparent 1px) 0 0 / 18px 18px; }
#canvas { margin: auto; display: block; flex: none; touch-action: none; user-select: none; -webkit-user-select: none; }

/* ---------- panel sections ---------- */
.sec { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.sec > h3 { margin: 0 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--text); }
.group { padding: 0; }
.group > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 14px 18px; cursor: pointer; user-select: none; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary:hover { background: #fafbfc; }
.sum-title { flex: 1; }
.sum-meta { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: 0; }
.group > summary .i { color: var(--muted); transition: transform .15s; }
.group[open] > summary .i { transform: rotate(90deg); }
.group-body { padding: 0 18px 16px; }
.panel-foot { padding: 12px 12px 18px; }

.field { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 10px; margin: 8px 0; }
.field.wide { grid-template-columns: 1fr; gap: 6px; }
.field .lbl { color: var(--text-2); font-size: 12.5px; }
.field .ctl { display: flex; align-items: center; gap: 4px; min-width: 0; }
.field.disabled { opacity: .45; }
.field input[type=number], .field input[type=text], .field select, .field textarea, .text-input {
  font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 9px; min-width: 0; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.field select { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8292' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center; padding-right: 28px; }
.field input[type=number] { text-align: right; -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
.field input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field textarea, textarea.text-input { resize: vertical; font-family: inherit; line-height: 1.4; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.btn:focus-visible, .step:focus-visible, .card:focus-visible, .tool:focus-visible, .tab:focus-visible, .drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.step { flex: none; width: 28px; height: 30px; border: 1px solid var(--line-2); background: #fff; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1; color: var(--text-2); padding: 0; }
.step:hover { background: #f4f5f8; }
.step:disabled { opacity: .5; cursor: default; }
.unit { flex: none; width: 22px; font-size: 11.5px; color: var(--muted); }
.unit.wide-unit { width: auto; font-family: ui-monospace, Consolas, monospace; }
input[type=color] { flex: none; width: 42px; height: 30px; padding: 3px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; cursor: pointer; }
.check { display: flex; align-items: flex-start; gap: 9px; margin: 10px 0; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.check input { margin: 1px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0; }
.hint:empty { display: none; }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.row-btns:empty { display: none; }
.mini-title { font-weight: 600; font-size: 12px; margin: 14px 0 8px; color: var(--text-2); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; margin: 6px 0; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; font-weight: 500; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-2); font-size: 11px; font-weight: 600; }
.note { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; margin: 10px 0 2px; border-radius: 9px; background: #f6f7f9; color: var(--text-2); font-size: 12.5px; }
.note .i { margin-top: 1px; color: var(--muted); }
.note.ok { background: #effaf3; color: #166534; }
.note.ok .i { color: #16a34a; }
.note.warn { background: #fff8eb; color: #92400e; }
.note.warn .i { color: #d97706; }

.seg { flex: 1; display: flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: #fff; padding: 6px 0; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent-2); font-weight: 700; }

/* ---------- picture cards (layouts, arrangements, templates) ---------- */
.cards { display: grid; gap: 8px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px 7px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s; min-width: 0; }
.card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-sm); }
.card.on { border-color: var(--accent); background: var(--accent-soft); }
.card-pic { display: grid; place-items: center; min-height: 52px; }
.card-pic svg { display: block; max-width: 100%; height: auto; }
.card-pic .pg { fill: #fff; stroke: #cfd4dc; stroke-width: 5; }
.card-pic .lb rect { fill: #e7e9f0; stroke: #9aa3b2; stroke-width: 3; }
.card.on .card-pic .lb rect { fill: #dfe1ff; stroke: var(--accent); }
.card-label { font-size: 11px; font-weight: 600; color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.card.on .card-label { color: var(--accent-2); }

/* ---------- design tools ---------- */
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 2px 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--text-2); transition: border-color .12s, background .12s, color .12s; }
.tool:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-2); }
.tool .i { color: var(--accent); }
.align-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.layers { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
.layer { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.layer .i { color: var(--muted); }
.layer:hover { background: #f5f6f9; }
.layer.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.layer.active .i { color: var(--accent); }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 99px; background: #f1f2f6; color: var(--text-2); font-size: 12px; font-family: ui-monospace, Consolas, monospace; border: 1px solid var(--line); }
.chip.btnish { cursor: pointer; font-family: inherit; }
.chip.btnish:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }

/* ---------- data step ---------- */
.drop { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 14px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: #fafbfc; cursor: pointer; color: var(--text-2); transition: border-color .12s, background .12s; }
.drop .i { color: var(--accent); }
.drop strong { font-size: 13px; color: var(--text); }
.drop span { font-size: 12px; color: var(--muted); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.file-card { display: flex; gap: 11px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; }
.file-card .i { color: var(--accent); }
.file-card > div { display: grid; min-width: 0; }
.file-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card span { font-size: 12px; color: var(--muted); }
.busy { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.busy > div { display: grid; }
.busy span:not(.spinner) { font-size: 12px; color: var(--muted); }
.spinner { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2.5px solid var(--accent-line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pos-pick { position: relative; width: 130px; background: #fff; border: 1px solid var(--line-2); border-radius: 6px; }
.pos-pick button { position: absolute; border: 1px solid var(--line-2); border-radius: 4px; background: #f6f7f9; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; padding: 0; }
.pos-pick button:hover { border-color: var(--accent); color: var(--accent-2); }
.pos-pick button.used { background: repeating-linear-gradient(45deg, #eceef2 0 4px, #f6f7f9 4px 8px); color: #b3b9c4; }
.pos-pick button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats > div { display: grid; justify-items: center; padding: 12px 4px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; }
.stats b { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11.5px; color: var(--muted); }
.table-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.table-tools .text-input { max-width: 280px; }
.table-wrap { overflow: auto; max-height: calc(100dvh - 240px); border: 1px solid var(--line); border-radius: 10px; }
.data-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
.data-table th { position: sticky; top: 0; z-index: 1; background: #f6f7f9; text-align: left; font-weight: 600; color: var(--text-2); padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { border-bottom: 1px solid var(--line); padding: 2px; vertical-align: top; }
.data-table td textarea { width: 100%; min-width: 120px; border: 1px solid transparent; border-radius: 6px; padding: 5px 6px; font: inherit; resize: vertical; background: transparent; field-sizing: content; max-height: 120px; }
.data-table td textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.data-table .c-inc, .data-table .c-num { width: 36px; text-align: center; padding-top: 8px; color: var(--muted); }
.data-table tr.off td { opacity: .45; }
.data-table tr:hover td { background: #fafbff; }

/* ---------- steps list & checks ---------- */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 0 0 10px 34px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); font-weight: 700; font-size: 12px; display: grid; place-items: center; }
.steps .step-title { font-weight: 600; margin: 2px 0; }
#warnings .sec { border-bottom: 0; }
.warn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.warn-list li { padding: 8px 10px; border-radius: 8px; font-size: 12px; cursor: pointer; border-left: 3px solid; }
.w-error { background: #fef2f2; border-color: var(--danger); color: #991b1b; }
.w-warn { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
.w-info { background: #f4f6f9; border-color: #a3acba; color: #3b4452; }
.check-ok { color: var(--ok); font-weight: 600; font-size: 12.5px; }

/* ---------- menu ---------- */
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 230px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); }
.menu-pop button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 11px; border-radius: 7px; cursor: pointer; }
.menu-pop button:hover { background: var(--bg); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { max-width: min(560px, 92vw); padding: 10px 15px; border-radius: 10px; background: #171a21; color: #fff; font-size: 12.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); animation: toast-in .18s ease-out; }
.toast.warn { background: #92400e; }
.toast.error { background: #991b1b; }
.toast.ok { background: #166534; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- dialogs ---------- */
.modal { width: min(460px, 94vw); padding: 0; border: 0; border-radius: 14px; color: var(--text); box-shadow: 0 24px 64px rgba(16, 24, 40, .3); }
.modal.wide { width: min(700px, 94vw); }
.modal.full { width: min(1100px, 96vw); }
.modal::backdrop { background: rgba(16, 24, 40, .4); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 14px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px 20px; max-height: 70vh; overflow: auto; }
.modal.full .modal-body { max-height: none; }
.modal-text { margin: 0; line-height: 1.55; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 20px; background: #fafbfc; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
.stack { display: grid; gap: 6px; margin-bottom: 12px; }
.stack .lbl { font-size: 12.5px; color: var(--text-2); }
.lib-list { display: grid; gap: 8px; }
.lib-row { display: flex; align-items: center; gap: 12px; padding: 9px; border: 1px solid var(--line); border-radius: 12px; }
.lib-thumb { flex: none; width: 66px; height: 66px; display: grid; place-items: center; background: var(--stage); border-radius: 8px; }
.lib-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.lib-meta span { color: var(--muted); font-size: 12px; }
.lib-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.logo-box { display: flex; align-items: center; gap: 8px; }
.logo-box img { max-width: 130px; max-height: 46px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* ---------- desktop-only / phone-only pieces ---------- */
.sheet-head, .bottom-nav { display: none; }

@media (max-width: 1200px) {
  .workspace { grid-template-columns: 272px minmax(0, 1fr) 290px; }
  .save-status, .lib-text, .reset-text { display: none; }
  .reset-btn { padding: 7px; }
  .brand { margin-right: 6px; }
}
@media (max-width: 1000px) {
  .brand-name, .tab em { display: none; }
}

/* ---------- phones & small tablets ----------
   Canvas fills the screen; the panels become slide-up sheets opened from a bottom bar. */
@media (max-width: 820px) {
  html { overflow: hidden; }
  body {
    height: 100vh;
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .topbar { gap: 4px; padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand { margin-right: 2px; }
  .brand-name, .save-status, #btnPdf, #btnPrint, .tab-sep, .tab .full, .lib-text, .reset-text { display: none; }
  .tab .short { display: inline; }
  .tab:not(.active) .short { display: none; }
  .tab:not(.active) { padding: 6px; }
  .tab { padding: 6px 9px 6px 6px; gap: 6px; font-size: 12.5px; }
  .tab .num { width: 20px; height: 20px; font-size: 11px; }
  .steps-nav { gap: 0; }

  .workspace { grid-template-columns: minmax(0, 1fr); position: relative; }
  .stage-bar { height: 44px; padding: 0 6px 0 10px; }
  .zoom .btn:last-child { display: none; }
  .canvas-wrap { padding: 10px; touch-action: pan-x pan-y; }

  .panel {
    position: fixed;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: calc(62px + env(safe-area-inset-bottom));
    max-height: min(70dvh, calc(100dvh - 150px));
    border: 0 !important;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(16, 24, 40, .22);
    transform: translateY(calc(100% + 80px));
    visibility: hidden;
    transition: transform .24s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .24s;
    overscroll-behavior: contain;
  }
  body[data-sheet="left"] .panel.left,
  body[data-sheet="right"] .panel.right { transform: none; visibility: visible; transition: transform .24s cubic-bezier(.2, .8, .2, 1); }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 2; padding: 14px 10px 10px 18px; background: #fff; border-bottom: 1px solid var(--line); font-size: 14px; }
  .sheet-head::before { content: ''; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: #d5d9e1; }

  .bottom-nav { display: grid; grid-template-columns: repeat(4, 1fr); z-index: 50; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 62px; min-width: 0; border: 0; background: none; font-size: 11.5px; font-weight: 500; color: var(--muted); cursor: pointer; }
  .bottom-nav button > span:not(.bn-badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
  .bottom-nav button.on { color: var(--accent-2); font-weight: 600; }
  .bottom-nav .bn-primary { color: var(--accent); font-weight: 700; }
  .bn-badge { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; }

  /* Touch-friendly controls; 16px text stops iOS zooming into inputs. */
  .field { grid-template-columns: 110px minmax(0, 1fr); margin: 10px 0; }
  .field input[type=number], .field input[type=text], .field select, .field textarea, .text-input { font-size: 16px; padding: 8px 9px; }
  .step { width: 38px; height: 38px; font-size: 18px; }
  input[type=color] { width: 52px; height: 38px; }
  .seg button { padding: 9px 0; }
  .btn.small { padding: 8px 12px; font-size: 13px; }
  .check { margin: 12px 0; font-size: 14px; }
  .check input { width: 18px; height: 18px; }
  .group > summary { padding: 16px 18px; font-size: 13px; }
  .layer { padding: 10px; }
  .warn-list li { padding: 10px; }
  .menu-pop button { padding: 12px; }
  .data-table td textarea { font-size: 16px; }

  #toasts { bottom: calc(74px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }

  .modal, .modal.wide, .modal.full { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92dvh; border-radius: 18px 18px 0 0; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .table-wrap { max-height: calc(92dvh - 200px); }
  .lib-row { flex-wrap: wrap; }
  .lib-actions { width: 100%; justify-content: flex-start; }
}
