@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600&display=swap');

:root {
    --bg: #f2efe7;
    --bg-top: #fffdf7;
    --bg-bottom: #e8e1d0;
    --ink: #1f1e1b;
    --muted: #5a564c;
    --accent: #1f6f8b;
    --accent-strong: #0f4c5c;
    --card: #ffffff;
    --border: #d9d4c7;
    --danger: #b83b2f;
    --shadow: 0 18px 40px rgba(31, 30, 27, 0.12);
    --pill-bg: #ece6d9;
    --field-bg: #fffdf8;
    --secondary-bg: #efe8d8;
    --notice-bg: #f6f3eb;
    --badge-bg: #e7f0f3;
    --badge-ink: #1e5567;
    --theme-icon-bg: #f0b43a;
    --theme-icon-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.18);
}

body[data-theme='dark'] {
    --bg: #121513;
    --bg-top: #1a1f1b;
    --bg-bottom: #0b0d0c;
    --ink: #f2efe6;
    --muted: #b6b0a2;
    --accent: #7bb5c8;
    --accent-strong: #9bd1e1;
    --card: #1b1f1d;
    --border: #30362f;
    --danger: #e06a5c;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --pill-bg: #2a2f2a;
    --field-bg: #141816;
    --secondary-bg: #2a2f2a;
    --notice-bg: #202624;
    --badge-bg: #20333c;
    --badge-ink: #a7d6e6;
    --theme-icon-bg: #f1d27a;
    --theme-icon-shadow: inset -3px -3px 0 rgba(255, 255, 255, 0.25);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 10% 20%, var(--bg-top) 0, var(--bg) 50%, var(--bg-bottom) 100%);
}

a {
    color: var(--accent-strong);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.header {
    padding: 24px 0 8px;
}

.container {
    width: min(1100px, 92vw);
    margin: 0 auto 48px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.brand {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0.4px;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--pill-bg);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--muted);
}

.auth-dropdown {
    position: relative;
}

.auth-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--pill-bg);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
}

.auth-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.auth-button:hover {
    color: var(--accent-strong);
    border-color: var(--accent-strong);
}

.auth-caret {
    width: 14px;
    height: 14px;
    opacity: 0.75;
}

.auth-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 200px;
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 30;
}

.auth-dropdown-menu::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.auth-dropdown:hover .auth-dropdown-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.auth-dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
}

.auth-dropdown-item:hover,
.auth-dropdown-item:focus-visible {
    background: var(--secondary-bg);
    color: var(--ink);
}

.auth-dropdown-item-static {
    padding: 0;
}

.auth-dropdown-item.auth-dropdown-item-static:hover,
.auth-dropdown-item.auth-dropdown-item-static:focus-visible {
    background: transparent;
    color: inherit;
}

.auth-dropdown-menu .theme-toggle {
    width: 100%;
    justify-content: space-between;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.card h2 {
    margin: 0 0 12px;
    font-size: 20px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--muted);
}

input[type='text'],
input[type='email'],
input[type='date'],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    background: var(--field-bg);
    color: var(--ink);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
}

body[data-theme='dark'] input[type='date']::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.2);
    opacity: 0.8;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(31, 111, 139, 0.2);
}

button.secondary,
.btn.secondary {
    background: var(--secondary-bg);
    color: var(--ink);
    border-color: var(--border);
}

.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.icon-btn:hover {
    transform: none;
    box-shadow: none;
}

.icon-btn.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -6px);
    background: var(--card);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
    font-size: 13px;
    opacity: 0;
    transform: translate(-50%, -6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2400;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

button.danger {
    background: var(--danger);
}

.inline-form {
    display: inline;
}

.notice {
    padding: 10px 12px;
    border-left: 4px solid var(--accent);
    background: var(--notice-bg);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}

.table td:last-child {
    white-space: nowrap;
}

.table .btn {
    margin-right: 6px;
}

.table .btn:last-child {
    margin-right: 0;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.table th.actions-cell,
.table td.actions-cell {
    text-align: right;
}

.icon-btn.icon-outline svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--badge-bg);
    font-size: 12px;
    color: var(--badge-ink);
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-card {
    text-align: center;
    padding: 32px 24px;
}

.auth-card h1 {
    margin: 0 0 10px;
    font-size: 28px;
}

.roleplay-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-form {
    overflow-x: auto;
    width: 100%;
}

.filter-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 100%;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-input {
    width: 100%;
}

.filter-input-name {
    width: 200px;
}

.filter-input-unit {
    width: 140px;
}

.filter-input-date {
    width: 160px;
}

.filter-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    align-self: flex-end;
}

.filter-actions .btn,
.filter-actions button {
    height: 38px;
    padding: 0 16px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.theme-toggle {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
    transform: none;
    box-shadow: none;
}

.theme-icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--theme-icon-bg);
    box-shadow: var(--theme-icon-shadow);
    border: 1px solid var(--border);
}

.conversation-log {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--field-bg);
    padding: 12px;
    min-height: 140px;
    max-height: 320px;
    overflow-y: auto;
    display: grid;
    gap: 10px;
}

.message-row {
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border);
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.thankyou-screen {
    text-align: center;
    padding: 32px 20px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--field-bg);
}

.thankyou-screen h3 {
    margin: 0 0 10px;
    font-size: 22px;
}

.thankyou-screen p {
    margin: 0;
    color: var(--muted);
}

.thankyou-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

.ai-feedback-card {
    margin: 20px auto 0;
    max-width: 640px;
    text-align: left;
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    padding: 18px 22px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.ai-feedback-heading {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 10px;
}

.ai-feedback-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 14px;
    padding: 4px 0;
}

.ai-feedback-loading .chat-loading-spinner {
    width: 20px;
    height: 20px;
    border-width: 3px;
    flex: 0 0 auto;
}

.ai-feedback-loading.is-error {
    color: #b3261e;
}

.ai-feedback-loading.is-error .chat-loading-spinner {
    display: none;
}

.ai-feedback-body {
    font-size: 15px;
    line-height: 1.65;
}

.ai-feedback-body p {
    margin: 0 0 12px;
}

.ai-feedback-body p:last-child,
.ai-feedback-body ul:last-child {
    margin-bottom: 0;
}

.ai-feedback-body ul {
    margin: 0 0 12px;
    padding-left: 22px;
}

.ai-feedback-body li {
    margin: 5px 0;
}

.thankyou-feedback {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.thankyou-feedback-label {
    font-weight: 600;
    font-size: 14px;
}

.rating-stars {
    display: flex;
    gap: 6px;
}

.rating-star {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--muted);
}

.rating-star svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.rating-star.is-selected {
    color: #f2b441;
}

.rating-indicator {
    font-size: 13px;
    color: var(--muted);
}

.feedback-text {
    width: 100%;
    max-width: 520px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--field-bg);
    color: var(--ink);
    font-family: inherit;
}

.thankyou-status {
    margin-top: 12px;
}

.thankyou-status.is-error {
    color: var(--danger);
}

.chat-intro {
    text-align: center;
    padding: 28px 20px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--field-bg);
    margin-bottom: 16px;
}

.chat-intro h2 {
    margin: 0 0 12px;
    font-size: 24px;
}

.roleplay-title {
    text-align: center;
}

.chat-intro p {
    margin: 0 0 16px;
    color: var(--muted);
}

.chatbot-avatar {
    width: 140px;
    height: 140px;
    border-radius: 22px;
    object-fit: cover;
    margin-bottom: 12px;
    border: 2px solid var(--border);
}

.chatbot-avatar-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.chatbot-avatar-small {
    width: 96px;
    height: 96px;
    border-radius: 18px;
    margin-bottom: 0;
}

/* Talking-avatar (3D head) — takes the place of the small static image
 * in-conversation when avatar_mode = 'talking'. */
.chatbot-avatar-wrap--talking {
    margin-bottom: 12px;
}

.talking-avatar-frame {
    position: relative;
    width: 300px;
    max-width: 100%;
    aspect-ratio: 1 / 1.1;
    border-radius: 22px;
    border: 2px solid var(--border);
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 236, 205, 0.35), rgba(255, 236, 205, 0.10));
    box-shadow: var(--shadow);
}

.talking-avatar-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.talking-avatar-fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 1;
    transition: opacity 350ms ease;
}

.talking-avatar-fallback.is-visible {
    opacity: 1;
}

.avatar-mode-field {
    display: grid;
    gap: 6px;
}

.rich-text {
    text-align: left;
    margin: 0 auto 16px;
    width: 90%;
    max-width: 90%;
    line-height: 1.6;
}

.rich-text ul,
.rich-text ol {
    margin: 0.5rem 0 0.5rem 1.25rem;
}

.rich-text a {
    color: var(--accent-strong);
}

.avatar-field {
    display: grid;
    gap: 10px;
}

.avatar-preview img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(31, 30, 27, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
}

.modal {
    background: var(--card);
    border-radius: 18px;
    border: 1px solid var(--border);
    padding: 20px;
    width: min(560px, 92vw);
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
}
.prompt-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 12px;
    align-items: center;
}

.prompt-row textarea {
    height: 48px;
    min-height: 48px;
    resize: none;
}

.prompt-row .btn,
.prompt-row .mic-button {
    height: 48px;
}

.mic-button {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: transparent;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mic-button svg {
    width: 100%;
    height: 100%;
    fill: var(--ink);
}

.mic-button.is-recording {
    border-color: var(--danger);
    box-shadow: 0 0 0 6px rgba(184, 59, 47, 0.15);
    animation: pulse-record 1s infinite;
}

.mic-button.is-recording svg {
    fill: var(--danger);
}

@keyframes pulse-record {
    0% {
        box-shadow: 0 0 0 0 rgba(184, 59, 47, 0.3);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(184, 59, 47, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(184, 59, 47, 0);
    }
}

.roleplay-status {
    font-size: 14px;
    color: var(--muted);
}

.chat-loading {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
}

.chat-loading-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: chat-spin 0.8s linear infinite;
}

.chat-loading-text {
    font-size: 14px;
    color: var(--muted);
}

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

.audio-list {
    display: grid;
    gap: 12px;
}

@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .prompt-row {
        grid-template-columns: 1fr;
    }

    .talking-avatar-frame {
        width: 220px;
    }
}

/* Custom-avatar (Avatar Studio) picker on the teacher create/edit forms.
   Distinct from .studio-* rules further down, which style the modal that
   avatar-studio.js injects. */
.studio-picker {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.studio-picker-status {
    font-size: 13px;
    color: var(--muted);
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--field-bg);
    border: 1px solid var(--border);
}

.studio-picker-status.is-error {
    color: var(--danger);
    border-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 8%, var(--field-bg));
}

.studio-picker-preview {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--badge-bg);
    color: var(--badge-ink);
    font-size: 13px;
    max-width: fit-content;
}

.studio-picker-preview[hidden] {
    display: none;
}

.studio-picker-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.studio-picker-preview-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

.studio-picker-preview-file {
    color: var(--muted);
    font-family: monospace;
    font-size: 12px;
}

/* Avatar Studio — in-app 3D avatar creator. The host container
   [data-avatar-studio] renders its own backdrop + modal in
   avatar-studio.js so styling stays self-contained. */
.studio-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--ink) 55%, transparent);
    z-index: 1200;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.studio-modal {
    width: min(1200px, 96vw);
    height: min(820px, 92vh);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.studio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.studio-header h3 {
    margin: 0;
    color: var(--accent-strong);
}

.studio-body {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
    gap: 18px;
    padding: 18px;
    flex: 1;
    min-height: 0;
}

.studio-preview {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--field-bg);
    display: flex;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
}

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

.studio-status {
    position: absolute;
    left: 14px;
    bottom: 12px;
    font-size: 13px;
    color: var(--muted);
    background: color-mix(in srgb, var(--card) 78%, transparent);
    padding: 4px 10px;
    border-radius: 999px;
}

.studio-controls {
    overflow-y: auto;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.studio-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.studio-section-title {
    font-weight: 600;
    color: var(--accent-strong);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.studio-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.studio-head-btn {
    padding: 8px 10px;
    font: inherit;
    border: 1px solid var(--border);
    background: var(--field-bg);
    color: var(--ink);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
}

.studio-head-btn.is-active {
    border-color: var(--accent);
    background: var(--badge-bg);
    color: var(--badge-ink);
}

.studio-swatches {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.studio-swatch {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0;
}

.studio-color-input {
    width: 40px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.studio-parts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.studio-part-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--field-bg);
    font-size: 13px;
}

.studio-actions {
    flex-direction: row;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: auto;
}

.studio-notice {
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--field-bg);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
}

.studio-notice.is-error {
    color: var(--danger);
    border-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 8%, var(--field-bg));
}

.studio-muted {
    font-size: 13px;
    color: var(--muted);
}

.studio-error {
    padding: 16px;
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 8%, var(--field-bg));
    border-radius: 12px;
}

@media (max-width: 900px) {
    .studio-body {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(280px, 1fr) auto;
    }
}

/* Parts picker — one section per category (hair / glasses / etc.) */
.studio-part-cat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
    border-top: 1px dashed var(--border);
}
.studio-part-cat:first-child {
    border-top: 0;
    padding-top: 0;
}
.studio-part-cat-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--accent-strong);
}
.studio-part-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 8px;
}
.studio-part-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--field-bg);
    cursor: pointer;
    text-align: center;
    font: inherit;
    color: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.studio-part-tile:hover {
    border-color: var(--accent);
}
.studio-part-tile.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}
.studio-part-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 8%, var(--field-bg));
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.studio-part-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.studio-part-thumb.is-glyph {
    font-weight: 700;
    color: var(--accent-strong);
    font-size: 20px;
}
.studio-part-label {
    font-size: 11px;
    line-height: 1.2;
    color: var(--muted);
    max-width: 76px;
    word-wrap: break-word;
}

/* Face-shape sliders */
.studio-shape-sliders {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0 8px;
}
.studio-shape-row {
    display: grid;
    grid-template-columns: 100px 1fr 40px;
    align-items: center;
    gap: 8px;
}
.studio-shape-name {
    font-size: 12px;
    color: var(--muted);
}
.studio-shape-row input[type=range] {
    width: 100%;
    accent-color: var(--accent);
}
.studio-shape-readout {
    font-size: 11px;
    color: var(--muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}


/* --- Avatar Studio: camera controls, colour reset + honest disabled state ---
   Added with the Studio UI rewrite (assets/avatar-studio.js). The canvas now
   carries OrbitControls, so it must swallow touch gestures rather than let the
   page scroll under the drag. */
.studio-modal-backdrop[hidden] {
    display: none !important;
}

.studio-canvas {
    touch-action: none;
    cursor: grab;
}
.studio-canvas:active {
    cursor: grabbing;
}

.studio-viewhint {
    position: absolute;
    right: 12px;
    bottom: 12px;
    font-size: 11px;
    color: var(--muted);
    background: color-mix(in srgb, var(--card) 78%, transparent);
    padding: 4px 10px;
    border-radius: 999px;
    pointer-events: none;
}

.studio-recentre {
    position: absolute;
    right: 12px;
    top: 12px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--card) 88%, transparent);
    color: var(--ink);
    cursor: pointer;
}
.studio-recentre:hover {
    border-color: var(--accent);
}

.studio-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
}

.studio-colour-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.studio-reset {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.studio-reset:hover {
    color: var(--ink);
    border-color: var(--accent);
}

.studio-swatch.is-active {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* A control with nothing to drive says so rather than silently no-oping. */
.studio-section.is-disabled .studio-swatches,
.studio-section.is-disabled .studio-colour-row {
    opacity: 0.45;
    pointer-events: none;
}

.studio-header .modal-close {
    color: var(--ink);
}

/* .studio-section sets display:flex, which beats the UA's [hidden]{display:none}
   — the Face shape block must actually disappear on heads with no shaped GLB. */
.studio-section[hidden],
.studio-notice[hidden] {
    display: none !important;
}
