/* KeyBoard.js Demo Simulator — Sheet & Biro Technical Design System */

:root {
    --bg: #ffffff;
    --surface: #f4f4f2;
    --surface-raised: #ffffff;
    --dark: #111111;
    --dark-surface: #1b1b19;
    --ink: #111111;
    --ink-dark: #f4f4f2;
    --muted: #5c5c59;
    --muted-dark: #a3a39e;
    --line: rgba(17, 17, 17, 0.12);
    --line-strong: rgba(17, 17, 17, 0.24);
    --line-dark: rgba(255, 255, 255, 0.14);
    --action: #1a4be0;
    --action-hover: #143bb3;
    --action-ink: #ffffff;
    --danger: #b92c2c;
    --ok: #126b42;

    --font-sans: 'IBM Plex Sans', 'IBM Plex Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 8px;

    --nav-h: 64px;
    --gut: clamp(20px, 5vw, 80px);
    --wrap-max: 1280px;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    word-break: keep-all;
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
    scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    overflow-x: hidden;
}

img, svg {
    display: block;
    max-width: 100%;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

a {
    color: var(--action);
    text-decoration: none;
}

:focus-visible {
    outline: 2px solid var(--action);
    outline-offset: 2px;
}

.wrap {
    width: min(100% - 2 * var(--gut), var(--wrap-max));
    margin-inline: auto;
}

/* Skip link */
.skip-link {
    position: absolute;
    left: var(--gut);
    top: -120px;
    z-index: 100;
    background: var(--dark);
    color: var(--ink-dark);
    padding: 10px 16px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 500;
}

.skip-link:focus {
    top: 12px;
}

/* Header */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    z-index: 40;
    display: flex;
    align-items: center;
}

.nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 500;
    font-size: 17px;
    letter-spacing: -0.02em;
}

.brand__mark {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.nav__links {
    display: flex;
    align-items: center;
    gap: 28px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav__link {
    position: relative;
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
    padding: 6px 0;
    transition: color 150ms var(--ease);
}

.nav__link::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.5px;
    background: var(--ink);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 150ms var(--ease);
}

.nav__link:hover::after {
    transform: scaleX(1);
}

.nav__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-switch {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    padding: 2px;
    gap: 2px;
    background: var(--bg);
}

.lang-switch__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 30px;
    padding: 0 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    border-radius: 3px;
    transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

.lang-switch__item:hover {
    color: var(--ink);
}

.lang-switch__item[aria-current="page"] {
    background: var(--dark);
    color: var(--ink-dark);
}

/* Buttons — Single strict system */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--r-sm);
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: transform 150ms var(--ease), background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}

.btn--sm {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
}

.btn--primary {
    background: var(--action);
    color: var(--action-ink);
    border-color: var(--action);
}

.btn--primary:hover {
    background: var(--action-hover);
    border-color: var(--action-hover);
    transform: translateY(-1px);
}

.btn--secondary {
    background: var(--bg);
    color: var(--ink);
    border-color: var(--line-strong);
}

.btn--secondary:hover {
    background: var(--surface);
    border-color: var(--ink);
    transform: translateY(-1px);
}

.btn--ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--line);
}

.btn--ghost:hover {
    background: var(--surface);
    border-color: var(--line-strong);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px) scale(0.985);
}

.btn[aria-pressed="true"],
.btn.is-active {
    background: var(--dark);
    color: var(--ink-dark);
    border-color: var(--dark);
}

/* Hero & Main Workbench */
main {
    padding-top: var(--nav-h);
}

.hero {
    padding: 56px 0 48px;
    border-bottom: 1px solid var(--line);
}

.hero__grid {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 32px 48px;
    align-items: end;
}

.hero__title {
    margin: 0;
    font-size: clamp(32px, 4.2vw, 56px);
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.032em;
    color: var(--ink);
}

.hero__title-muted {
    display: block;
    color: var(--muted);
}

.hero__side {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hero__lead {
    margin: 0;
    font-size: 17px;
    line-height: 1.6;
    color: var(--ink);
    max-width: 52ch;
}

.hero__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--muted);
}

.hero__cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Section scaffolding */
.section {
    padding: 64px 0;
}

.section--alt {
    background: var(--surface);
}

.section__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.section__title {
    margin: 0;
    font-size: clamp(24px, 2.6vw, 36px);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.section__desc {
    margin: 8px 0 0;
    font-size: 16px;
    color: var(--muted);
    max-width: 60ch;
}

/* Simulator Workbench */
.workbench {
    border: 1px solid var(--line-strong);
    border-radius: var(--r-lg);
    background: var(--bg);
    overflow: hidden;
}

.stage-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    flex-wrap: wrap;
}

.stage-bar__group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.seg {
    display: inline-flex;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--bg);
    padding: 2px;
    gap: 2px;
}

.seg__btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 3px;
    cursor: pointer;
    min-height: 30px;
    transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

.seg__btn:hover {
    color: var(--ink);
}

.seg__btn[aria-pressed="true"] {
    background: var(--dark);
    color: var(--ink-dark);
}

.stage-telemetry {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--muted);
}

.stage-telemetry strong {
    color: var(--ink);
    font-weight: 500;
}

.stage-canvas {
    padding: 28px 20px;
    min-height: 290px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background:
        radial-gradient(rgba(17, 17, 17, 0.08) 1px, transparent 1px) 0 0 / 16px 16px,
        #fafaf8;
    border-bottom: 1px solid var(--line);
    transition: background-color 180ms var(--ease);
}

.stage-canvas[data-stage-bg="dark"] {
    background:
        radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px) 0 0 / 16px 16px,
        #111112;
}

/* Typing Practice Simulator Tray */
.typing-tray {
    width: 100%;
    max-width: 980px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--bg);
    color: var(--ink);
    overflow: hidden;
}

.typing-tray[hidden] {
    display: none;
}

.stage-canvas[data-stage-bg="dark"] .typing-tray {
    background: var(--dark-surface);
    color: var(--ink-dark);
    border-color: var(--line-dark);
}

.typing-tray__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    flex-wrap: wrap;
}

.stage-canvas[data-stage-bg="dark"] .typing-tray__head {
    background: #141416;
    border-bottom-color: var(--line-dark);
}

.typing-tray__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.typing-tray__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}

.stage-canvas[data-stage-bg="dark"] .typing-tray__label {
    color: #ffffff;
}

.typing-tray__stats {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}

.stage-canvas[data-stage-bg="dark"] .typing-tray__stats {
    color: var(--muted-dark);
}

.typing-tray__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.typing-select {
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--ink);
    font-size: 13px;
    cursor: pointer;
}

.stage-canvas[data-stage-bg="dark"] .typing-select,
.stage-canvas[data-stage-bg="dark"] .typing-tray__actions .btn--ghost {
    background: #222226;
    color: var(--ink-dark);
    border-color: var(--line-dark);
}

.typing-line {
    padding: 13px 18px;
    font-size: 17px;
    line-height: 1.55;
    letter-spacing: -0.01em;
    word-break: keep-all;
}

.typing-line--target {
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    min-height: 52px;
}

.stage-canvas[data-stage-bg="dark"] .typing-line--target {
    border-bottom-color: var(--line-dark);
    color: #7c7c82;
}

.typing-char--done {
    color: var(--ink);
}

.stage-canvas[data-stage-bg="dark"] .typing-char--done {
    color: #f4f4f2;
}

.typing-char--err {
    color: var(--danger);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.typing-char--cur {
    color: var(--action);
    border-bottom: 2px solid var(--action);
}

.stage-canvas[data-stage-bg="dark"] .typing-char--cur {
    color: #7ea2ff;
    border-bottom-color: #7ea2ff;
}

.typing-line--output {
    font-family: var(--font-sans);
    background: #fafaf8;
    color: var(--ink);
    min-height: 52px;
}

.typing-line--output.is-manual {
    padding: 6px 12px;
}

#typingOutputText {
    white-space: pre-wrap;
}

.typing-manual-input {
    width: 100%;
    min-height: 40px;
    padding: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    outline: none;
}

.typing-manual-input::placeholder {
    color: var(--muted);
}

.stage-canvas[data-stage-bg="dark"] .typing-manual-input::placeholder {
    color: var(--muted-dark);
}

.typing-manual-input[hidden],
.typing-select[hidden],
#typingPauseBtn[hidden],
#typingOutputText[hidden],
#typingCaret[hidden] {
    display: none;
}

.stage-canvas[data-stage-bg="dark"] .typing-line--output {
    background: #131315;
    color: #ffffff;
}

.typing-line--output.is-typo {
    background: #fdf2f2;
}

.stage-canvas[data-stage-bg="dark"] .typing-line--output.is-typo {
    background: #261617;
}

.typing-caret {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    margin-left: 1px;
    vertical-align: -0.15em;
    background: var(--action);
    animation: caretStep 1s steps(1, end) infinite;
}

.stage-canvas[data-stage-bg="dark"] .typing-caret {
    background: #7ea2ff;
}

@keyframes caretStep {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

#keyboard-area {
    width: 100%;
    max-width: 980px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Live Code Bar */
.code-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: var(--dark);
    color: var(--ink-dark);
    border-bottom: 1px solid var(--line-dark);
    color-scheme: dark;
}

.code-bar__content {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.code-bar__tag {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted-dark);
    flex-shrink: 0;
}

.code-bar__snippet {
    font-family: var(--font-mono);
    font-size: 13px;
    color: #ffffff;
    white-space: nowrap;
    overflow-x: auto;
    padding: 2px 0 4px;
    margin-bottom: -4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

/* Custom theme-matched scrollbars (dark code/log bars & light lab surfaces) */
.code-bar__snippet::-webkit-scrollbar,
.code-block pre::-webkit-scrollbar,
.log-box::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.code-bar__snippet::-webkit-scrollbar-track,
.code-block pre::-webkit-scrollbar-track,
.log-box::-webkit-scrollbar-track {
    background: transparent;
}

.code-bar__snippet::-webkit-scrollbar-thumb,
.code-block pre::-webkit-scrollbar-thumb,
.log-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
}

.code-bar__snippet::-webkit-scrollbar-thumb:hover,
.code-block pre::-webkit-scrollbar-thumb:hover,
.log-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.code-bar__snippet::-webkit-scrollbar-corner,
.code-block pre::-webkit-scrollbar-corner,
.log-box::-webkit-scrollbar-corner {
    background: transparent;
}

.code-block pre,
.log-box {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.lab-stage {
    scrollbar-width: thin;
    scrollbar-color: rgba(17, 17, 17, 0.22) transparent;
}

.lab-stage::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.lab-stage::-webkit-scrollbar-track {
    background: transparent;
}

.lab-stage::-webkit-scrollbar-thumb {
    background: rgba(17, 17, 17, 0.2);
    border-radius: 999px;
}

.lab-stage::-webkit-scrollbar-thumb:hover {
    background: rgba(17, 17, 17, 0.36);
}

.code-bar__copy {
    min-height: 32px;
    padding: 0 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-dark);
    background: transparent;
    color: var(--ink-dark);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}

.code-bar__copy:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Status strip (replaces all alert() dialogs) */
.status-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    color: var(--ink);
    min-height: 42px;
}

.status-strip__msg {
    margin: 0;
}

.status-strip__hint {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

/* Simulator Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    position: relative;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    min-height: 48px;
    transition: color 150ms var(--ease), background-color 150ms var(--ease);
}

.tab:hover {
    color: var(--ink);
    background: var(--surface);
}

.tab[aria-selected="true"] {
    color: var(--ink);
}

.tab[aria-selected="true"]::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--action);
}

.tab__code {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
    margin-left: 6px;
}

.panel {
    padding: 24px 20px;
}

.panel[hidden] {
    display: none;
}

.panel__grid {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 24px 32px;
    align-items: start;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
    flex: 1;
}

.field--compact {
    flex: 0 1 200px;
}

.field--colors {
    flex: 0 1 260px;
}

.field__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.input, .select {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    width: 100%;
    transition: border-color 140ms var(--ease);
}

.input--mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

.input:focus, .select:focus {
    outline: none;
    border-color: var(--action);
    box-shadow: 0 0 0 3px rgba(26, 75, 224, 0.14);
}

.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.swatch {
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
    border: 1px solid rgba(17, 17, 17, 0.2);
    cursor: pointer;
    padding: 0;
    transition: transform 120ms var(--ease);
}

.swatch:hover {
    transform: translateY(-1px);
}

.swatch.is-selected {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.color-native {
    width: 36px;
    height: 32px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--bg);
    padding: 2px;
    cursor: pointer;
}

.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    align-items: center;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    min-height: 32px;
}

.check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--action);
    cursor: pointer;
}

.range-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
    flex: 1;
}

.range-field__top {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.range-field__val {
    font-family: var(--font-mono);
    color: var(--ink);
    font-weight: 500;
}

.range-field input[type="range"] {
    width: 100%;
    accent-color: var(--action);
    cursor: pointer;
}

/* Preset column */
.preset-box {
    border-left: 1px solid var(--line);
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preset-box__title {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.preset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    min-height: 28px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink);
}

.chip__x {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
}

.chip__x:hover {
    color: var(--ink);
}

/* Event Log Table */
.log-box {
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--dark);
    color: var(--ink-dark);
    font-family: var(--font-mono);
    font-size: 13px;
    height: 240px;
    overflow-y: auto;
    color-scheme: dark;
}

.log-head {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-columns: 78px 86px 96px 1fr 80px;
    gap: 12px;
    padding: 10px 14px;
    background: var(--dark-surface);
    border-bottom: 1px solid var(--line-dark);
    color: var(--muted-dark);
    font-size: 12px;
}

.log-body {
    padding: 4px 0;
}

.log-row {
    display: grid;
    grid-template-columns: 78px 86px 96px 1fr 80px;
    gap: 12px;
    padding: 6px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    align-items: center;
}

.log-row--empty {
    display: block;
    padding: 20px 14px;
    color: var(--muted-dark);
}

.log-type--press {
    color: #82aaff;
}

.log-type--unpress {
    color: #c3c3be;
}

.log-code {
    color: #ffffff;
}

.log-meta {
    color: var(--muted-dark);
}

/* Responsive Viewport Lab */
.lab-card {
    border: 1px solid var(--line-strong);
    border-radius: var(--r-lg);
    background: var(--bg);
    overflow: hidden;
    margin-bottom: 40px;
}

.lab-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 20px 28px;
    padding: 20px;
    border-bottom: 1px solid var(--line);
    align-items: end;
}

.lab-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.lab-stage {
    padding: 28px 20px;
    background:
        radial-gradient(rgba(17, 17, 17, 0.08) 1px, transparent 1px) 0 0 / 16px 16px,
        #fafaf8;
    display: flex;
    justify-content: safe center;
    align-items: center;
    overflow-x: auto;
    min-height: 320px;
}

.lab-frame {
    position: relative;
    border: 1px dashed var(--action);
    background: var(--bg);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: width 160ms var(--ease), height 160ms var(--ease);
    flex-shrink: 0;
}

.lab-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    background: var(--bg);
}

.metric {
    padding: 14px 18px;
    border-right: 1px solid var(--line);
}

.metric:last-child {
    border-right: 0;
}

.metric__label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.metric__val {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 500;
    color: var(--ink);
}

/* Multi-Panel Aspect Matrix */
.matrix-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.matrix-head h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.matrix-head p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.matrix {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
}

.matrix-tile {
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.matrix-tile__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    font-size: 13px;
}

.matrix-tile__name {
    font-weight: 500;
    color: var(--ink);
}

.matrix-tile__dim {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}

.matrix-tile__mount {
    flex: 1;
    width: 100%;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.matrix-tile--banner { grid-column: span 12; height: 210px; }
.matrix-tile--standard { grid-column: span 7; height: 280px; }
.matrix-tile--square { grid-column: span 5; height: 280px; }
.matrix-tile--compact { grid-column: span 5; height: 240px; }
.matrix-tile--tower { grid-column: span 4; height: 240px; }
.matrix-tile--micro { grid-column: span 3; height: 240px; }

/* API Reference */
.api-grid {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 32px 48px;
    align-items: start;
}

.code-block {
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: var(--dark);
    color: var(--ink-dark);
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
    color-scheme: dark;
}

.spec-list {
    border-top: 1px solid var(--line-strong);
    min-width: 0;
}

.code-block__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line-dark);
    background: var(--dark-surface);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted-dark);
}

.code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
}

.spec-row {
    display: grid;
    grid-template-columns: minmax(170px, 220px) minmax(0, 1fr) auto;
    gap: 12px 20px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    align-items: baseline;
}

.spec-row__sig {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}

.spec-row__desc {
    font-size: 14px;
    color: var(--muted);
    margin: 0;
}

.spec-row__try {
    border: 0;
    background: transparent;
    color: var(--action);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
    white-space: nowrap;
}

.spec-row__try:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Open FAQ list (SEO / GEO clarity, zero accordion hiding) */
.faq-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 48px;
    border-top: 1px solid var(--line-strong);
    padding-top: 28px;
}

.faq-item {
    min-width: 0;
}

.faq-item__q {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--ink);
}

.faq-item__a {
    margin: 0;
    font-size: 15px;
    line-height: 1.65;
    color: var(--muted);
}

/* Mobile Quick Section Strip */
.mobile-jump {
    display: none;
}

/* Footer */
.footer {
    background: var(--dark);
    color: var(--ink-dark);
    padding: 48px 0 36px;
}

.footer__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--line-dark);
    flex-wrap: wrap;
}

.footer__brand {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.footer__note {
    margin: 8px 0 0;
    font-size: 14px;
    color: var(--muted-dark);
    max-width: 44ch;
}

.footer__links {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.footer__link {
    color: var(--ink-dark);
    font-size: 14px;
}

.footer__link:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.footer__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 20px;
    font-size: 13px;
    color: var(--muted-dark);
    flex-wrap: wrap;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .hero__grid,
    .panel__grid,
    .api-grid {
        grid-template-columns: 1fr;
    }

    .preset-box {
        border-left: 0;
        border-top: 1px solid var(--line);
        padding-left: 0;
        padding-top: 20px;
    }

    .lab-controls {
        grid-template-columns: 1fr 1fr;
    }

    .lab-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .matrix-tile--standard,
    .matrix-tile--square,
    .matrix-tile--compact,
    .matrix-tile--tower,
    .matrix-tile--micro {
        grid-column: span 6;
    }
}

@media (max-width: 640px) {
    .nav__links {
        display: none;
    }

    .nav__actions .btn--primary {
        display: none;
    }

    .nav__actions .btn--sm {
        padding: 0 10px;
        min-height: 36px;
    }

    .mobile-jump {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        scrollbar-width: none;
        padding: 10px var(--gut);
        border-bottom: 1px solid var(--line);
        background: var(--surface);
    }

    .mobile-jump::-webkit-scrollbar {
        display: none;
    }

    .mobile-jump__link {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
        padding: 0 12px;
        border: 1px solid var(--line-strong);
        border-radius: var(--r-sm);
        background: var(--bg);
        color: var(--ink);
        font-size: 13px;
        font-weight: 500;
        white-space: nowrap;
    }

    .hero {
        padding: 28px 0 28px;
    }

    .hero__title {
        font-size: 30px;
    }

    .hero__cta .btn {
        flex: 1 1 140px;
    }

    .section {
        padding: 40px 0;
    }

    .stage-bar {
        padding: 12px;
        gap: 10px;
    }

    .stage-bar__group {
        width: 100%;
        gap: 8px;
    }

    .seg {
        max-width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .seg::-webkit-scrollbar {
        display: none;
    }

    .seg__btn {
        min-height: 36px;
        padding: 6px 10px;
        white-space: nowrap;
    }

    .stage-canvas {
        padding: 14px 8px;
        min-height: 190px;
        gap: 12px;
    }

    .typing-tray__head {
        padding: 10px 12px;
    }

    .typing-line {
        padding: 11px 12px;
        font-size: 15px;
    }

    .lab-stage {
        padding: 20px 12px;
        min-height: 230px;
    }

    .status-strip {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 10px 14px;
    }

    .panel {
        padding: 18px 14px;
    }

    .lab-controls,
    .lab-metrics,
    .faq-list {
        grid-template-columns: 1fr;
    }

    .metric {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .metric:last-child {
        border-bottom: 0;
    }

    .matrix-tile--banner,
    .matrix-tile--standard,
    .matrix-tile--square,
    .matrix-tile--compact,
    .matrix-tile--tower,
    .matrix-tile--micro {
        grid-column: span 12;
        height: 210px;
    }

    .spec-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .log-head,
    .log-row {
        grid-template-columns: 60px 70px 70px 1fr;
    }

    .log-head > :last-child,
    .log-row > :last-child {
        display: none;
    }
}

@media (max-width: 360px) {
    .brand span {
        font-size: 15px;
    }

    .nav__actions .btn--secondary {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
