:root {
    color-scheme: light;
    --surface: #ffffff;
    --surface-subtle: #f5f7f7;
    --surface-hover: #edf0f0;
    --surface-active: #fff0e9;
    --canvas: #ffffff;
    --editor-canvas: #f6f7f7;
    --editor-gutter: #eef1f1;
    --ink: #202527;
    --muted: #687277;
    --faint: #98a1a4;
    --line: #dfe4e5;
    --accent: #bd4d1c;
    --accent-strong: #94360e;
    --accent-soft: #fff0e9;
    --error: #a9342d;
    --error-soft: #fff1ef;
    --success: #34714a;
    --focus: #12639a;
    --shadow: 0 18px 56px rgb(21 29 31 / 18%);
    --radius: 7px;
    --text-small: 12px;
    --text-body: 14px;
    --text-title: 18px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; color: var(--ink); background: var(--surface); font-size: var(--text-body); }
button, input, select, textarea { font: inherit; }
button, select { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { min-height: 32px; }
a { color: var(--ink); text-decoration-color: #aeb7ba; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}
[hidden] { display: none !important; }
.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; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; min-height: 32px; flex: 0 0 32px; padding: 0; border: 0; border-radius: var(--radius); color: var(--muted); background: transparent; line-height: 1; list-style: none; cursor: pointer; }
.icon-button:hover:not(:disabled) { color: var(--ink); background: var(--surface-hover); }
.icon-button:disabled { opacity: .4; cursor: default; }
.button-icon { width: 18px; height: 18px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }

.app-shell { display: grid; grid-template-rows: 52px auto minmax(0, 1fr) 44px; width: 100%; height: 100dvh; }
.app-header { grid-row: 1; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-width: 0; padding: 0 16px; background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: 9px; width: max-content; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand > span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: var(--text-title); line-height: 1; letter-spacing: -.025em; }
.brand small { color: var(--muted); font-size: var(--text-small); font-weight: 400; line-height: 1; }
.brand-mark { position: relative; width: 24px; height: 24px; flex: 0 0 24px; }
.brand-mark i { position: absolute; width: 10px; height: 10px; border: 1.5px solid var(--ink); border-radius: 1px; }
.brand-mark i:nth-child(1) { left: 0; top: 0; border-color: var(--accent); }
.brand-mark i:nth-child(2) { left: 12px; top: 0; }
.brand-mark i:nth-child(3) { left: 12px; top: 12px; }
.main-nav { display: flex; align-items: center; gap: 2px; }
.main-nav > a {
    min-height: 32px;
    padding: 7px 9px;
    border: 0;
    border-radius: var(--radius);
    color: var(--muted);
    background: transparent;
    font-size: var(--text-small);
    font-weight: 500;
    line-height: 18px;
    list-style: none;
    text-decoration: none;
}
.model-summary > summary::-webkit-details-marker { display: none; }
.main-nav > a:hover { color: var(--ink); background: var(--surface-hover); }
.main-nav > .cubetto-link { color: var(--accent-strong); }
.cubetto-link-short { display: none; }
.language-switch { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 6px; background: var(--surface-subtle); }
.language-switch a { min-width: 30px; padding: 3px 6px; border-radius: 4px; color: var(--muted); font-size: var(--text-small); font-weight: 600; line-height: 18px; text-align: center; text-decoration: none; }
.language-switch a:hover { color: var(--ink); background: var(--surface-hover); }
.language-switch a[aria-current="page"] { color: var(--accent-strong); background: var(--surface); }

.mobile-view-tabs { grid-row: 2; display: none; }
.workspace {
    --editor-width: 45%;
    grid-row: 3;
    display: grid;
    grid-template-columns: var(--editor-width) 9px minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    background: var(--surface);
    box-shadow: inset 0 1px var(--line);
}
.pane { --pane-header-height: 44px; min-width: 0; min-height: 0; background: var(--surface); }
.editor-pane { position: relative; display: grid; grid-template-rows: auto minmax(120px, 1fr) auto auto; }
.preview-pane { position: relative; display: grid; grid-template-rows: auto minmax(160px, 1fr); }
.pane-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; height: var(--pane-header-height); padding: 0 14px; }
.pane-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pane-title h1, .pane-title h2 { margin: 0; font-size: var(--text-body); font-weight: 700; letter-spacing: -.01em; }
.pane-title > span { overflow: hidden; color: var(--muted); font-size: var(--text-small); text-overflow: ellipsis; white-space: nowrap; }
.changed-badge { padding: 2px 6px; border-radius: 99px; color: var(--accent-strong) !important; background: var(--accent-soft); font-weight: 700; }

.editor-actions, .preview-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; opacity: 0; pointer-events: none; transition: opacity 140ms ease; }
.editor-pane:hover .editor-actions, .editor-pane:focus-within .editor-actions,
.preview-pane:hover .preview-actions, .preview-pane:focus-within .preview-actions { opacity: 1; pointer-events: auto; }
.editor-actions button, .preview-actions > button, .model-summary > summary,
.copy-example, .filter-group button, .empty-state button, .confirm-actions button {
    min-height: 30px;
    padding: 6px 8px;
    border: 0;
    border-radius: var(--radius);
    color: var(--muted);
    background: transparent;
    font-size: var(--text-small);
    line-height: 18px;
    list-style: none;
    cursor: pointer;
}
.editor-actions button:hover, .preview-actions > button:hover:not(:disabled), .model-summary > summary:hover,
.copy-example:hover, .filter-group button:hover, .empty-state button:hover, .confirm-actions button:hover {
    color: var(--ink);
    background: var(--surface-hover);
}
.editor-actions button:disabled, .preview-actions > button:disabled { opacity: .4; cursor: default; }
.editor-actions .icon-button, .preview-actions > .icon-button, .model-summary > .icon-button,
.copy-example.icon-button, .filter-group .icon-button, .empty-state .icon-button, .confirm-actions .icon-button { padding: 0; }

.editor-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 0; background: var(--editor-canvas); box-shadow: inset 0 1px var(--line); }
.line-numbers, #source { margin: 0; padding-top: 16px; padding-bottom: 28px; border: 0; font: 14px/1.65 "SFMono-Regular", Consolas, "Liberation Mono", monospace; tab-size: 4; }
.line-numbers { min-width: 48px; padding-right: 10px; padding-left: 8px; overflow: hidden; color: var(--faint); background: var(--editor-gutter); text-align: right; user-select: none; }
#source { width: 100%; height: 100%; padding-right: 18px; padding-left: 16px; resize: none; outline: 0; color: var(--ink); background: var(--editor-canvas); white-space: pre; overflow: auto; caret-color: var(--accent); box-shadow: inset 1px 0 var(--line); }
#source::selection { background: #ffd9c7; }
.editor-wrap.wrap-enabled { grid-template-columns: minmax(0, 1fr); }
.editor-wrap.wrap-enabled .line-numbers { display: none; }
.editor-wrap.wrap-enabled #source { white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: none; }
.splitter { position: relative; z-index: 3; width: 9px; padding: 0; border: 0; background: transparent; cursor: col-resize; }
.splitter::after { content: ""; position: absolute; left: 4px; top: 0; width: 1px; height: 100%; background: var(--line); transition: background-color 140ms ease; }
.splitter:hover::after, .splitter:focus-visible::after { background: var(--accent); }

.help-panel { position: absolute; z-index: 20; top: 0; right: 0; bottom: 0; left: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; background: var(--surface-subtle); }
.help-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: var(--pane-header-height); padding: 0 14px; background: var(--surface); box-shadow: inset 0 -1px var(--line); }
.help-header > div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.help-header h2 { margin: 0; font-size: var(--text-body); }
.help-header span { overflow: hidden; color: var(--muted); font-size: var(--text-small); text-overflow: ellipsis; white-space: nowrap; }
.help-header button { color: var(--ink); background: var(--surface-hover); }
.help-header button:hover { color: var(--ink); background: var(--surface-hover); }
.help-content { min-height: 0; padding: 14px; overflow: auto; }
.help-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.help-toolbar label, .help-toolbar a { color: var(--muted); font-size: var(--text-small); }
.help-toolbar a { margin-left: auto; }
.help-toolbar select, .gallery-controls input, .gallery-controls select { min-height: 36px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); font-size: var(--text-small); }
.help-intro { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.help-intro h3 { margin: 0 0 4px; font-size: var(--text-body); }
.help-intro p, .help-status { margin: 0; color: var(--muted); font-size: var(--text-small); line-height: 1.5; }
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.help-grid section { min-width: 0; padding: 10px; border-radius: var(--radius); background: var(--surface); }
.help-grid h4, .help-grid dt { margin: 0 0 6px; font-size: var(--text-small); }
.help-grid dl { margin: 0; }
.help-grid dt { margin-top: 8px; font-weight: 700; }
.help-grid dd { margin: 2px 0 0; color: var(--muted); font-size: var(--text-small); line-height: 1.4; }
.help-grid code { display: block; margin: 4px 0; padding: 5px 6px; overflow: auto; color: var(--ink); background: var(--surface-subtle); font: 12px/1.4 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; }
.support-flags { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 4px; }
.support-flag { padding: 2px 6px; border-radius: 99px; color: var(--success); background: #eaf4ed; font-size: var(--text-small); }
.support-flag.unchecked { color: var(--accent-strong); background: var(--accent-soft); }
.attribute-catalog { margin-top: 18px; padding: 12px; border-radius: var(--radius); background: var(--surface); }
.attribute-catalog h4 { margin: 0; font-size: var(--text-body); }
.attribute-catalog > p { margin: 3px 0 10px; color: var(--muted); font-size: var(--text-small); line-height: 1.45; }
.attribute-list article { display: grid; grid-template-columns: minmax(100px, .55fr) minmax(0, 1.45fr); gap: 4px 12px; padding: 10px 0; }
.attribute-list article + article { box-shadow: inset 0 1px var(--line); }
.attribute-name { grid-column: 1; grid-row: 1 / span 3; align-self: start; color: var(--accent-strong); font: 12px/1.45 "SFMono-Regular", Consolas, monospace; }
.attribute-scope { grid-column: 2; color: var(--muted); font-size: var(--text-small); }
.attribute-list p { grid-column: 2; margin: 0; font-size: var(--text-small); line-height: 1.45; }
.attribute-usage, .attribute-values { grid-column: 2; overflow-wrap: anywhere; font: 12px/1.45 "SFMono-Regular", Consolas, monospace; }
.attribute-usage { color: var(--ink); }
.attribute-values { color: var(--muted); }

.diagnostics { max-height: 160px; overflow: auto; background: var(--error-soft); box-shadow: inset 0 1px #f0d1cc; }
.diagnostic { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; width: 100%; min-height: 48px; padding: 9px 14px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.diagnostic + .diagnostic { box-shadow: inset 0 1px #f0d1cc; }
.diagnostic:hover { background: #ffe9e6; }
.diagnostic[disabled] { cursor: default; opacity: 1; }
.diagnostic-badge { margin-top: 2px; padding: 2px 5px; border-radius: 4px; color: #fff; background: var(--error); font-size: var(--text-small); font-weight: 800; }
.diagnostic-message { font-size: var(--text-small); line-height: 1.45; }
.diagnostic-code, .diagnostic-location { color: var(--muted); font: 12px/1.4 "SFMono-Regular", Consolas, monospace; }
.diagnostic-help { display: block; margin-top: 3px; color: var(--accent-strong); font-size: var(--text-small); text-decoration: underline; }

.preview-viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--canvas); cursor: grab; outline: none; touch-action: none; box-shadow: inset 0 1px var(--line); }
.preview-viewport:active { cursor: grabbing; }
.preview-viewport:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.preview-grid { display: none; }
.diagram-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.diagram-stage img { display: block; max-width: none; user-select: none; }
.preview-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; color: var(--muted); pointer-events: none; }
.preview-placeholder p { max-width: 300px; margin: 0; font-size: var(--text-small); line-height: 1.5; text-align: center; }
.preview-placeholder.hidden { display: none; }
.placeholder-cube { width: 42px; height: 42px; border: 1.5px solid var(--faint); transform: rotate(30deg) skew(-4deg); box-shadow: 12px 8px 0 -1px var(--canvas), 12px 8px 0 .5px var(--faint); }
.render-state { position: absolute; z-index: 8; top: 12px; left: 50%; display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 99px; color: var(--muted); background: rgb(255 255 255 / 92%); box-shadow: 0 4px 18px rgb(21 29 31 / 10%); font-size: var(--text-small); transform: translateX(-50%); }
.state-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }

.model-summary { position: relative; }
.model-summary[open] > summary { color: var(--ink); background: var(--surface-hover); }
.summary-popover { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: min(460px, calc(100vw - 32px)); max-height: min(460px, calc(100dvh - 100px)); padding: 14px; overflow: auto; border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }
.summary-popover > p { margin: 0 0 12px; color: var(--muted); font-size: var(--text-small); }
.summary-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.summary-columns h3 { margin: 0 0 6px; font-size: var(--text-small); }
.summary-columns ul { margin: 0; padding-left: 18px; }
.summary-columns li { margin: 3px 0; color: var(--muted); font-size: var(--text-small); }

dialog { max-width: none; max-height: none; padding: 0; border: 0; color: var(--ink); background: transparent; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: var(--text-body); }
dialog::backdrop { background: rgb(21 29 31 / 34%); backdrop-filter: blur(2px); }
.gallery-dialog { width: min(1180px, calc(100vw - 32px)); height: min(780px, calc(100dvh - 32px)); }
.dialog-shell { display: grid; grid-template-rows: auto auto minmax(0, 1fr); width: 100%; height: 100%; overflow: hidden; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; }
.dialog-header h2 { margin: 0; font-size: var(--text-title); letter-spacing: -.02em; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: var(--text-small); font-weight: 700; }
.gallery-controls { display: flex; align-items: center; gap: 12px; padding: 0 20px 14px; }
.search-field { flex: 1; }
.gallery-controls input { width: 100%; min-height: 40px; padding: 8px 11px; font-size: var(--text-body); }
.gallery-selects { display: flex; align-items: center; gap: 8px; }
.gallery-selects label { display: contents; }
.gallery-selects select { max-width: 190px; min-height: 40px; }
.filter-group { display: flex; align-items: center; gap: 3px; }
.filter-group button[aria-pressed="true"] { color: var(--accent-strong); background: var(--accent-soft); }
.gallery-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 0; background: var(--surface-subtle); }
.gallery-results { min-width: 0; overflow: auto; padding: 16px 18px 22px; }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.example-card { isolation: isolate; display: grid; grid-template-rows: 126px auto; min-width: 0; padding: 0; overflow: hidden; border: 0; border-radius: var(--radius); background: var(--surface); text-align: left; cursor: pointer; transition: background-color 140ms ease, box-shadow 140ms ease; }
.example-card:hover { background: var(--surface-hover); }
.example-card[aria-current="true"] { background: var(--surface-active); box-shadow: inset 3px 0 var(--accent); }
.example-thumb-frame { display: block; min-width: 0; min-height: 0; overflow: hidden; background: var(--surface); clip-path: inset(0); contain: paint; }
.example-thumb { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; padding: 5px; background: var(--surface); }
.example-card-copy { display: grid; align-content: start; gap: 3px; min-width: 0; min-height: 82px; padding: 9px 10px; }
.example-card-copy strong { font-size: var(--text-body); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.example-card-meta, .example-card-description { color: var(--muted); font-size: var(--text-small); line-height: 1.4; }
.example-card-meta { font-weight: 500; }
.example-detail { min-width: 0; overflow: auto; padding: 20px; background: var(--surface); box-shadow: inset 1px 0 var(--line); }
.example-detail h3 { margin: 4px 0; font-size: var(--text-title); line-height: 1.2; }
.example-detail h4 { margin: 20px 0 6px; font-size: var(--text-small); }
.example-detail p, .example-detail ul { color: var(--muted); font-size: var(--text-small); line-height: 1.5; }
.example-detail img { width: 100%; height: 170px; object-fit: contain; border-radius: var(--radius); background: var(--surface-subtle); }
.detail-meta { color: var(--accent-strong) !important; font-weight: 700; }
.example-detail ul { padding-left: 20px; }
.primary, .example-detail .primary { width: 100%; min-height: 40px; padding: 8px 12px; border: 0; border-radius: var(--radius); color: #fff; background: var(--accent); font-weight: 700; cursor: pointer; }
.primary:hover, .example-detail .primary:hover { color: #fff; background: var(--accent-strong); }
.primary.icon-button, .example-detail .primary.icon-button { width: 40px; min-height: 40px; padding: 0; }
.example-detail .primary.icon-button { margin-left: auto; }
.empty-state { max-width: 430px; margin: 60px auto; padding: 24px; text-align: center; }
.empty-state .icon-button { margin: 12px auto 0; }
.replace-dialog { width: min(520px, calc(100vw - 32px)); }
.confirm-card { padding: 24px; border: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.confirm-card h2 { margin: 4px 0 8px; font-size: var(--text-title); }
.confirm-card > p:not(.eyebrow) { color: var(--muted); font-size: var(--text-body); line-height: 1.5; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; margin-top: 20px; }
.confirm-actions .primary { width: auto; }
.legal-dialog { width: min(860px, calc(100vw - 32px)); height: min(760px, calc(100dvh - 32px)); }
.legal-dialog-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); width: 100%; height: 100%; overflow: hidden; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.legal-dialog-header { padding: 14px 18px; box-shadow: inset 0 -1px var(--line); }
.legal-dialog-header h2 { margin: 0; font-size: var(--text-title); letter-spacing: -.02em; }
.legal-dialog-content { min-height: 0; padding: 18px clamp(18px, 5vw, 48px) 40px; overflow: auto; }
.legal-dialog-content > .lead { margin: 0 0 30px; color: var(--muted); font-size: var(--text-body); line-height: 1.6; }
.legal-dialog-content section { margin-top: 30px; }
.legal-dialog-content section h2 { margin: 0 0 8px; font-size: var(--text-title); }
.legal-dialog-content section p, .legal-dialog-content section li { color: #465054; line-height: 1.65; }
.legal-dialog-content section ul { padding-left: 22px; }
.legal-dialog-content section li + li { margin-top: 5px; }
.legal-dialog-content .info-links { margin-top: 30px; }

.app-footer { grid-row: 4; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-width: 0; padding: 5px 16px; color: var(--muted); background: var(--surface); box-shadow: inset 0 1px var(--line); font-size: var(--text-small); }
.app-footer p { min-width: 0; margin: 0; overflow: hidden; font-size: 11px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.app-footer nav { display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.app-footer a { color: inherit; white-space: nowrap; }

.info-body { min-height: 100%; overflow: auto; background: var(--surface); }
.info-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px max(20px, calc((100vw - 820px) / 2)); }
.info-header-actions { display: flex; align-items: center; gap: 14px; }
.info-main { width: min(780px, calc(100% - 40px)); margin: 50px auto 80px; }
.info-main h1 { margin: 8px 0 12px; font-size: clamp(32px, 6vw, 50px); letter-spacing: -.04em; }
.info-main .lead { color: var(--muted); font-size: var(--text-title); line-height: 1.55; }
.info-main section { margin-top: 38px; }
.info-main h2 { margin-bottom: 8px; font-size: var(--text-title); }
.info-main section p, .info-main section li { color: #465054; line-height: 1.7; }
.info-main section ul { padding-left: 22px; }
.info-main section li + li { margin-top: 5px; }
.draft-badge { display: inline-block; margin: 0; padding: 5px 8px; border-radius: 99px; color: var(--error); background: var(--error-soft); font-size: var(--text-small); font-weight: 700; }
.info-links { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 34px; }

@keyframes pulse { 50% { opacity: .3; } }

@media (hover: none), (pointer: coarse) {
    .editor-actions, .preview-actions { opacity: 1; pointer-events: auto; }
}

@media (max-width: 1080px) {
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { grid-template-rows: 48px auto minmax(0, 1fr) 68px; }
    .app-header { padding: 0 10px; }
    .app-header .brand small { display: none; }
    .cubetto-link-label { display: none; }
    .cubetto-link-short { display: inline; }
    .main-nav > a { padding-right: 7px; padding-left: 7px; }
    .mobile-view-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px 10px; background: var(--surface); box-shadow: inset 0 -1px var(--line); }
    .mobile-view-tabs button { width: 100%; min-height: 34px; }
    .mobile-view-tabs button[aria-selected="true"] { color: var(--accent-strong); background: var(--accent-soft); }
    .workspace { display: block; min-height: 0; box-shadow: none; }
    .workspace[data-mobile-view="text"] .preview-pane, .workspace[data-mobile-view="preview"] .editor-pane { display: none; }
    .editor-pane, .preview-pane { width: 100%; height: 100%; }
    .splitter { display: none; }
    .editor-actions, .preview-actions { opacity: 1; pointer-events: auto; }
    .pane-header { padding-right: 10px; padding-left: 10px; }
    .pane-title > span:not(.changed-badge) { display: none; }
    .editor-actions { gap: 0; }
    .help-grid { grid-template-columns: 1fr; }
    .help-content { padding-right: 10px; padding-left: 10px; }
    .preview-actions { max-width: calc(100vw - 100px); overflow-x: auto; }
    .preview-actions > button { min-width: 30px; white-space: nowrap; }
    .summary-popover { position: fixed; top: 96px; right: 10px; left: 10px; width: auto; }
    .gallery-dialog { width: 100vw; height: 100dvh; }
    .dialog-shell { border-radius: 0; }
    .gallery-controls { display: grid; padding-right: 12px; padding-left: 12px; }
    .gallery-selects { display: grid; grid-template-columns: 1fr 1fr; }
    .gallery-selects label { display: contents; }
    .gallery-selects select { width: 100%; max-width: none; }
    .filter-group { overflow-x: auto; }
    .filter-group button { white-space: nowrap; }
    .gallery-layout { display: block; overflow: auto; }
    .gallery-results { overflow: visible; padding: 12px; }
    .gallery-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .example-card { grid-template-rows: 95px auto; }
    .example-detail { box-shadow: inset 0 1px var(--line); }
    .info-header { padding: 12px 16px; }
    .info-main { margin-top: 34px; }
    .legal-dialog { width: 100vw; height: 100dvh; }
    .legal-dialog-shell { border-radius: 0; }
    .app-footer { align-items: stretch; flex-direction: column; justify-content: center; gap: 3px; padding: 5px 12px; }
    .app-footer p { line-height: 1.3; white-space: normal; }
    .app-footer nav { align-self: flex-end; }
}

@media (max-width: 430px) {
    .main-nav { gap: 0; }
    .main-nav > a { padding-right: 6px; padding-left: 6px; }
    .pane { --pane-header-height: 72px; }
    .pane-header { align-items: flex-start; flex-direction: column; justify-content: center; gap: 2px; }
    .editor-actions, .preview-actions { width: 100%; justify-content: flex-start; overflow-x: auto; }
    .gallery-grid { grid-template-columns: 1fr; }
    .attribute-list article { grid-template-columns: 1fr; }
    .attribute-name, .attribute-scope, .attribute-list p, .attribute-usage, .attribute-values { grid-column: 1; grid-row: auto; }
}

@media (max-height: 620px) and (min-width: 431px) {
    .pane { --pane-header-height: 40px; }
}

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