:root,
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0b0d;
    --bg-elevated: #14161a;
    --bg-card: #1a1d22;
    --bg-soft: #d9ebf7;
    --bg-stage: #050607;
    --panel: #14161a;
    --surface: #16181d;
    --ink: #f4f6f8;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --ink-muted: #9aa3ad;
    --line: #2a3038;
    --accent: #6ea8ff;
    --accent-strong: #4f8fff;
    --accent-soft: rgba(110, 168, 255, 0.18);
    --danger: #ef6b6b;
    --success: #5fd38d;
    --success-bg: rgba(95, 211, 141, 0.08);
    --success-line: #3a4f35;
    --success-ink: #b9f0cd;
    --alert-bg: rgba(239, 107, 107, 0.1);
    --alert-line: #6b3030;
    --alert-ink: #ffb4b4;
    --primary-ink: #173a66;
    --chip-active-ink: #d8e8ff;
    --brand-ink: #1d4f91;
    --header-bg: rgba(10, 11, 13, 0.92);
    --input-bg: #0f1217;
    --preview-bg: #0f1218;
    --tab-bg: #12151a;
    --tab-active-bg: #1f242c;
    --btn-hover-bg: #20242b;
    --btn-hover-border: #3d4654;
    --measure-red: #dc2626;
    --ui-scale: 0.8;
    --viewport-fill: calc(100dvh / var(--ui-scale));
    --radius-lg: calc(18px * var(--ui-scale));
    --radius-md: calc(12px * var(--ui-scale));
    --radius-sm: calc(8px * var(--ui-scale));
    --shadow: 0 calc(24px * var(--ui-scale)) calc(60px * var(--ui-scale)) rgba(0, 0, 0, 0.45);
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.edge-context-menu {
    position: fixed;
    z-index: 1200;
    min-width: 180px;
    background: #1a1d22;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
    padding: 6px;
}

.edge-context-menu[hidden] {
    display: none !important;
}

.edge-context-menu button {
    width: 100%;
    border: 0;
    border-radius: 8px;
    padding: 9px 10px;
    background: transparent;
    color: #e2e8f0;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
}

.edge-context-menu button:hover {
    background: rgba(34, 211, 238, 0.14);
    color: #67e8f9;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f6fa;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-soft: #e8f3fc;
    --bg-stage: #e9edf2;
    --panel: #f4f7fb;
    --surface: #eef3f8;
    --ink: #15202b;
    --text: #15202b;
    --muted: #5f6b78;
    --ink-muted: #5f6b78;
    --line: #d7dee7;
    --accent: #2f6fed;
    --accent-strong: #1f57c7;
    --accent-soft: rgba(47, 111, 237, 0.12);
    --danger: #c53b3b;
    --success: #1f8f5f;
    --success-bg: rgba(31, 143, 95, 0.08);
    --success-line: #b7e2cc;
    --success-ink: #176644;
    --alert-bg: rgba(197, 59, 59, 0.08);
    --alert-line: #efc2c2;
    --alert-ink: #8f2f2f;
    --primary-ink: #173a66;
    --chip-active-ink: #173a66;
    --brand-ink: #1d4f91;
    --header-bg: rgba(255, 255, 255, 0.92);
    --input-bg: #f8fafc;
    --preview-bg: #eef2f7;
    --tab-bg: #f4f7fb;
    --tab-active-bg: #ffffff;
    --btn-hover-bg: #eef3f8;
    --btn-hover-border: #b8c5d4;
    --shadow: 0 calc(18px * var(--ui-scale)) calc(40px * var(--ui-scale)) rgba(21, 32, 43, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    zoom: var(--ui-scale);
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
}

body[data-page="workspace"],
body[data-page="dev-mode"] {
    height: var(--viewport-fill);
    min-height: var(--viewport-fill);
    overflow: hidden;
}

body {
    overscroll-behavior-y: none;
}

button,
input,
select {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: var(--viewport-fill);
    display: flex;
    flex-direction: column;
}

.app-shell.workspace,
.app-shell.dev-shell {
    position: relative;
    height: var(--viewport-fill);
    max-height: var(--viewport-fill);
    min-height: var(--viewport-fill);
    overflow: hidden;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 84px;
    padding: 20px 24px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    border-bottom: 1px solid var(--line);
    background: var(--header-bg);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.measure-tool-btn.is-active {
    border-color: color-mix(in srgb, var(--accent-strong, #38bdf8) 65%, transparent);
    background: color-mix(in srgb, var(--accent-soft, rgba(56, 189, 248, 0.12)) 100%, transparent);
    color: var(--accent-strong, #38bdf8);
}

.measure-tool-btn.is-active .btn-icon svg {
    stroke: currentColor;
}

.quick-measure-setup {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 8px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, #22c55e 45%, var(--line));
    background: color-mix(in srgb, #22c55e 10%, transparent);
}

.quick-measure-setup[hidden] {
    display: none !important;
}

.quick-measure-setup-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #86efac;
    white-space: nowrap;
}

.quick-measure-select,
.cad-fit-qm-select {
    max-width: 11rem;
    min-width: 7.5rem;
    height: 30px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel, #14161a) 92%, transparent);
    color: inherit;
    font-size: 0.75rem;
}

.quick-measure-along,
.cad-fit-qm-along {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.quick-measure-along-opt,
.cad-fit-qm-opt {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 0.72rem;
    cursor: pointer;
    user-select: none;
}

.quick-measure-along-opt:has(input:checked),
.cad-fit-qm-opt:has(input:checked) {
    border-color: color-mix(in srgb, #22c55e 70%, transparent);
    background: color-mix(in srgb, #22c55e 18%, transparent);
    color: #bbf7d0;
}

.quick-measure-along-opt input,
.cad-fit-qm-opt input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.cad-fit-qm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px 2px 2px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel, #14161a) 70%, transparent);
}

.cad-fit-qm-select {
    max-width: 9.5rem;
}

.measure-bounds-btn.is-active {
    border-color: color-mix(in srgb, var(--accent-strong, #38bdf8) 65%, transparent);
    background: color-mix(in srgb, var(--accent-soft, rgba(56, 189, 248, 0.12)) 100%, transparent);
    color: var(--accent-strong, #38bdf8);
}

.measure-bounds-btn.is-active .btn-icon svg {
    stroke: currentColor;
}

.hand-mode-btn.is-active {
    border-color: color-mix(in srgb, var(--accent-strong, #38bdf8) 65%, transparent);
    background: color-mix(in srgb, var(--accent-soft, rgba(56, 189, 248, 0.12)) 100%, transparent);
    color: var(--accent-strong, #38bdf8);
}

.hand-mode-btn.is-active .btn-icon svg {
    stroke: currentColor;
}

.tile-row-align-btn.is-active {
    border-color: color-mix(in srgb, #a855f7 70%, transparent);
    background: color-mix(in srgb, rgba(168, 85, 247, 0.16) 100%, transparent);
    color: #c084fc;
}

.tile-row-align-btn.is-active .btn-icon svg {
    stroke: currentColor;
}

.tile-row-align-btn.is-disabled,
.tile-row-align-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.brand-logo {
    height: 52px;
    width: auto;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-copy {
    min-width: 0;
    line-height: 1.3;
}

.brand-system {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.brand-mark {
    display: none;
}

.brand-short {
    font-size: 0.92em;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.btn-icon svg,
.action-icon svg,
.tab-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.action-icon {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--bg-soft);
    color: var(--primary-ink);
    flex-shrink: 0;
}

.action-icon svg {
    width: 34px;
    height: 34px;
}

.btn {
    border: 1px solid var(--line);
    background: var(--bg-card);
    color: var(--ink);
    border-radius: var(--radius-md);
    padding: 11px 16px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
    border-color: var(--btn-hover-border);
    background: var(--btn-hover-bg);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--bg-soft);
    color: var(--primary-ink);
    border-color: transparent;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(0.97);
}

.btn-icon-only {
    padding: 10px;
    min-width: 42px;
    min-height: 42px;
}

.btn-export .btn-label {
    white-space: nowrap;
}

.btn-ghost {
    background: transparent;
}

.btn-outline-light {
    background: transparent;
    border-color: var(--line);
}

.btn-block {
    width: 100%;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ARMS page backgrounds (landing, workspace, developer mode) */
body[data-page="landing"],
body[data-page="workspace"],
body[data-page="dev-mode"] {
    background-color: #0d0d0d;
}

[data-theme="light"] body[data-page="landing"],
[data-theme="light"] body[data-page="dev-mode"] {
    background-color: #eef0f4;
}

[data-theme="light"] body[data-page="workspace"] {
    background-color: var(--bg);
}

.arms-page-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background-color: #0d0d0d;
}

[data-theme="light"] .arms-page-bg {
    background-color: #eef0f4;
    background-image: url("../images/background/ARMS_background_light.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.arms-page-bg__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.arms-page-bg__dark {
    display: block;
}

.arms-page-bg__light {
    display: none;
}

[data-theme="light"] .arms-page-bg__dark {
    display: none;
}

[data-theme="light"] .arms-page-bg__light {
    display: block;
}

body[data-page="landing"] .app-shell,
body[data-page="dev-mode"] .app-shell {
    position: relative;
    z-index: 1;
    background: transparent;
}

body[data-page="landing"] .landing,
body[data-page="dev-mode"] .dev-shell-main {
    background: transparent;
}

/* Workspace uses a solid shell so the wallpaper grid does not bleed beside the sidebar */
body[data-page="workspace"] .arms-page-bg {
    display: none;
}

body[data-page="workspace"] .app-shell {
    position: relative;
    z-index: 1;
    background: var(--bg);
}

body[data-page="workspace"] .workspace-main {
    background: var(--bg);
}

body[data-page="landing"] .app-header,
body[data-page="workspace"] .app-header,
body[data-page="dev-mode"] .app-header {
    background: rgba(10, 11, 13, 0.78);
    border-bottom-color: rgba(42, 48, 56, 0.72);
}

[data-theme="light"] body[data-page="landing"] .app-header,
[data-theme="light"] body[data-page="workspace"] .app-header,
[data-theme="light"] body[data-page="dev-mode"] .app-header {
    background: rgba(255, 255, 255, 0.82);
    border-bottom-color: rgba(215, 222, 231, 0.9);
}

body[data-page="workspace"] .thumb-strip,
body[data-page="dev-mode"] .dev-thumb-strip {
    background: rgba(10, 11, 13, 0.55);
    backdrop-filter: blur(8px);
}

[data-theme="light"] body[data-page="workspace"] .thumb-strip,
[data-theme="light"] body[data-page="dev-mode"] .dev-thumb-strip {
    background: rgba(255, 255, 255, 0.72);
}

/* ---- Light theme only: dock / calibrate / CAD (does not alter dark base) ---- */
[data-theme="light"] .edge-context-menu {
    background: var(--bg-card);
    border-color: var(--line);
    box-shadow: var(--shadow);
}

[data-theme="light"] .edge-context-menu button {
    color: var(--ink);
}

[data-theme="light"] .edge-context-menu button:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

[data-theme="light"] .calibrate-stat {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

[data-theme="light"] .calibrate-stat strong {
    color: var(--accent-strong);
}

[data-theme="light"] .calibrate-tile-ref {
    border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
    background: var(--bg-soft);
    color: var(--ink);
}

[data-theme="light"] .calibrate-sample-card {
    border-color: var(--line);
    background: var(--bg-elevated);
    color: var(--ink);
}

[data-theme="light"] .calibrate-next {
    color: var(--accent-strong);
}

[data-theme="light"] .calibrate-pair-stats {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
    background: var(--bg-soft);
    color: var(--ink);
}

[data-theme="light"] .calibrate-pair-row span {
    color: var(--muted);
}

[data-theme="light"] .calibrate-pair-row strong {
    color: var(--ink);
}

[data-theme="light"] .cad-script {
    border-color: var(--line);
    background: var(--input-bg);
    color: var(--ink);
}

[data-theme="light"] .cad-summary-grid > div {
    border-color: var(--line);
    background: var(--bg-elevated);
}

[data-theme="light"] .cad-errors {
    color: var(--danger);
}

[data-theme="light"] .cad-sync-bar {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

[data-theme="light"] .cad-preview-canvas {
    background: var(--preview-bg);
}

[data-theme="light"] .cad-live-tag {
    color: #1f8f5f;
}

[data-theme="light"] .cad-sync-bar.is-live {
    background: color-mix(in srgb, var(--success) 10%, var(--surface));
}

[data-theme="light"] .cad-sync-bar.is-blocked {
    background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

[data-theme="light"] .dock-details {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

[data-theme="light"] .hotkey {
    border-color: var(--line);
    background: var(--bg-elevated);
    color: var(--muted);
}

[data-theme="light"] .selection-panel,
[data-theme="light"] .selection-panel--compact {
    background: var(--panel);
}

[data-theme="light"] .selection-ref-option span {
    background: var(--surface);
    color: var(--ink);
}

[data-theme="light"] .selection-details {
    background: var(--surface);
}

[data-theme="light"] .measure-bar-toggle {
    border-color: var(--line);
    background: var(--bg-elevated);
    color: var(--ink);
}

[data-theme="light"] .measure-bar-toggle input {
    accent-color: var(--accent);
}

[data-theme="light"] .arms-confirm-overlay {
    background: rgba(21, 32, 43, 0.28);
}

.landing {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 28px 24px 56px;
}

/* Landing header: logo already carries Milieu — avoid repeating product name. */
body[data-page="landing"] .brand-copy {
    display: none;
}

body[data-page="landing"] .brand {
    gap: 0;
}

body[data-page="landing"] .brand-logo {
    height: 44px;
    max-width: min(168px, 46vw);
}

.landing-hero {
    width: min(520px, 100%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.landing-logo {
    width: min(240px, 72vw);
    height: auto;
    margin: 0 0 22px;
    opacity: 0;
    animation: landing-rise 0.7s ease-out 0.05s forwards;
}

.landing-product {
    margin: 0 0 14px;
    font-size: clamp(1.55rem, 4.2vw, 2.15rem);
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--ink);
    opacity: 0;
    animation: landing-rise 0.7s ease-out 0.14s forwards;
}

.landing-lede {
    margin: 0 0 28px;
    color: color-mix(in srgb, var(--muted) 88%, var(--ink));
    line-height: 1.55;
    font-size: clamp(0.98rem, 2.4vw, 1.08rem);
    max-width: 42ch;
    opacity: 0;
    animation: landing-rise 0.7s ease-out 0.22s forwards;
}

.landing-title-end {
    white-space: nowrap;
}

.landing-import {
    width: min(340px, 100%);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border-radius: 16px;
    border: 1px dashed color-mix(in srgb, var(--accent) 42%, var(--line));
    background: color-mix(in srgb, var(--bg-card) 82%, transparent);
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    opacity: 0;
    animation: landing-rise 0.75s ease-out 0.32s forwards;
}

.landing-import:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    border-style: solid;
    background: color-mix(in srgb, var(--bg-card) 92%, var(--accent-soft));
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.34);
}

.landing-import:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.landing-import-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: var(--bg-soft);
    color: var(--primary-ink);
}

.landing-import-icon svg {
    width: 26px;
    height: 26px;
    display: block;
}

.landing-import-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.landing-import-title {
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.landing-import-sub {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.35;
}

[data-theme="light"] .landing-import {
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 16px 36px rgba(23, 58, 102, 0.1);
}

[data-theme="light"] .landing-import:hover {
    background: #fff;
    box-shadow: 0 20px 44px rgba(23, 58, 102, 0.14);
}

.landing-hero .queue-panel {
    width: 100%;
    margin-top: 20px;
    opacity: 0;
    animation: landing-rise 0.55s ease-out forwards;
}

@keyframes landing-rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .landing-logo,
    .landing-product,
    .landing-lede,
    .landing-import,
    .landing-hero .queue-panel {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

.landing-toast {
    position: fixed;
    top: calc(72px + env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(calc(100% - 32px), 320px);
    margin: 0;
    padding: 11px 12px 11px 14px;
    border-radius: 999px;
    border: 1px solid rgba(248, 113, 113, 0.35);
    background: linear-gradient(180deg, rgba(69, 10, 10, 0.94), rgba(42, 8, 8, 0.98));
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
    text-align: left;
    transform: translateX(-50%);
    animation: landing-toast-in 0.28s ease-out;
}

@keyframes landing-toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.landing-toast[hidden] {
    display: none !important;
}

.landing-toast-icon {
    flex: 0 0 auto;
    display: inline-flex;
    width: 20px;
    height: 20px;
    color: #f87171;
}

.landing-toast-icon svg {
    width: 20px;
    height: 20px;
}

.landing-toast-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.landing-toast-text strong {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    color: #fecaca;
}

.landing-toast-text span {
    font-size: 0.78rem;
    line-height: 1.35;
    color: #fca5a5;
}

.landing-toast-text span:empty,
.landing-toast-text span[hidden] {
    display: none;
}

.landing-toast-close {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: #fca5a5;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.landing-toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

[data-theme="light"] .landing-toast {
    border-color: rgba(220, 38, 38, 0.22);
    background: linear-gradient(180deg, #fff5f5, #fee2e2);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .landing-toast-text strong {
    color: #991b1b;
}

[data-theme="light"] .landing-toast-text span {
    color: #b91c1c;
}

[data-theme="light"] .landing-toast-icon,
[data-theme="light"] .landing-toast-close {
    color: #dc2626;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 36px;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.action-grid--single {
    grid-template-columns: minmax(0, 1fr);
    max-width: 280px;
}

.action-card {
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    min-height: 168px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid var(--line);
    color: var(--ink);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.action-card.selected {
    background: var(--bg-soft);
    border-color: transparent;
    color: var(--primary-ink);
    box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.12);
}

.action-card.selected .action-icon {
    background: rgba(23, 58, 102, 0.12);
    color: var(--primary-ink);
}

.action-card .title {
    font-size: 1.15rem;
    font-weight: 700;
}

.action-card .subtitle {
    font-size: 0.95rem;
    color: var(--muted);
}

.action-card.selected .subtitle {
    color: var(--primary-ink);
    opacity: 0.72;
}

.hidden-input {
    display: none;
}

.queue-panel {
    margin-top: 24px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: left;
}

.queue-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.queue-head strong {
    font-size: 0.95rem;
}

.thumb-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.thumb {
    position: relative;
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    background: #0f1115;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
}

.start-row {
    margin-top: 16px;
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: var(--viewport-fill);
    max-height: var(--viewport-fill);
    overflow: hidden;
}

.workspace .app-header {
    flex-shrink: 0;
}

/* Compact toast inside the stage area — never full-bleed across the header */
.workspace .alert,
.workspace .result-banner {
    position: absolute;
    left: 50%;
    right: auto;
    top: 10px;
    z-index: 46;
    width: max-content;
    max-width: min(420px, calc(100% - 24px));
    margin: 0;
    padding: 9px 14px;
    font-size: 0.8rem;
    line-height: 1.35;
    text-align: center;
    transform: translateX(-50%);
    pointer-events: none;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
    animation: workspace-toast-in 0.22s ease-out;
}

.workspace .alert {
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.94);
    color: #e2e8f0;
    backdrop-filter: blur(10px);
}

.workspace .alert.alert-error {
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(69, 10, 10, 0.94);
    color: #fecaca;
}

.workspace .result-banner {
    top: 10px;
    border: 1px solid rgba(52, 211, 153, 0.35);
    background: rgba(6, 40, 28, 0.94);
    color: #a7f3d0;
    backdrop-filter: blur(10px);
}

.workspace .alert:not([hidden]) ~ .result-banner:not([hidden]) {
    top: calc(10px + 3.1rem);
}

@keyframes workspace-toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .workspace .alert,
    .workspace .result-banner {
        animation: none;
    }
}

[data-theme="light"] .workspace .alert {
    border-color: rgba(100, 116, 139, 0.28);
    background: rgba(255, 255, 255, 0.96);
    color: #0f172a;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .workspace .alert.alert-error {
    border-color: rgba(220, 38, 38, 0.35);
    background: rgba(254, 242, 242, 0.98);
    color: #991b1b;
}

[data-theme="light"] .workspace .result-banner {
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(236, 253, 245, 0.98);
    color: #065f46;
}

.workspace-main {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace-main > .workspace-body {
    flex: 1;
    min-height: 0;
}

.workspace-batch-lock .control-dock .detection-tuning {
    opacity: 0.65;
}

html.workspace-detect-locked,
body.workspace-detect-locked {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
    height: 100%;
}

body.workspace-detect-locked {
    position: fixed;
    width: 100%;
}

.app-shell.workspace.workspace-batch-lock {
    overflow: hidden;
    touch-action: none;
}

.app-shell.workspace.workspace-batch-lock > :not(.app-header):not(.batch-detect-overlay) {
    pointer-events: none;
    user-select: none;
}

.app-shell.workspace.workspace-batch-lock .app-header {
    pointer-events: auto;
    touch-action: manipulation;
    position: relative;
    z-index: 50;
}

.app-shell.workspace.workspace-batch-lock .workspace-body,
.app-shell.workspace.workspace-batch-lock .control-dock,
.app-shell.workspace.workspace-batch-lock .thumb-strip,
.app-shell.workspace.workspace-batch-lock .tab-scroll,
.app-shell.workspace.workspace-batch-lock .measure-results-section,
.app-shell.workspace.workspace-batch-lock .control-dock .tab-panel,
.app-shell.workspace.workspace-batch-lock .workspace-main {
    overflow: hidden !important;
}

.batch-detect-overlay {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    padding-top: max(24px, env(safe-area-inset-top, 0px));
    background: rgba(4, 6, 10, 0.78);
    backdrop-filter: blur(6px);
    pointer-events: auto;
    touch-action: none;
    overscroll-behavior: contain;
}

.batch-detect-overlay[hidden] {
    display: none;
}

.batch-detect-card {
    width: min(360px, 100%);
    padding: 22px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    text-align: center;
}

.batch-detect-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 14px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--accent-strong);
    animation: batch-detect-spin 0.85s linear infinite;
}

@keyframes batch-detect-spin {
    to {
        transform: rotate(360deg);
    }
}

.batch-detect-title {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
}

.batch-detect-detail {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.45;
    color: var(--muted);
}

.workspace-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0;
}

.thumb-strip {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.thumb-strip .thumb {
    cursor: pointer;
    width: 56px;
    height: 56px;
}

.thumb-strip .thumb.active {
    border-color: var(--accent-strong);
    scroll-snap-align: start;
    flex-shrink: 0;
}

.thumb-strip .thumb.detecting {
    opacity: 0.72;
}

.thumb-strip .thumb.detecting::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid var(--accent-strong);
    animation: thumb-detect-pulse 1.1s ease-in-out infinite;
    pointer-events: none;
}

@keyframes thumb-detect-pulse {
    0%,
    100% {
        opacity: 0.35;
    }
    50% {
        opacity: 1;
    }
}

.stage-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 8px 12px 10px;
}

.stage-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.stage-toolbar-lead {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.stage-toolbar .selection-pill {
    font-size: 0.78rem;
    color: var(--muted);
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-card);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(52vw, 280px);
}

.stage-toolbar .btn-icon-only {
    min-width: 34px;
    min-height: 34px;
    padding: 6px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.zoom-label {
    min-width: 40px;
    text-align: center;
    font-size: 0.76rem;
    color: var(--muted);
}

.stage {
    position: relative;
    flex: 1;
    min-height: 0;
    background: var(--bg-stage);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    touch-action: none;
}

.stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.stage img {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.stage.stage-segment-mode {
    cursor: crosshair;
}

.segment-hint {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    z-index: 4;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #fff;
    background: rgba(10, 11, 13, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.14);
    pointer-events: none;
    white-space: nowrap;
}

.roof-segment-panel {
    display: grid;
    gap: 6px;
    padding: 8px 0 2px;
    border-top: 1px solid var(--line);
}

.roof-segment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.roof-segment-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
}

.roof-segment-status {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
}

.roof-segment-status.is-ready {
    color: #34d399;
}

.roof-segment-status.is-drawing {
    color: #f5b942;
}

.roof-segment-actions,
.roof-segment-apply-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.roof-segment-hint {
    margin: 0;
    font-size: 0.68rem;
    line-height: 1.35;
    color: var(--muted);
}

.detection-tuning-actions .btn-primary.btn-compact {
    min-height: 28px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 700;
}

.detection-tuning {
    padding: 8px 12px 10px;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 6px;
    flex-shrink: 0;
}

.detection-tuning--in-tab {
    padding: 0;
    border-bottom: none;
    gap: 10px;
}

.detection-tuning--in-tab .detection-tuning-actions {
    justify-content: flex-end;
}

.detection-tuning-head {
    display: grid;
    gap: 8px;
}

.detection-tuning-lead {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--muted);
}

.dock-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
}

.dock-section + .dock-section {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.dock-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.25;
}

.dock-section-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
}

.measure-section-label {
    margin: 0 0 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    line-height: 1.2;
}

.detection-tuning-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.detection-tuning-actions .btn-icon-only {
    min-width: 28px;
    min-height: 28px;
    padding: 5px;
}

.detection-tuning-actions .btn-icon svg {
    width: 15px;
    height: 15px;
}

.btn-compact {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.76rem;
}

.tuning-field {
    display: grid;
    gap: 5px;
}

.tuning-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.76rem;
    color: var(--ink);
}

.tuning-label em {
    font-style: normal;
    font-variant-numeric: tabular-nums;
    color: var(--accent-strong);
    font-weight: 600;
}

.tuning-field input[type="range"] {
    width: 100%;
    margin: 0;
    accent-color: var(--accent-strong);
}

.detection-mode-panel {
    display: grid;
    gap: 8px;
    padding: 2px 0 4px;
}

.detection-mode-panel.is-disabled {
    opacity: 0.72;
}

.tuning-field--mode {
    gap: 8px;
}

.detection-mode-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.detection-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    min-height: 58px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-elevated, rgba(255, 255, 255, 0.04));
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.detection-mode-btn:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--accent-strong) 35%, var(--line));
    transform: translateY(-1px);
}

.detection-mode-btn:focus-visible {
    outline: none;
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-strong) 22%, transparent);
}

.detection-mode-btn.is-active {
    border-color: var(--accent-strong);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-strong) 18%, transparent);
}

.detection-mode-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.detection-mode-btn-label {
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
}

.detection-mode-btn-meta {
    font-size: 0.66rem;
    line-height: 1.25;
    color: var(--muted);
}

.detection-mode-select-wrap {
    position: relative;
}

.detection-mode-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-elevated, rgba(255, 255, 255, 0.04));
    color: var(--ink);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.detection-mode-select:hover {
    border-color: color-mix(in srgb, var(--accent-strong) 35%, var(--line));
}

.detection-mode-select:focus {
    outline: none;
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-strong) 22%, transparent);
}

.detection-mode-select-chevron {
    position: absolute;
    top: 50%;
    right: 14px;
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
}

.detection-mode-tagline {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--muted);
}

.detection-mode-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.detection-mode-chip {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 7px 8px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--accent-strong) 6%, transparent);
    text-align: center;
}

.detection-mode-chip-label {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detection-mode-chip strong {
    font-size: 0.78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent-strong);
}

html[data-theme="light"] .detection-mode-select {
    background: #fff;
}

html[data-theme="light"] .detection-mode-chip {
    background: #f8fafc;
}

html[data-theme="light"] .detection-mode-btn {
    background: #fff;
}

html[data-theme="light"] .detection-mode-btn.is-active {
    background: color-mix(in srgb, var(--accent-soft) 88%, white);
}

@media (min-width: 420px) {
    .detection-mode-buttons {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1180px) {
    .detection-mode-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .detection-mode-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detection-mode-btn {
        min-height: 54px;
        padding: 9px 10px;
    }

    .detection-mode-meta {
        grid-template-columns: 1fr;
    }

    .detection-mode-chip {
        grid-template-columns: 1fr auto;
        align-items: center;
        text-align: left;
    }
}

.control-dock {
    margin: 0 12px 10px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    max-height: min(52vh, 420px);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.mobile-dock-handle,
.mobile-dock-backdrop {
    display: none;
}

.mobile-dock-sheet {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.tab-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 6px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.tab-btn {
    border: 1px solid var(--line);
    background: var(--tab-bg);
    color: var(--ink);
    border-radius: var(--radius-sm);
    padding: 8px 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
}

.tab-btn.active {
    background: var(--tab-active-bg);
    border-color: var(--accent-strong);
    box-shadow: inset 0 0 0 1px rgba(79, 143, 255, 0.08);
}

.tab-panel {
    display: none;
    padding: 0;
    overflow: hidden;
    min-height: 0;
}

.tab-panel.active {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.areas-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px;
    min-height: min-content;
}

.measure-filter-section,
.measure-results-section,
.measure-adjust-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.measure-adjust-wrap {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.measure-adjust-wrap[hidden] {
    display: none !important;
}

.area-tag-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.area-tag {
    border: 1px solid var(--line);
    background: var(--tab-bg);
    color: var(--ink);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    text-align: center;
    line-height: 1.25;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.area-tag.active {
    border-color: var(--accent);
    background: rgba(79, 143, 255, 0.18);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px rgba(79, 143, 255, 0.12);
}

.area-tag-all {
    grid-column: 1 / -1;
    justify-self: stretch;
    font-weight: 700;
}

.measure-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.measure-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    font-size: 0.8rem;
    line-height: 1.35;
}

.measure-item > span {
    flex: 1;
    min-width: 0;
}

.measure-item button {
    border: 0;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.76rem;
    padding: 4px 8px;
    flex-shrink: 0;
    border-radius: 6px;
}

.measure-item button:hover {
    background: rgba(220, 38, 38, 0.1);
}

.measure-adjust-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.measure-adjust-empty {
    margin: 0;
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--muted);
    text-align: center;
    background: var(--bg);
}

.measure-adjust {
    display: grid;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--tab-bg);
}

.measure-adjust-head strong {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.measure-adjust-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.measure-adjust-target {
    margin: 0;
    flex: 1 1 120px;
    min-width: 0;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--ink);
}

.measure-adjust-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.measure-adjust-reset {
    padding: 2px 8px;
}

.measure-adjust-hint {
    margin: 10px 0 0;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--muted);
}

.action-bar,
.workspace-measure-bar {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    margin: 0;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
    background: var(--bg-card);
}

.control-dock--areas .workspace-measure-bar {
    display: grid;
}

.workspace-measure-bar .btn,
.action-bar .btn {
    padding: 9px 12px;
    font-size: 0.86rem;
    min-height: 40px;
}

#tab-tile.active,
#tab-custom.active {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    gap: 0;
}

.workspace-tab-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px;
    min-height: min-content;
}

.workspace-tab-hint {
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--accent-soft);
    color: var(--ink);
    font-size: 0.8rem;
    line-height: 1.45;
}

.workspace-tab-hint strong {
    font-weight: 700;
    color: var(--accent-strong);
}

.workspace-tab-hint-icon {
    display: inline-block;
    font-size: 0.9em;
    opacity: 0.85;
}

.workspace-tab-hint--compact {
    padding: 9px 11px;
    font-size: 0.78rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tile-picker-selected {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
    background: var(--accent-soft);
}

.tile-picker-selected-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.tile-picker-selected-size {
    margin-left: auto;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--muted);
}

.tile-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.tile-picker-card {
    display: grid;
    gap: 4px;
    padding: 12px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--tab-bg);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 72px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.tile-picker-card.active {
    border-color: var(--accent);
    background: rgba(79, 143, 255, 0.12);
    box-shadow: inset 0 0 0 1px rgba(79, 143, 255, 0.2);
}

.tile-picker-name {
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.25;
}

.tile-picker-size {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--accent-strong);
}

.tile-picker-notes {
    font-size: 0.68rem;
    line-height: 1.3;
    color: var(--muted);
}

.tile-picker-empty {
    margin: 0;
    padding: 14px 12px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
}

.field-tile-select--fallback {
    margin-top: 2px;
}

.custom-tile-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, var(--accent-soft), var(--tab-bg));
}

.custom-tile-preview-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    font-size: 1.2rem;
    color: var(--accent-strong);
    flex-shrink: 0;
}

.custom-tile-preview-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.custom-tile-preview-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.custom-tile-preview-size {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
}

.unit-chip-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.unit-chip {
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--tab-bg);
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.unit-chip.active {
    border-color: var(--accent);
    background: rgba(79, 143, 255, 0.14);
    color: var(--accent-strong);
}

.field-touch input {
    min-height: 48px;
    font-size: 1rem;
}

.btn-touch {
    min-height: 50px;
    font-size: 0.95rem;
    font-weight: 700;
}

.custom-tile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.custom-tile-unit-field {
    grid-column: 1 / -1;
}

.field-tile-select select {
    min-height: 48px;
}

.measure-list-empty {
    margin: 0;
    padding: 14px 12px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.45;
    text-align: center;
}

.measure-list-empty strong {
    color: var(--accent-strong);
    font-weight: 700;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 0;
}

.field span {
    color: var(--muted);
    font-size: 0.8rem;
}

.field input,
.field select {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--input-bg);
    color: var(--ink);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 0.9rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#tab-custom .btn-block {
    margin-top: 4px;
    min-height: 40px;
    padding: 9px 12px;
    font-size: 0.86rem;
}

.result-banner {
    margin: 0 16px 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--success-line);
    background: var(--success-bg);
    color: var(--success-ink);
    font-size: 0.92rem;
    line-height: 1.45;
}

.alert {
    margin: 12px 16px 0;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--alert-line);
    background: var(--alert-bg);
    color: var(--alert-ink);
}

.alert.alert-error {
    border-color: rgba(220, 38, 38, 0.45);
    background: rgba(220, 38, 38, 0.12);
    color: #fecaca;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 5;
    color: var(--ink);
    font-weight: 600;
}

.loading-overlay.visible {
    display: grid;
}

.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(4, 6, 10, 0.62);
    backdrop-filter: blur(6px);
}

.help-overlay[hidden] {
    display: none;
}

.help-modal {
    width: min(640px, 100%);
    max-height: min(88vh, 760px);
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.help-modal--wide,
.help-modal--guide {
    width: min(720px, 100%);
    max-height: min(90vh, 860px);
}

.cad-fit-overlay {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: grid;
    place-items: stretch;
    padding: 12px;
    background: rgba(4, 6, 10, 0.72);
    backdrop-filter: blur(8px);
}

.cad-fit-overlay[hidden] {
    display: none;
}

.cad-fit-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    background: var(--bg-card, #121417);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg, 14px);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.cad-fit-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.cad-fit-header-copy h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
}

.cad-fit-header-copy p {
    margin: 0;
    font-size: 0.78rem;
    opacity: 0.72;
    max-width: 52ch;
}

.cad-fit-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.cad-fit-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: 0;
    min-height: 0;
    flex: 1;
}

.cad-fit-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: color-mix(in srgb, var(--preview-bg, #0b0d10) 92%, #000);
    border-right: 1px solid var(--line);
}

.cad-fit-zoom {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel, #14161a) 88%, transparent);
    backdrop-filter: blur(6px);
}

.cad-fit-zoom-label {
    min-width: 3.2rem;
    text-align: center;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}

.cad-fit-canvas {
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 280px;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

.cad-fit-stage-hint {
    margin: 0;
    padding: 8px 12px;
    font-size: 0.74rem;
    opacity: 0.7;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}

.cad-fit-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    min-height: 0;
    overflow: auto;
}

.cad-fit-live {
    display: grid;
    gap: 4px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel, #14161a) 80%, transparent);
}

.cad-fit-live-label {
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.65;
}

.cad-fit-live-value {
    font-size: 1.2rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    color: #22d3ee;
}

.cad-fit-live-tiles {
    font-size: 0.84rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.cad-fit-live-target {
    font-size: 0.8rem;
    opacity: 0.78;
    font-variant-numeric: tabular-nums;
}

.cad-fit-script {
    min-height: 220px;
    flex: 1;
    font-size: 0.72rem;
}

.cad-fit-live-value.is-matched {
    color: #34d399;
}

.cad-fit-live--side {
    border-color: color-mix(in srgb, #22d3ee 35%, var(--line));
}

.cad-fit-live--side .cad-fit-live-value {
    font-size: 1.05rem;
    color: #67e8f9;
}

.cad-fit-triangle-tune,
.cad-fit-edge-tune {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, #fbbf24 40%, var(--line));
    background: color-mix(in srgb, #fbbf24 8%, var(--panel, #14161a));
}

.cad-fit-edge-tune {
    border-color: color-mix(in srgb, #22d3ee 40%, var(--line));
    background: color-mix(in srgb, #22d3ee 8%, var(--panel, #14161a));
}

.cad-fit-triangle-tune-hint {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.35;
    opacity: 0.8;
}

.cad-fit-triangle-field {
    gap: 4px;
}

.cad-fit-triangle-field input {
    width: 100%;
    font-variant-numeric: tabular-nums;
}

.cad-fit-triangle-field em {
    font-style: normal;
    font-size: 0.72rem;
    opacity: 0.7;
}

.cad-fit-triangle-tune-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.cad-fit-note {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.4;
    opacity: 0.65;
}

@media (max-width: 900px) {
    .cad-fit-body {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(240px, 1fr) auto;
    }

    .cad-fit-stage {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        min-height: 42vh;
    }

    .cad-fit-header {
        flex-wrap: wrap;
    }
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elevated);
}

.help-header h2 {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.guide-header-copy {
    display: grid;
    gap: 2px;
}

.guide-eyebrow {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.help-body,
.guide-body {
    padding: 16px 18px 20px;
    overflow-y: auto;
}

.guide-lead {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.guide-section {
    margin-bottom: 20px;
}

.guide-section:last-child {
    margin-bottom: 0;
}

.guide-section-title {
    margin: 0 0 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink);
}

.guide-section-lead {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.guide-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.guide-step {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 12px;
    align-items: start;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--input-bg) 88%, transparent);
}

.guide-step-num {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 700;
}

.guide-step h4 {
    margin: 0 0 2px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
}

.guide-step p {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.guide-tile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.guide-tile-card {
    display: grid;
    grid-template-rows: auto 1fr;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--input-bg);
    transition: border-color 0.18s ease, transform 0.18s ease;
}

.guide-tile-card:hover {
    border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
    transform: translateY(-1px);
}

.guide-tile-media {
    aspect-ratio: 16 / 11;
    background:
        linear-gradient(160deg, color-mix(in srgb, var(--accent-soft) 55%, transparent), transparent 60%),
        var(--bg-elevated);
    display: grid;
    place-items: center;
    overflow: hidden;
}

.guide-tile-media.is-empty::after {
    content: "No preview";
    font-size: 0.72rem;
    color: var(--muted);
}

.guide-tile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.guide-tile-fallback {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 1rem;
}

.guide-tile-copy {
    padding: 10px 11px 12px;
}

.guide-tile-copy h4 {
    margin: 0 0 4px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
}

.guide-tile-copy p {
    margin: 0;
    font-size: 0.74rem;
    color: var(--muted);
    line-height: 1.35;
}

.guide-empty {
    margin: 0;
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.86rem;
}

.guide-hotkeys {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.guide-hotkey {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
}

.guide-hotkey kbd {
    display: inline-block;
    margin: 0;
    padding: 3px 7px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--bg-card);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.guide-hotkey span {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.3;
}

/* Legacy help selectors kept for compatibility */
.help-intro,
.help-tip,
.help-block-lead {
    margin: 0 0 12px;
    color: var(--muted);
    line-height: 1.5;
    font-size: 0.9rem;
}

.help-block {
    margin-bottom: 18px;
}

.help-block-title {
    margin: 0 0 10px;
    font-size: 0.92rem;
    font-weight: 700;
}

.help-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.help-step {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--input-bg);
}

.help-step-num {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 0.8rem;
}

.help-step h4 {
    margin: 0 0 2px;
    font-size: 0.9rem;
}

.help-step p {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.help-hotkeys {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.help-hotkey-row {
    display: grid;
    grid-template-columns: minmax(7.5rem, 11rem) 1fr;
    gap: 12px;
    align-items: start;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
}

.help-hotkey-keys {
    display: inline-block;
    margin: 0;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--bg-card);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
}

.help-hotkey-action {
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

@media (max-width: 640px) {
    .help-hotkey-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .guide-tile-grid,
    .guide-hotkeys {
        grid-template-columns: 1fr;
    }

    .help-modal--guide {
        max-height: min(92dvh, 900px);
    }
}

@media (min-width: 720px) {
    .guide-tile-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.help-grid {
    display: grid;
    gap: 12px;
}

.help-card {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--input-bg);
}

.help-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.help-card-icon svg {
    width: 20px;
    height: 20px;
}

.help-card h3 {
    margin: 0 0 4px;
    font-size: 0.98rem;
}

.help-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.help-card kbd,
.help-tip kbd {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid var(--line);
    background: var(--bg-card);
    color: var(--ink);
    font-size: 0.8rem;
    font-family: inherit;
}

.help-block-tiles {
    margin-bottom: 18px;
}

.tile-sample-intro {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.55;
}

.tile-sample-intro strong {
    color: var(--ink);
    font-weight: 600;
}

.tile-sample-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.tile-sample-card {
    min-width: 0;
    min-height: 0;
    perspective: 1200px;
}

.tile-sample-card.is-flipped {
    z-index: 2;
}

.tile-sample-flip {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    -webkit-tap-highlight-color: transparent;
    transition:
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        transform 0.22s ease;
}

.tile-sample-flip:hover {
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.tile-sample-card.is-flipped .tile-sample-flip {
    border-color: rgba(56, 189, 248, 0.42);
    box-shadow: 0 14px 36px rgba(14, 116, 144, 0.18);
}

.tile-sample-flip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.tile-sample-flip-inner {
    display: block;
    position: relative;
    width: 100%;
    min-height: 200px;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.33, 1, 0.38, 1);
}

.tile-sample-card.is-flipped .tile-sample-flip-inner {
    transform: rotateY(180deg);
}

.tile-sample-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 11px;
    overflow: hidden;
    background: var(--input-bg);
}

.tile-sample-front {
    transform: rotateY(0deg);
}

.tile-sample-back {
    transform: rotateY(180deg);
    padding: 12px;
    background: var(--bg-elevated);
}

.tile-sample-back-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.tile-sample-media {
    position: relative;
    flex: 1 1 auto;
    min-height: 112px;
    aspect-ratio: 4 / 3;
    background: #0f1419;
    overflow: hidden;
}

.tile-sample-media-shade {
    position: absolute;
    inset: auto 0 0;
    height: 42%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.42), transparent);
    pointer-events: none;
}

.tile-sample-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.tile-sample-front-copy {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 11px 11px;
    border-top: 1px solid var(--line);
    background: var(--input-bg);
}

.tile-sample-name {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tile-sample-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.tile-sample-hint-icon {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    font-size: 0.62rem;
    line-height: 1;
}

[data-theme="light"] .tile-sample-hint-icon {
    background: rgba(2, 132, 199, 0.1);
    color: #0284c7;
}

.tile-sample-back-name {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--muted);
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tile-sample-size-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--input-bg);
}

.tile-sample-size-label {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--muted);
}

.tile-sample-size-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.tile-sample-size-cell {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.tile-sample-size-value {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.tile-sample-size-unit {
    margin-left: 2px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
}

.tile-sample-size-caption {
    font-size: 0.64rem;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.03em;
}

.tile-sample-size-sep {
    flex-shrink: 0;
    padding-bottom: 14px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted);
    opacity: 0.7;
}

.tile-sample-footnote {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.tile-sample-footnote code {
    font-size: 0.76rem;
}

@media (min-width: 560px) {
    .tile-sample-gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
    }

    .tile-sample-flip-inner {
        min-height: 208px;
    }

    .tile-sample-name {
        font-size: 0.82rem;
    }

    .tile-sample-size-value {
        font-size: 1.22rem;
    }
}

@media (min-width: 820px) {
    .tile-sample-gallery {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1040px) {
    .tile-sample-gallery {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .tile-sample-flip-inner {
        transition: none;
        transform: none !important;
    }

    .tile-sample-back {
        position: absolute;
        transform: none;
    }

    .tile-sample-card:not(.is-flipped) .tile-sample-back {
        display: none;
    }

    .tile-sample-card.is-flipped .tile-sample-front {
        display: none;
    }
}

.help-tip {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--accent-soft);
    color: var(--ink);
    font-size: 0.86rem;
    line-height: 1.5;
}

/* Developer mode password popup — no page backdrop */
.dev-auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: grid;
    place-items: center;
    padding: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: transparent;
    pointer-events: none;
}

.dev-auth-overlay:not([hidden]) {
    pointer-events: auto;
}

.dev-auth-overlay[hidden] {
    display: none;
}

.dev-auth-modal {
    position: relative;
    width: min(460px, calc(100vw - 24px));
    max-height: min(92dvh, 720px);
    overflow: auto;
    pointer-events: auto;
    background: var(--bg-card);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: clamp(16px, 4vw, 24px);
    box-shadow: var(--shadow);
    padding: clamp(22px, 5vw, 34px) clamp(18px, 4.5vw, 34px) clamp(20px, 4vw, 28px);
    -webkit-overflow-scrolling: touch;
}

.dev-auth-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 24px 24px 0 0;
    background: linear-gradient(90deg, var(--accent-strong) 0%, var(--success) 100%);
}

.dev-auth-info-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--accent-strong);
    border-radius: 50%;
    background: transparent;
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
}

.dev-auth-info-btn:hover {
    background: var(--accent-soft);
}

.dev-auth-header {
    text-align: center;
    margin-bottom: 28px;
    padding-top: 6px;
}

.dev-auth-logo {
    height: 52px;
    width: auto;
    display: block;
    margin: 0 auto 18px;
    object-fit: contain;
}

.dev-auth-header h2 {
    margin: 0 0 8px;
    font-size: clamp(1.35rem, 4.5vw, 1.65rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.dev-auth-subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.45;
}

.dev-auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dev-auth-label {
    font-size: 0.92rem;
    font-weight: 700;
}

.dev-auth-required {
    color: var(--danger);
}

.dev-auth-password-wrap {
    position: relative;
}

.dev-auth-input {
    width: 100%;
    min-height: 52px;
    padding: 14px 48px 14px 18px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    background: var(--input-bg);
    color: var(--ink);
    font-size: 1rem;
    line-height: 1.2;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dev-auth-input::placeholder {
    color: var(--muted);
    opacity: 0.75;
}

.dev-auth-input:focus {
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.dev-auth-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.dev-auth-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.dev-auth-toggle:hover:not(:disabled) {
    color: var(--ink);
    background: var(--btn-hover-bg);
}

.dev-auth-toggle:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dev-auth-eye {
    width: 20px;
    height: 20px;
    display: block;
    flex-shrink: 0;
}

.dev-auth-error {
    margin: 2px 0 0;
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--danger);
}

.dev-auth-error[hidden] {
    display: none;
}

.dev-auth-submit {
    margin-top: 8px;
    width: 100%;
    min-height: 52px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.dev-auth-submit:hover:not(:disabled) {
    filter: brightness(1.05);
}

.dev-auth-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none;
}

.dev-auth-cancel {
    width: 100%;
    min-height: 42px;
    margin-top: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.dev-auth-cancel:hover {
    background: var(--btn-hover-bg);
    border-color: var(--btn-hover-border);
    color: var(--ink);
}

.dev-auth-footer {
    margin-top: 28px;
    text-align: center;
}

.dev-auth-footer p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.dev-auth-info-panel {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--input-bg);
}

.dev-auth-info-panel[hidden] {
    display: none;
}

.dev-auth-info-panel h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.dev-auth-info-panel p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .dev-auth-modal {
        width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);
    }

    .dev-auth-header {
        margin-bottom: 22px;
    }

    .dev-auth-logo {
        height: 44px;
        margin-bottom: 14px;
    }

    .dev-auth-info-btn {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
    }

    .dev-auth-input,
    .dev-auth-submit {
        min-height: 48px;
        font-size: 16px;
    }

    .dev-auth-footer {
        margin-top: 22px;
    }
}

.arms-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(4, 6, 10, 0.62);
    backdrop-filter: blur(6px);
}

.arms-confirm-overlay[hidden] {
    display: none;
}

.arms-confirm-modal {
    width: min(420px, 100%);
    padding: 22px 24px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.arms-confirm-modal h2 {
    margin: 0 0 10px;
    font-size: 1.1rem;
}

.arms-confirm-modal p {
    margin: 0 0 20px;
    color: var(--ink-muted);
    line-height: 1.5;
    font-size: 0.95rem;
}

.arms-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

@media (min-width: 600px) {
    .help-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .help-card.span-2 {
        grid-column: span 2;
    }
}

@media (min-width: 721px) {
    .brand-mark {
        display: none;
    }

    .brand-system--desktop {
        display: inline;
    }

    .brand-logo {
        height: 52px;
        max-width: none;
    }
}

@media (max-width: 720px) and (pointer: coarse) {
    html {
        zoom: 1;
    }

    :root {
        --ui-scale: 1;
        --viewport-fill: 100dvh;
    }

    .app-header {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        min-height: 56px;
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .brand {
        flex: 1 1 auto;
        gap: 8px;
        min-width: 0;
        max-width: calc(100% - 172px);
        align-items: center;
        overflow: hidden;
    }

    .brand-copy {
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
    }

    .brand-logo {
        height: 34px;
        max-width: min(104px, 30vw);
        flex-shrink: 0;
    }

    body[data-page="landing"] .brand-logo {
        height: 36px;
        max-width: min(140px, 40vw);
    }

    .brand-system--desktop {
        display: none;
    }

    .brand-mark {
        display: block;
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--ink);
        letter-spacing: 0.03em;
        line-height: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-actions {
        flex: 0 0 auto;
        flex-shrink: 0;
        gap: 3px;
        margin-left: auto;
        position: relative;
        z-index: 2;
    }

    .app-header .btn-outline-light {
        border-color: transparent;
        background: var(--input-bg);
    }

    .app-header .btn-icon-only,
    .app-header .btn-export {
        min-width: 40px;
        min-height: 40px;
        width: 40px;
        height: 40px;
        padding: 0;
    }

    .app-header .btn-export .btn-label {
        display: none;
    }

    .app-header .btn-icon svg {
        width: 17px;
        height: 17px;
    }
}

@media (max-width: 720px) {
    .app-header {
        gap: 8px;
        min-height: 56px;
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .brand {
        flex: 1 1 auto;
        min-width: 0;
        max-width: calc(100% - 172px);
        overflow: hidden;
        gap: 8px;
    }

    .brand-copy {
        min-width: 0;
        overflow: hidden;
    }

    .brand-logo {
        height: 34px;
        max-width: min(104px, 30vw);
    }

    .brand-system--desktop {
        display: none;
    }

    .brand-mark {
        display: block;
        font-size: 1.05rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-actions {
        flex: 0 0 auto;
        margin-left: auto;
        gap: 3px;
        z-index: 2;
    }

    .app-header .btn-icon-only,
    .app-header .btn-export {
        min-width: 40px;
        min-height: 40px;
        width: 40px;
        height: 40px;
    }

    .app-header .btn-export .btn-label {
        display: none;
    }

    .action-grid {
        grid-template-columns: 1fr;
    }

    .landing {
        padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
    }

    .landing-logo {
        width: min(200px, 68vw);
        margin-bottom: 18px;
    }

    .landing-product {
        font-size: clamp(1.4rem, 5.5vw, 1.85rem);
    }

    .landing-lede {
        font-size: 0.98rem;
        margin-bottom: 24px;
        padding: 0 4px;
    }

    .landing-import {
        width: 100%;
        padding: 16px;
        gap: 14px;
    }

    .landing-import-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }

    .landing-import-title {
        font-size: 1.02rem;
    }

    .action-grid {
        gap: 14px;
        margin-top: 28px;
        max-width: none;
    }

    .action-card {
        min-height: 156px;
        padding: 24px 16px;
        gap: 12px;
    }

    .action-icon {
        width: 64px;
        height: 64px;
    }

    .action-icon svg {
        width: 32px;
        height: 32px;
    }

    .action-card .title {
        font-size: 1.08rem;
    }

    .action-card .subtitle {
        font-size: 0.9rem;
    }

    .result-banner,
    .alert {
        margin-left: 12px;
        margin-right: 12px;
        font-size: 0.88rem;
    }

    .app-shell.workspace {
        height: var(--viewport-fill);
        min-height: var(--viewport-fill);
        max-height: var(--viewport-fill);
        overflow: hidden;
    }

    .workspace .thumb-strip {
        flex-shrink: 0;
    }

    .workspace .result-banner,
    .workspace .alert {
        position: absolute;
        left: 50%;
        right: auto;
        top: 8px;
        width: max-content;
        max-width: min(360px, calc(100% - 20px));
        transform: translateX(-50%);
        pointer-events: none;
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    .workspace .alert:not([hidden]) ~ .result-banner:not([hidden]) {
        top: calc(8px + 2.9rem);
    }

    .thumb-strip {
        padding: 6px 10px;
    }

    .thumb-strip .thumb {
        width: 48px;
        height: 48px;
    }

    .workspace-body {
        grid-template-rows: minmax(0, min(34vh, 260px)) minmax(0, 1fr);
        overflow: hidden;
    }

    .app-shell.workspace.is-mobile-workspace .workspace-body {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .app-shell.workspace.is-mobile-workspace .workspace-body > .stage-wrap {
        flex: 1 1 auto;
        min-height: 0;
    }

    .app-shell.workspace.is-mobile-workspace {
        --mobile-dock-peek: 198px;
    }

    .app-shell.workspace.is-mobile-workspace .workspace-main {
        padding-bottom: calc(var(--mobile-dock-peek) + env(safe-area-inset-bottom));
        transition: padding-bottom 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .app-shell.workspace.is-mobile-workspace.mobile-dock-expanded .workspace-main {
        padding-bottom: calc(min(82dvh, 720px) + env(safe-area-inset-bottom));
    }

    body.mobile-dock-sheet-open {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        top: 0;
        z-index: 24;
        border: 0;
        padding: 0;
        margin: 0;
        background: rgba(4, 8, 14, 0.42);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.28s ease;
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-backdrop:not([hidden]) {
        opacity: 1;
        pointer-events: auto;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 28;
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 22px 22px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.28);
        max-height: calc(var(--mobile-dock-peek) + env(safe-area-inset-bottom));
        overflow: hidden;
        transition: max-height 0.34s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .app-shell.workspace.is-mobile-workspace .control-dock:not(.control-dock--expanded) {
        display: flex;
        flex-direction: column;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock:not(.control-dock--expanded) .mobile-dock-sheet {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock:not(.control-dock--expanded) .tab-row {
        padding: 6px 8px;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock:not(.control-dock--expanded) .mobile-dock-handle {
        padding: 14px 16px 6px;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock:not(.control-dock--expanded) .workspace-measure-bar {
        margin-top: 0;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .workspace-measure-bar {
        display: none;
        flex-shrink: 0;
        padding: 6px 8px;
        gap: 4px;
        border-top: none;
        border-bottom: 1px solid var(--line);
        background: transparent;
        box-shadow: none;
        position: static;
    }

    .workspace .control-dock.control-dock--areas .workspace-measure-bar--compact {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    [data-theme="light"] .workspace .workspace-measure-bar {
        box-shadow: none;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .control-dock.control-dock--areas .workspace-measure-bar,
    .app-shell.workspace.is-mobile-workspace .workspace .control-dock:not(.control-dock--expanded).control-dock--areas .workspace-measure-bar {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .app-shell.workspace.is-mobile-workspace .workspace .workspace-measure-bar .btn,
    .workspace .workspace-measure-bar .btn {
        min-height: 28px;
        font-size: 0.68rem;
        font-weight: 600;
        border-radius: 6px;
        padding: 3px 6px;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock.control-dock--expanded {
        max-height: min(82dvh, 720px);
        box-shadow: 0 -20px 56px rgba(0, 0, 0, 0.34);
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-handle {
        display: flex;
        flex-shrink: 0;
        align-items: center;
        gap: 12px;
        width: 100%;
        margin: 0;
        padding: 10px 16px 8px;
        border: 0;
        border-bottom: 1px solid var(--line);
        background: var(--bg-elevated);
        color: var(--ink);
        text-align: left;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        padding-top: 16px;
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-grabber {
        position: absolute;
        top: 7px;
        left: 50%;
        width: 42px;
        height: 4px;
        border-radius: 999px;
        background: color-mix(in srgb, var(--muted) 55%, transparent);
        transform: translateX(-50%);
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-handle-copy {
        display: grid;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-handle-title {
        font-size: 0.82rem;
        font-weight: 700;
        color: var(--ink);
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-handle-meta {
        font-size: 0.72rem;
        color: var(--muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-chevron {
        width: 10px;
        height: 10px;
        flex-shrink: 0;
        border-right: 2px solid var(--muted);
        border-bottom: 2px solid var(--muted);
        transform: rotate(45deg);
        margin-top: -4px;
        transition: transform 0.28s ease;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock.control-dock--expanded .mobile-dock-chevron {
        transform: rotate(-135deg);
        margin-top: 4px;
    }

    .app-shell.workspace.is-mobile-workspace .mobile-dock-sheet {
        display: flex;
        flex-direction: column;
        min-height: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock:not(.control-dock--expanded) .mobile-dock-sheet > :not(.tab-row) {
        display: none !important;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock.control-dock--expanded .mobile-dock-sheet {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .workspace .stage-wrap {
        padding: 60px 30px 4px;
        min-height: 0;
        max-height: min(34vh, 260px);
    }

    .app-shell.workspace.is-mobile-workspace .workspace .stage-wrap {
        padding: 4px 10px 0;
        min-height: 0;
        max-height: none;
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .stage {
        flex: 1 1 auto;
        min-height: 0;
        border-radius: 14px;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .stage-toolbar {
        margin-bottom: 4px;
    }

    .workspace .stage {
        min-height: 160px;
    }

    .workspace .alert,
    .workspace .result-banner {
        position: absolute;
        left: 50%;
        right: auto;
        top: 8px;
        z-index: 46;
        width: max-content;
        max-width: min(360px, calc(100% - 20px));
        margin: 0;
        padding: 8px 12px;
        font-size: 0.78rem;
        transform: translateX(-50%);
        pointer-events: none;
    }

    .workspace .alert:not([hidden]) ~ .result-banner:not([hidden]) {
        top: calc(8px + 2.9rem);
    }

    .workspace .tab-row {
        position: sticky;
        top: 0;
        z-index: 4;
        background: var(--bg-card);
        flex-shrink: 0;
        padding: 8px;
        gap: 8px;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .tab-btn {
        flex-direction: column;
        gap: 5px;
        min-height: 58px;
        padding: 10px 6px;
        font-size: 0.72rem;
        border-radius: 14px;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .tab-btn .tab-icon svg {
        width: 22px;
        height: 22px;
    }

    .workspace .tab-btn {
        min-height: 48px;
        padding: 8px 6px;
        font-size: 0.74rem;
    }

    .workspace .tab-panel {
        display: none;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .workspace .tab-panel.active {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 0;
    }

    .workspace .workspace-tab-body {
        padding: 12px 12px 16px;
        gap: 14px;
    }

    .workspace .workspace-tab-hint {
        font-size: 0.78rem;
        padding: 9px 11px;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .workspace-measure-bar {
        display: none;
        flex-shrink: 0;
        padding: 6px 8px;
        gap: 4px;
        border-top: none;
        border-bottom: 1px solid var(--line);
        background: transparent;
        box-shadow: none;
        position: static;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .control-dock.control-dock--expanded .workspace-measure-bar {
        position: static;
        bottom: auto;
        z-index: auto;
        padding-bottom: 6px;
        box-shadow: none;
    }

    .workspace .workspace-measure-bar {
        display: none;
        flex-shrink: 0;
        padding: 6px 8px;
        gap: 4px;
        border-top: none;
        border-bottom: 1px solid var(--line);
        background: transparent;
        box-shadow: none;
    }

    .workspace .control-dock.control-dock--areas .workspace-measure-bar {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    [data-theme="light"] .workspace .workspace-measure-bar {
        box-shadow: none;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .control-dock.control-dock--areas .workspace-measure-bar,
    .app-shell.workspace.is-mobile-workspace .workspace .control-dock:not(.control-dock--expanded).control-dock--areas .workspace-measure-bar {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .app-shell.workspace.is-mobile-workspace .workspace .workspace-measure-bar .btn {
        min-height: 28px;
        font-size: 0.68rem;
        font-weight: 600;
        border-radius: 6px;
        padding: 3px 6px;
    }

    .workspace .workspace-measure-bar .btn {
        min-height: 28px;
        font-size: 0.68rem;
        font-weight: 600;
        border-radius: 6px;
        padding: 3px 6px;
    }

    .workspace .area-tag-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .workspace .area-tag {
        font-size: 0.76rem;
        padding: 10px 8px;
        min-height: 44px;
    }

    .workspace .measure-item {
        padding: 12px;
        font-size: 0.82rem;
    }

    .workspace .measure-item button {
        min-height: 36px;
        padding: 6px 10px;
    }

    .app-shell.workspace.is-mobile-workspace .tile-picker-grid {
        grid-template-columns: 1fr;
    }

    .app-shell.workspace.is-mobile-workspace .tile-picker-card {
        min-height: 64px;
    }

    .app-shell.workspace.is-mobile-workspace .unit-chip {
        min-height: 48px;
    }

    .app-shell.workspace.is-mobile-workspace .field-touch input {
        min-height: 52px;
    }

    .workspace .custom-tile-grid {
        gap: 12px;
    }

    .workspace #tab-custom .btn-block {
        min-height: 48px;
        font-size: 0.92rem;
        font-weight: 700;
    }

    .workspace .detection-tuning-actions .btn-compact,
    .workspace .roof-segment-actions .btn-compact,
    .workspace .roof-segment-apply-row .btn-compact {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .workspace .detection-tuning-actions .btn-primary.btn-compact {
        min-height: 44px;
        padding: 8px 14px;
    }

    .measure-adjust-hint,
    .roof-segment-hint {
        font-size: 0.7rem;
        line-height: 1.35;
    }

    .workspace .stage-toolbar .selection-pill {
        font-size: 0.74rem;
        padding: 4px 8px;
        max-width: 42vw;
    }

    .workspace .zoom-label {
        min-width: 36px;
        font-size: 0.72rem;
    }

    .workspace .stage-toolbar .btn-icon-only {
        min-width: 40px;
        min-height: 40px;
        width: 40px;
        height: 40px;
    }

    .segment-hint {
        white-space: normal;
        text-align: center;
        max-width: min(92vw, 360px);
        line-height: 1.35;
        bottom: 8px;
    }

    .arms-confirm-modal {
        padding: 20px 18px;
        max-height: calc(100dvh - 32px);
        overflow-y: auto;
    }

    .arms-confirm-actions .btn {
        min-height: 44px;
        flex: 1 1 auto;
    }

    .tab-btn {
        flex-direction: column;
        gap: 3px;
        padding: 6px 4px;
        font-size: 0.72rem;
        min-height: 44px;
    }

    .tab-icon svg {
        width: 16px;
        height: 16px;
    }

    .area-tag {
        font-size: 0.72rem;
        padding: 6px 8px;
        min-height: 36px;
    }

    .field input,
    .field select {
        min-height: 44px;
        font-size: 16px;
    }

    .help-overlay {
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .help-modal {
        max-height: min(92dvh, 760px);
    }

    .help-modal--wide {
        max-height: min(94dvh, 900px);
    }

    .help-grid {
        grid-template-columns: 1fr;
    }

    .help-card.span-2 {
        grid-column: auto;
    }
}

@media (max-width: 380px) and (pointer: coarse) {
    .brand-logo {
        height: 30px;
        max-width: min(88px, 28vw);
    }

    .brand-mark {
        display: none;
    }

    .header-actions {
        gap: 2px;
    }

    .app-header .btn-icon-only,
    .app-header .btn-export {
        min-width: 38px;
        min-height: 38px;
        width: 38px;
        height: 38px;
    }

    .brand {
        max-width: calc(100% - 158px);
    }
}

@media (max-width: 380px) {
    .tab-btn {
        font-size: 0.72rem;
        padding: 8px 4px;
    }
}

@media (min-width: 900px) {
    .app-header {
        min-height: 92px;
        padding: 22px 28px;
    }

    .brand-logo {
        height: 58px;
    }

    .brand-system {
        font-size: 1.32rem;
    }

    .workspace-body {
        grid-template-rows: none;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
        gap: 0 12px;
        padding: 0 28px 12px 16px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    .workspace .stage-wrap {
        padding: 8px 8px 0 0;
        min-height: 0;
        min-width: 0;
    }

    .workspace .control-dock {
        margin: 0;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        max-height: none;
        height: 100%;
        min-height: 0;
        align-self: stretch;
        border-radius: var(--radius-md);
        overflow: hidden;
        background: var(--bg-card);
        box-shadow: var(--shadow);
        isolation: isolate;
    }

    .workspace .tab-row {
        padding: 8px 12px;
    }

    .workspace .workspace-tab-body {
        padding: 12px 16px 16px;
    }

    .workspace .detection-tuning--in-tab {
        padding: 0 2px;
    }

    .workspace .workspace-measure-bar {
        flex-shrink: 0;
        padding: 10px 16px 12px;
    }

    .workspace .workspace-measure-bar--compact {
        padding: 6px 8px;
        box-shadow: none;
    }

    .workspace .workspace-measure-bar--compact .btn {
        min-height: 26px;
        font-size: 0.66rem;
        font-weight: 600;
        border-radius: 6px;
        padding: 3px 6px;
    }

    .workspace .tab-panel.active {
        min-height: 0;
        flex: 1 1 auto;
        overflow-x: hidden;
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: color-mix(in srgb, var(--line) 70%, transparent) transparent;
    }

    .workspace .tab-panel.active::-webkit-scrollbar {
        width: 6px;
    }

    .workspace .tab-panel.active::-webkit-scrollbar-track {
        background: transparent;
    }

    .workspace .tab-panel.active::-webkit-scrollbar-thumb {
        background: color-mix(in srgb, var(--line) 80%, transparent);
        border-radius: 999px;
    }

    .workspace .tab-btn {
        flex-direction: row;
        min-height: 38px;
        font-size: 0.8rem;
    }
}

@media (min-width: 1200px) {
    .workspace-body {
        grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
        gap: 0 14px;
        padding: 0 32px 12px 20px;
    }

    .workspace .stage-wrap {
        padding-right: 12px;
    }

    .workspace .workspace-tab-body {
        padding-left: 18px;
        padding-right: 18px;
    }

    .workspace .tab-row {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (min-width: 901px) {
    html {
        zoom: 1;
    }

    :root {
        --ui-scale: 1;
        --viewport-fill: 100dvh;
        --radius-lg: 18px;
        --radius-md: 12px;
        --radius-sm: 8px;
    }
}

@media (max-width: 900px) and (orientation: landscape) {
    .workspace-body {
        grid-template-rows: none;
        grid-template-columns: minmax(0, 1fr) minmax(260px, min(300px, 34vw));
        gap: 0 12px;
        padding: 0 16px 10px 10px;
    }

    .workspace .control-dock {
        margin: 0;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        max-height: none;
        height: 100%;
        min-height: 0;
    }

    .workspace .stage-wrap {
        padding: 6px 8px 0 0;
    }
}

@supports not (zoom: 1) {
    :root {
        --viewport-fill: 100dvh;
    }

    html {
        font-size: 80%;
    }

    @media (max-width: 720px) and (pointer: coarse) {
        html {
            font-size: 100%;
        }
    }
}

/* ---- Roof Sketch workflow ---- */
.tab-row--sketch {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
}

.tab-row--sketch .tab-btn {
    padding: 8px 4px;
    font-size: 0.72rem;
    flex-direction: column;
    gap: 2px;
}

.calibrate-status {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 12px 0;
}

.calibrate-stat {
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 14%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface, #16181d) 80%, transparent);
}

.calibrate-stat strong {
    color: #38bdf8;
}

.calibrate-stat-label {
    display: block;
    font-size: 0.72rem;
    opacity: 0.7;
    margin-bottom: 4px;
}

.calibrate-warning {
    color: #f59e0b;
    font-size: 0.85rem;
    margin: 0 0 10px;
}

.calibrate-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.section-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 14%, transparent);
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.section-row.active {
    border-color: #22d3ee;
    background: color-mix(in srgb, rgba(34, 211, 238, 0.14) 100%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, #22d3ee 40%, transparent);
}

.section-row.active strong {
    color: #22d3ee;
}

.section-row span {
    font-size: 0.8rem;
    opacity: 0.75;
}

.field-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    cursor: pointer;
}

.triangle-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 12px;
    max-height: min(52vh, 420px);
    overflow-y: auto;
    padding-right: 2px;
}

.triangle-list-empty {
    margin: 0;
    padding: 14px 12px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--muted);
    border: 1px dashed color-mix(in srgb, var(--line) 80%, transparent);
    border-radius: 10px;
}

.triangle-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 8px 10px;
    background: color-mix(in srgb, var(--bg-card) 88%, transparent);
}

.triangle-card.is-active {
    border-color: color-mix(in srgb, #22d3ee 55%, var(--line));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #22d3ee 22%, transparent);
}

.triangle-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    min-width: 0;
}

.triangle-card-head strong {
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}

.triangle-card-status {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: auto;
}

.triangle-card-status.is-done {
    color: #67e8f9;
}

.triangle-card-delete {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.triangle-card-delete:hover {
    color: var(--danger);
    background: var(--alert-bg);
}

.triangle-metrics {
    display: grid;
    gap: 8px;
    margin: 0;
}

.triangle-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 12%, transparent);
    background: color-mix(in srgb, var(--text, #e8eaed) 4%, transparent);
}

.triangle-metric-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.triangle-metric-main span {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.72;
}

.triangle-metric-main strong {
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.triangle-metric-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.triangle-tile-stepper {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.triangle-tile-btn {
    min-width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 18%, transparent);
    background: color-mix(in srgb, var(--panel, #14161a) 80%, transparent);
    color: var(--ink, #e8eaed);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.triangle-tile-btn:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--accent-strong, #38bdf8) 55%, transparent);
    color: var(--accent-strong, #38bdf8);
}

.triangle-tile-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.triangle-tile-count {
    min-width: 1.6rem;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.triangle-axis-toggle {
    display: inline-flex;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 18%, transparent);
}

.triangle-axis-btn {
    appearance: none;
    border: 0;
    margin: 0;
    min-width: 2rem;
    padding: 6px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    color: color-mix(in srgb, var(--text, #e8eaed) 75%, transparent);
    background: transparent;
}

.triangle-axis-btn + .triangle-axis-btn {
    border-left: 1px solid color-mix(in srgb, var(--text, #e8eaed) 18%, transparent);
}

.triangle-axis-btn.is-active {
    color: #0a0b0d;
    background: #fbbf24;
}

.triangle-axis-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.triangle-axis-fixed {
    flex-shrink: 0;
    min-width: 2rem;
    padding: 6px 8px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    border-radius: 6px;
    color: #0a0b0d;
    background: #22d3ee;
}

.triangle-hint {
    font-size: 0.82rem;
    opacity: 0.8;
    margin: 0;
}

.triangle-candidate-picker {
    margin: 0 0 10px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, #f59e0b 35%, transparent);
    background: color-mix(in srgb, #f59e0b 10%, transparent);
}

.triangle-candidate-picker[hidden] {
    display: none !important;
}

.triangle-picker-title {
    margin: 0 0 8px;
    font-size: 0.84rem;
    opacity: 0.85;
}

.triangle-picker-list {
    display: grid;
    gap: 6px;
}

.triangle-picker-btn {
    display: grid;
    gap: 2px;
    text-align: left;
    width: 100%;
}

.triangle-picker-btn span {
    font-size: 0.78rem;
    opacity: 0.85;
}

.cad-script {
    width: 100%;
    min-height: 180px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.4;
    resize: vertical;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 16%, transparent);
    background: color-mix(in srgb, #000 35%, transparent);
    color: inherit;
}

.cad-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.cad-summary-grid > div {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 12%, transparent);
}

.cad-summary-grid span {
    display: block;
    font-size: 0.7rem;
    opacity: 0.7;
}

.cad-errors {
    color: #f87171;
    font-size: 0.85rem;
    margin-top: 10px;
}

.custom-tile-block {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid color-mix(in srgb, var(--text, #e8eaed) 12%, transparent);
}

.workspace-measure-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 900px) {
    .tab-row--sketch .tab-btn {
        font-size: 0.65rem;
    }

    .cad-summary-grid {
        grid-template-columns: 1fr;
    }
}

.help-lead {
    margin: 0 0 14px;
    opacity: 0.85;
}

.help-steps {
    display: grid;
    gap: 12px;
}

.help-step {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
}

.help-step-num {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, #dc2626 25%, transparent);
    font-weight: 700;
    font-size: 0.85rem;
}

.help-step h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.help-step p {
    margin: 0;
    opacity: 0.8;
    font-size: 0.9rem;
}

.section-row-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

.section-row-mode {
    font-size: 0.72rem;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.section-row-area {
    font-size: 0.85rem;
    opacity: 0.85;
}

.section-edge-list {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    display: grid;
    gap: 2px;
    width: 100%;
    font-size: 0.78rem;
    opacity: 0.8;
}

.calibrate-tile-ref {
    display: grid;
    gap: 2px;
    margin: 10px 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, #38bdf8 35%, transparent);
    background: color-mix(in srgb, #38bdf8 10%, transparent);
}

.calibrate-tile-ref-label {
    font-size: 0.72rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.calibrate-sample-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.calibrate-sample-card {
    display: grid;
    gap: 2px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 14%, transparent);
    font-size: 0.8rem;
}

.calibrate-sample-card.is-empty {
    opacity: 0.55;
}

.calibrate-next {
    margin: 0 0 10px;
    font-size: 0.88rem;
    color: color-mix(in srgb, #38bdf8 80%, white);
}

.calibrate-pair-stats {
    display: grid;
    gap: 6px;
    margin: 0 0 10px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, #22d3ee 35%, transparent);
    background: color-mix(in srgb, #0ea5e9 12%, transparent);
    font-size: 0.8rem;
}

.calibrate-pair-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}

.calibrate-pair-row span {
    color: var(--muted, #94a3b8);
}

.calibrate-pair-row strong {
    text-align: right;
    font-weight: 600;
}

.calibrate-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.calibrate-hide-samples {
    margin-top: 10px;
}

.measure-bar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    grid-column: 1 / -1;
    justify-self: start;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--text, #e8eaed) 14%, transparent);
    font-size: 0.88rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.measure-bar-toggle input {
    accent-color: #38bdf8;
}

.selection-panel {
    margin: 0 12px 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--panel, #14161a) 88%, #1e293b);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.selection-panel[hidden] {
    display: none !important;
}

.selection-panel-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.selection-kicker {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--ink) 55%, transparent);
}

.selection-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
}

.selection-kind {
    font-size: 0.78rem;
    color: color-mix(in srgb, var(--accent-strong, #38bdf8) 85%, white);
}

.selection-final {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent-soft, rgba(56, 189, 248, 0.12)) 100%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-strong, #38bdf8) 35%, transparent);
}

.selection-final-label {
    font-size: 0.78rem;
    opacity: 0.8;
}

.selection-final-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-strong, #38bdf8);
    font-variant-numeric: tabular-nums;
}

.selection-ref-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.7;
}

.selection-ref-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.selection-ref-option {
    position: relative;
    cursor: pointer;
}

.selection-ref-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.selection-ref-option span {
    display: block;
    text-align: center;
    padding: 9px 8px;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-size: 0.82rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--panel, #14161a) 70%, transparent);
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.selection-ref-option input:checked + span {
    border-color: var(--accent-strong, #38bdf8);
    background: color-mix(in srgb, var(--accent-strong, #38bdf8) 18%, transparent);
    color: var(--ink);
}

.selection-ref-option input:focus-visible + span {
    outline: 2px solid var(--accent-strong, #38bdf8);
    outline-offset: 2px;
}

.selection-facts {
    margin: 0;
    display: grid;
    gap: 6px;
}

.selection-fact {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.selection-fact:last-child {
    border-bottom: 0;
}

.selection-fact dt {
    margin: 0;
    font-size: 0.78rem;
    opacity: 0.7;
}

.selection-fact dd {
    margin: 0;
    font-size: 0.86rem;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.selection-fact--emphasis dd {
    color: var(--accent-strong, #38bdf8);
}

.selection-details {
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 0 10px;
    background: color-mix(in srgb, #0f172a 25%, transparent);
}

.selection-details summary {
    cursor: pointer;
    list-style: none;
    padding: 10px 2px;
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.9;
}

.selection-details summary::-webkit-details-marker {
    display: none;
}

.selection-details summary::after {
    content: "+";
    float: right;
    opacity: 0.6;
}

.selection-details[open] summary::after {
    content: "–";
}

.selection-details-body {
    padding: 0 2px 10px;
    font-size: 0.78rem;
    line-height: 1.45;
    opacity: 0.9;
}

.selection-details-body p {
    margin: 0 0 8px;
}

.selection-details-body p:last-child {
    margin-bottom: 0;
}

.selection-triangle {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px solid var(--line);
}

.selection-tri-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.selection-tri-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--line);
    text-align: center;
}

.selection-tri-item span {
    font-size: 0.7rem;
    opacity: 0.65;
}

.selection-tri-item strong {
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.selection-tri-item.is-active {
    border-color: color-mix(in srgb, var(--accent-strong, #38bdf8) 55%, transparent);
    background: color-mix(in srgb, var(--accent-strong, #38bdf8) 14%, transparent);
}

.selection-tri-item.is-active span {
    opacity: 1;
    color: var(--accent-strong, #38bdf8);
    font-weight: 700;
}

.selection-correction {
    margin: 0;
}

.selection-empty {
    margin: 0;
    padding: 10px 12px;
    font-size: 0.82rem;
    opacity: 0.75;
    border: 1px dashed var(--line);
    border-radius: 8px;
}

.triangle-hint {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.4;
    opacity: 0.8;
}

.line-inspector {
    display: none !important;
}

.control-dock--measure-bar.control-dock--areas .workspace-measure-bar,
.control-dock--measure-bar .workspace-measure-bar {
    display: grid;
}

.workspace-measure-bar[hidden] {
    display: none !important;
}

.cad-sync-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel, #14161a) 80%, transparent);
    font-size: 0.82rem;
}

.cad-sync-bar.is-live {
    border-color: color-mix(in srgb, #34d399 45%, var(--line));
}

.cad-sync-bar.is-blocked {
    border-color: color-mix(in srgb, #f87171 45%, var(--line));
}

.cad-sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    flex: 0 0 auto;
}

.cad-sync-dot.is-live {
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
}

.cad-sync-dot.is-blocked {
    background: #f87171;
}

.cad-preview-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cad-preview-canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #0f1218;
}

.cad-preview-caption {
    margin: 0;
    font-size: 0.72rem;
    opacity: 0.7;
}

.cad-live-tag {
    font-style: normal;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #34d399;
    margin-left: 6px;
}

/* ---- Compact control dock (Roof Sketch workspace) ---- */

.dock-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--line) 70%, transparent) transparent;
}

.dock-scroll::-webkit-scrollbar {
    width: 5px;
}

.dock-scroll::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--line) 80%, transparent);
    border-radius: 999px;
}

.hotkey {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
    background: color-mix(in srgb, var(--panel, #14161a) 75%, transparent);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0.02em;
    color: color-mix(in srgb, var(--ink) 72%, transparent);
    flex-shrink: 0;
}

.hotkey--inline {
    margin-left: auto;
}

.btn-hotkey {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.btn-hotkey .btn-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-hotkey .hotkey {
    opacity: 0.75;
    flex-shrink: 0;
}

.btn-export.btn-hotkey {
    gap: 8px;
    justify-content: space-between;
}

.btn-export.btn-hotkey .hotkey {
    display: none;
}

@media (min-width: 901px) {
    .btn-export.btn-hotkey .hotkey {
        display: inline-flex;
    }
}

.tab-row--sketch {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    padding: 4px 6px;
}

.tab-row--sketch .tab-btn {
    padding: 4px 2px 3px;
    min-height: 0;
    font-size: 0.62rem;
    flex-direction: column;
    gap: 1px;
    line-height: 1.1;
}

.tab-row--sketch .tab-btn .tab-icon svg {
    width: 14px;
    height: 14px;
}

.tab-row--sketch .tab-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-hotkey {
    font-size: 0.55rem;
    padding: 0 3px;
    border: none;
    background: transparent;
    opacity: 0.5;
    min-width: 0;
}

.workspace-tab-body--compact {
    gap: 8px;
    padding: 8px 10px 10px;
}

.dock-section-label {
    margin: 0 0 6px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.dock-details {
    margin: 0;
    border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel, #14161a) 40%, transparent);
}

.dock-details > summary {
    padding: 6px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.dock-details > summary::-webkit-details-marker {
    display: none;
}

.dock-details > summary::before {
    content: "▸ ";
    opacity: 0.55;
}

.dock-details[open] > summary::before {
    content: "▾ ";
}

.dock-details-body,
.dock-details > .workspace-tab-hint {
    padding: 0 8px 8px;
}

.dock-details--open {
    border-color: color-mix(in srgb, var(--line) 55%, transparent);
}

.field-compact {
    gap: 3px;
    margin: 0;
}

.field-compact > span {
    font-size: 0.68rem;
}

.field-compact input,
.field-compact select {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 0.78rem;
}

.field-toggle--compact {
    margin: 0;
    gap: 8px;
    font-size: 0.78rem;
}

.field-toggle--compact input {
    width: 14px;
    height: 14px;
}

.tile-picker-selected {
    padding: 6px 8px;
    gap: 4px 8px;
}

.tile-picker-grid {
    gap: 5px;
}

.tile-picker-card {
    padding: 7px 8px;
    min-height: 0;
    border-radius: 8px;
    gap: 2px;
}

.tile-picker-name {
    font-size: 0.72rem;
    line-height: 1.2;
}

.tile-picker-size {
    font-size: 0.68rem;
}

.unit-chip-row--compact {
    gap: 4px;
}

.unit-chip-row--compact .unit-chip {
    min-height: 28px;
    padding: 4px 6px;
    font-size: 0.72rem;
    border-radius: 8px;
}

.calibrate-tile-ref--compact {
    margin: 0;
    padding: 6px 8px;
    gap: 2px;
}

.calibrate-status--compact {
    margin: 0;
    gap: 6px;
}

.calibrate-status--compact .calibrate-stat {
    padding: 6px 8px;
    border-radius: 8px;
}

.calibrate-stat-label {
    margin-bottom: 2px;
    font-size: 0.65rem;
}

.calibrate-sample-cards {
    gap: 5px;
    margin-bottom: 6px;
}

.calibrate-sample-card {
    padding: 6px 7px;
    font-size: 0.72rem;
    border-radius: 8px;
}

.calibrate-pair-stats {
    padding: 7px 8px;
    font-size: 0.72rem;
    margin-bottom: 6px;
}

.calibrate-next--compact {
    margin: 0;
    font-size: 0.74rem;
    line-height: 1.35;
}

.calibrate-actions--compact {
    gap: 5px;
}

.calibrate-actions--compact .btn-compact {
    flex: 1 1 auto;
    min-width: 0;
}

.section-list {
    gap: 5px;
}

.section-row {
    padding: 6px 8px;
    border-radius: 8px;
}

.section-row-head strong {
    font-size: 0.78rem;
}

.section-row span,
.section-row-area {
    font-size: 0.68rem !important;
}

.triangle-candidate-picker {
    margin: 0;
    padding: 7px 8px;
    border-radius: 8px;
}

.triangle-hint {
    font-size: 0.72rem;
}

.cad-sync-bar {
    padding: 5px 8px;
    font-size: 0.72rem;
}

.cad-preview-wrap--compact {
    margin-bottom: 6px;
}

.cad-preview-wrap--compact .cad-preview-canvas {
    max-height: 140px;
}

.cad-script--compact {
    min-height: 100px;
    padding: 7px 8px;
    font-size: 0.7rem;
}

.cad-summary-grid {
    gap: 5px;
    margin-bottom: 8px;
}

.selection-panel--compact {
    margin: 0;
    padding: 8px 10px;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--line);
    gap: 8px;
    background: color-mix(in srgb, var(--panel, #14161a) 55%, transparent);
}

.selection-panel--compact .selection-title {
    font-size: 0.88rem;
}

.selection-panel--compact .selection-final {
    padding: 7px 9px;
}

.selection-panel--compact .selection-final-value {
    font-size: 1rem;
}

.selection-panel--compact .selection-ref-option span {
    padding: 6px 5px;
    font-size: 0.72rem;
}

.selection-panel--compact .selection-facts {
    gap: 4px;
}

.selection-panel--compact .selection-fact {
    padding: 4px 0;
    font-size: 0.72rem;
}

.selection-panel--compact .selection-details > summary {
    font-size: 0.72rem;
    padding: 4px 0;
}

.selection-panel--compact .selection-details--facts .selection-facts {
    margin: 0;
    padding-top: 4px;
}

.selection-tiles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 11px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel, #14161a) 72%, transparent);
}

.selection-tiles-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selection-tiles-head .selection-ref-label {
    margin: 0;
}

.selection-tiles-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.55rem;
    height: 1.55rem;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--accent-strong, #38bdf8) 45%, transparent);
    background: color-mix(in srgb, var(--accent-strong, #38bdf8) 16%, transparent);
    color: var(--accent-strong, #38bdf8);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1;
}

.selection-tile-axis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.selection-tile-along {
    margin-top: 6px;
}

.selection-tile-axis-opt {
    position: relative;
    cursor: pointer;
}

.selection-tile-axis-opt input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.selection-tile-axis-opt span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 32px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-size: 0.78rem;
    font-weight: 650;
    background: color-mix(in srgb, var(--panel, #14161a) 80%, transparent);
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.selection-tile-axis-opt span em {
    font-style: normal;
    opacity: 0.65;
    font-weight: 600;
}

.selection-tile-axis-opt input:checked + span {
    border-color: var(--accent-strong, #38bdf8);
    background: color-mix(in srgb, var(--accent-strong, #38bdf8) 18%, transparent);
    color: var(--ink);
}

.selection-tile-axis-opt input:focus-visible + span {
    outline: 2px solid var(--accent-strong, #38bdf8);
    outline-offset: 2px;
}

.selection-tile-axis-opt input:disabled + span {
    opacity: 0.45;
    cursor: not-allowed;
}

.selection-tile-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 4px 0 2px;
}

.selection-tile-btn {
    min-width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel, #14161a) 85%, #334155);
    color: var(--ink);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.selection-tile-btn:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--accent-strong, #38bdf8) 55%, transparent);
    color: var(--accent-strong, #38bdf8);
    background: color-mix(in srgb, var(--accent-strong, #38bdf8) 10%, transparent);
}

.selection-tile-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.selection-tile-count-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 3.4rem;
    gap: 1px;
}

.selection-tile-count {
    text-align: center;
    font-size: 1.35rem;
    font-weight: 780;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    color: var(--ink);
}

.selection-tile-unit {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.62;
    font-weight: 600;
}

.selection-tile-mm {
    margin: 0;
    text-align: center;
    font-size: 0.84rem;
    font-weight: 650;
    color: var(--accent-strong, #38bdf8);
    font-variant-numeric: tabular-nums;
}

.selection-tile-hint {
    margin: 0;
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.35;
    opacity: 0.68;
}

[data-theme="light"] .selection-tiles {
    background: color-mix(in srgb, #fff 88%, #e2e8f0);
}

[data-theme="light"] .selection-tile-axis-opt span {
    background: color-mix(in srgb, #fff 92%, #e2e8f0);
}

.selection-ref-toggle--inline {
    margin-top: 2px;
}

.selection-lines {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.selection-lines-empty {
    margin: 0;
    padding: 6px 8px;
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--ink) 65%, transparent);
}

.selection-lines-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.selection-lines-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: color-mix(in srgb, var(--panel, #14161a) 65%, transparent);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.selection-lines-item:hover {
    border-color: color-mix(in srgb, var(--accent-strong, #38bdf8) 40%, transparent);
    background: color-mix(in srgb, var(--accent-soft, rgba(56, 189, 248, 0.1)) 100%, transparent);
}

.selection-lines-item.is-active {
    border-color: color-mix(in srgb, #22d3ee 75%, transparent);
    background: color-mix(in srgb, rgba(34, 211, 238, 0.18) 100%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, #22d3ee 55%, transparent);
    color: var(--ink);
}

.selection-lines-item.is-active strong {
    color: #22d3ee;
}

.selection-lines-item.is-active span {
    color: color-mix(in srgb, #22d3ee 80%, white);
}

.selection-lines-item strong {
    font-size: 0.78rem;
}

.selection-lines-item span {
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--ink) 70%, transparent);
    font-variant-numeric: tabular-nums;
}

.workspace-measure-bar--compact {
    display: none;
    flex-shrink: 0;
    padding: 6px 8px;
    margin: 0;
    gap: 4px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: none;
    border-bottom: 1px solid var(--line);
    background: transparent;
    box-shadow: none;
    position: static;
}

.control-dock--areas .workspace-measure-bar--compact,
.control-dock--measure-bar .workspace-measure-bar--compact {
    display: grid;
}

.workspace-measure-bar--compact .btn,
.workspace-measure-bar--compact .btn-compact {
    min-height: 34px !important;
    height: auto;
    padding: 4px 4px !important;
    font-size: 0.66rem !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    line-height: 1.15;
    min-width: 0;
    overflow: hidden;
}

.workspace-measure-bar--compact .btn-hotkey {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
}

.workspace-measure-bar--compact .btn-text {
    max-width: 100%;
    text-align: center;
}

.workspace-measure-bar--compact .btn.active {
    border-color: color-mix(in srgb, #38bdf8 55%, var(--line));
    background: color-mix(in srgb, #38bdf8 14%, transparent);
    color: inherit;
}

.workspace-measure-bar--compact .hotkey {
    font-size: 0.52rem;
    padding: 0 3px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.calibrate-actions--compact .btn-hotkey {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    min-width: 0;
    padding: 4px 6px;
}

.calibrate-actions--compact .btn-text {
    max-width: 100%;
    text-align: center;
}

.calibrate-actions--compact .hotkey {
    font-size: 0.55rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.measure-bar-toggle--compact {
    grid-column: 1 / -1;
    padding: 4px 6px;
    font-size: 0.68rem;
    border-radius: 6px;
    min-height: 0;
}

.control-dock {
    max-height: min(56vh, 480px);
}

@media (min-width: 901px) {
    .workspace .control-dock {
        max-height: none;
    }

    .workspace .tab-row--sketch {
        padding: 5px 8px;
    }

    .workspace .workspace-tab-body--compact {
        padding: 8px 10px 12px;
    }

    .workspace .tab-panel.active {
        display: block;
        overflow: visible;
        flex: none;
    }

    .workspace .dock-scroll {
        flex: 1 1 auto;
        min-height: 0;
    }

    .workspace .workspace-measure-bar--compact {
        padding: 6px 8px;
        box-shadow: none;
        position: static;
    }
}

@media (max-width: 900px) {
    .app-shell.workspace.is-mobile-workspace .control-dock:not(.control-dock--expanded) .mobile-dock-sheet > :not(.tab-row) {
        display: none !important;
    }

    .app-shell.workspace.is-mobile-workspace .control-dock.control-dock--expanded .dock-scroll {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .workspace-measure-bar--compact,
    .workspace .workspace-measure-bar--compact {
        box-shadow: none !important;
        padding: 6px 8px !important;
        gap: 4px !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        position: static !important;
        bottom: auto !important;
    }

    .app-shell.workspace.is-mobile-workspace .workspace .workspace-measure-bar--compact .btn,
    .workspace .workspace-measure-bar--compact .btn {
        min-height: 34px !important;
        font-size: 0.68rem !important;
        font-weight: 600 !important;
        border-radius: 6px !important;
        padding: 4px 4px !important;
    }

    .tab-hotkey {
        display: none;
    }

    /* Hide inline hotkeys on most buttons; keep stacked ones in compact bars */
    .btn-hotkey .hotkey {
        display: none;
    }

    .workspace-measure-bar--compact .btn-hotkey .hotkey,
    .calibrate-actions--compact .btn-hotkey .hotkey {
        display: inline-flex;
    }
}
