:root {
    --ink: #17202a;
    --muted: #737d88;
    --line: #e1e5e9;
    --panel: #ffffff;
    --accent: #ef5a2f;
    --accent-dark: #d94a24;
    --blue: #2867d6;
    --topbar-height: 60px;
    --sidebar-width: 292px;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

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

body {
    background: #eef0f2;
    color: var(--ink);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

.step-app {
    display: grid;
    grid-template: var(--topbar-height) minmax(0, 1fr) / var(--sidebar-width) minmax(0, 1fr);
    width: 100vw;
    height: 100dvh;
}

.topbar {
    z-index: 30;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) auto;
    align-items: center;
    min-width: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 1px 10px rgba(23, 31, 42, 0.05);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 100%;
    padding: 0 20px;
    border-right: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    position: relative;
    display: block;
    width: 27px;
    height: 27px;
    flex: 0 0 auto;
    transform: rotate(30deg);
}

.brand-mark i {
    position: absolute;
    display: block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent);
}

.brand-mark i:nth-child(1) {
    top: 0;
    left: 7px;
}

.brand-mark i:nth-child(2) {
    bottom: 0;
    left: 0;
}

.brand-mark i:nth-child(3) {
    right: 0;
    bottom: 0;
}

.brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.05;
}

.brand-copy b {
    font-size: 14px;
    letter-spacing: 0.08em;
}

.brand-copy small {
    margin-top: 4px;
    color: #8a929c;
    font-size: 9px;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    margin-left: 20px;
    color: #69727e;
    font-size: 12px;
    white-space: nowrap;
}

.status span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #3bb273;
    box-shadow: 0 0 0 3px rgba(59, 178, 115, 0.12);
}

.status.is-loading .status-dot {
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(239, 90, 47, 0.12);
    animation: pulse 1s ease-in-out infinite;
}

.status.is-error .status-dot {
    background: #d64545;
    box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.12);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 14px;
}

.open-button {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    box-shadow: 0 5px 14px rgba(239, 90, 47, 0.22);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: 160ms ease;
}

.open-button:hover {
    transform: translateY(-1px);
    background: var(--accent-dark);
}

.open-button:active {
    transform: translateY(0);
}

.open-button > span:first-child {
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
}

.icon-button {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid #d9dde2;
    border-radius: 8px;
    background: #fff;
    color: #626c77;
    cursor: pointer;
}

.icon-button span {
    display: grid;
    width: 18px;
    height: 18px;
    margin: auto;
    place-items: center;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    font-family: Georgia, serif;
    font-size: 12px;
    font-weight: 700;
}

.sidebar {
    z-index: 20;
    display: flex;
    min-height: 0;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: var(--panel);
}

.sidebar-section {
    padding: 19px 20px;
    border-bottom: 1px solid var(--line);
}

.file-summary {
    padding-top: 21px;
    padding-bottom: 18px;
}

.eyebrow,
.section-title {
    margin: 0 0 10px;
    color: #8a929c;
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.file-summary h1 {
    max-width: 100%;
    margin: 0 0 6px;
    overflow: hidden;
    font-size: 13px;
    font-weight: 680;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    margin: 0;
    color: #949ba4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 9px;
}

.properties {
    display: grid;
    gap: 12px;
    margin: 0;
}

.properties div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 10px;
}

.properties dt {
    color: #858d97;
}

.properties dd {
    margin: 0;
    color: #3b444e;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 9px;
    text-align: right;
}

.parts-section {
    min-height: 0;
    flex: 1;
    padding-right: 9px;
    overflow: hidden;
}

.section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 11px;
}

.count-badge {
    display: grid;
    min-width: 21px;
    height: 17px;
    padding: 0 5px;
    place-items: center;
    border-radius: 9px;
    background: #eef1f4;
    color: #737c87;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 8px;
}

.tree {
    height: calc(100% - 21px);
    padding-right: 7px;
    overflow-y: auto;
    scrollbar-color: #ced3d9 transparent;
    scrollbar-width: thin;
}

.tree-root,
.tree-item {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 29px;
    border-radius: 5px;
    color: #414a54;
    font-size: 10px;
}

.tree-root {
    gap: 7px;
    font-weight: 650;
}

.tree-item {
    position: relative;
    gap: 8px;
    padding-left: 31px;
    color: #6f7883;
}

.tree-item > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-item:hover {
    background: #f5f6f7;
    color: #323b45;
}

.tree-empty,
.tree-more {
    padding: 8px 4px;
    color: #9aa1a9;
    font-size: 10px;
    line-height: 1.5;
}

.tree-more {
    padding-left: 31px;
}

.chevron {
    width: 9px;
    color: #8a929b;
    text-align: center;
}

.cube-icon {
    width: 12px;
    height: 12px;
    border: 1px solid #74818d;
    transform: rotate(30deg) skew(-4deg, -4deg);
}

.part-dot {
    width: 6px;
    height: 6px;
    flex: 0 0 auto;
    border: 1px solid #a5acb5;
    border-radius: 1px;
    background: #f4f5f6;
}

.tree-line {
    position: absolute;
    left: 15px;
    width: 10px;
    height: 1px;
    background: #e1e4e8;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 20px;
    border-top: 1px solid var(--line);
    color: #8a929c;
    font-size: 9px;
    line-height: 1.3;
}

.lock {
    position: relative;
    display: block;
    width: 10px;
    height: 8px;
    flex: 0 0 auto;
    border: 1px solid #9ca4ad;
    border-radius: 2px;
}

.lock::before {
    position: absolute;
    bottom: 6px;
    left: 2px;
    width: 4px;
    height: 4px;
    border: 1px solid #9ca4ad;
    border-bottom: 0;
    border-radius: 4px 4px 0 0;
    content: "";
}

.viewer {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.62), transparent 46%),
        #eef0f2;
}

.viewport {
    position: absolute;
    inset: 0;
    touch-action: none;
}

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

.viewer.measure-mode .viewport canvas {
    cursor: crosshair;
}

.measurement-labels {
    position: absolute;
    z-index: 6;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.measurement-label {
    position: absolute;
    display: block;
    padding: 5px 8px;
    transform: translate(-50%, calc(-50% - 12px));
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 6px;
    background: rgba(32, 39, 47, 0.9);
    box-shadow: 0 3px 12px rgba(20, 27, 34, 0.2);
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.measurement-label[hidden],
.view-toolbar button[hidden] {
    display: none;
}

.view-toolbar {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 3px;
    height: 38px;
    padding: 3px;
    border: 1px solid rgba(200, 205, 211, 0.9);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 5px 18px rgba(36, 45, 55, 0.09);
    backdrop-filter: blur(10px);
}

.view-toolbar button {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #626c77;
    cursor: pointer;
}

.view-toolbar button:hover,
.view-toolbar button.active {
    background: #edf1f4;
    color: var(--accent);
}

.toolbar-divider {
    width: 1px;
    height: 18px;
    background: #e0e4e8;
}

.fit-icon {
    position: relative;
    display: block;
    width: 14px;
    height: 14px;
}

.fit-icon::before,
.fit-icon::after {
    position: absolute;
    inset: 0;
    border: solid currentColor;
    content: "";
}

.fit-icon::before {
    border-width: 1.5px 0 0 1.5px;
    clip-path: polygon(0 0, 45% 0, 45% 14%, 14% 14%, 14% 45%, 0 45%);
}

.fit-icon::after {
    border-width: 0 1.5px 1.5px 0;
    clip-path: polygon(55% 55%, 100% 55%, 100% 100%, 55% 100%, 55% 86%, 86% 86%, 86% 55%);
}

.edges-icon {
    display: block;
    width: 14px;
    height: 14px;
    border: 1px solid currentColor;
    transform: rotate(30deg) skew(-5deg, -5deg);
}

.ruler-icon {
    position: relative;
    display: block;
    width: 17px;
    height: 7px;
    border: 1.5px solid currentColor;
    transform: rotate(-35deg);
}

.ruler-icon::before {
    position: absolute;
    top: -1px;
    left: 3px;
    width: 1px;
    height: 3px;
    background: currentColor;
    box-shadow: 4px 0 currentColor, 8px 0 currentColor;
    content: "";
}

.clear-icon {
    position: relative;
    display: block;
    width: 14px;
    height: 14px;
}

.clear-icon::before,
.clear-icon::after {
    position: absolute;
    top: 6px;
    left: 1px;
    width: 12px;
    height: 1.5px;
    background: currentColor;
    content: "";
}

.clear-icon::before {
    transform: rotate(45deg);
}

.clear-icon::after {
    transform: rotate(-45deg);
}

.controls-hint {
    position: absolute;
    right: 18px;
    bottom: 17px;
    display: flex;
    gap: 17px;
    color: #7c858f;
    font-size: 9px;
}

.controls-hint span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mouse {
    position: relative;
    display: inline-block;
    width: 10px;
    height: 14px;
    border: 1px solid #8f98a2;
    border-radius: 5px;
}

.mouse::after {
    position: absolute;
    top: 1px;
    left: 4px;
    width: 1px;
    height: 4px;
    background: #8f98a2;
    content: "";
}

.mouse.left::before,
.mouse.right::before {
    position: absolute;
    top: 0;
    width: 4px;
    height: 5px;
    background: rgba(239, 90, 47, 0.55);
    content: "";
}

.mouse.left::before {
    left: 0;
    border-radius: 5px 0 0;
}

.mouse.right::before {
    right: 0;
    border-radius: 0 5px 0 0;
}

.loading-card,
.error-card {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    width: min(350px, calc(100% - 40px));
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(211, 216, 221, 0.9);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 16px 45px rgba(30, 39, 49, 0.14);
    backdrop-filter: blur(12px);
}

.loading-card[hidden],
.error-card[hidden] {
    display: none;
}

.loading-card > div {
    min-width: 0;
    flex: 1;
}

.loading-card strong,
.error-card strong {
    display: block;
    margin-bottom: 9px;
    font-size: 12px;
}

.loader-cube {
    display: block;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border: 2px solid var(--accent);
    animation: cube-spin 1.8s ease-in-out infinite;
}

.progress-track {
    height: 3px;
    overflow: hidden;
    border-radius: 2px;
    background: #e9ecef;
}

.progress-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 280ms ease;
}

.error-card {
    display: block;
    text-align: center;
}

.error-card p {
    margin: 0 0 14px;
    color: #737d88;
    font-size: 11px;
    line-height: 1.5;
}

.error-card button {
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.drop-overlay {
    position: absolute;
    z-index: 15;
    inset: 15px;
    display: grid;
    visibility: hidden;
    place-items: center;
    border: 2px dashed rgba(239, 90, 47, 0.72);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.91);
    opacity: 0;
    pointer-events: none;
    transition: 140ms ease;
    backdrop-filter: blur(11px);
}

.drop-overlay.visible {
    visibility: visible;
    opacity: 1;
}

.drop-overlay > div {
    text-align: center;
}

.drop-icon {
    display: grid;
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    place-items: center;
    border-radius: 50%;
    background: rgba(239, 90, 47, 0.1);
    color: var(--accent);
    font-size: 24px;
}

.drop-overlay strong {
    display: block;
    font-size: 15px;
}

.drop-overlay p {
    margin: 7px 0 0;
    color: #7b858f;
    font-size: 11px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

noscript {
    display: block;
    padding: 40px;
    text-align: center;
}

@keyframes pulse {
    50% {
        opacity: 0.45;
        transform: scale(0.82);
    }
}

@keyframes cube-spin {
    0%,
    100% {
        transform: rotate(0) scale(0.85);
        border-radius: 3px;
    }
    50% {
        transform: rotate(135deg) scale(1);
        border-radius: 8px;
    }
}

@media (max-width: 760px) {
    :root {
        --topbar-height: 56px;
    }

    .step-app {
        display: grid;
        grid-template: var(--topbar-height) minmax(0, 1fr) / minmax(0, 1fr);
    }

    .topbar {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .brand {
        padding: 0 14px;
        border-right: 0;
    }

    .brand-mark {
        width: 24px;
        height: 24px;
    }

    .brand-mark i {
        width: 12px;
        height: 12px;
    }

    .brand-copy small,
    .status {
        display: none;
    }

    .top-actions {
        margin-right: 8px;
    }

    .icon-button {
        display: block;
    }

    .open-button {
        width: 38px;
        padding: 0;
        justify-content: center;
    }

    .open-button > span:last-child {
        display: none;
    }

    .sidebar {
        position: fixed;
        z-index: 25;
        top: var(--topbar-height);
        bottom: 0;
        left: 0;
        width: min(292px, calc(100vw - 54px));
        transform: translateX(-102%);
        box-shadow: 18px 0 45px rgba(21, 29, 38, 0.18);
        transition: transform 200ms ease;
    }

    .step-app.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .step-app.sidebar-open::after {
        position: fixed;
        z-index: 21;
        inset: var(--topbar-height) 0 0;
        background: rgba(23, 31, 40, 0.25);
        content: "";
    }

    .viewer {
        grid-row: 2;
    }

    .view-toolbar {
        top: 12px;
        right: 12px;
    }

    .controls-hint {
        right: auto;
        bottom: 12px;
        left: 50%;
        gap: 11px;
        transform: translateX(-50%);
        white-space: nowrap;
    }

    .controls-hint span {
        gap: 4px;
    }
}

@media (max-width: 430px) {
    .controls-hint span {
        font-size: 0;
    }

    .controls-hint .mouse {
        width: 12px;
        height: 16px;
    }
}

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