/* ========================================
   LIVER.TR — Liver Anatomy Studio
   Inspired by Cell Architecture Studio
   ======================================== */

:root {
    --bg: #0d1117;
    --shell: #0a1220f0;
    --card: #0c1a28e6;
    --card-strong: #0e2030f5;
    --border: #e7434342;
    --border-subtle: #ffffff12;
    --text: #f5f0f0;
    --muted: #bfc0c8;
    --red: #e74c3c;
    --red-glow: #e74c3c40;
    --crimson: #dc143c;
    --dark-red: #8B0000;
    --blue: #3498db;
    --purple: #9b59b6;
    --green: #27ae60;
    --orange: #e67e22;
    --teal: #1abc9c;
    --lobes: #e74c3c;
    --vessels: #3498db;
    --bile: #27ae60;
    --cells: #e67e22;
    --pathology: #9b59b6;
    --ink: #1a1520;
    --control: #0a1220e6;
    --shadow: 0 24px 70px #0000006b;
    --soft-shadow: 0 16px 42px #00000061;
    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'Cascadia Mono', 'SFMono-Regular', 'Consolas', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body, #root { min-height: 100%; }

body {
    color: var(--text);
    background:
        radial-gradient(circle at top left, #e74c3c18, transparent 28rem),
        radial-gradient(circle at bottom right, #dc143c12, transparent 30rem),
        var(--bg);
    margin: 0;
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { text-decoration: none; color: inherit; }

/* ===== APP SHELL ===== */
.app-shell {
    width: min(1560px, 100vw - 28px);
    min-height: calc(100vh - 28px);
    box-shadow: var(--shadow), inset 0 1px 0 #ffffff24;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    background: linear-gradient(145deg, #0a1220fa, #0d1a28f0);
    border: 1px solid #e7434330;
    border-radius: 30px;
    margin: 14px auto;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.app-shell::before {
    content: "";
    pointer-events: none;
    opacity: .12;
    background-image: radial-gradient(#e74c3c18 1px, transparent 1px);
    background-size: 26px 26px;
    position: absolute;
    inset: 0;
}

.header, .studio-grid, .app-footer, .toast,
.bottom-panel { z-index: 1; position: relative; }

/* ===== HEADER ===== */
.header {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: linear-gradient(135deg, #12202ef0, #0c1820e6);
    border: 1px solid #e7434335;
    border-radius: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    height: 74px;
    padding: 10px 16px 14px;
    box-shadow: 0 16px 38px #00000052;
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 280px;
}

.brand-logo {
    background: linear-gradient(#0d1117, #0d1117) padding-box,
                conic-gradient(from var(--brand-angle, 0deg), var(--red), var(--blue), var(--purple), var(--red)) border-box;
    width: 42px;
    height: 42px;
    color: var(--red);
    border: 2px solid transparent;
    border-radius: 50%;
    display: grid;
    place-items: center;
    animation: 5s linear infinite brandSpin;
    box-shadow: 0 0 24px #e74c3c2e, inset 0 1px #ffffff47;
}

@property --brand-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

@keyframes brandSpin { to { --brand-angle: 360deg; } }

.brand h1 {
    color: #fff;
    text-shadow: 0 0 24px #e74c3c1f;
    margin: 0;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(1.35rem, 2vw, 1.9rem);
    font-style: italic;
    line-height: 1;
}

.accent-dot { color: var(--red); }

.brand p {
    color: #bfc4ca;
    margin: 4px 0 0;
    font-size: .82rem;
}

/* Top Nav */
.top-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-nav a, .nav-btn {
    color: #e8f0f2;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    font-size: .88rem;
    text-decoration: none;
    transition: all .2s;
}

.top-nav a:hover, .nav-btn:hover {
    border-color: var(--border);
    background: #ffffff1f;
}

.top-nav a.active, .nav-btn.active {
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.3);
    color: #ffcbc4;
}

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

.lang-toggle {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-subtle);
    color: var(--muted);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    letter-spacing: .5px;
}

.lang-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}

.profile-button {
    background: linear-gradient(#0d1117, #0d1117) padding-box,
                conic-gradient(from var(--brand-angle, 0deg), var(--red), var(--blue), var(--purple), var(--red)) border-box;
    width: 42px;
    height: 42px;
    color: var(--muted);
    border: 2px solid transparent;
    border-radius: 50%;
    display: grid;
    place-items: center;
    animation: 5s linear infinite brandSpin;
    box-shadow: 0 0 24px #e74c3c1e, inset 0 1px #ffffff30;
    transition: all .2s;
}

.profile-button:hover {
    border-color: var(--border);
    background: #ffffff1f;
    color: var(--text);
}

/* ===== STUDIO GRID ===== */
.studio-grid {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr) 380px;
    gap: 16px;
    padding-top: 16px;
}

/* ===== SIDEBAR ===== */
.sidebar, .viewer-card, .detail-card, .bottom-panel {
    border: 1px solid var(--border);
    box-shadow: var(--soft-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text);
    background: linear-gradient(145deg, #101e2cf0, #0a1620e6);
}

.sidebar {
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-self: start;
    min-height: 0;
    max-height: calc(100vh - 126px);
    padding: 16px;
    position: sticky;
    top: 16px;
}

.sidebar-top { flex: none; }

.section-heading {
    color: var(--red);
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: .7rem;
    font-weight: 800;
}

.search-box {
    border: 1px solid var(--border);
    color: #dbe0e8;
    background: #ffffff0f;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding: 10px 12px;
    transition: box-shadow .2s, border-color .2s;
}

.search-box:focus-within {
    border-color: #e74c3ca6;
    box-shadow: 0 0 0 3px #e74c3c22;
}

.search-box input {
    color: #f4f6ff;
    background: transparent;
    border: 0;
    outline: 0;
    width: 100%;
    font-size: .88rem;
}

.search-box input::placeholder { color: #8090a0; }

/* Filter Chips */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 13px 0 15px;
}

.chip {
    border: 1px solid var(--border);
    color: #edf0f2;
    background: #ffffff14;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 10px;
    font-size: .78rem;
    transition: all .2s;
}

.chip:hover { background: #ffffff22; }

.chip.active {
    background: var(--chip-color, var(--red));
    color: #071510;
    border-color: var(--chip-color, var(--red));
    font-weight: 900;
}

.filter-all { --chip-color: var(--red); }
.filter-lobes { --chip-color: var(--lobes); }
.filter-vessels { --chip-color: var(--vessels); }
.filter-bile { --chip-color: var(--bile); }
.filter-cells { --chip-color: var(--cells); }
.filter-pathology { --chip-color: var(--pathology); }

/* Object List */
.object-scroll {
    scrollbar-width: thin;
    scrollbar-color: #e74c3c85 #e74c3c1f;
    flex: auto;
    min-height: 0;
    padding: 4px 4px 2px 0;
    overflow-y: auto;
}

.object-scroll::-webkit-scrollbar { width: 8px; }
.object-scroll::-webkit-scrollbar-track { background: #e74c3c1f; border-radius: 999px; }
.object-scroll::-webkit-scrollbar-thumb { background: linear-gradient(#e74c3ca3, #3498db94); border-radius: 999px; }

.object-list { display: grid; gap: 9px; }

.object-section { display: grid; gap: 9px; }
.object-section + .object-section { margin-top: 16px; }

.object-section-heading {
    z-index: 2;
    border: 1px solid color-mix(in srgb, var(--group-color, var(--red)) 38%, transparent);
    color: #f1f4ff;
    letter-spacing: .1em;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: #0a1220f0;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 9px;
    font-size: .72rem;
    font-weight: 900;
    position: sticky;
    top: 0;
}

.object-section-heading b {
    background: color-mix(in srgb, var(--group-color, var(--red)) 22%, transparent);
    min-width: 22px;
    height: 22px;
    color: var(--group-color, var(--red));
    letter-spacing: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: .75rem;
}

/* Object Item */
.object-item {
    color: #f5f8ff;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 17px;
    display: grid;
    grid-template-columns: 48px 1fr 18px;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 66px;
    padding: 8px 9px;
    transition: transform .18s, box-shadow .18s, background .18s;
}

.object-item:hover {
    background: #ffffff14;
    transform: translateY(-1px);
}

.object-item.selected {
    background: linear-gradient(90deg, color-mix(in srgb, var(--group-color, var(--red)) 28%, transparent), #ffffff12);
    border-color: color-mix(in srgb, var(--group-color, var(--red)) 44%, transparent);
    border-left: 4px solid var(--group-color, var(--red));
    box-shadow: 0 12px 28px color-mix(in srgb, var(--group-color, var(--red)) 16%, transparent);
}

.model-icon {
    width: 46px;
    height: 46px;
    color: var(--group-color, var(--red));
    background: linear-gradient(145deg, #ffffff24, color-mix(in srgb, var(--group-color, var(--red)) 18%, transparent));
    border: 1px solid color-mix(in srgb, var(--group-color, var(--red)) 34%, transparent);
    border-radius: 14px;
    display: grid;
    place-items: center;
    box-shadow: inset 0 1px #ffffffbf;
}

.detail-model-icon {
    width: 54px;
    height: 54px;
    color: var(--group-color, var(--red));
    background: linear-gradient(145deg, #ffffff20, color-mix(in srgb, var(--group-color, var(--red)) 16%, transparent));
    border: 1px solid color-mix(in srgb, var(--group-color, var(--red)) 30%, transparent);
    border-radius: 50%;
    display: grid;
    place-items: center;
    box-shadow: inset 0 1px #ffffff40;
    flex-shrink: 0;
}

.object-item strong {
    color: #f5f8ff;
    font-size: .92rem;
    font-weight: 700;
    display: block;
}

.object-item small {
    color: #8ca0b0;
    margin-top: 3px;
    font-size: .74rem;
    display: block;
    font-style: italic;
}

.selected-arrow { color: var(--purple); }

/* ===== VIEWER ===== */
.center-stack {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.viewer-card {
    border-radius: 28px;
    min-height: 660px;
    padding: 18px;
    overflow: hidden;
}

.viewer-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 12px;
}

.viewer-title-row h2 {
    letter-spacing: 0;
    background: linear-gradient(135deg, #fff 0%, #ffd4d0 48%, #e74c3c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 34px #e74c3c1f;
    margin: 0;
    font-size: clamp(2.2rem, 3vw, 3.6rem);
}

.tip-note {
    color: #ffefec;
    background: #e74c3c1e;
    border: 1px solid #e74c3c50;
    border-radius: 7px 17px 17px;
    max-width: 210px;
    padding: 12px 14px;
    font-size: .82rem;
    line-height: 1.45;
    box-shadow: 0 8px 20px #0000002e;
}

.spin-area {
    background:
        radial-gradient(circle at 50% 54%, #ffffff18 0 18%, #e74c3c15 35%, transparent 62%) 0 0 / 100% 100%,
        linear-gradient(135deg, #1a1012, #0d0a18, #12100a) 0 0 / 220% 220%;
    border: 1px solid #e74c3c30;
    border-radius: 24px;
    min-height: 530px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px #ffffff2e, inset 0 -30px 80px #00000038;
    animation: 14s ease-in-out infinite livingGradient;
}

.spin-area canvas {
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    inset: 0;
    outline: none;
    display: block;
    z-index: 2;
}

.spin-area::after {
    content: "";
    z-index: 3;
    pointer-events: none;
    background: radial-gradient(transparent 40%, #0d111773 100%);
    position: absolute;
    inset: 0;
}

.spin-area::before {
    content: "";
    filter: blur(28px);
    background: linear-gradient(115deg, #8B000020, #3498db18, #9b59b618);
    border-radius: 50%;
    position: absolute;
    inset: 8%;
    animation: 8s ease-in-out infinite breathingGlow;
}

@keyframes livingGradient {
    0%, 100% { background-position: 50%, 0%; }
    50% { background-position: 50%, 100%; }
}

@keyframes breathingGlow {
    0%, 100% { opacity: .72; transform: scale(.94) rotate(0); }
    50% { opacity: 1; transform: scale(1.05) rotate(8deg); }
}

/* Particles */
.particle {
    background: color-mix(in srgb, var(--red) 70%, white 10%);
    width: 6px;
    height: 6px;
    box-shadow: 0 0 18px var(--red-glow);
    border-radius: 50%;
    position: absolute;
    z-index: 1;
    animation: 7s ease-in-out infinite floatParticle;
    pointer-events: none;
}

.particle-one { top: 27%; left: 19%; }
.particle-two { opacity: .7; animation-delay: -2s; top: 22%; right: 25%; }
.particle-three { opacity: .8; animation-delay: -4s; bottom: 27%; right: 18%; }

@keyframes floatParticle {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(10px, -18px); }
}

/* Orbit Ring */
.orbit-ring {
    z-index: 4;
    aspect-ratio: 1;
    border: 1px solid color-mix(in srgb, var(--red) 36%, transparent);
    width: min(62%, 390px);
    box-shadow: 0 0 32px color-mix(in srgb, var(--red) 18%, transparent);
    opacity: 0;
    pointer-events: none;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotateX(68deg) scale(.9);
    transition: opacity .18s, transform .18s;
}

.spin-area.is-interacting .orbit-ring {
    opacity: 1;
    transform: translate(-50%, -50%) rotateX(68deg) scale(1);
}

/* Viewer Status Strip */
.viewer-status-strip {
    z-index: 6;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff8f2;
    background: #1a15209e;
    border: 1px solid #ffffff2e;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    position: absolute;
    top: 16px;
    right: 16px;
    box-shadow: 0 16px 36px #1a15202e;
}

.toggle-line {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .82rem;
    color: #d7dcdf;
}

.toggle-line input {
    accent-color: var(--red);
}

.frame-pill {
    white-space: nowrap;
    color: #f7f8ff;
    background: #ffffff1f;
    border: 1px solid #ffffff1f;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .78rem;
    font-family: var(--mono);
}

/* Bottom Controls */
.bottom-controls {
    z-index: 6;
    background: var(--control);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid #ffffff29;
    border-radius: 999px;
    display: flex;
    gap: 4px;
    padding: 6px;
    position: absolute;
    bottom: 18px;
    box-shadow: 0 18px 42px #1a152038;
}

.bottom-controls.left { left: 18px; }
.bottom-controls.center { left: 50%; transform: translateX(-50%); }
.bottom-controls.right { right: 18px; }

.bottom-controls button {
    color: #fff8f2;
    backdrop-filter: blur(10px);
    background: #ffffff14;
    border: 1px solid #ffffff1f;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 0;
    font-weight: 700;
    display: grid;
    place-items: center;
    transition: all .18s;
}

.bottom-controls button:hover {
    background: #ffffff29;
    transform: translateY(-1px);
}

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

.bottom-controls button svg { color: #f0b0a0; flex: none; }

.bottom-controls button.control-active {
    background: linear-gradient(135deg, #8B0000f2, #e74c3ce6);
    border-color: #ffffff38;
    box-shadow: 0 8px 18px #e74c3c2e;
}

.bottom-controls button.rotate-active svg {
    color: var(--red);
    animation: 1.2s ease-in-out infinite rotatePulse;
}

@keyframes rotatePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Viewer Meta Strip */
.viewer-meta-strip {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.viewer-meta-strip span {
    border: 1px solid var(--border);
    color: #e6f0f2;
    background: #ffffff0f;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: .86rem;
}

.viewer-meta-strip b {
    font-family: var(--mono);
    color: var(--red);
}

/* ===== DETAIL PANEL ===== */
.detail-panel {
    display: grid;
    align-content: start;
    gap: 16px;
}

.detail-card {
    border-radius: 24px;
    padding: 17px;
    transition: transform .18s;
}

.detail-card:hover { transform: translateY(-2px); }

.detail-panel .detail-card {
    border-top: 2px solid color-mix(in srgb, var(--group-color, var(--red)) 55%, transparent);
}

.detail-panel .section-heading {
    color: var(--group-color, var(--red));
}

.structure-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0;
}

.structure-row h3 {
    color: #fff;
    margin: 0;
    font-size: 1.15rem;
}

.structure-row p {
    color: var(--muted);
    margin: 2px 0 0;
    font-size: .82rem;
}

.detail-card p {
    color: #e0e4e8;
    line-height: 1.6;
    font-size: .92rem;
}

/* Stats List */
.stats-list {
    display: grid;
    gap: 9px;
    margin: 0;
}

.stats-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 9px;
    border-bottom: 1px dashed #e7434329;
}

.stats-list dt {
    color: #a0a8b8;
    font-size: .8rem;
}

.stats-list dd {
    text-align: right;
    color: #f2f4fb;
    margin: 0;
    font-family: var(--mono);
    font-size: .84rem;
    font-weight: 700;
}

/* Parts List */
.parts-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.part-item {
    background: #ffffff0f;
    border: 1px solid #e7434320;
    border-radius: 14px;
    padding: 10px 11px;
    display: grid;
    gap: 3px;
    cursor: pointer;
    transition: all .2s;
}

.part-item:hover {
    background: #ffffff1a;
    border-color: #e7434340;
    transform: translateX(3px);
}

.part-item strong {
    color: var(--group-color, #e74c3c);
    font-size: .86rem;
}

.part-item span {
    color: #c0c8d0;
    font-size: .8rem;
    line-height: 1.35;
}

/* Fun Fact */
.fun-fact {
    border: 1px solid #ffffff24;
    border-left: 4px solid var(--group-color, var(--red));
    color: #eef0ff;
    background: #ffffff0f;
    border-radius: 16px;
    padding: 12px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: .95rem;
    font-style: italic;
    display: grid;
    gap: 5px;
    line-height: 1.55;
}

.fun-fact strong {
    color: var(--group-color, var(--red));
    font-family: var(--font);
    font-size: .78rem;
    font-style: normal;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* Mini Map */
.mini-map {
    color: #edf0f2;
    background: linear-gradient(135deg, #e74c3c1a, #dc143c10);
    border-radius: 18px;
    display: grid;
    place-items: center;
    min-height: 96px;
    position: relative;
    overflow: hidden;
    margin-top: 12px;
}

.mini-map span {
    background: #8B000030;
    border-radius: 50%;
    position: absolute;
}

.mini-map span:first-child { width: 54px; height: 54px; top: 18px; left: 18px; }
.mini-map span:nth-child(2) { background: #3498db28; width: 34px; height: 34px; top: 26px; right: 36px; }
.mini-map span:nth-child(3) { background: #e6722228; width: 28px; height: 28px; bottom: 16px; left: 50%; }

/* ===== BOTTOM PANEL ===== */
.bottom-panel {
    border-radius: 26px;
    display: flex;
    gap: 14px;
    padding: 16px;
    margin-top: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
}

.micro-card {
    scroll-snap-align: start;
    color: #effcff;
    border: 1px solid var(--border);
    border-radius: 18px;
    min-width: 220px;
    padding: 14px;
    transition: transform .18s;
    cursor: pointer;
    flex-shrink: 0;
}

.micro-card:hover { transform: translateY(-2px); }

.micro-card.tone-lobes { background: linear-gradient(135deg, #e74c3c20, #0f1d2ee0); }
.micro-card.tone-vessels { background: linear-gradient(135deg, #3498db20, #0f1d2ee0); }
.micro-card.tone-bile { background: linear-gradient(135deg, #27ae6020, #0f1d2ee0); }
.micro-card.tone-cells { background: linear-gradient(135deg, #e67e2220, #0f1d2ee0); }
.micro-card.tone-pathology { background: linear-gradient(135deg, #9b59b620, #0f1d2ee0); }

.micro-card-img {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.micro-card-img img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
    opacity: .85;
    transition: opacity .3s, transform .4s;
}

.micro-card:hover .micro-card-img img {
    opacity: 1;
    transform: scale(1.06);
}

.micro-card h4 {
    font-size: .9rem;
    margin: 0 0 6px;
    color: #fff;
}

.micro-card p {
    font-size: .78rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.4;
}

.micro-card .micro-tag {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    background: #ffffff14;
    border: 1px solid var(--border);
}

/* ===== IMAGE CARD ===== */
.detail-image-wrap {
    margin-top: 10px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    position: relative;
    background: #000;
}

.detail-image-wrap img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    opacity: .92;
    transition: opacity .3s, transform .4s;
    filter: saturate(1.1);
}

.detail-image-wrap:hover img {
    opacity: 1;
    transform: scale(1.04);
}

.detail-image-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(10, 18, 32, 0.6) 0%, transparent 50%);
    pointer-events: none;
}

/* Welcome hero image */
.welcome-hero-img {
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-top: 12px;
    position: relative;
}

.welcome-hero-img img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    opacity: .85;
    filter: saturate(1.05) brightness(0.9);
}

.welcome-hero-img::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(231,76,60,0.15), transparent 60%);
    pointer-events: none;
}

/* ===== FOOTER ===== */
.app-footer {
    border: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: #b8c0c8;
    text-align: center;
    background: #0c1a28c7;
    border-radius: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 12px 16px;
    font-size: .86rem;
    box-shadow: 0 10px 28px #0000002e, inset 0 1px #ffffff1f;
}

.app-footer span { color: var(--red); font-weight: 800; }
.app-footer b { color: #edf0f6; font-weight: 700; }

/* ===== TOAST ===== */
.toast {
    color: #fff8f0;
    box-shadow: var(--shadow);
    background: #1c1418;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 13px 16px;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    font-size: .9rem;
    animation: fadeInUp .3s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== GROUP COLORS ===== */
.group-lobes { --group-color: var(--lobes); }
.group-vessels { --group-color: var(--vessels); }
.group-bile { --group-color: var(--bile); }
.group-cells { --group-color: var(--cells); }
.group-pathology { --group-color: var(--pathology); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1180px) {
    .studio-grid {
        grid-template-columns: 240px minmax(0, 1fr);
    }
    .detail-panel {
        grid-column: 1 / -1;
        grid-template-columns: repeat(3, 1fr);
    }
    .top-nav a span { display: none; }
    .top-nav a { padding: 10px; }
}

@media (max-width: 850px) {
    .app-shell {
        border-radius: 22px;
        width: 100vw;
        margin: 0;
        padding: 10px;
    }

    .header { height: auto; flex-wrap: wrap; }
    .brand { min-width: 0; }
    .brand p { display: none; }

    .studio-grid {
        grid-template-columns: 1fr;
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar {
        max-height: none;
        position: relative;
        top: auto;
    }

    .object-scroll {
        max-height: 250px;
        overflow-y: auto;
    }

    .viewer-card {
        min-height: auto;
        border-radius: 20px;
    }

    .spin-area { min-height: 400px; }

    .viewer-title-row { flex-direction: column; }
    .tip-note { max-width: 100%; }

    .viewer-status-strip {
        position: relative;
        inset: auto;
        margin-bottom: 10px;
        justify-content: center;
    }

    .detail-panel { grid-template-columns: 1fr; }

    .bottom-panel { flex-wrap: nowrap; }
}

@media (max-width: 540px) {
    .top-nav a:nth-child(n+3) { display: none; }
    .brand h1 { font-size: 1.18rem; }
    .spin-area { min-height: 350px; }
    .bottom-controls button { flex: 0 0 34px; }
    .viewer-meta-strip { grid-template-columns: 1fr; }
}

/* ===== LOADING STATE ===== */
.model-loading {
    z-index: 7;
    border: 1px solid color-mix(in srgb, var(--red) 45%, transparent);
    color: #edf0ff;
    width: min(420px, 100% - 40px);
    box-shadow: 0 24px 58px #0000006b, 0 0 34px #e74c3c14;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    pointer-events: none;
    background: #0a1220db;
    border-radius: 20px;
    display: grid;
    gap: 12px;
    padding: 16px 18px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.model-loading-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

.model-loading b {
    color: var(--red);
    font-family: var(--mono);
}

.model-progress-track {
    background: #e74c3c24;
    border-radius: 999px;
    height: 11px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px #0000005c;
}

.model-progress-fill {
    border-radius: inherit;
    background: linear-gradient(90deg, var(--red), var(--crimson), var(--blue), var(--purple));
    height: 100%;
    box-shadow: 0 0 18px var(--red-glow);
    background-size: 180% 100%;
    transition: width .18s;
    animation: 1.4s linear infinite progressFlow;
}

@keyframes progressFlow { to { background-position: 180% 0; } }

/* ===== LABELS ON 3D ===== */
.label-3d {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    text-shadow: 0 1px 4px #000, 0 0 12px #00000080;
    white-space: nowrap;
    background: #0a122080;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #ffffff20;
    backdrop-filter: blur(4px);
    transition: opacity .2s;
}

.label-3d::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: var(--group-color, var(--red));
    border-radius: 50%;
    box-shadow: 0 0 8px var(--group-color, var(--red));
}
