/* ====== Reset & base ====== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
}

/* ====== Header ====== */
.v3d-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .7rem 1.2rem;
    background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid #334155;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.v3d-header-left, .v3d-header-right {
    display: flex; align-items: center; gap: .8rem;
}
.v3d-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex; align-items: center; gap: .5rem;
    color: #f1f5f9;
}
.v3d-header h1 i { width: 22px; height: 22px; color: #a78bfa; }
.v3d-back {
    color: #94a3b8;
    background: #1e293b;
    border-radius: 8px;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    transition: background .2s;
}
.v3d-back:hover { background: #334155; color: #f1f5f9; }
.v3d-back i { width: 18px; height: 18px; }

.v3d-select {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    padding: .5rem .8rem;
    border-radius: 8px;
    font-size: .88rem;
    cursor: pointer;
    min-width: 220px;
}
.v3d-select:hover { border-color: #475569; }

.v3d-upload-btn {
    background: #7c3aed;
    color: white;
    padding: .55rem 1rem;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 600;
    display: flex; align-items: center; gap: .4rem;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.v3d-upload-btn:hover { background: #6d28d9; transform: translateY(-1px); }
.v3d-upload-btn i { width: 16px; height: 16px; }

.v3d-link {
    color: #94a3b8;
    text-decoration: none;
    font-size: .88rem;
    padding: .5rem .8rem;
    border-radius: 6px;
    transition: background .2s;
}
.v3d-link:hover { background: #1e293b; color: #f1f5f9; }

/* ====== Main layout ====== */
.v3d-main {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    overflow: hidden;
}

/* ====== Sidebars ====== */
.v3d-sidebar, .v3d-details {
    background: #1e293b;
    border-right: 1px solid #334155;
    overflow-y: auto;
    padding: 1rem;
}
.v3d-details {
    border-right: none;
    border-left: 1px solid #334155;
}

.v3d-section { margin-bottom: 1.5rem; }
.v3d-section h3 {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    display: flex; align-items: center; gap: .4rem;
    margin-bottom: .6rem;
}
.v3d-section h3 i { width: 14px; height: 14px; }

.v3d-input {
    width: 100%;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
    padding: .55rem .7rem;
    border-radius: 8px;
    font-size: .88rem;
    transition: border-color .2s;
}
.v3d-input:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167,139,250,.2);
}

.v3d-search-results {
    list-style: none;
    margin-top: .5rem;
    max-height: 220px;
    overflow-y: auto;
}
.v3d-search-results li {
    padding: .5rem .7rem;
    border-radius: 6px;
    font-size: .82rem;
    cursor: pointer;
    color: #cbd5e1;
    transition: background .15s;
    border: 1px solid transparent;
}
.v3d-search-results li:hover {
    background: #334155;
    border-color: #475569;
}
.v3d-search-results li .v3d-mini-id {
    display: block;
    font-size: .72rem;
    color: #94a3b8;
    font-family: monospace;
    margin-top: .15rem;
}

.v3d-chip-row {
    display: flex; flex-wrap: wrap; gap: .35rem;
}
.v3d-chip {
    background: #0f172a;
    color: #cbd5e1;
    border: 1px solid #334155;
    padding: .4rem .8rem;
    border-radius: 999px;
    font-size: .8rem;
    cursor: pointer;
    transition: all .15s;
}
.v3d-chip:hover { background: #334155; }
.v3d-chip.active {
    background: #a78bfa;
    color: #0f172a;
    border-color: #a78bfa;
    font-weight: 600;
}

.v3d-toggle {
    display: flex; align-items: center; gap: .5rem;
    cursor: pointer;
    font-size: .85rem;
    color: #cbd5e1;
    margin-bottom: .7rem;
}
.v3d-toggle input { width: 16px; height: 16px; accent-color: #a78bfa; }

.v3d-legend {
    list-style: none;
    display: flex; flex-direction: column; gap: .35rem;
}
.v3d-legend li {
    display: flex; align-items: center; gap: .5rem;
    font-size: .8rem; color: #cbd5e1;
}
.v3d-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,.1);
}

/* ====== Canvas zone ====== */
.v3d-canvas-wrap {
    position: relative;
    background: radial-gradient(ellipse at center, #1e293b 0%, #0f172a 100%);
    overflow: hidden;
}
#threeCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}
#threeCanvas:active { cursor: grabbing; }

.v3d-overlay {
    position: absolute; inset: 0;
    background: rgba(15,23,42,.85);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 5;
    backdrop-filter: blur(4px);
}
.v3d-overlay.hidden { display: none; }
.v3d-spinner {
    width: 40px; height: 40px;
    border: 3px solid #334155;
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadingText { color: #cbd5e1; font-size: .9rem; }

.v3d-empty {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    color: #64748b;
    pointer-events: none;
}
.v3d-empty i { width: 64px; height: 64px; margin-bottom: 1rem; color: #475569; }
.v3d-empty h2 { font-size: 1.3rem; color: #94a3b8; margin-bottom: .5rem; }
.v3d-empty p { font-size: .88rem; max-width: 320px; line-height: 1.5; }
.v3d-empty.hidden { display: none; }

.v3d-toolbar {
    position: absolute;
    bottom: 1rem; left: 50%;
    transform: translateX(-50%);
    background: rgba(30,41,59,.95);
    backdrop-filter: blur(8px);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: .4rem;
    display: flex; align-items: center; gap: .3rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.v3d-toolbar button {
    background: transparent;
    color: #cbd5e1;
    border: none;
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.v3d-toolbar button:hover { background: #475569; color: #f1f5f9; }
.v3d-toolbar button.active { background: #a78bfa; color: #0f172a; }
.v3d-toolbar button i { width: 18px; height: 18px; }
.v3d-model-info {
    font-size: .78rem;
    color: #94a3b8;
    padding: 0 .8rem;
    border-left: 1px solid #334155;
    margin-left: .3rem;
}

/* ====== Details panel ====== */
.v3d-details-empty {
    text-align: center;
    color: #64748b;
    padding: 3rem 1rem;
}
.v3d-details-empty i { width: 48px; height: 48px; color: #475569; margin-bottom: 1rem; }
.v3d-details-empty p { font-size: .85rem; line-height: 1.5; }

.v3d-detail-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: .8rem;
}
.v3d-detail-title {
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: .3rem;
    word-break: break-word;
}
.v3d-detail-subtitle {
    font-size: .78rem;
    color: #94a3b8;
    font-family: monospace;
    margin-bottom: .8rem;
}

.v3d-detail-row {
    display: flex;
    justify-content: space-between;
    padding: .4rem 0;
    border-bottom: 1px solid #1e293b;
    font-size: .82rem;
}
.v3d-detail-row:last-child { border-bottom: none; }
.v3d-detail-row .v3d-key { color: #94a3b8; }
.v3d-detail-row .v3d-val {
    color: #e2e8f0;
    font-weight: 500;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.v3d-status-badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ====== Responsive ====== */
@media (max-width: 1024px) {
    .v3d-main { grid-template-columns: 240px 1fr 280px; }
}
@media (max-width: 768px) {
    .v3d-main { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
    .v3d-sidebar, .v3d-details { max-height: 200px; }
}
