:root {
    --blue: #3b82f6;
    --blue-dark: #2563eb;
    --blue-soft: #eff6ff;
    --ink: #0f172a;
    --text: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --panel: #ffffff;
    --canvas: #f8fafc;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 12px 32px rgba(15, 23, 42, .12);
    --header-h: 58px;
    --left-w: 244px;
    --right-w: 286px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overscroll-behavior: none; }
body { margin: 0; overflow: hidden; color: var(--text); background: var(--canvas); font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, svg:focus-visible {
    outline: 3px solid rgba(59, 130, 246, .3); outline-offset: 1px;
}

.app-shell { height: 100dvh; display: flex; flex-direction: column; }
.app-header {
    height: var(--header-h); flex: 0 0 var(--header-h); display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); z-index: 40;
}
.icon-btn, .toolbar button, .zoom-controls button, .panel-heading button {
    min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; background: transparent; border-radius: 8px; cursor: pointer; text-decoration: none;
}
.icon-btn:hover, .toolbar button:hover, .zoom-controls button:hover, .panel-heading button:hover { background: #f1f5f9; border-color: var(--line); }
.back-link { color: var(--blue); font-size: 21px; }
.brand-lockup { display: flex; align-items: center; gap: 8px; min-width: 128px; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
    color: #fff; font-size: 18px; font-weight: 800; background: linear-gradient(145deg, #60a5fa, #2563eb);
}
.brand-lockup strong, .brand-lockup small { display: block; white-space: nowrap; }
.brand-lockup strong { color: var(--ink); line-height: 1.05; font-size: 14px; }
.brand-lockup small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.project-name {
    width: 168px; border: 1px solid transparent; border-radius: 7px; padding: 7px 9px; color: var(--ink);
    font-weight: 600; background: transparent; text-overflow: ellipsis;
}
.project-name:hover, .project-name:focus { border-color: var(--line); background: #f8fafc; }
.save-state { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.save-state i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
.save-state.saving i { background: #f59e0b; animation: pulse 1s infinite; }
.save-state.error i { background: #ef4444; }
@keyframes pulse { 50% { opacity: .35; } }
.toolbar { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.toolbar button { padding: 0 9px; font-size: 13px; }
.toolbar .separator { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.primary-btn { background: var(--blue) !important; border-color: var(--blue) !important; color: #fff !important; font-weight: 700; }
.primary-btn:hover { background: var(--blue-dark) !important; }
.danger-btn { background: var(--danger) !important; color: #fff !important; border-color: var(--danger) !important; }
.mobile-more { display: none; font-weight: 800; letter-spacing: 1px; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w); }
.panel { background: var(--panel); z-index: 20; min-height: 0; display: flex; flex-direction: column; }
.shape-panel { border-right: 1px solid var(--line); }
.properties-panel { border-left: 1px solid var(--line); }
.panel-heading { min-height: 64px; padding: 14px 16px 11px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading strong, .panel-heading small { display: block; }
.panel-heading strong { color: var(--ink); font-size: 15px; }
.panel-heading small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.panel-close { display: none !important; font-size: 22px; }
.search-box { margin: 12px 14px 8px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; display: flex; align-items: center; padding: 0 10px; color: var(--muted); }
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, .1); }
.search-box input { width: 100%; height: 36px; padding-left: 8px; border: 0; outline: 0; background: transparent; color: var(--text); }
.shape-library { flex: 1; overflow: auto; padding: 4px 12px 14px; }
.shape-category-title { width: 100%; margin: 12px 0 7px; padding: 4px 3px; display: flex; align-items: center; justify-content: space-between; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; text-align: left; }
.shape-category-title:hover { color: var(--blue-dark); }
.shape-category-title b { font-size: 14px; }
.shape-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.shape-item {
    min-height: 64px; padding: 7px 5px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: grab; color: var(--text); transition: .15s ease;
}
.shape-item:hover { color: var(--blue-dark); border-color: #93c5fd; background: var(--blue-soft); transform: translateY(-1px); }
.shape-item:active { cursor: grabbing; transform: scale(.98); }
.shape-preview { width: 48px; height: 30px; overflow: visible; color: var(--blue); }
.shape-preview * { vector-effect: non-scaling-stroke; }
.shape-item span:last-child { margin-top: 4px; font-size: 11px; }
.privacy-note { margin: 0 12px 12px; padding: 9px; border-radius: 8px; color: #047857; background: #ecfdf5; font-size: 11px; text-align: center; }

.canvas-area { min-width: 0; min-height: 0; position: relative; overflow: hidden; background: var(--canvas); touch-action: none; }
#canvas { display: block; width: 100%; height: 100%; cursor: default; user-select: none; -webkit-user-select: none; touch-action: none; }
#canvas.panning { cursor: grabbing; }
.node { cursor: move; }
.node.locked { cursor: not-allowed; }
.node-shape { filter: url(#nodeShadow); }
.node-detail { pointer-events: none; }
.node:hover .node-shape { stroke: #60a5fa !important; filter: url(#nodeShadow) drop-shadow(0 0 4px rgba(59,130,246,.2)); }
.node.selected .node-shape { stroke: var(--blue) !important; stroke-width: 3 !important; }
.node.connect-target .node-shape { stroke: #16a34a !important; stroke-width: 3 !important; filter: drop-shadow(0 0 7px rgba(22,163,74,.38)); }
.node.connecting-source .node-shape { stroke: var(--blue-dark) !important; stroke-width: 3 !important; filter: drop-shadow(0 0 7px rgba(37,99,235,.35)); }
.node-text { pointer-events: none; user-select: none; }
.selection-box { fill: rgba(59, 130, 246, .08); stroke: var(--blue); stroke-width: 1; stroke-dasharray: 5 4; }
.port { fill: #fff; stroke: var(--blue); stroke-width: 2; cursor: crosshair; opacity: 0; transition: opacity .12s, r .12s, fill .12s; pointer-events: none; }
.node:hover .port, .node.selected .port { opacity: 1; }
.node.connect-target .port, .node.connecting-source .port, .node.connection-mode .port { opacity: 1; }
.port.active { fill: #16a34a; stroke: #fff; filter: drop-shadow(0 0 4px #16a34a); }
.port-hit { fill: transparent; cursor: crosshair; pointer-events: all; }
.edge-path { fill: none; cursor: pointer; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 18; cursor: pointer; pointer-events: stroke; vector-effect: non-scaling-stroke; }
.edge:hover .edge-path, .edge.hovered .edge-path { filter: drop-shadow(0 0 3px rgba(59,130,246,.45)); }
.edge.selected .edge-path { stroke: var(--blue) !important; filter: drop-shadow(0 0 2px rgba(59,130,246,.4)); }
.edge-label-bg { fill: #fff; stroke: var(--line); }
.edge-label { fill: var(--text); font-size: 13px; text-anchor: middle; dominant-baseline: middle; cursor: grab; }
.edge-label-bg { cursor: grab; }
.free-line-path { fill: none; cursor: move; }
.free-line-hit { fill: none; stroke: transparent; stroke-width: 18; cursor: move; pointer-events: stroke; vector-effect: non-scaling-stroke; }
.free-line:hover .free-line-path, .free-line.selected .free-line-path { filter: drop-shadow(0 0 3px rgba(59,130,246,.45)); }
.free-line.selected .free-line-path { stroke: var(--blue) !important; }
.free-line-label, .edge-label { text-anchor: middle; dominant-baseline: middle; cursor: grab; }
.free-line-label-bg, .edge-label-bg { cursor: grab; stroke: var(--line); }
.line-point-handle { fill: #fff; stroke: var(--blue); stroke-width: 2; cursor: move; }
.line-point-handle.endpoint { fill: #dbeafe; cursor: crosshair; }
.line-rotate-handle { fill: #fff; stroke: #8b5cf6; stroke-width: 2; cursor: grab; }
.line-rotate-stem { stroke: #8b5cf6; stroke-width: 1.5; stroke-dasharray: 3 3; pointer-events: none; }
.edge-point-handle { fill: #fff; stroke: #2563eb; stroke-width: 2; cursor: move; }
.edge-point-handle:hover { fill: #dbeafe; r: 8px; }
.independent-line-preview { fill: none; stroke: #2563eb; stroke-width: 2; stroke-dasharray: 7 5; pointer-events: none; }
.shape-drawing-preview { transform: translate(var(--preview-x, 0), var(--preview-y, 0)); opacity: .55; stroke: #2563eb !important; stroke-dasharray: 7 5; pointer-events: none; }
.shape-drawing-detail { opacity: .45; pointer-events: none; }
.purpose-container .node-shape { filter: none; }
.purpose-decoration .port, .purpose-decoration .port-hit, .purpose-container .port, .purpose-container .port-hit { display: none; }
.temp-edge { fill: none; stroke: var(--blue); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }
.temp-edge.valid { stroke: #16a34a; stroke-width: 3; stroke-dasharray: none; }
.connection-cursor { fill: #fff; stroke: var(--blue); stroke-width: 2; stroke-dasharray: 3 3; pointer-events: none; }
.connection-cursor.valid { fill: #dcfce7; stroke: #16a34a; stroke-dasharray: none; }
.endpoint-hit, .quick-connect-hit { fill: transparent; cursor: crosshair; pointer-events: all; }
.endpoint-handle { fill: #fff; stroke: var(--blue); stroke-width: 2; pointer-events: none; }
.quick-connect { fill: #fff; stroke: var(--blue); stroke-width: 2; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(15,23,42,.12)); }
.quick-connect-plus { fill: var(--blue-dark); font-size: 14px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.segment-handle-hit { stroke: transparent; stroke-width: 18; cursor: move; pointer-events: stroke; }
.segment-handle { stroke: var(--blue); stroke-width: 4; stroke-linecap: round; opacity: .55; pointer-events: none; stroke-dasharray: 7 5; }
.snap-guide { stroke: #f43f5e; stroke-width: 1; stroke-dasharray: 4 4; pointer-events: none; }

.empty-hint {
    position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); width: min(360px, 80%);
    text-align: center; color: var(--muted); pointer-events: none;
}
.empty-hint[hidden] { display: none; }
.hint-icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 22px rgba(15,23,42,.08); display: grid; place-items: center; font-size: 28px; color: var(--blue); }
.empty-hint strong { display: block; color: var(--ink); font-size: 18px; }
.empty-hint p { margin: 5px 0 14px; font-size: 13px; }
.empty-hint button { pointer-events: auto; border: 0; padding: 9px 15px; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 700; cursor: pointer; }
.canvas-status { position: absolute; left: 12px; bottom: 10px; display: flex; gap: 12px; color: var(--muted); font-size: 11px; pointer-events: none; }
.connection-hint { position: absolute; z-index: 18; max-width: 180px; padding: 7px 10px; border: 1px solid #bfdbfe; border-radius: 8px; color: var(--blue-dark); background: #eff6ff; box-shadow: 0 4px 12px rgba(15,23,42,.1); font-size: 11px; pointer-events: none; }
.connection-hint.valid { color: #047857; border-color: #86efac; background: #ecfdf5; }
.cancel-connection { position: absolute; z-index: 19; left: 50%; bottom: 58px; transform: translateX(-50%); min-height: 40px; padding: 0 18px; border: 1px solid #fecaca; border-radius: 99px; background: #fff; color: var(--danger); box-shadow: var(--shadow); font-weight: 700; cursor: pointer; }
.zoom-controls { position: absolute; right: 12px; bottom: 10px; height: 36px; display: flex; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 3px 10px rgba(15,23,42,.08); }
.zoom-controls button { border-radius: 0; border-right: 1px solid var(--line); font-size: 15px; }
.zoom-controls button:last-child { border-right: 0; }
#zoomLabelFloating { min-width: 50px; font-size: 11px; }
.mobile-fab { display: none; }

.properties-content { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
.property-section { padding-bottom: 15px; margin-bottom: 15px; border-bottom: 1px solid var(--line); }
.property-section:last-child { border-bottom: 0; }
.property-section h3 { margin: 0 0 10px; color: var(--ink); font-size: 12px; }
.field { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; margin-bottom: 9px; font-size: 12px; color: var(--muted); }
.field.full { display: block; }
.field.full span { display: block; margin-bottom: 5px; }
.field input:not([type="checkbox"]):not([type="color"]), .field select, .field textarea {
    width: 100%; min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: #fff;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input[type="color"] { width: 100%; height: 32px; border: 1px solid var(--line); border-radius: 7px; padding: 3px; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); outline: 0; box-shadow: 0 0 0 2px rgba(59,130,246,.1); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.field-row .field { display: block; }
.field-row .field span { display: block; margin-bottom: 4px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 12px; }
.toggle { appearance: none; width: 36px; height: 20px; padding: 2px; border-radius: 99px; background: #cbd5e1; cursor: pointer; transition: .15s; }
.toggle::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: white; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle:checked { background: var(--blue); }
.toggle:checked::after { transform: translateX(16px); }
.button-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.button-grid button, .property-action {
    min-height: 34px; border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; font-size: 11px;
}
.button-grid button:hover, .property-action:hover { border-color: #93c5fd; background: var(--blue-soft); color: var(--blue-dark); }
.property-action { width: 100%; margin-top: 6px; }
.property-action.danger { color: var(--danger); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 8px; }
.swatches button { aspect-ratio: 1; border: 2px solid #fff; border-radius: 7px; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.quick-labels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.quick-labels button { min-height: 30px; border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; font-size: 11px; }
.quick-labels button:hover { border-color: #93c5fd; color: var(--blue-dark); background: var(--blue-soft); }

.popover { position: fixed; z-index: 100; min-width: 180px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.popover[hidden] { display: none; }
.popover button { width: 100%; min-height: 36px; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; cursor: pointer; }
.popover button:hover { background: #f1f5f9; }
.popover hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.popover button.danger { color: var(--danger); }
.export-options { padding: 8px 10px; border-top: 1px solid var(--line); }
.export-options label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0; color: var(--muted); font-size: 11px; }
.export-options select { border: 1px solid var(--line); border-radius: 5px; padding: 3px; }
.toast-region { position: fixed; right: 18px; top: 72px; z-index: 150; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 240px; max-width: 360px; padding: 11px 14px; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 9px; background: #fff; color: var(--text); box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: #16a34a; }
@keyframes toast-in { from { transform: translateY(-7px); opacity: 0; } }
.busy-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(255,255,255,.82); backdrop-filter: blur(3px); display: grid; place-content: center; justify-items: center; gap: 12px; }
.busy-overlay[hidden] { display: none; }
.spinner { width: 34px; height: 34px; border: 3px solid #dbeafe; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal {
    width: min(720px, calc(100vw - 28px)); max-height: min(720px, calc(100dvh - 32px)); padding: 0;
    border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: #fff; box-shadow: 0 24px 70px rgba(15,23,42,.25);
}
.modal::backdrop { background: rgba(15,23,42,.42); backdrop-filter: blur(2px); }
.modal form { padding: 20px; overflow: auto; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.modal-heading strong, .modal-heading small { display: block; }
.modal-heading strong { color: var(--ink); font-size: 19px; }
.modal-heading small { color: var(--muted); font-size: 12px; margin-top: 4px; }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.template-card { min-height: 118px; border: 1px solid var(--line); border-radius: 11px; background: #fff; padding: 14px; text-align: left; cursor: pointer; }
.template-card:hover { border-color: #93c5fd; background: var(--blue-soft); transform: translateY(-1px); }
.template-card b { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 12px; border-radius: 9px; background: #dbeafe; color: var(--blue-dark); font-size: 18px; }
.template-card strong, .template-card small { display: block; }
.template-card strong { color: var(--ink); font-size: 13px; }
.template-card small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.guide-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.guide-steps article { display: flex; gap: 9px; padding: 12px; border-radius: 10px; background: #f8fafc; }
.guide-steps b { flex: 0 0 26px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--blue); color: white; }
.guide-steps strong { font-size: 12px; color: var(--ink); }
.guide-steps p { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.shortcut-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px 16px; margin: 18px 0; font-size: 12px; }
.shortcut-grid div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 6px 0; }
kbd { padding: 2px 6px; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 5px; background: #f8fafc; color: var(--text); font-size: 10px; }
.dont-show { display: block; margin: 12px 0; font-size: 12px; color: var(--muted); }
.wide { width: 100%; min-height: 42px; border: 0; border-radius: 9px; cursor: pointer; }
.confirm-modal { width: min(420px, calc(100vw - 28px)); }
.confirm-modal p { line-height: 1.6; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-actions button { min-width: 80px; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }

@media (max-width: 1180px) {
    :root { --left-w: 216px; --right-w: 258px; }
    .toolbar button { padding: 0 7px; }
    .brand-lockup small { display: none; }
    .brand-lockup { min-width: 104px; }
    .save-state span { display: none; }
}

@media (max-width: 1100px) {
    .desktop-tools { display: none; }
    .mobile-more { display: inline-flex; margin-left: auto; }
    .workspace { display: block; position: relative; }
    .canvas-area { width: 100%; height: 100%; }
    .panel {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; width: 100%; height: min(68dvh, 560px);
        border: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 35px rgba(15,23,42,.18);
        transform: translateY(105%); transition: transform .22s ease;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .panel.open { transform: translateY(0); }
    .panel-heading::before { content: ""; position: absolute; top: 7px; left: calc(50% - 20px); width: 40px; height: 4px; border-radius: 5px; background: #cbd5e1; }
    .panel-heading { padding-top: 20px; }
    .panel-close { display: inline-flex !important; }
    .shape-grid { grid-template-columns: repeat(4, 1fr); }
    .privacy-note { display: none; }
    .port-hit, .endpoint-hit, .quick-connect-hit { r: 17px; }
    .mobile-fab {
        display: flex; position: absolute; bottom: calc(58px + env(safe-area-inset-bottom)); align-items: center; gap: 5px;
        min-height: 44px; padding: 0 14px; border: 0; border-radius: 99px; color: white; background: var(--blue); box-shadow: 0 8px 22px rgba(37,99,235,.28); font-weight: 700;
    }
    .shapes-fab { left: 12px; }
    .props-fab { right: 12px; background: #334155; }
    .zoom-controls { bottom: calc(10px + env(safe-area-inset-bottom)); }
    .canvas-status { bottom: calc(14px + env(safe-area-inset-bottom)); left: 74px; }
    .canvas-status span:first-child { display: none; }
    .template-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    :root { --header-h: 54px; }
    .app-header { padding: 7px 8px; gap: 6px; }
    .brand-lockup { min-width: 0; }
    .brand-lockup > div { display: none; }
    .project-name { width: min(48vw, 180px); font-size: 13px; }
    .save-state { font-size: 0; }
    .shape-grid { grid-template-columns: repeat(3, 1fr); }
    .panel { height: min(72dvh, 600px); }
    .zoom-controls { right: 8px; }
    .zoom-controls button { min-width: 31px; }
    .mobile-fab { bottom: calc(57px + env(safe-area-inset-bottom)); }
    .canvas-status { left: 8px; bottom: calc(14px + env(safe-area-inset-bottom)); }
    .template-grid, .guide-steps, .shortcut-grid { grid-template-columns: 1fr; }
    .modal form { padding: 16px; }
    .toast-region { left: 12px; right: 12px; top: 64px; }
    .toast { min-width: 0; max-width: none; }
}

@media (max-height: 470px) and (max-width: 900px) {
    .panel { height: calc(100dvh - var(--header-h)); max-height: none; }
    .mobile-fab { bottom: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
