* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: #0b1020;
}

body {
    margin: 0;
    min-height: 100vh;
    color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 15% 10%, rgba(59, 130, 246, .32), transparent 30rem),
        radial-gradient(circle at 90% 0%, rgba(168, 85, 247, .24), transparent 26rem),
        linear-gradient(145deg, #090d19 0%, #111827 52%, #182235 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

.model-shell {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top)) 16px 34px;
}

.model-index-shell {
    display: grid;
    gap: 18px;
}

.hero-panel,
.model-card,
.empty-card {
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 28px;
    background: rgba(15, 23, 42, .72);
    box-shadow: 0 24px 80px rgba(2, 6, 23, .36);
    backdrop-filter: blur(18px);
}

.hero-panel {
    min-height: 42vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 28px;
    overflow: hidden;
    position: relative;
}

.hero-panel::after {
    content: "";
    position: absolute;
    inset: 22px 22px auto auto;
    width: 94px;
    height: 94px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, .16);
    background: linear-gradient(135deg, rgba(96, 165, 250, .3), rgba(244, 114, 182, .18));
    transform: rotate(12deg);
}

.eyebrow {
    margin: 0 0 12px;
    color: #93c5fd;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.hero-panel h1 {
    margin: 0;
    font-size: clamp(36px, 10vw, 72px);
    line-height: .95;
    letter-spacing: -.08em;
}

.hero-copy {
    max-width: 660px;
    margin: 18px 0 0;
    color: #cbd5e1;
    font-size: 15px;
    line-height: 1.8;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-top: 24px;
}

.primary-action,
.card-action,
.back-link,
.viewer-toolbar button {
    border: 0;
    border-radius: 999px;
    color: #06111f;
    background: linear-gradient(135deg, #e0f2fe, #93c5fd);
    font-weight: 800;
    box-shadow: 0 14px 34px rgba(59, 130, 246, .28);
}

.primary-action,
.card-action {
    display: inline-flex;
    justify-content: center;
    padding: 13px 18px;
}

.card-actions {
    display: grid;
    gap: 10px;
}

.card-action.secondary {
    color: #dbeafe;
    border: 1px solid rgba(147, 197, 253, .28);
    background: rgba(30, 41, 59, .78);
    box-shadow: none;
}

.hint-pill,
.status-badge,
.format-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
}

.hint-pill {
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, .2);
    background: rgba(15, 23, 42, .56);
}

.model-list {
    display: grid;
    gap: 14px;
}

.model-card {
    display: grid;
    gap: 18px;
    padding: 18px;
}

.model-card-topline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.model-card h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -.04em;
}

.file-name {
    margin: 8px 0 0;
    color: #94a3b8;
    word-break: break-all;
}

.model-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: #cbd5e1;
    font-size: 13px;
}

.model-meta span {
    border-radius: 12px;
    padding: 8px 10px;
    background: rgba(30, 41, 59, .72);
}

.format-badge {
    color: #dbeafe;
    background: rgba(37, 99, 235, .28);
}

.format-step,
.format-stp {
    color: #fde68a;
    background: rgba(217, 119, 6, .24);
}

.format-igs,
.format-iges {
    color: #c4b5fd;
    background: rgba(124, 58, 237, .28);
}

.format-sldprt {
    color: #fecdd3;
    background: rgba(225, 29, 72, .24);
}

.status-badge.ready {
    color: #bbf7d0;
    background: rgba(22, 163, 74, .22);
}

.status-badge.direct {
    color: #bae6fd;
    background: rgba(2, 132, 199, .22);
}

.status-badge.pending {
    color: #fed7aa;
    background: rgba(234, 88, 12, .2);
}

.empty-card {
    padding: 28px;
}

.viewer-body {
    height: 100vh;
    overflow: hidden;
}

.viewer-page {
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    gap: 10px;
}

.viewer-header,
.viewer-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 22px;
    padding: 12px;
    background: rgba(15, 23, 42, .72);
    backdrop-filter: blur(18px);
}

.viewer-header {
    justify-content: space-between;
}

.back-link,
.viewer-toolbar button {
    flex: 0 0 auto;
    padding: 10px 14px;
    cursor: pointer;
}

.viewer-title-block {
    min-width: 0;
    text-align: right;
}

.viewer-title-block h1 {
    margin: 7px 0 2px;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-title-block p {
    margin: 0;
    color: #94a3b8;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-stage {
    position: relative;
    min-height: 0;
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 26px;
    overflow: hidden;
    background: radial-gradient(circle at 50% 20%, rgba(59, 130, 246, .16), rgba(2, 6, 23, .94) 62%);
}

#model-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.viewer-overlay,
.viewer-message {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    padding: 24px;
    text-align: center;
    background: rgba(2, 6, 23, .55);
}

.viewer-overlay.visible,
.viewer-message:not([hidden]) {
    display: grid;
}

.spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 12px;
    border-radius: 50%;
    border: 4px solid rgba(147, 197, 253, .22);
    border-top-color: #93c5fd;
    animation: spin 1s linear infinite;
}

.viewer-message {
    color: #fee2e2;
    line-height: 1.7;
}

.viewer-toolbar {
    justify-content: space-between;
    color: #cbd5e1;
    font-size: 12px;
}

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

@media (min-width: 720px) {
    .model-shell {
        padding-top: 34px;
    }

    .model-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-panel {
        min-height: 360px;
        padding: 46px;
    }

    .viewer-page {
        padding: 18px;
        gap: 14px;
    }

    .viewer-title-block h1 {
        font-size: 22px;
    }
}

@media (min-width: 1024px) {
    .model-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .viewer-page {
        width: min(1280px, 100%);
        margin: 0 auto;
    }
}
