/* 2D Cut — design system (design/project/Main.dc.html). Tokens map 1:1 to the iOS Tailwind theme. */

:root {
  --bg: #F3F2EE; --surface: #FFFFFF; --surface-2: #F8F7F4; --sunken: #ECEAE4;
  --line: #DEDBD3; --line-strong: #C9C5BB;
  --ink: #17191C; --ink-2: #474B52; --ink-3: #686C73;
  --accent: #C2410C; --accent-ink: #FFFFFF; --accent-soft: #FCEBE1; --accent-text: #A8380A;
  --info: #1D4ED8; --info-soft: #E3EAFD; --ok: #15803D; --ok-soft: #DFF3E5;
  --warn: #A16207; --warn-soft: #FBF0D3; --danger: #B91C1C; --danger-soft: #FBE3E3;
  --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 20px;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --shadow: 0 12px 32px rgba(0, 0, 0, .16);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1113; --surface: #171A1D; --surface-2: #1D2125; --sunken: #121417;
    --line: #2B3035; --line-strong: #3A4046; --ink: #ECEDEE; --ink-2: #B3B8BE; --ink-3: #8C929A;
    --accent: #FF7A45; --accent-ink: #1B0C05; --accent-soft: #3A1E12; --accent-text: #FF9466;
    --info: #7FA4FF; --info-soft: #1A2440; --ok: #4ADE80; --ok-soft: #12301D;
    --warn: #FACC15; --warn-soft: #3A3010; --danger: #F87171; --danger-soft: #3D1616;
    color-scheme: dark;
  }
}
:root[data-theme="dark"], .t-dark {
  --bg: #0F1113; --surface: #171A1D; --surface-2: #1D2125; --sunken: #121417;
  --line: #2B3035; --line-strong: #3A4046; --ink: #ECEDEE; --ink-2: #B3B8BE; --ink-3: #8C929A;
  --accent: #FF7A45; --accent-ink: #1B0C05; --accent-soft: #3A1E12; --accent-text: #FF9466;
  --info: #7FA4FF; --info-soft: #1A2440; --ok: #4ADE80; --ok-soft: #12301D;
  --warn: #FACC15; --warn-soft: #3A3010; --danger: #F87171; --danger-soft: #3D1616;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/24px var(--font); }
a { color: var(--accent-text); }
a:hover { color: var(--ink); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 30px; line-height: 38px; letter-spacing: -0.02em; }
h2 { font-size: 18px; line-height: 26px; }
h3 { font-size: 16px; line-height: 24px; }
p { margin: 0; }
img, svg { display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 13px; line-height: 18px; }
.xs { font-size: 12px; line-height: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grow { flex-grow: 1; min-width: 0; }
.hidden, [hidden] { display: none !important; }

/* Buttons: 44 px default (touch), 36 px dense. One primary per view. */
.btn {
  height: 44px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 500 15px var(--font); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { color: var(--ink); background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.06); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-dark:hover { background: var(--ink); color: var(--bg); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; }
.btn-icon { width: 36px; padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 99px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); }
.input, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 400 15px var(--font);
}
.field textarea { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-color: transparent; }
.field .hint { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.field .error, .error-text { font-size: 13px; line-height: 18px; color: var(--danger); }
.field.has-error input, .field.has-error .measure { border-color: var(--danger); }
.measure { height: 44px; display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); overflow: hidden; }
.measure:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; border-color: transparent; }
.measure input { flex: 1; min-width: 0; height: 100%; border: 0 !important; padding: 0 0 0 12px !important; background: transparent; color: var(--ink); font: 500 15px var(--mono) !important; font-variant-numeric: tabular-nums; outline: none !important; }
.measure .unit { padding: 0 12px; font: 13px var(--mono); color: var(--ink-3); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-sm); background: var(--sunken); gap: 2px; }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font: 500 13px var(--font); cursor: pointer; }
.seg.mono button { font-family: var(--mono); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.seg.lg button { height: 34px; padding: 0 14px; font-size: 14px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink-2); font: 500 14px var(--font); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-sm { height: 32px; padding: 0 10px; border-radius: 7px; font-size: 13px; }

/* Cards */
.card { border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.card-pad { padding: 24px; }
.card-head { padding: 18px 24px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }

/* Badges & status */
.badge { height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; background: var(--ink); color: var(--bg); letter-spacing: .02em; }
.badge-accent { background: var(--accent); color: var(--accent-ink); }
.badge-soft { background: var(--sunken); color: var(--ink-2); font-family: var(--mono); font-weight: 500; border-radius: 6px; height: 22px; font-size: 12px; }
.status { height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; background: var(--sunken); color: var(--ink-3); white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.status.completed { background: var(--ok-soft); color: var(--ok); }
.status.processing, .status.queued { background: var(--info-soft); color: var(--info); }
.status.failed { background: var(--danger-soft); color: var(--danger); }
.status.cancelled { background: var(--sunken); color: var(--ink-3); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 10px; display: flex; align-items: center; gap: 10px; font-size: 14px; line-height: 20px; }
.alert svg { flex-shrink: 0; }
.alert-warn { background: var(--warn-soft); }
.alert-danger { background: var(--danger-soft); color: var(--ink); }
.alert-info { background: var(--info-soft); }
.alert-ok { background: var(--ok-soft); }
.alert-accent { background: var(--accent-soft); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 10px 8px; background: var(--surface-2); text-align: left; color: var(--ink-3); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.table td { padding: 12px 8px; border-top: 1px solid var(--line); }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table td.num, .table th.num { text-align: right; }
.table a { color: var(--ink); font-weight: 500; text-decoration: none; }
.table a:hover { color: var(--accent-text); }

/* Empty state */
.empty { padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.empty svg { color: var(--ink-3); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .k { font-size: 12px; color: var(--ink-3); }
.kpi .v { font: 500 26px/32px var(--mono); letter-spacing: -0.02em; }
.kpi .v.sm { font-size: 17px; line-height: 24px; }
.kpi .v small { font-size: 15px; }
.meter { height: 5px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 96px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 17, 19, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 920px; max-height: calc(100vh - 32px); overflow: auto; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.modal-head { padding: 18px 24px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-foot { padding: 16px 24px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand span { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.brand:hover { color: var(--ink); }

/* ---- App shell ---- */
.app { min-height: 100vh; display: flex; }
.sidebar { width: 240px; flex-shrink: 0; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 4px 8px 18px; }
.sidebar .new { height: 40px; margin-bottom: 12px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
.sidebar .new:hover { color: var(--accent-ink); filter: brightness(1.06); }
.nav-item { height: 38px; padding: 0 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--sunken); color: var(--ink); font-weight: 600; }
.nav-item .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--sunken); color: var(--ink-2); font: 500 11px var(--mono); display: flex; align-items: center; justify-content: center; }
.plan-box { padding: 14px; border-radius: 10px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.page { padding: 32px 48px 48px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.topbar { height: 64px; flex-shrink: 0; padding: 0 24px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.mobile-bar { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-bar { display: flex; height: 56px; padding: 0 8px 0 16px; align-items: center; gap: 8px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .sidebar.open { display: flex; position: fixed; inset: 56px 0 0 0; width: auto; height: auto; z-index: 30; }
  .page { padding: 16px; gap: 16px; }
  .topbar { padding: 0 12px; height: auto; min-height: 56px; flex-wrap: wrap; padding-block: 8px; }
  h1 { font-size: 24px; line-height: 30px; }
  .card-pad { padding: 16px; }
  .table th:first-child, .table td:first-child { padding-left: 12px; }
  .table th:last-child, .table td:last-child { padding-right: 12px; }
  .hide-sm { display: none !important; }
}

/* ---- Auth ---- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-form { padding: 32px 48px; display: flex; flex-direction: column; }
.auth-card { width: 100%; max-width: 400px; margin: auto; display: flex; flex-direction: column; gap: 18px; padding: 32px 0; }
.auth-side { padding: 56px; background: var(--bg); color: var(--ink); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.btn-apple { height: 48px; border-radius: 10px; background: #000; color: #fff; border: 0; font: 600 15px var(--font); display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.t-dark .btn-apple, [data-theme="dark"] .btn-apple { background: #fff; color: #000; }
.or { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-3); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-form { padding: 16px; }
}
.auth-art { width: 100%; aspect-ratio: 2800 / 2070; max-width: 640px; }

/* ---- New calculation (design/project/WebNewCalc.dc.html) ---- */
.calc-form { display: flex; flex-direction: column; min-height: 100vh; }
.calc-form .page { flex-grow: 1; }
.title-input { height: 32px; width: 280px; max-width: 100%; padding: 0 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); font: 500 15px var(--font); }
.title-input:hover { border-color: var(--line); }
.title-input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.section-nav a { height: 34px; padding: 0 14px; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.section-nav a:hover { background: var(--surface); color: var(--ink); }
.section-nav .step { width: 20px; height: 20px; border-radius: 99px; border: 1.5px solid var(--line-strong); font: 600 11px var(--mono); color: var(--ink-3); display: flex; align-items: center; justify-content: center; }
.section-nav .step.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.section-nav .step.bad { background: var(--danger); border-color: var(--danger); color: #fff; }
.sheet-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1200px) { .sheet-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .sheet-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

.parts-card { overflow: hidden; }
.parts-scroll { overflow-x: auto; }
.parts { width: 100%; border-collapse: collapse; font-size: 14px; }
.parts th { padding: 10px 8px; background: var(--surface-2); text-align: left; color: var(--ink-3); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.parts .unit-h { text-transform: none; }
.parts td { padding: 4px 8px; border-top: 1px solid var(--line); }
.parts .c-n { width: 64px; padding-left: 24px; font: 13px var(--mono); color: var(--ink-3); white-space: nowrap; }
.parts .c-num { width: 130px; }
.parts .c-qty { width: 80px; }
.parts .c-rot { width: 70px; text-align: center; }
.parts .c-shape { width: 210px; }
.parts .c-del { width: 56px; padding-right: 24px; }
.parts .dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 8px; }
.parts input.cell { width: 100%; height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); font: 14px var(--font); }
.parts input.cell:hover { border-color: var(--line); }
.parts input.cell:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.parts input.num { font: 500 14px var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.parts input.invalid { border-color: var(--danger); color: var(--danger); }
.parts input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.parts tr.bad { background: var(--danger-soft); }
.parts tr.err td { padding: 0 8px 10px; font-size: 13px; color: var(--danger); border-top: 0; }
.shape-btn { height: 32px; max-width: 100%; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink); font: 13px var(--font); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shape-btn svg { flex-shrink: 0; }
.parts-foot { padding: 10px 16px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .parts thead { display: none; }
  .parts, .parts tbody { display: block; }
  .parts tr.part { display: grid; grid-template-columns: 1fr 1fr 70px 44px; gap: 6px 8px; padding: 12px; border-top: 1px solid var(--line); }
  .parts tr.part td { padding: 0; border: 0; }
  .parts .c-n { display: none; }
  .parts .c-label { grid-column: 1 / 4; }
  .parts .c-del { grid-column: 4; grid-row: 1; width: auto; padding: 0; }
  .parts .c-num, .parts .c-qty { width: auto; }
  .parts .c-rot { grid-column: 4; grid-row: 2; width: auto; }
  .parts .c-shape { grid-column: 1 / 5; width: auto; }
  .parts input.cell { border-color: var(--line); }
  .parts tr.err { display: block; }
  .parts tr.err td { display: block; padding: 0 12px 10px; }
}

.cut-types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cut-type { padding: 18px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-align: left; display: flex; gap: 16px; cursor: pointer; font-family: inherit; }
.cut-type svg { flex-shrink: 0; }
.cut-type[aria-checked="true"] { border: 2px solid var(--accent); background: var(--accent-soft); padding: 17px; }
.cut-type .ct-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
@media (max-width: 1100px) { .cut-types { grid-template-columns: 1fr; } .cut-type svg { width: 64px; height: 48px; } }
.seg.quality button { width: 150px; height: auto; padding: 8px 12px; text-align: left; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
@media (max-width: 560px) { .seg.quality { width: 100%; } .seg.quality button { width: auto; flex: 1; padding: 8px; } }

.calc-bar { position: sticky; bottom: 0; min-height: 76px; padding: 12px 48px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--surface); z-index: 10; }
.bar-msg { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.bar-msg.bad { color: var(--danger); }
@media (max-width: 900px) { .calc-bar { padding: 12px 16px; } .calc-bar .btn { flex: 1; } .bar-msg { width: 100%; } }

/* Shape picker (design/project/WebShapePicker.dc.html) */
.shape-modal { max-width: 1080px; }
.sp-body { display: grid; grid-template-columns: 170px minmax(0, 1fr) 320px; min-height: 480px; }
.sp-groups { padding: 16px 12px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.sp-groups button { height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); text-align: left; cursor: pointer; font-size: 14px; }
.sp-groups button[aria-pressed="true"] { background: var(--sunken); color: var(--ink); font-weight: 600; }
.sp-grid { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; align-content: start; overflow: auto; max-height: 560px; }
.sp-shape { height: 104px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer; padding: 6px; font-size: 12px; font-weight: 500; text-align: center; line-height: 14px; }
.sp-shape[aria-checked="true"] { border: 2px solid var(--accent); background: var(--accent-soft); }
.sp-side { padding: 20px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; }
.sp-preview { aspect-ratio: 4 / 3; border-radius: 10px; background: var(--sunken); display: flex; align-items: center; justify-content: center; padding: 12px; }
.sp-preview svg { width: 100%; height: 100%; }
@media (max-width: 900px) {
  .sp-body { grid-template-columns: 1fr; }
  .sp-groups { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sp-groups button { white-space: nowrap; }
  .sp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); max-height: 300px; }
  .sp-side { border-left: 0; border-top: 1px solid var(--line); }
}

/* ---- Calculation page (design/project/WebProcessing + WebResult) ---- */
.calc-title { font-size: 17px; line-height: 24px; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.calc-actions { gap: 8px; }
.dl-group { display: flex; height: 36px; border-radius: 8px; overflow: hidden; background: var(--accent); }
.dl-group a, .dl-group button { padding: 0 12px; border: 0; background: transparent; color: var(--accent-ink); font: 600 13px var(--mono); display: flex; align-items: center; gap: 6px; cursor: pointer; text-decoration: none; }
.dl-group > * + * { border-left: 1px solid rgba(255, 255, 255, .3); }
.dl-group .locked { opacity: .65; }
.dl-group a:hover { color: var(--accent-ink); background: rgba(255, 255, 255, .08); }

.processing { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; align-items: start; max-width: 1200px; }
@media (max-width: 900px) { .processing { grid-template-columns: 1fr; } }
.progress { height: 10px; border-radius: 99px; background: var(--sunken); overflow: hidden; position: relative; }
.progress span { position: absolute; top: 0; bottom: 0; width: 35%; border-radius: 99px; background: var(--accent); animation: indeterminate 1.4s ease-in-out infinite; }
@keyframes indeterminate { 0% { left: -35%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress span { animation: none; left: 0; width: 100%; opacity: .5; } }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--ink-3); }
.steps .dot { width: 24px; height: 24px; border-radius: 99px; border: 2px solid var(--line-strong); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; }
.steps li.done { color: var(--ink); }
.steps li.done .dot { background: var(--ok); border-color: var(--ok); }
.steps li.done .dot::after { content: "✓"; font-size: 13px; font-weight: 700; }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active .dot { border-color: var(--accent); border-right-color: transparent; animation: spin .9s linear infinite; }
.proc-art { padding: 20px; background: var(--sunken); aspect-ratio: 2800 / 2070; opacity: .55; }

.result { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; padding: 20px 24px 32px; align-items: start; }
@media (max-width: 1100px) { .result { grid-template-columns: 1fr; padding: 12px; } }
.result-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.result-side { display: flex; flex-direction: column; gap: 14px; }
.viewer-card { overflow: hidden; }
.viewer-bar { min-height: 52px; padding: 8px 12px 8px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-title { font-size: 15px; font-weight: 600; }
.vsep { width: 1px; height: 22px; background: var(--line); }
.zoom { display: flex; align-items: center; }
.zoom span { width: 44px; text-align: center; }
.viewer { position: relative; height: min(68vh, 640px); min-height: 320px; background: var(--sunken); overflow: hidden; cursor: grab; touch-action: none; outline: none; }
.viewer:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.viewer.dragging { cursor: grabbing; }
.viewer-svg { position: absolute; inset: 16px; }
.viewer-svg svg { width: 100%; height: 100%; }
.viewer [data-piece] { cursor: pointer; }
.piece-card { position: absolute; width: 240px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; z-index: 2; cursor: default; }
.piece-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 13px; }
.piece-card dt { color: var(--ink-3); }
.piece-card dd { margin: 0; text-align: right; font-family: var(--mono); }
.chip-dot { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(23, 25, 28, .4); flex-shrink: 0; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.thumb { width: 132px; flex-shrink: 0; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 6px; cursor: pointer; color: var(--ink); }
.thumb[aria-current="true"] { border: 2px solid var(--accent); padding: 7px; }
.thumb .art { height: 83px; }
.thumb .meta { display: flex; justify-content: space-between; font: 500 11px var(--mono); }
.sheet-row { padding: 10px 18px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); font-size: 13px; cursor: pointer; background: transparent; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; color: var(--ink); }
.sheet-row[aria-current="true"] { background: var(--accent-soft); }
.sheet-row .n { font: 600 13px var(--mono); width: 44px; }
.unplaced { border-color: var(--warn); overflow: hidden; }
.settings-summary { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 13px; }
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); }

/* ---- Dashboard / projects ---- */
.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dash-kpis .kpi { gap: 4px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.project { position: relative; overflow: visible; display: flex; flex-direction: column; }
.project-art { height: 150px; border-radius: 14px 14px 0 0; background: var(--sunken); display: flex; align-items: center; justify-content: center; padding: 12px; text-decoration: none; border-bottom: 1px solid var(--line); }
.project-art img { max-width: 100%; max-height: 100%; }
.project-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.project-name { font-size: 15px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: absolute; right: 10px; top: 190px; z-index: 5; min-width: 180px; padding: 6px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.menu > a, .menu > button { height: 36px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 14px; text-align: left; text-decoration: none; display: flex; align-items: center; cursor: pointer; }
.menu > a:hover, .menu > button:hover { background: var(--surface-2); color: var(--ink); }
.menu .danger { color: var(--danger); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.lib-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; text-align: left; cursor: pointer; color: var(--ink); font: inherit; }
.lib-card:hover { border-color: var(--line-strong); }
.lib-props { display: flex; gap: 28px; font-size: 14px; }
.account { max-width: 860px; }
.avatar { width: 48px; height: 48px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.pref { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.linklike { border: 0; padding: 0; background: none; color: var(--accent-text); font: inherit; cursor: pointer; text-decoration: underline; }
.seg-link { height: 34px; padding: 0 14px; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; display: flex; align-items: center; }
.seg:not(.lg) .seg-link { height: 28px; padding: 0 12px; font-size: 13px; }
.seg-link[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .admin-grid { grid-template-columns: 1fr; } }

/* Developer */
.dev-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; align-items: start; }
.card-head { padding: 16px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 16px; }
.fresh-key { margin: 16px 20px 4px; padding: 14px 16px; border-radius: 10px; background: var(--warn-soft); display: flex; flex-direction: column; gap: 10px; }
.fresh-key code { flex: 1; min-width: 0; height: 38px; box-sizing: border-box; padding: 0 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line-strong); font: 13px var(--mono); display: flex; align-items: center; overflow-x: auto; white-space: nowrap; }
.hook-row { padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); }
.hook-actions { padding-left: 22px; display: flex; flex-wrap: wrap; gap: 8px; }
.nowrap { white-space: nowrap; }
.hook-row:first-child { border-top: 0; }
.hook-row .url { font: 500 14px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hook-secret { padding: 0 20px 14px 42px; margin-top: -4px; display: flex; gap: 8px; align-items: center; }
.hook-secret code { font: 12px var(--mono); padding: 6px 10px; border-radius: 6px; background: var(--sunken); overflow-x: auto; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.dev-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dev-stats b { display: block; font: 500 22px var(--mono); }
.dev-bars { height: 150px; display: flex; align-items: flex-end; gap: 3px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.dev-bars span { flex: 1; min-height: 1px; border-radius: 2px 2px 0 0; background: var(--line-strong); }
.dev-bars span.peak { background: var(--accent); }
.delivery { padding: 10px 20px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.delivery:first-child { border-top: 0; }
.delivery > span { white-space: nowrap; }
.delivery > .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.code-pill { min-width: 40px; height: 22px; padding: 0 6px; box-sizing: border-box; border-radius: 6px; font: 600 12px var(--mono); display: flex; align-items: center; justify-content: center; }
.code-pill.ok { background: var(--ok-soft); color: var(--ok); }
.code-pill.bad { background: var(--danger-soft); color: var(--danger); }
.code-pill.wait { background: var(--sunken); color: var(--ink-2); }
@media (max-width: 1000px) { .dev-grid { grid-template-columns: minmax(0, 1fr); } }
