/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --white: #ffffff;
    --off-white: #f8f7f4;
    --cream: #f0ede6;
    --gold: #b8975a;
    --gold-light: #d4bc8a;
    --dark: #1a1a1a;
    --text: #2c2c2c;
    --text-light: #6b6b6b;
    --border: #e5e2db;
    --shadow: rgba(0, 0, 0, 0.06);
    --header-bg: rgba(255, 255, 255, 0.92);
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --white: #111111;
    --off-white: #1c1c1c;
    --cream: #242424;
    --dark: #f0ede6;
    --text: #d4d0c8;
    --text-light: #7a7a7a;
    --border: #2d2d2d;
    --shadow: rgba(0, 0, 0, 0.5);
    --header-bg: rgba(17, 17, 17, 0.92);
}

html, body {
    height: 100%;
    font-family: var(--font-body);
    background: var(--white);
    color: var(--text);
    overflow: hidden;
}

/* ===== Header ===== */
#site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 400;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 8px;
}

/* Theme-aware logo switching */
.logo-img-dark,
.about-title-logo.logo-img-dark {
    display: none;
}

[data-theme="dark"] .logo-img-light,
[data-theme="dark"] .about-title-logo.logo-img-light {
    display: none;
}

[data-theme="dark"] .logo-img-dark,
[data-theme="dark"] .about-title-logo.logo-img-dark {
    display: block;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--dark);
}

nav {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: color var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--dark);
}

/* ===== Paysage Toggle ===== */
#paysage-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

#paysage-toggle:hover {
    color: #4a8c3f;
    border-color: #4a8c3f;
}

[data-paysage="on"] #paysage-toggle {
    color: #4a8c3f;
    border-color: #4a8c3f;
    background: rgba(74, 140, 63, 0.1);
}

/* ===== Theme Toggle ===== */
#theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

#theme-toggle:hover {
    color: var(--dark);
    border-color: var(--text-light);
}

#theme-toggle svg {
    display: none;
    pointer-events: none;
}

:root:not([data-theme="dark"]) #icon-sun {
    display: block;
}

[data-theme="dark"] #icon-moon {
    display: block;
}

/* ===== 3D Viewer ===== */
#viewer-section {
    position: relative;
    width: 100%;
    height: 100vh;
    background: linear-gradient(180deg, var(--white) 0%, var(--off-white) 100%);
}

#three-container {
    width: 100%;
    height: 100%;
}

#three-container canvas {
    display: block;
}

#viewer-instructions {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    animation: fadeInUp 1s ease 0.5s both;
}

#viewer-instructions p {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
}

#viewer-instructions .hint {
    font-size: 13px;
    color: var(--text-light);
    letter-spacing: 0.05em;
}

[data-paysage="on"] #viewer-instructions p {
    color: #ffffff;
}

[data-paysage="on"] #viewer-instructions .hint {
    color: rgba(255, 255, 255, 0.7);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Info Panel ===== */
#info-panel {
    position: fixed;
    top: 72px;
    right: 0;
    width: 480px;
    height: calc(100vh - 72px);
    background: var(--white);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 40px var(--shadow);
    z-index: 200;
    overflow-y: auto;
    transition: transform var(--transition);
    transform: translateX(0);
}

#info-panel.panel-hidden {
    transform: translateX(100%);
    pointer-events: none;
}

#panel-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--white);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: all var(--transition);
}

#panel-close:hover {
    background: var(--dark);
    color: var(--white);
    border-color: var(--dark);
}

#panel-content {
    padding: 80px 40px 40px;
}

#bone-name {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 15px;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 36px;
}

/* ===== Bone header (name + Quiz me button) ===== */
.bone-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.bone-header #bone-name {
    margin-bottom: 0;
}

.bone-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-top: 6px;
}

#anatomy-btn {
    padding: 8px 16px;
    background: transparent;
    color: var(--gold);
    border: 1.5px solid var(--gold);
    border-radius: 20px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), transform var(--transition);
    white-space: nowrap;
}

#anatomy-btn:hover {
    background: var(--gold);
    color: #ffffff;
    transform: translateY(-1px);
}

#quiz-me-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--gold);
    color: #ffffff;
    border: 1.5px solid var(--gold);
    border-radius: 20px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}

#quiz-me-btn:hover {
    background: #a07840;
    box-shadow: 0 4px 16px rgba(184, 151, 90, 0.35);
    transform: translateY(-1px);
}

#quiz-me-btn:active {
    transform: translateY(0);
}

/* ===== Anatomy Overlay ===== */
#anatomy-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: #080810;
    display: flex;
    flex-direction: column;
    transition: opacity 0.4s ease;
}

#anatomy-overlay.anatomy-hidden {
    opacity: 0;
    pointer-events: none;
}

#anatomy-canvas-wrap {
    width: 100%;
    height: 100%;
    position: relative;
}

#anat-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#anat-loading.anat-loaded {
    display: none;
}

.anat-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: rgba(255,255,255,0.7);
    border-radius: 50%;
    animation: anat-spin 0.8s linear infinite;
}

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

#anatomy-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

#rotate-toggle {
    position: absolute;
    top: 24px;
    right: 220px;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    border: 1px solid rgba(184, 151, 90, 0.45);
    border-radius: 20px;
    background: rgba(184, 151, 90, 0.12);
    color: var(--gold);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.25s ease;
    z-index: 1;
}

#rotate-toggle:hover {
    background: rgba(184, 151, 90, 0.25);
    border-color: var(--gold);
}

#rotate-toggle.rotate-off {
    border-color: rgba(255, 255, 255, 0.15);
    background: transparent;
    color: rgba(255, 255, 255, 0.35);
}

#annot-toggle {
    position: absolute;
    top: 24px;
    right: 80px;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    border: 1px solid rgba(184, 151, 90, 0.45);
    border-radius: 20px;
    background: rgba(184, 151, 90, 0.12);
    color: var(--gold);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.25s ease;
    z-index: 1;
}

#annot-toggle:hover {
    background: rgba(184, 151, 90, 0.25);
    border-color: var(--gold);
}

#annot-toggle.annot-off {
    border-color: rgba(255, 255, 255, 0.15);
    background: transparent;
    color: rgba(255, 255, 255, 0.35);
}

#anatomy-close {
    position: absolute;
    top: 24px;
    right: 28px;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.55);
    transition: all var(--transition);
    z-index: 1;
}

#anatomy-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.5);
}

#anatomy-info {
    position: absolute;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    z-index: 1;
}

.anatomy-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 6px;
}

#anatomy-bone-title {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 10px;
}

.anatomy-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.06em;
}

/* ===== Anatomy landmark hover tooltip ===== */
/* ===== Anatomy label description (shown on click) ===== */
.ann-label-desc {
    display: none;
    font-size: 10px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.5;
    margin-top: 4px;
    white-space: normal;
    max-width: 180px;
}

.ann-label--expanded {
    white-space: normal;
    border-color: var(--label-color) !important;
    background: rgba(8, 12, 20, 0.95) !important;
}

.ann-label--expanded .ann-label-desc {
    display: block;
}

/* ===== Annotation position multipliers (humerus) ===== */
#annot-multipliers {
    position: absolute;
    bottom: 44px;
    right: 24px;
    background: rgba(8, 8, 16, 0.80);
    border: 1px solid rgba(184, 151, 90, 0.35);
    border-radius: 12px;
    padding: 12px 16px;
    backdrop-filter: blur(8px);
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#annot-multipliers.annot-mult-hidden {
    display: none;
}

.annot-mult-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 2px;
}

.annot-mult-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.annot-mult-axis {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--gold);
    width: 10px;
    flex-shrink: 0;
}

.annot-mult-field input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 130px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.annot-mult-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(184, 151, 90, 0.6);
}

.annot-mult-field input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(184, 151, 90, 0.6);
}

.annot-mult-val {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    font-family: var(--font-body);
    width: 36px;
    text-align: right;
    flex-shrink: 0;
}

/* ===== Anatomy landmark labels (CSS2DRenderer) ===== */

/* ann-label: CSS2DObject labels — same style as example.html */
.ann-label {
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    background: rgba(8, 12, 20, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--label-color);
    border-color: var(--label-color-dim);
    backdrop-filter: blur(6px);
    transition: border-color 0.15s, background 0.15s;
}

.ann-label-name {
    font-size: 11px;
    font-weight: 500;
}

.ann-label.active {
    font-size: 12.5px;
    font-weight: 700;
    background: rgba(20, 30, 60, 0.92);
    border-color: var(--label-color);
}

/* ===== Quiz Modal ===== */
#quiz-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition);
}

#quiz-modal.modal-hidden {
    opacity: 0;
    pointer-events: none;
}

#quiz-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
}

#quiz-content {
    position: relative;
    width: 620px;
    max-width: 95vw;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--white);
    border-radius: 20px;
    padding: 48px;
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.18);
}

#quiz-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--white);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: all var(--transition);
}

#quiz-close:hover {
    background: var(--dark);
    color: var(--white);
    border-color: var(--dark);
}

#quiz-header {
    margin-bottom: 32px;
}

.quiz-label {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}

#quiz-bone-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    padding-right: 40px;
}

.quiz-placeholder {
    font-size: 15px;
    color: var(--text-light);
    line-height: 1.7;
    text-align: center;
    padding: 40px 0;
}

/* ===== Quiz Engine ===== */

/* Progress */
.qb-progress {
    margin-bottom: 28px;
}

.qb-progress-text {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 8px;
}

.qb-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.qb-progress-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* Question stem */
.qb-stem {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 24px;
    padding: 20px;
    background: var(--off-white);
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Options */
.qb-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

/* Wrap holds the button + its inline dropdown */
.qb-option-wrap {
    display: flex;
    flex-direction: column;
}

.qb-option {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 14px 18px;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
    transition: border-color 0.2s, background 0.2s, transform 0.15s, border-radius 0.2s;
    position: relative;
}

/* When its dropdown is open, square off the bottom corners */
.qb-option-wrap:has(.qb-inline-expl-open) .qb-option {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

.qb-option:hover:not(:disabled) {
    border-color: var(--gold);
    background: rgba(184, 151, 90, 0.04);
    transform: translateX(2px);
}

.qb-letter {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--off-white);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-light);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.qb-option:hover:not(:disabled) .qb-letter {
    background: var(--gold);
    border-color: var(--gold);
    color: #fff;
}

/* Chevron icon (right side) */
.qb-chevron {
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    color: var(--text-light);
    transition: opacity 0.2s, transform 0.2s;
    padding-top: 2px;
}

/* Show chevron on wrong/dimmed options after resolution */
.qb-option.qb-wrong .qb-chevron,
.qb-option.qb-dimmed .qb-chevron {
    opacity: 1;
}

/* Rotate chevron when dropdown is open */
.qb-option-wrap:has(.qb-inline-expl-open) .qb-option .qb-chevron {
    transform: rotate(180deg);
}

/* Correct state */
.qb-option.qb-correct {
    border-color: #2a9d5c;
    background: rgba(42, 157, 92, 0.07);
    cursor: default;
}

.qb-option.qb-correct .qb-letter {
    background: #2a9d5c;
    border-color: #2a9d5c;
    color: #fff;
}

/* Wrong state */
.qb-option.qb-wrong {
    border-color: #d94f4f;
    background: rgba(217, 79, 79, 0.07);
    cursor: pointer;
}

.qb-option.qb-wrong .qb-letter {
    background: #d94f4f;
    border-color: #d94f4f;
    color: #fff;
}

/* Dimmed (unchosen wrong, after resolution) */
.qb-option.qb-dimmed {
    opacity: 0.5;
    cursor: pointer;
}

.qb-option.qb-dimmed:hover {
    opacity: 0.85;
    border-color: #d94f4f;
    background: rgba(217, 79, 79, 0.04);
    transform: none;
}

/* Inline dropdown explanation (below each option) */
.qb-inline-expl {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
    border: 1.5px solid transparent;
    border-top: none;
    border-radius: 0 0 10px 10px;
    background: rgba(217, 79, 79, 0.05);
}

.qb-inline-expl-open {
    max-height: 300px;
    padding: 14px 18px;
    border-color: #d94f4f;
    border-top-color: transparent;
}

/* Action row (reveal / next buttons) */
.qb-action-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    min-height: 44px;
}

.qb-btn-reveal {
    padding: 10px 20px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-light);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.qb-btn-reveal:hover {
    border-color: var(--text-light);
    color: var(--text);
}

.qb-btn-next {
    padding: 12px 26px;
    background: var(--gold);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    letter-spacing: 0.01em;
}

.qb-btn-next:hover {
    background: #a07840;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(184, 151, 90, 0.35);
}

/* Explanation area */
.qb-explanation {
    display: none;
    flex-direction: column;
    gap: 14px;
    margin-top: 4px;
}

.qb-explanation.qb-expl-visible {
    display: flex;
}

.qb-expl-correct {
    background: rgba(42, 157, 92, 0.07);
    border: 1px solid rgba(42, 157, 92, 0.3);
    border-radius: 10px;
    padding: 16px 18px;
}

.qb-expl-wrong {
    background: rgba(217, 79, 79, 0.06);
    border: 1px solid rgba(217, 79, 79, 0.25);
    border-radius: 10px;
    padding: 16px 18px;
    animation: fadeSlideIn 0.2s ease;
}

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

.qb-expl-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #2a9d5c;
    margin-bottom: 8px;
}

.qb-expl-label svg {
    stroke: #2a9d5c;
}

.qb-expl-label-wrong {
    color: #d94f4f;
}

.qb-expl-label-wrong svg {
    stroke: #d94f4f;
}

.qb-expl-correct p,
.qb-expl-wrong p,
.qb-inline-expl p {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
}

/* Summary screen */
.qb-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 0;
    gap: 16px;
}

.qb-summary-score {
    position: relative;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 3px solid var(--grade-color, var(--gold));
    background: color-mix(in srgb, var(--grade-color, var(--gold)) 8%, transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.qb-score-fraction {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--grade-color, var(--gold));
    line-height: 1;
}

.qb-score-pct-inline {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 400;
    color: var(--grade-color, var(--gold));
    opacity: 0.8;
    margin-top: 3px;
}

.qb-score-bar-wrap {
    width: 200px;
    height: 6px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.qb-score-bar {
    height: 100%;
    width: var(--pct, 0%);
    background: var(--bar-color, var(--gold));
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}


.qb-summary h3 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
}

.qb-summary p {
    font-size: 15px;
    color: var(--text-light);
    max-width: 320px;
}

/* Dark mode adjustments */
[data-theme="dark"] .qb-stem {
    background: var(--cream);
    border-color: var(--border);
}

[data-theme="dark"] .qb-option {
    background: var(--off-white);
}

[data-theme="dark"] .qb-letter {
    background: var(--cream);
}

[data-theme="dark"] .qb-expl-correct {
    background: rgba(42, 157, 92, 0.12);
}

[data-theme="dark"] .qb-expl-wrong {
    background: rgba(217, 79, 79, 0.1);
}

/* ===== Fracture Cards ===== */
.fracture-card {
    background: var(--off-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: all var(--transition);
}

.fracture-card:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 20px rgba(184, 151, 90, 0.1);
    transform: translateY(-2px);
}

.fracture-card h3 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.fracture-card .card-preview {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.5;
}

.fracture-card .card-tag {
    display: inline-block;
    margin-top: 12px;
    padding: 4px 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gold);
    letter-spacing: 0.03em;
}

/* ===== Fracture Modal ===== */
#fracture-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition);
}

#fracture-modal.modal-hidden {
    opacity: 0;
    pointer-events: none;
}

#modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
}

#modal-content {
    position: relative;
    width: 680px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--white);
    border-radius: 16px;
    padding: 48px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.12);
}

#modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--white);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: all var(--transition);
}

#modal-close:hover {
    background: var(--dark);
    color: var(--white);
    border-color: var(--dark);
}

#fracture-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 32px;
    padding-right: 40px;
}

/* Detail sections in modal */
.detail-section {
    margin-bottom: 28px;
}

.detail-section h4 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 10px;
}

.detail-section p,
.detail-section ul {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
}

.detail-section ul {
    padding-left: 20px;
}

.detail-section li {
    margin-bottom: 6px;
}

.detail-divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

/* ===== About Section ===== */
#about-section {
    position: fixed;
    top: 72px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    background: var(--white);
    overflow-y: auto;
    transition: opacity var(--transition), transform var(--transition);
    opacity: 1;
    transform: translateY(0);
}

#about-section.about-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(24px);
}

.about-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 120px 40px 80px;
}

.about-header {
    text-align: center;
    margin-bottom: 72px;
}

.about-title {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 20px;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0px;
}

.about-title-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 10px;
    flex-shrink: 0;
}

.about-subtitle {
    font-size: 17px;
    color: var(--text-light);
    line-height: 1.7;
    max-width: 620px;
    margin: 0 auto;
    margin-bottom: 20px;
}

.about-team {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 48px;
}

.about-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 32px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--off-white);
    transition: box-shadow var(--transition), transform var(--transition);
}

.about-card:hover {
    box-shadow: 0 8px 40px rgba(184, 151, 90, 0.1);
    transform: translateY(-4px);
}

.about-photo-wrap {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 24px;
    border: 3px solid var(--gold-light);
    flex-shrink: 0;
}

.about-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.about-name {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
}

.about-role {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 16px;
}

.about-bio {
    font-size: 15px;
    color: var(--text-light);
    line-height: 1.7;
    margin-bottom: 20px;
}

.about-linkedin {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--white);
    transition: all var(--transition);
}

.about-linkedin:hover {
    border-color: #0077b5;
    color: #0077b5;
    box-shadow: 0 2px 12px rgba(0, 119, 181, 0.12);
}

.linkedin-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

/* ===== Anatomy unavailable toast ===== */
#anatomy-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--dark);
    color: var(--white);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    padding: 12px 20px;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 90vw;
    text-align: center;
    white-space: normal;
}

#anatomy-toast.anatomy-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#anatomy-toast.anatomy-toast-hide {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ===== Mobile / Touch ===== */
@media (max-width: 768px) {

    /* ── Header ── */
    .header-inner {
        padding: 0 16px;
        height: 60px;
    }

    .logo img {
        width: 38px;
        height: 38px;
    }

    .logo-text {
        font-size: 18px;
    }

    nav {
        gap: 16px;
    }

    /* Bigger touch targets for icon buttons */
    #paysage-toggle,
    #theme-toggle {
        width: 42px;
        height: 42px;
    }

    /* ── Viewer ── */
    #viewer-section {
        height: 100dvh; /* avoids browser-chrome overlap on iOS/Android */
        height: 100vh;  /* fallback for older browsers */
    }

    #viewer-instructions {
        bottom: 32px;
        width: 100%;
        padding: 0 16px;
    }

    /* ── Info panel — bottom sheet ── */
    #info-panel {
        width: 100%;
        height: min(72vh, calc(100vh - 120px));
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 40px var(--shadow);
        /* Override desktop translateX with translateY */
        transform: translateY(0);
    }

    #info-panel.panel-hidden {
        transform: translateY(100%);
        pointer-events: none;
    }

    /* Drag handle pill */
    #info-panel::before {
        content: '';
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
    }

    #panel-content {
        padding: 52px 20px 40px;
    }

    #bone-name {
        font-size: 24px;
    }

    /* Bigger close buttons */
    #panel-close,
    #modal-close,
    #quiz-close {
        width: 44px;
        height: 44px;
        font-size: 22px;
        top: 16px;
        right: 16px;
    }

    /* Move the panel close button to top-LEFT on mobile so it doesn't
       overlap the Anatomy / Quiz me buttons which live on the right;
       also shrink it slightly to leave more breathing room */
    #panel-close {
        right: auto;
        left: 16px;
        width: 32px;
        height: 32px;
        font-size: 17px;
    }

    /* ── Fracture modal — bottom sheet ── */
    #fracture-modal {
        align-items: flex-end;
    }

    #modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        padding: 48px 20px 32px;
    }

    #fracture-title {
        font-size: 22px;
    }

    /* ── Quiz modal — bottom sheet ── */
    #quiz-modal {
        align-items: flex-end;
    }

    #quiz-content {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        padding: 48px 20px 32px;
    }

    #quiz-bone-title {
        font-size: 22px;
    }

    /* ── Anatomy overlay ── */
    #anatomy-close {
        top: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
    }

    #annot-toggle {
        top: 16px;
        right: 72px;
    }

    /* Align Rotate button to same vertical level as Landmarks on mobile */
    #rotate-toggle {
        top: 16px;
        left: 16px;
        right: auto;
    }

    #anatomy-bone-title {
        font-size: 22px;
    }

    /* ── About section ── */
    #about-section {
        top: 60px; /* match mobile header height */
    }

    .about-team {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .about-title {
        font-size: 32px;
    }

    .about-inner {
        padding: 80px 20px 60px;
    }

    .about-subtitle {
        font-size: 15px;
    }
}

/* Prevent accidental text selection while dragging the 3D scene */
#three-container {
    user-select: none;
    -webkit-user-select: none;
}

/* Small phones (≤430px, e.g. iPhone 12/14): shrink nav to prevent overlap with logo */
@media (max-width: 430px) {
    .logo-text {
        font-size: 16px;
    }

    .logo img {
        width: 30px;
        height: 30px;
    }

    nav {
        gap: 8px;
    }

    .nav-link {
        font-size: 12px;
        letter-spacing: 0.02em;
    }

    #paysage-toggle,
    #theme-toggle {
        width: 32px;
        height: 32px;
    }
}

/* Extra-small phones: hide logo text to save space */
@media (max-width: 360px) {
    .logo-text {
        display: none;
    }
}
