* { box-sizing: border-box; }
body { margin: 0; }

.ds-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.ds-main {
    padding: 56px 48px 110px;
    max-width: 920px;
    margin: 0 auto;
}
.ds-tab-panel { display: none; }
.ds-tab-panel.is-active { display: block; }

.ds-page-header { margin-bottom: 32px; }
.ds-page-header h1 {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 8px;
}
.ds-page-header p {
    font-size: 0.9375rem;
    color: var(--web-text-sub);
    line-height: 1.55;
    max-width: 640px;
    margin: 0;
}

.ds-section { margin: 0 0 56px; }
.ds-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--web-text-muted);
    margin: 0 0 6px;
}
.ds-section > h2 {
    font-family: inherit;
    font-weight: 600;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
    color: var(--web-text);
    margin: 0 0 6px;
}
.ds-section .ds-section-desc {
    font-size: 0.875rem;
    color: var(--web-text-sub);
    line-height: 1.55;
    margin: 0 0 20px;
    max-width: 720px;
}

.ds-card {
    background: var(--web-surface);
    border-radius: 14px;
    box-shadow: var(--web-shadow-card);
    padding: 24px 28px;
    margin: 0 0 16px;
}
.ds-card > h3 {
    font-family: inherit;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    margin: 0 0 4px;
}
.ds-card .ds-sub {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12px;
    color: var(--web-text-muted);
    margin: 0 0 14px;
}
.ds-card .ds-desc {
    font-size: 0.875rem;
    color: var(--web-text-sub);
    line-height: 1.55;
    margin: 0 0 18px;
}
.ds-mini-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--web-text-muted);
    margin: 16px 0 10px;
}
code, .mono {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.85em;
    background: var(--web-code-bg);
    padding: 1px 6px;
    border-radius: 4px;
}

.ds-stage {
    display: flex;
    flex-wrap: wrap;
    gap: 24px 32px;
    align-items: flex-end;
    padding: 32px 28px;
    background: var(--web-bg);
    border-radius: 12px;
    margin: 4px 0 12px;
}
.ds-stage.dark { background: #2c2c30; }
.ds-stage.cream { background: var(--color-bg); }
.ds-stage.canvas { background: #1a1a1e; padding: 36px 28px; }

.ds-stage.ds-stage--column {
    flex-direction: column;
    align-items: center;
    gap: 36px;
    padding: 40px 28px;
}
.ds-stage--column .ds-tile { width: 100%; max-width: 480px; }
.ds-stage--column .ds-tile:has(.preview-step-bar) { max-width: 660px; }
.ds-stage--column .ds-tile .modal-card,
.ds-stage--column .ds-tile .completion-card {
    width: 100%;
}
.ds-stage--column .ds-tile-label { margin-top: 4px; }
.ds-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.ds-tile-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--web-text-muted);
    letter-spacing: 0.02em;
    text-align: center;
}
.ds-stage.dark .ds-tile-label,
.ds-stage.canvas .ds-tile-label { color: rgba(255, 255, 255, 0.7); }

html.dark .ds-stage.cream { background: #2c2c30; }
html.dark .ds-stage.cream .ds-tile-label { color: rgba(255, 255, 255, 0.7); }

.ds-swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.ds-swatch {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--web-border);
    background: var(--web-surface);
}
.ds-swatch-fill {
    height: 84px;
    border-bottom: 1px solid var(--web-border);
}
.ds-swatch-meta { padding: 10px 12px 12px; }
.ds-swatch-name {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--web-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ds-swatch-hex {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: var(--web-text-muted);
    margin-top: 2px;
}

.ds-type-row {
    display: grid;
    grid-template-columns: 130px 80px 1fr;
    gap: 24px;
    align-items: baseline;
    padding: 14px 0;
    border-bottom: 1px dashed var(--web-border);
}
.ds-type-row:last-child { border-bottom: 0; }
.ds-type-row .ds-type-key,
.ds-type-row .ds-type-px {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: var(--web-text-muted);
}
.ds-type-sample-inter { font-family: 'Inter', sans-serif; color: var(--web-text); line-height: 1.2; }
.ds-type-sample-fraunces { font-family: var(--font-display); color: var(--web-text); line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }

.ds-space-row {
    display: grid;
    grid-template-columns: 110px 70px 80px 1fr;
    gap: 20px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px dashed var(--web-border);
}
.ds-space-row:last-child { border-bottom: 0; }
.ds-space-key {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11.5px;
    color: var(--web-text);
    font-weight: 600;
}
.ds-space-rem,
.ds-space-px {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: var(--web-text-muted);
}
.ds-space-bar {
    height: 16px;
    background: var(--web-accent);
    border-radius: 2px;
}

.ds-radii-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}
.ds-radius-tile {
    background: var(--web-bg);
    border: 1px solid var(--web-border);
    padding: 16px;
    text-align: center;
}
.ds-radius-shape {
    margin: 0 auto 10px;
    width: 80px;
    height: 56px;
    background: var(--web-accent);
}
.ds-radius-name {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--web-text);
}
.ds-radius-px {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: var(--web-text-muted);
    margin-top: 2px;
}

.ds-shadow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    padding: 32px;
    background: var(--web-bg);
    border-radius: 12px;
}
.ds-shadow-tile {
    background: #fff;
    height: 80px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: var(--web-text);
    text-align: center;
    padding: 0 12px;
}
.ds-shadow-tile.s-panel        { box-shadow: var(--shadow-panel); }
.ds-shadow-tile.s-panel-hover  { box-shadow: var(--shadow-panel-hover); }
.ds-shadow-tile.s-button       { box-shadow: var(--shadow-button); }
.ds-shadow-tile.s-hard         { box-shadow: var(--shadow-hard); }
.ds-shadow-tile.s-widget-bar   { box-shadow: var(--widget-bar-shadow); }

.preview-step-bar {
    position: relative; transform: none; top: auto; left: auto;
    width: 620px; max-width: 100%;
    background: var(--step-bar-surface, #FFFDF5);
    border: var(--step-bar-border, 2px solid #1A1A1A);
    border-radius: var(--step-bar-radius, 12px);
    filter: drop-shadow(var(--step-bar-shadow, 6px 6px 0 rgba(26, 26, 26, 0.18)));
    padding: 15px 20px 20px;
    display: flex; flex-direction: column; gap: 10px;
}

.preview-time-control {
    position: relative; transform: none; bottom: auto; left: auto;
}

.preview-pause-viewport {
    position: relative; width: 320px; height: 200px;
    background: #1a1a1e; border-radius: 8px;
    box-shadow: inset 0 0 0 6px var(--color-success);
    overflow: hidden;
    display: flex; align-items: flex-start; justify-content: flex-end;
}
.preview-pause-viewport .pill-paused { margin: 18px; }

.preview-orbit-readout {
    position: relative; left: auto; bottom: auto;
    transform: rotate(-0.75deg); display: inline-block;
    background: var(--color-yellow-sticky); color: #1A1A1A;
    font-family: var(--font-display); font-weight: 700;
    font-size: 18px; letter-spacing: 0.01em;
    padding: 10px 18px; border: 2px solid #1A1A1A;
    border-radius: 2px; box-shadow: 3px 3px 0 #1A1A1A;
    white-space: nowrap;
}

.preview-loading {
    position: relative; inset: auto;
    width: 320px; height: 200px;
    background: #0c0c0e; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.preview-loading .ls-content { text-align: center; color: #e8e8ec; font-family: var(--font-family); }
.preview-loading .ls-spinner {
    width: 36px; height: 36px; margin: 0 auto 14px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #4f6bed; border-radius: 50%;
    animation: ls-spin 0.8s linear infinite;
}
@keyframes ls-spin { to { transform: rotate(360deg); } }
.preview-loading .ls-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.preview-loading .ls-subtitle { font-size: 12px; color: #a0a0a8; margin: 0; }

.preview-widget-label {
    position: relative; top: auto; left: auto;
    opacity: 1; transition: none;
}

.preview-contents-chip {
    position: relative; top: auto; left: auto;
    transform: none;
}

.preview-selection-stage {
    background: #1a1a1e; padding: 40px 20px; border-radius: 8px;
    display: flex; justify-content: space-around; flex-wrap: wrap; gap: 20px;
}

.ds-density-row {
    display: grid;
    grid-template-columns: 110px 80px 1fr;
    gap: 18px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px dashed var(--web-border);
}
.ds-density-row:last-child { border-bottom: 0; }

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 14px;
}
.chip-list span {
    font-size: 12px;
    background: var(--web-code-bg);
    padding: 4px 12px;
    border-radius: 9999px;
    color: var(--web-text-sub);
}

.ds-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin: 0 0 16px;
}
.ds-nav-card {
    appearance: none;
    text-align: left;
    background: var(--web-surface);
    border: 0;
    border-left: 3px solid var(--web-accent);
    border-radius: 14px;
    padding: 22px 22px 18px;
    cursor: pointer;
    color: inherit;
    font-family: inherit;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 1px 2px -1px rgba(0, 0, 0, 0.06),
        0 2px 4px rgba(0, 0, 0, 0.04);
    transition: box-shadow 180ms ease, transform 180ms ease;
    display: flex;
    flex-direction: column;
}
.ds-nav-card:hover {
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.08),
        0 4px 14px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}
.ds-nav-card:focus-visible {
    outline: 2px solid var(--web-accent);
    outline-offset: 2px;
}
.ds-nav-card .ds-nav-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 10px;
}
.ds-nav-card h3 {
    font-family: inherit;
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    color: var(--web-text);
    margin: 0 0 6px;
}
.ds-nav-card .ds-nav-desc {
    font-size: 12.5px;
    color: var(--web-text-sub);
    line-height: 1.55;
    margin: 0 0 14px;
    flex: 1;
}
.ds-nav-card .ds-nav-stats {
    font-size: 11px;
    color: var(--web-text-muted);
    margin: 0 0 8px;
}
.ds-nav-card .ds-nav-stats strong { color: var(--web-text-sub); font-weight: 600; }
.ds-nav-card .ds-nav-cta {
    font-size: 12px;
    font-weight: 600;
    color: var(--web-accent);
}
.ds-nav-card[data-accent="components"] { border-left-color: #00b8d4; }
.ds-nav-card[data-accent="components"] .ds-nav-tag,
.ds-nav-card[data-accent="components"] .ds-nav-cta { color: #008ba3; }
.ds-nav-card[data-accent="widgets"] { border-left-color: #f5a623; }
.ds-nav-card[data-accent="widgets"] .ds-nav-tag,
.ds-nav-card[data-accent="widgets"] .ds-nav-cta { color: #b46e00; }
.ds-nav-card[data-accent="atoms"] { border-left-color: #3080ff; }
.ds-nav-card[data-accent="atoms"] .ds-nav-tag,
.ds-nav-card[data-accent="atoms"] .ds-nav-cta { color: #1f5fb8; }
.ds-nav-card[data-accent="foundations"] { border-left-color: #9b59b6; }
.ds-nav-card[data-accent="foundations"] .ds-nav-tag,
.ds-nav-card[data-accent="foundations"] .ds-nav-cta { color: #6f3a85; }

.ds-back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--web-surface);
    color: var(--web-text-sub);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 200ms ease, transform 200ms ease, color 120ms ease, border-color 120ms ease;
}
.ds-back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.ds-back-to-top:hover {
    color: var(--web-text);
    border-color: rgba(0, 0, 0, 0.2);
}

.ds-stats-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 6px 14px;
    background: var(--web-surface);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 9999px;
    font-size: 12px;
    color: var(--web-text-sub);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 1px 2px rgba(0, 0, 0, 0.03);
}
.ds-stats-pill strong {
    color: var(--web-text);
    font-weight: 600;
}
.ds-stats-pill .ds-stats-sep {
    color: var(--web-border);
    user-select: none;
}

.ds-widgets-nav {
    background: var(--web-surface);
    border: 1px solid var(--web-border);
    border-radius: 12px;
    padding: 16px 20px;
    margin: 0 0 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.ds-widgets-nav-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--web-text-muted);
    margin: 0 0 12px;
}
.ds-widgets-nav-group {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 10px 14px;
    align-items: baseline;
    padding: 8px 0;
    border-top: 1px dashed var(--web-border);
}
.ds-widgets-nav-group:first-of-type { border-top: 0; padding-top: 0; }
.ds-widgets-nav-group:last-child { padding-bottom: 0; }
.ds-widgets-nav-group-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--web-text-muted);
}
.ds-widgets-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.ds-widgets-nav-link {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    background: var(--web-bg);
    border: 1px solid var(--web-border);
    color: var(--web-text-sub);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.ds-widgets-nav-link:hover {
    background: var(--web-accent);
    color: #fff;
    border-color: var(--web-accent);
}
.ds-tab-panel[data-panel="widgets"] .ds-section[id] {
    scroll-margin-top: 24px;
}

.ds-main:has(.ds-tab-panel[data-panel="screens"].is-active) {
    max-width: 1440px;
}

.ds-card--screen { max-width: 1360px; }

.screen-viewport {
    position: relative;
    width: min(1280px, 100%);
    aspect-ratio: 16 / 9;
    background: linear-gradient(180deg, #d8d4c4 0%, #c6c2b1 100%);
    border: 1px solid rgba(26, 26, 26, 0.18);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 16px;
    container-type: inline-size;
}

.screen-viewport .preview-time-control {
    max-width: calc(100cqw - 400px);
}
.screen-viewport::before {
    content: '3D LAB SCENE';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(26, 26, 26, 0.30);
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.10em;
    pointer-events: none;
}

.screen-chrome { position: absolute; z-index: 2; }
.screen-chrome--top { top: 20px; left: 50%; transform: translateX(-50%); }
.screen-chrome--bl  { bottom: 20px; left: 20px; display: flex; gap: 12px; align-items: center; }
.screen-chrome--br  { bottom: 20px; right: 20px; }
.screen-chrome--mr  { top: 148px; right: 20px; bottom: 92px; display: flex; flex-direction: column; justify-content: center; }
.ds-stage lab-pip-panel          { --pip-panel-width: 260px; }
.screen-chrome--mr lab-pip-panel { --pip-panel-width: 300px; }

.screen-chrome--bc  {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.preview-camera-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mock-beaker-row {
    position: absolute;
    left: 50%;
    bottom: 30%;
    transform: translateX(-50%);
    display: flex;
    gap: 64px;
    align-items: flex-end;
}
.mock-beaker {
    width: 72px;
    height: 92px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.mock-beaker__glass {
    width: 72px;
    height: 92px;
    border: 2px solid rgba(26, 26, 26, 0.45);
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: linear-gradient(180deg, transparent 0%, transparent 12%, rgba(73, 137, 199, 0.55) 12%, rgba(73, 137, 199, 0.72) 100%);
    box-shadow: inset -6px 0 12px rgba(26, 26, 26, 0.10);
}
.mock-beaker--empty .mock-beaker__glass {
    background: transparent;
}
.mock-beaker__chip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}
.mock-beaker__chip .contents-chip {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
}
.mock-beaker__state {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: rgba(26, 26, 26, 0.55);
    text-align: center;
    white-space: nowrap;
}

a.ds-nav-card { display: flex; flex-direction: column; text-decoration: none; }
.ds-nav-card .ds-nav-stats code { font-size: 10.5px; overflow-wrap: anywhere; }
.ds-nav-card[data-accent="patterns"] { border-left-color: #1f8f4e; }
.ds-nav-card[data-accent="patterns"] .ds-nav-tag,
.ds-nav-card[data-accent="patterns"] .ds-nav-cta { color: #177a40; }
.ds-main:has(.ds-tab-panel[data-panel="overview"].is-active) { max-width: 1440px; }
.ds-page-header .cat-meta { margin: 10px 0 14px; }

.screen-fit {
    position: relative;
    width: 100%;
    max-width: 1280px;
    aspect-ratio: 16 / 9;
    margin-top: 16px;
    overflow: hidden;
    border-radius: 10px;
}
.screen-fit > .screen-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    margin-top: 0;
    transform-origin: 0 0;
    transform: scale(var(--screen-scale, 1));
}
.screen-viewport--scene { background: #c6c2b1 url('assets/lab_scene_bg.webp') center / cover no-repeat; }
.screen-viewport--scene::before { content: none; }

@media (max-width: 760px) {
    .ds-shell { display: block; }
    .ds-main { padding: 28px 16px 80px; }
    .ds-page-header h1 { font-size: 1.6rem; }
    .ds-stats-pill { flex-wrap: wrap; border-radius: 14px; }
    .ds-card { padding: 18px 16px; overflow-x: auto; }
    .ds-card table { min-width: 560px; }
    .ds-back-to-top { bottom: 16px; right: 16px; }
}
