:root {
    --bg: #f3f1ec;
    --panel: #ffffff;
    --ink: #1c1d1f;
    --muted: #6d6b66;
    --line: #e2ded6;
    --accent: #b4532e;
    --accent-ink: #ffffff;
    --shadow: 0 10px 30px rgba(28, 29, 31, 0.12);
    --radius: 10px;
    --bar: 60px;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    display: flex;
    flex-direction: column;
}

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

.bar {
    height: var(--bar);
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mark {
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.03em;
}

.logo {
    display: block;
    height: 32px;
    max-width: 160px;
    object-fit: contain;
}

.credit a {
    color: inherit;
}

.divider {
    width: 1px;
    height: 22px;
    background: var(--line);
}

.product {
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

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

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    opacity: 0;
}

.track {
    width: 34px;
    height: 20px;
    border-radius: 10px;
    background: var(--line);
    position: relative;
    transition: background 0.15s;
}

.track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s;
}

.toggle input:checked + .track {
    background: var(--accent);
}

.toggle input:checked + .track::after {
    transform: translateX(14px);
}

.toggle input:focus-visible + .track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.view {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.view select {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 8px;
    background: var(--panel);
}

.ghost, .solid {
    border-radius: 6px;
    padding: 7px 14px;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--panel);
}

.solid {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.studio {
    flex: 1;
    min-height: 0;
    display: flex;
    position: relative;
}

.stage {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    overflow: auto;
}

.frame {
    flex: none;
    position: relative;
    width: min(100%, calc((100dvh - var(--bar) - 150px) * 1.6));
    aspect-ratio: 16 / 10;
    border-radius: var(--radius);
    overflow: hidden;
    background: #ddd8cf;
    box-shadow: var(--shadow);
    touch-action: none;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hotspots {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hotspot {
    position: absolute;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s, background 0.15s;
}

.hotspot::after {
    content: "";
    position: absolute;
    inset: 7px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.95);
}

.hotspot:hover, .hotspot:focus-visible, .hotspot.active {
    transform: scale(1.18);
    background: rgba(180, 83, 46, 0.55);
    outline: none;
}

.studio.comparing .hotspot, .studio.debug .hotspot {
    display: none;
}

.hint {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    background: rgba(28, 29, 31, 0.72);
    color: #fff;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}

.hint[hidden] {
    display: none;
}

.tooltip {
    position: absolute;
    transform: translate(-50%, calc(-100% - 14px));
    background: var(--ink);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}

.tooltip small {
    display: block;
    color: #c9c6bf;
}

.compare-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
    cursor: ew-resize;
}

.compare-line .knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow);
}

.compare-line .knob::before {
    content: "‹ ›";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: var(--ink);
}

.compare-line .tag {
    position: absolute;
    top: 14px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(28, 29, 31, 0.72);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
}

.compare-line .left {
    right: 12px;
}

.compare-line .right {
    left: 12px;
}

.loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #ece8e0;
    color: var(--muted);
}

.loading.done {
    display: none;
}

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

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

.spec {
    width: min(100%, calc((100dvh - var(--bar) - 150px) * 1.6));
}

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

.spec h2 {
    margin: 0 0 8px;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}

.spec ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
}

.spec button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    cursor: pointer;
}

.spec button:hover, .spec button.active {
    border-color: var(--accent);
}

.spec img {
    width: 38px;
    height: 38px;
    border-radius: 5px;
    object-fit: cover;
    flex: none;
}

.spec .what {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

.spec .which {
    display: block;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer {
    width: 400px;
    flex: none;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-left: 1px solid var(--line);
    min-height: 0;
}

.drawer[hidden] {
    display: none;
}

.drawer header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 18px 20px 10px;
}

.eyebrow {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
}

.drawer h2 {
    margin: 2px 0 0;
    font-size: 20px;
}

.close {
    border: 0;
    background: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
}

.filters {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filters input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chips button {
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.chips button[aria-pressed="true"] {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.drawer-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px 6px;
    font-size: 12px;
    color: var(--muted);
}

.link {
    border: 0;
    background: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
}

.grid {
    list-style: none;
    margin: 0;
    padding: 6px 20px 24px;
    overflow: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 12px;
    align-content: start;
}

.card {
    width: 100%;
    border: 0;
    padding: 0;
    background: none;
    text-align: left;
    cursor: pointer;
}

.card .swatch {
    position: relative;
    display: block;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    background: var(--line);
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition: outline-color 0.12s;
}

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

.card:hover .swatch, .card:focus-visible .swatch {
    outline-color: var(--line);
}

.card.applied .swatch {
    outline-color: var(--accent);
}

.badge {
    position: absolute;
    left: 8px;
    top: 8px;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    font-size: 11px;
    font-weight: 600;
}

.card.loading-texture .swatch::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.5);
}

.card .name {
    display: block;
    margin-top: 6px;
    font-weight: 600;
    font-size: 13px;
}

.card .meta {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

@media (max-width: 860px) {
    .bar {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 16px;
    }

    .view span, .product {
        display: none;
    }

    .actions {
        flex-wrap: wrap;
        gap: 10px;
        min-width: 0;
    }

    .view select {
        max-width: 100%;
    }

    .stage {
        padding: 12px 16px;
    }

    .frame, .spec {
        width: 100%;
    }

    .drawer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-height: 62dvh;
        border-left: 0;
        border-top: 1px solid var(--line);
        border-radius: 14px 14px 0 0;
        box-shadow: var(--shadow);
        z-index: 5;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}
