/* ============================================================
   MaestraAI — Design System "Aurora"
   Tema chiaro/scuro via [data-theme] sull'elemento <html>.
   ============================================================ */

:root {
    --font: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --radius: 22px;
    --radius-sm: 14px;

    --brand-1: #7c5cf0;
    --brand-2: #4f9cf7;
    --brand-3: #f26daa;
    --grad-brand: linear-gradient(120deg, var(--brand-1) 0%, var(--brand-2) 100%);
    --grad-warm: linear-gradient(120deg, var(--brand-3) 0%, var(--brand-1) 100%);

    --bg: #f3f1fc;
    --ink: #262045;
    --ink-soft: #6f6a92;
    --surface: rgba(255, 255, 255, 0.62);
    --surface-strong: rgba(255, 255, 255, 0.88);
    --stroke: rgba(124, 92, 240, 0.14);
    --shadow: 0 24px 60px -28px rgba(84, 62, 190, 0.35);
    --blob-opacity: 0.55;
}

[data-theme="dark"] {
    /* Contrasto alzato: testo quasi bianco e secondario più chiaro (WCAG AA su tutte le superfici) */
    --bg: #0f0e20;
    --ink: #f7f5ff;
    --ink-soft: #c3bde6;
    --brand-1: #a68dff;
    --brand-2: #74b6ff;
    --brand-3: #ff92c2;
    --surface: rgba(40, 36, 78, 0.68);
    --surface-strong: rgba(48, 43, 92, 0.94);
    --stroke: rgba(255, 255, 255, 0.16);
    --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.6);
    --blob-opacity: 0.32;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    /* Fa adattare al tema anche i controlli nativi: tendine select, scrollbar, caret */
    color-scheme: light;
}

[data-theme="dark"] { color-scheme: dark; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;   /* fallback per i browser integrati delle lavagne */
    min-height: 100dvh;
    transition: background 0.4s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
}

/* Touch delle lavagne interattive (SMART Board, Promethean) e dei tablet:
   niente ritardo di 300 ms, niente zoom da doppio tocco, niente riquadro grigio. */
button, a, .lim-option, .lim-blank, .regia-key, .regia-team, select, input, textarea {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

::selection { background: color-mix(in srgb, var(--brand-1) 30%, transparent); }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--brand-2) 65%, transparent);
    outline-offset: 2px;
    border-radius: 6px;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Sfondo animato (aurora + blob) ---------- */

.app-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background:
        radial-gradient(60% 50% at 8% 0%, color-mix(in srgb, var(--brand-1) 14%, transparent), transparent 70%),
        radial-gradient(50% 45% at 100% 20%, color-mix(in srgb, var(--brand-2) 13%, transparent), transparent 70%),
        radial-gradient(45% 45% at 40% 110%, color-mix(in srgb, var(--brand-3) 11%, transparent), transparent 70%),
        var(--bg);
    transition: background 0.4s ease;
}

.blob {
    position: absolute;
    width: 44vmax;
    height: 44vmax;
    border-radius: 50%;
    filter: blur(90px);
    opacity: var(--blob-opacity);
    animation: blob-float 26s ease-in-out infinite alternate;
}

.blob-1 { top: -18vmax; left: -12vmax; background: radial-gradient(circle, #a58bff, transparent 65%); }
.blob-2 { top: 4vmax; right: -16vmax; background: radial-gradient(circle, #6db4ff, transparent 65%); animation-delay: -8s; }
.blob-3 { bottom: -20vmax; left: 22vw; background: radial-gradient(circle, #ff9ecb, transparent 65%); animation-delay: -16s; }

@keyframes blob-float {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(5vmax, 4vmax, 0) scale(1.12); }
}

/* ---------- Utility ---------- */

.glass {
    background: var(--surface);
    backdrop-filter: blur(18px) saturate(1.35);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.32rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--brand-1) 12%, transparent);
    color: color-mix(in srgb, var(--brand-1) 80%, var(--ink));
    border: 1px solid color-mix(in srgb, var(--brand-1) 22%, transparent);
    white-space: nowrap;
}

.chip-phase {
    background: color-mix(in srgb, var(--brand-3) 13%, transparent);
    color: color-mix(in srgb, var(--brand-3) 75%, var(--ink));
    border-color: color-mix(in srgb, var(--brand-3) 25%, transparent);
}

.reveal { animation: reveal 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.reveal:nth-of-type(2) { animation-delay: 0.08s; }
.reveal:nth-of-type(3) { animation-delay: 0.16s; }
.reveal:nth-of-type(4) { animation-delay: 0.24s; }

@keyframes reveal {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Struttura ---------- */

.app-shell {
    display: flex;
    gap: 1.4rem;
    padding: 1.4rem;
    max-width: 1500px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    min-width: 0;
}

.page {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    padding-bottom: 2rem;
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: 258px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.1rem;
    position: sticky;
    top: 1.4rem;
    height: calc(100vh - 2.8rem);
    height: calc(100dvh - 2.8rem);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.4rem 0.6rem 1.4rem;
    font-size: 1.18rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.brand-logo {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 15px;
    font-size: 1.5rem;
    background: var(--grad-brand);
    box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--brand-1) 70%, transparent);
}

/* Avatar di Teacher Annalisa: sidebar e pagina di accesso */
.brand-avatar {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid transparent;
    background: var(--grad-brand) border-box;
    box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s ease;
}

.brand:hover .brand-avatar { transform: scale(1.06) rotate(-3deg); }

.brand-avatar-lg {
    width: 76px;
    height: 76px;
    border-width: 3px;
}

@supports not (background: linear-gradient(red, red) border-box) {
    .brand-avatar { border-color: #7c5cf0; }
}

.brand-ai {
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav { display: flex; flex-direction: column; gap: 0.35rem; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.78rem 0.95rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--ink-soft);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover {
    background: color-mix(in srgb, var(--brand-1) 9%, transparent);
    color: var(--ink);
    transform: translateX(3px);
}

.nav-link.active {
    background: var(--grad-brand);
    color: #fff;
    box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--brand-1) 85%, transparent);
}

.nav-icon { font-size: 1.25rem; width: 1.6rem; text-align: center; }

.sidebar-footer { margin-top: auto; padding: 1rem 0.4rem 0.2rem; }

/* ---------- Topbar ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.4rem;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.topbar-actions { display: flex; align-items: center; gap: 0.8rem; }

.theme-toggle {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--stroke);
    background: var(--surface-strong);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover { transform: translateY(-2px) rotate(12deg); box-shadow: var(--shadow); }

.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }
[data-theme="dark"] .theme-icon-light { display: none; }

/* ---------- Hero ---------- */

.hero { padding: 1.2rem 0.4rem 0; }

.hero-title { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 800; }

.wave { display: inline-block; animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 70%; }

@keyframes wave {
    0%, 55%, 100% { transform: rotate(0); }
    60%, 75% { transform: rotate(18deg); }
    68%, 82% { transform: rotate(-10deg); }
}

.hero-sub {
    margin: 0.6rem 0 0;
    max-width: 46rem;
    font-size: 1.08rem;
    color: var(--ink-soft);
    line-height: 1.55;
}

.hero-link { display: inline-block; margin-top: 0.4rem; font-weight: 700; color: var(--brand-1); }
.hero-link:hover { text-decoration: underline; }

/* ---------- Bento grid ---------- */

.bento {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
    gap: 1.1rem;
}

.bento-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1.5rem 1.4rem;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.bento-tile::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: var(--grad-brand);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.bento-tile:hover { transform: translateY(-6px); box-shadow: 0 30px 60px -24px color-mix(in srgb, var(--brand-1) 45%, transparent); }
.bento-tile:hover::after { opacity: 1; }

.bento-emoji {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    font-size: 1.7rem;
    border-radius: 17px;
    background: color-mix(in srgb, var(--brand-1) 10%, transparent);
}

.bento-title { font-size: 1.22rem; }
.bento-desc { margin: 0; color: var(--ink-soft); font-size: 0.94rem; line-height: 1.5; flex: 1; }
.bento-tile .chip { align-self: flex-start; }

/* ---------- Materie ---------- */

.section-title { font-size: 1.25rem; padding: 0.2rem 0.4rem; }

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.7rem;
}

.subject-chip {
    --sc: #888;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 0.95rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.93rem;
    color: var(--ink);
    background: color-mix(in srgb, var(--sc) 12%, var(--surface-strong));
    border: 1px solid color-mix(in srgb, var(--sc) 30%, transparent);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: default;
}

/* In tema scuro i colori materia vanno schiariti per restare leggibili sul bordo/sfondo */
[data-theme="dark"] .subject-chip,
[data-theme="dark"] .lesson-card {
    background: color-mix(in srgb, var(--sc) 18%, var(--surface-strong));
    border-color: color-mix(in srgb, var(--sc) 55%, transparent);
}

.subject-chip:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 14px 28px -14px color-mix(in srgb, var(--sc) 60%, transparent);
}

.subject-icon { font-size: 1.2rem; }

/* ---------- Statistiche ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.1rem; }

.stat-tile { padding: 1.2rem 1.4rem; display: flex; flex-direction: column; gap: 0.2rem; }

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-label { color: var(--ink-soft); font-weight: 600; font-size: 0.9rem; }

/* ---------- Pagine "in arrivo" ---------- */

.coming {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
    padding: 3.5rem 2rem;
}

.coming-emoji { font-size: 3.6rem; animation: float-soft 3.5s ease-in-out infinite; }

@keyframes float-soft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.coming-title { font-size: 2rem; }
.coming-desc { margin: 0; max-width: 38rem; color: var(--ink-soft); line-height: 1.6; }
.coming-features { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; max-width: 44rem; }

/* ---------- Impostazioni: provider ---------- */

.page-head { padding: 0.6rem 0.4rem 0; display: flex; flex-direction: column; gap: 0.4rem; }
.page-head h1 { font-size: 2rem; }
.page-head p { margin: 0; color: var(--ink-soft); }

.provider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.1rem; }

.provider-card { padding: 1.4rem; display: flex; flex-direction: column; gap: 0.5rem; }
.provider-name { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 0.55rem; justify-content: space-between; }
.provider-meta { color: var(--ink-soft); font-size: 0.88rem; word-break: break-all; margin: 0; }

.badge-ok {
    background: color-mix(in srgb, #22b573 15%, transparent);
    color: #17915c;
    border-color: color-mix(in srgb, #22b573 30%, transparent);
}

.badge-warn {
    background: color-mix(in srgb, #f59e0b 15%, transparent);
    color: #b47408;
    border-color: color-mix(in srgb, #f59e0b 30%, transparent);
}

[data-theme="dark"] .badge-ok { color: #52d99a; }
[data-theme="dark"] .badge-warn { color: #f7bd58; }

.note { color: var(--ink-soft); font-size: 0.92rem; padding: 0 0.4rem; }

/* ---------- Form (default Blazor) ---------- */

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

/* ---------- Errori Blazor ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 0.9rem 1.4rem;
    border-radius: var(--radius-sm);
    background: #3b1f2b;
    color: #ffd9e2;
    box-shadow: var(--shadow);
    font-weight: 600;
}

#blazor-error-ui .reload { text-decoration: underline; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: 0.75rem; }

.blazor-error-boundary {
    padding: 1rem 1.4rem;
    border-radius: var(--radius-sm);
    background: #b32121;
    color: #fff;
}

.blazor-error-boundary::after { content: "Si è verificato un errore in questo componente."; }

/* ---------- Responsive: tablet e telefono ---------- */

@media (max-width: 900px) {
    .app-shell { flex-direction: column; padding: 1rem 1rem 6.2rem; }

    .sidebar {
        position: fixed;
        bottom: 0.8rem;
        left: 50%;
        transform: translateX(-50%);
        top: auto;
        width: min(96vw, 560px);
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 0.55rem 0.8rem;
        z-index: 100;
    }

    .brand { display: none; }
    .sidebar-footer { display: none; }

    .nav { flex-direction: row; width: 100%; justify-content: space-around; gap: 0.1rem; }
    .nav-label { display: none; }
    .nav-link { padding: 0.7rem 0.8rem; border-radius: 14px; }
    .nav-link:hover { transform: none; }
    .nav-icon { font-size: 1.45rem; width: auto; }

    .topbar { padding: 0.7rem 1rem; }
    .topbar-date { font-size: 0.9rem; }
    .hero-title { font-size: 1.8rem; }
}

@media (max-width: 520px) {
    .chip-year { display: none; }
    .subject-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ============================================================
   Fase 1 — Generatore, form e viste contenuto
   ============================================================ */

/* ---------- Controlli form ---------- */

.input {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--stroke);
    background: var(--surface-strong);
    color: var(--ink);
    font: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input:focus {
    outline: none;
    border-color: var(--brand-1);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-1) 18%, transparent);
}

.input::placeholder { color: var(--ink-soft); opacity: 0.85; }

.select { cursor: pointer; }

/* Le tendine native ereditano i colori del sistema: le forziamo sul tema dell'app */
.select option { background: var(--surface-strong); color: var(--ink); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.4rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.btn-primary {
    background: var(--grad-brand);
    color: #fff;
    box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--brand-1) 80%, transparent);
}

.btn-primary:not(:disabled):hover { transform: translateY(-2px); }

.btn-ghost {
    background: var(--surface-strong);
    border-color: var(--stroke);
    color: var(--ink);
}

.btn-ghost:not(:disabled):hover { transform: translateY(-2px); border-color: var(--brand-1); }

/* ---------- Wizard generatore ---------- */

.gen-form { padding: 1.6rem; display: flex; flex-direction: column; gap: 1.4rem; }

.field { display: flex; flex-direction: column; gap: 0.6rem; }

.field-label { font-weight: 700; font-size: 1.02rem; }

.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.6rem;
}

.option-btn { cursor: pointer; border: 1.5px solid transparent; font: inherit; text-align: left; }

.option-btn.selected {
    border-color: var(--brand-1);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-1) 20%, transparent);
}

.seg-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.seg-btn {
    padding: 0.6rem 1.05rem;
    border-radius: 999px;
    border: 1.5px solid var(--stroke);
    background: var(--surface-strong);
    color: var(--ink-soft);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s ease;
}

.seg-btn.selected {
    background: var(--grad-brand);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--brand-1) 80%, transparent);
}

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.7rem; }

.type-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
}

.type-emoji { font-size: 1.6rem; }
.type-name { font-weight: 800; }
.type-desc { color: var(--ink-soft); font-size: 0.85rem; }

.gen-options-row {
    display: grid;
    grid-template-columns: minmax(110px, 0.4fr) 1fr 1fr;
    gap: 1.2rem;
    align-items: start;
}

.btn-generate { font-size: 1.15rem; padding: 1rem 1.6rem; align-self: center; min-width: min(100%, 320px); }

/* ---------- Pannello caricamento ---------- */

.loading-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3.2rem 2rem;
    text-align: center;
}

.loading-emoji { font-size: 3.4rem; animation: loading-bounce 1.1s ease-in-out infinite; }

@keyframes loading-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-14px) scale(1.08); }
}

.loading-msg { margin: 0; font-size: 1.15rem; font-weight: 700; }

.loading-bar {
    width: min(100%, 340px);
    height: 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--brand-1) 14%, transparent);
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    width: 45%;
    border-radius: 999px;
    background: var(--grad-brand);
    animation: loading-slide 1.6s ease-in-out infinite;
}

@keyframes loading-slide {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(320%); }
}

.loading-hint { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }

/* ---------- Risultato ---------- */

.gen-result { padding: 1.6rem; display: flex; flex-direction: column; gap: 1.2rem; }

.gen-result-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }

.gen-result-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.gen-notes summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.gen-notes ul { margin: 0.5rem 0 0; color: var(--ink-soft); }

.gen-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; }

.gen-save-title { flex: 1; min-width: 220px; }

/* ---------- Viste contenuto (cv) ---------- */

.cv { display: flex; flex-direction: column; gap: 0.9rem; }

.cv-title { font-size: 1.45rem; }

.cv-instructions { margin: 0; font-weight: 600; color: var(--ink-soft); }

.cv-list { display: flex; flex-direction: column; gap: 1.1rem; margin: 0; padding-left: 1.3rem; }
div.cv-list { padding-left: 0; }

.cv-item { border-radius: var(--radius-sm); }

.cv-qtext { margin: 0 0 0.5rem; font-weight: 700; font-size: 1.05rem; }

.cv-exnum {
    display: inline-grid;
    place-items: center;
    width: 1.7rem;
    height: 1.7rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    background: var(--grad-brand);
    color: #fff;
    font-size: 0.9rem;
}

.cv-options { display: flex; flex-direction: column; gap: 0.4rem; }

.cv-option {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--stroke);
    background: var(--surface-strong);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.cv-letter {
    display: grid;
    place-items: center;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--brand-1) 12%, transparent);
    font-weight: 800;
    flex-shrink: 0;
}

.cv-correct {
    border-color: #22b573;
    background: color-mix(in srgb, #22b573 12%, var(--surface-strong));
}

.cv-correct .cv-letter { background: #22b573; color: #fff; }

.cv-explanation {
    margin: 0.5rem 0 0;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--brand-2) 10%, transparent);
    color: var(--ink);
    font-size: 0.95rem;
}

.cv-passage { line-height: 2.1; font-size: 1.08rem; margin: 0; }

.cv-reading p { margin: 0 0 0.7rem; line-height: 1.8; }

.cv-blank {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    min-width: 5.5rem;
    padding: 0 0.5rem;
    border-bottom: 2.5px solid var(--brand-1);
    font-weight: 700;
    color: var(--brand-1);
    white-space: pre;
}

.cv-blank-solved { color: #17915c; border-color: #22b573; white-space: normal; }

.cv-blank-num {
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    background: var(--brand-1);
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    align-self: center;
}

.cv-blank-solved .cv-blank-num { background: #22b573; }

.cv-wordbank {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--brand-3) 8%, transparent);
}

.cv-wordbank-label { font-weight: 700; }

.cv-answerkey { border-top: 1.5px dashed var(--stroke); padding-top: 0.8rem; }
.cv-key-row { margin: 0.2rem 0; color: var(--ink-soft); }

.cv-writelines {
    height: 3.2rem;
    border-radius: 6px;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 1.45rem,
        var(--stroke) 1.45rem,
        var(--stroke) calc(1.45rem + 1.5px)
    );
}

/* ---------- Impostazioni: righe chiave ---------- */

.key-row { display: flex; gap: 0.6rem; align-items: center; }
.key-input { flex: 1; min-width: 0; }

.key-msg { margin: 0; font-size: 0.9rem; font-weight: 600; }
.key-ok { color: #17915c; }
.key-err { color: #c93b5b; }
[data-theme="dark"] .key-ok { color: #52d99a; }
[data-theme="dark"] .key-err { color: #ff8aa5; }

/* ---------- Login ---------- */

.login-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: min(94vw, 420px);
    padding: 2.4rem 2.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    justify-content: center;
}

.login-brand-text { color: var(--ink); }

.login-sub { margin: 0; text-align: center; color: var(--ink-soft); }

.login-card form { display: flex; flex-direction: column; gap: 1rem; }

.login-remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink-soft);
    font-weight: 600;
    cursor: pointer;
}

.btn-login { width: 100%; font-size: 1.08rem; padding: 0.9rem; }

/* ---------- Utente / logout ---------- */

.user-chip { cursor: pointer; }
.user-chip:hover { filter: brightness(1.1); }

.logout-form { display: inline-flex; margin: 0; }

.btn-small { padding: 0.45rem 0.9rem; font-size: 0.88rem; }

/* ---------- Gestione utenti ---------- */

.users-new-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.7rem;
    align-items: center;
}

.users-list { padding: 0.6rem 1.4rem; }

.users-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.9rem 0;
    border-bottom: 1.5px solid var(--stroke);
    flex-wrap: wrap;
}

.users-row:last-child { border-bottom: none; }

.users-info { display: flex; flex-direction: column; }
.users-email { color: var(--ink-soft); font-size: 0.88rem; }
.users-actions { display: flex; align-items: center; gap: 0.6rem; }

.profile-card { max-width: 560px; }
.profile-sep { border: none; border-top: 1.5px dashed var(--stroke); margin: 0.4rem 0; }

@media (max-width: 900px) {
    .users-new-row { grid-template-columns: 1fr; }
}

/* ---------- Responsive del generatore ---------- */

@media (max-width: 900px) {
    .gen-options-row { grid-template-columns: 1fr; gap: 1rem; }
    .gen-actions { flex-direction: column; align-items: stretch; }
    .gen-save-title { min-width: 0; }
    .key-row { flex-wrap: wrap; }
}

/* ============================================================
   Fase 2 — Archivio, editor, stampa
   ============================================================ */

.archive-toolbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.7rem;
    padding: 0.9rem 1.1rem;
    align-items: center;
}

.archive-filter { min-width: 160px; }

.folders-bar { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }

.folder-new { display: inline-flex; gap: 0.4rem; align-items: center; }
.folder-new .input { width: 200px; padding: 0.55rem 0.85rem; }

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.1rem;
}

.lesson-card {
    --sc: #888;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1.3rem 1.3rem 1.1rem;
    border-top: 4px solid var(--sc);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.lesson-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 26px 50px -22px color-mix(in srgb, var(--sc) 55%, transparent);
}

.lesson-card-top { display: flex; justify-content: space-between; align-items: center; }
.lesson-icon { font-size: 1.7rem; }
.lesson-title { font-size: 1.08rem; margin: 0; }
.lesson-meta { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: 0.85rem; }
.lesson-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.chip-mini { font-size: 0.72rem; padding: 0.18rem 0.6rem; }

.back-link { color: var(--ink-soft); font-weight: 700; font-size: 0.9rem; }
.back-link:hover { color: var(--brand-1); }

.lesson-toolbar {
    display: flex;
    gap: 1rem;
    padding: 1.1rem 1.3rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.lesson-toolbar-field { flex: 1; min-width: 200px; }

.btn-danger { color: #c93b5b; border-color: color-mix(in srgb, #c93b5b 35%, transparent); }
.btn-danger:not(:disabled):hover { border-color: #c93b5b; }
[data-theme="dark"] .btn-danger { color: #ff8aa5; }

.confirm-box { padding: 1.2rem 1.4rem; display: flex; flex-direction: column; gap: 0.6rem; border: 1.5px solid color-mix(in srgb, #c93b5b 40%, transparent); }

/* ---------- Editor di rifinitura ---------- */

.editor { padding: 1.3rem; display: flex; flex-direction: column; gap: 1rem; background: color-mix(in srgb, var(--brand-2) 5%, var(--surface)); }

.editor-title { font-size: 1.15rem; }

.editor-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.9rem;
    border-radius: var(--radius-sm);
    border: 1.5px dashed var(--stroke);
}

.editor-block-head { display: flex; justify-content: space-between; align-items: center; }

.editor-option { display: flex; gap: 0.5rem; align-items: center; }

.editor-radio {
    flex-shrink: 0;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    border: 2px solid var(--stroke);
    background: var(--surface-strong);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
}

.editor-radio.checked { background: #22b573; border-color: #22b573; color: #fff; }

.editor-textarea { min-height: 90px; resize: vertical; font-family: inherit; }
.editor-textarea-tall { min-height: 160px; }

@media (max-width: 900px) {
    .archive-toolbar { grid-template-columns: 1fr; }
    .lesson-toolbar { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   Fase 3 — Modalità LIM: schermo intero, alto contrasto, touch
   ============================================================ */

.lim-stage {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, #141233 0%, #1d1a4a 55%, #241c5e 100%);
    color: #f4f2ff;
    padding: 1.2rem 1.6rem 2rem;
    gap: 1.2rem;
}

.lim-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.lim-header-title { flex: 1; font-weight: 800; font-size: 1.15rem; opacity: 0.9; }
.lim-header-tools { display: flex; gap: 0.5rem; }

.lim-content { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 1150px; width: 100%; margin: 0 auto; }


.lim-center { min-height: 70dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; }

.lim-big { font-size: clamp(1.5rem, 3.5vw, 2.3rem); font-weight: 800; text-align: center; margin: 0; }

.lim-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    min-height: 52px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.08);
    color: #f4f2ff;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, background 0.15s ease;
}

.lim-btn:not(:disabled):hover { background: rgba(255, 255, 255, 0.16); transform: translateY(-2px); }
.lim-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.lim-btn-primary { background: var(--grad-brand); border-color: transparent; }
.lim-btn-small { min-height: 44px; padding: 0.5rem 1rem; font-size: 0.95rem; }

.lim-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.6rem; }
.lim-counter { font-weight: 800; opacity: 0.75; font-size: 1.1rem; }

.lim-progress { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin-bottom: 1rem; }
.lim-progress-fill { height: 100%; border-radius: 999px; background: var(--grad-brand); transition: width 0.4s ease; }

/* ---------- Quiz live ---------- */

.lim-score-row { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.2rem; }

.lim-team {
    --tc: #4f9cf7;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tc) 25%, transparent);
    border: 2px solid var(--tc);
    font-weight: 800;
}

.lim-team-score { font-size: 1.35rem; min-width: 1.6rem; text-align: center; }
.lim-team-score.pop { animation: score-pop 0.45s ease; }

@keyframes score-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.7); }
    100% { transform: scale(1); }
}

.lim-team-plus {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--tc);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.lim-team-plus:hover { transform: scale(1.12); }

.lim-question-box { animation: lim-slide 0.45s cubic-bezier(0.2, 0.7, 0.2, 1); }

@keyframes lim-slide {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: none; }
}

.lim-question { font-size: clamp(1.6rem, 3.2vw, 2.4rem); font-weight: 800; line-height: 1.35; margin: 0 0 1.4rem; }

.lim-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0.9rem; }

.lim-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.3rem;
    min-height: 68px;
    border-radius: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.07);
    color: #f4f2ff;
    font: inherit;
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lim-option:hover { background: rgba(255, 255, 255, 0.14); }

.lim-option-letter {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    font-weight: 800;
    font-size: 1.2rem;
}

.lim-option.selected { border-color: #6db4ff; background: rgba(109, 180, 255, 0.2); }
.lim-option.correct { border-color: #35e39b; background: rgba(53, 227, 155, 0.22); animation: correct-glow 0.7s ease; }
.lim-option.wrong { border-color: #ff7d9c; background: rgba(255, 125, 156, 0.16); opacity: 0.85; }
.lim-option-check { margin-left: auto; font-size: 1.6rem; color: #35e39b; }

@keyframes correct-glow {
    0% { box-shadow: 0 0 0 0 rgba(53, 227, 155, 0.7); }
    100% { box-shadow: 0 0 0 26px rgba(53, 227, 155, 0); }
}

.lim-explain {
    margin-top: 1.3rem;
    padding: 1rem 1.3rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
    font-size: clamp(1.05rem, 1.8vw, 1.35rem);
    line-height: 1.5;
    animation: lim-slide 0.4s ease;
}

.lim-explain-happy { background: rgba(53, 227, 155, 0.15); }

.lim-celebrate { display: inline-block; font-size: 1.7rem; margin-right: 0.5rem; animation: celebrate 0.9s ease; }

@keyframes celebrate {
    0% { transform: scale(0) rotate(-40deg); }
    60% { transform: scale(1.6) rotate(15deg); }
    100% { transform: scale(1) rotate(0); }
}

/* ---------- Cloze live ---------- */

.lim-instructions { font-size: 1.15rem; opacity: 0.85; margin: 0 0 1rem; }

.lim-wordbank { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.4rem; }

.lim-word {
    padding: 0.45rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    font-weight: 700;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.lim-word.used { opacity: 0.35; text-decoration: line-through; }

.lim-cloze-text { font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 2.2; margin: 0; }

.lim-blank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    min-height: 48px;
    margin: 0 0.3rem;
    padding: 0.2rem 0.9rem;
    border-radius: 12px;
    border: 2.5px dashed rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.06);
    color: inherit;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.2s ease;
}

.lim-blank:hover { background: rgba(255, 255, 255, 0.14); }
.lim-blank.open { border-style: solid; border-color: #35e39b; background: rgba(53, 227, 155, 0.18); color: #7dffc8; animation: correct-glow 0.6s ease; }

.lim-blank-num {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 1rem;
}

/* ---------- Lettura e scheda live ---------- */

.lim-passage { font-size: clamp(1.35rem, 2.4vw, 1.9rem); line-height: 1.9; }
.lim-passage p { margin: 0 0 1.1rem; }

.lim-exnum {
    display: inline-grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    margin-right: 0.7rem;
    border-radius: 50%;
    background: var(--grad-brand);
    color: #fff;
    font-size: 1.3rem;
}

/* ---------- Overlay strumenti (timer, ruota, dado) ---------- */

.lim-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    background: rgba(10, 8, 30, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: reveal 0.25s ease;
}

.lim-modal {
    position: relative;
    width: min(94vw, 560px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    padding: 2.2rem;
    border-radius: 26px;
    background: #221e50;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.8);
    color: #f4f2ff;
}

.lim-modal-title { font-size: 1.5rem; margin: 0; }
.lim-modal-emoji { font-size: 4rem; animation: celebrate 0.9s ease; }

.lim-modal-close {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #f4f2ff;
    font-size: 1.1rem;
    cursor: pointer;
}

.lim-tool-row { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; }

.lim-timer-display {
    font-size: clamp(3.5rem, 12vw, 6rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.lim-timer-warn { color: #ffb84d; animation: timer-pulse 1s ease infinite; }
.lim-timer-done { color: #ff7d9c; animation: timer-pulse 0.5s ease infinite; }

@keyframes timer-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.lim-wheel-display {
    min-height: 90px;
    display: grid;
    place-items: center;
    font-size: clamp(2rem, 6vw, 3.2rem);
    font-weight: 800;
    text-align: center;
}

.lim-wheel-display.winner { color: #7dffc8; animation: celebrate 0.8s ease; }

.lim-dice-display { font-size: clamp(6rem, 18vw, 9rem); line-height: 1; }
.lim-dice-display.rolling { animation: dice-roll 0.3s linear infinite; }

@keyframes dice-roll {
    0% { transform: rotate(-12deg) scale(0.95); }
    50% { transform: rotate(12deg) scale(1.05); }
    100% { transform: rotate(-12deg) scale(0.95); }
}

.lim-textarea {
    width: 100%;
    min-height: 200px;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #f4f2ff;
    font: inherit;
    font-size: 1.1rem;
    resize: vertical;
}

.lim-note { margin: 0; opacity: 0.75; font-size: 1rem; text-align: center; }

/* ---------- Pagina Guida (About) ---------- */

.about-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.2rem; }

.about-card { padding: 1.6rem; display: flex; flex-direction: column; gap: 0.7rem; }

.about-list { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.45rem; color: var(--ink-soft); line-height: 1.5; }
.about-list strong { color: var(--ink); }
.about-list .chip { display: inline-flex; }

/* ---------- Dettato vocale ---------- */

.lim-dictation-counter { font-size: 1.3rem; opacity: 0.8; margin: 0 0 1rem; text-align: center; }

.lim-dictation-display {
    min-height: 180px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.15);
    padding: 1.4rem;
    transition: all 0.3s ease;
}

.lim-dictation-display.speaking { border-color: #6db4ff; box-shadow: 0 0 40px -8px rgba(109, 180, 255, 0.6); }

.lim-dictation-ear { font-size: 4.5rem; animation: float-soft 2.6s ease-in-out infinite; }

.lim-dictation-text { font-size: clamp(1.5rem, 3vw, 2.3rem); font-weight: 700; line-height: 1.6; text-align: center; margin: 0; }

/* ---------- Regia: codice sulla LIM ---------- */

.lim-regia-code {
    font-size: clamp(3.2rem, 10vw, 5rem);
    font-weight: 800;
    letter-spacing: 0.35em;
    padding-left: 0.35em;
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Regia: telecomando (iPad/telefono) ---------- */

.regia-join { align-items: center; }

.regia-code-input {
    max-width: 260px;
    text-align: center;
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 0.4em;
}

.regia-position { font-size: 1.15rem; font-weight: 700; color: var(--brand-1); }

.regia-pad {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 0.8rem;
    padding: 1rem;
}

.regia-key {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 110px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--stroke);
    background: var(--surface-strong);
    color: var(--ink);
    font: inherit;
    font-size: 2rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
}

.regia-key span { font-size: 0.95rem; }
.regia-key:active { transform: scale(0.94); }

.regia-key-main {
    background: var(--grad-brand);
    color: #fff;
    border-color: transparent;
}

.regia-teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; padding: 1rem; }

.regia-team {
    --tc: #4f9cf7;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.9rem;
    border-radius: var(--radius-sm);
    border: 2.5px solid var(--tc);
    background: color-mix(in srgb, var(--tc) 12%, var(--surface-strong));
    color: var(--ink);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.regia-team:active { transform: scale(0.94); }
.regia-team-score { font-size: 1.9rem; }
.regia-team-plus { font-size: 0.9rem; color: color-mix(in srgb, var(--tc) 80%, var(--ink)); }

.regia-tools { display: flex; flex-wrap: wrap; gap: 0.6rem; padding: 1rem; }

/* Schermi grandi (LIM, Smartboard, monitor touch da 65-86"): sfruttiamo la larghezza
   e ingrandiamo tutto, così si legge anche dall'ultimo banco.
   NOTA: questo blocco deve restare DOPO le regole base .lim-*, altrimenti viene sovrascritto. */
@media (min-width: 1500px) {
    .lim-content { max-width: 1600px; }
    /* Massimo 2 colonne di risposte: con 3 si legge a zig-zag */
    .lim-options { grid-template-columns: repeat(2, 1fr); }
    .lim-question { font-size: clamp(2.2rem, 2.9vw, 3.2rem); }
    .lim-option { font-size: clamp(1.5rem, 1.9vw, 2.1rem); min-height: 92px; padding: 1.3rem 1.6rem; }
    .lim-option-letter { width: 60px; height: 60px; font-size: 1.6rem; }
    .lim-explain { font-size: clamp(1.4rem, 1.7vw, 1.9rem); }
    .lim-cloze-text { font-size: clamp(2rem, 2.5vw, 2.8rem); }
    .lim-passage { font-size: clamp(1.8rem, 2.2vw, 2.5rem); }
    .lim-dictation-text { font-size: clamp(2.1rem, 2.7vw, 3rem); }
    .lim-word { font-size: 1.45rem; padding: 0.6rem 1.3rem; }
    .lim-btn { font-size: 1.25rem; min-height: 64px; padding: 1rem 1.8rem; }
    .lim-team { font-size: 1.25rem; }
    .lim-team-score { font-size: 1.8rem; }
    .lim-counter { font-size: 1.4rem; }
    .lim-instructions { font-size: 1.5rem; }
}

@media (max-width: 700px) {
    .lim-stage { padding: 0.9rem 0.9rem 1.4rem; }
    .lim-header-title { order: 3; width: 100%; }
}

/* ---------- Compatibilità lavagne interattive con browser datati ----------
   I display SMART/Promethean meno recenti non supportano color-mix():
   forniamo colori pieni equivalenti per gli elementi essenziali. */

@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .chip { background: rgba(124, 92, 240, 0.14); color: #6a4fd8; border-color: rgba(124, 92, 240, 0.3); }
    [data-theme="dark"] .chip { color: #cdc4ff; }
    .chip-phase { background: rgba(242, 109, 170, 0.15); color: #d54f8c; border-color: rgba(242, 109, 170, 0.3); }
    [data-theme="dark"] .chip-phase { color: #ffb9d5; }
    .badge-ok { background: rgba(34, 181, 115, 0.15); color: #17915c; }
    .badge-warn { background: rgba(245, 158, 11, 0.15); color: #b47408; }
    .subject-chip, .lesson-card { background: var(--surface-strong); border-color: var(--sc); }
    .bento-emoji, .cv-letter { background: rgba(124, 92, 240, 0.14); }
    .cv-correct { background: rgba(34, 181, 115, 0.14); }
    .cv-explanation { background: rgba(79, 156, 247, 0.12); }
    .cv-wordbank { background: rgba(242, 109, 170, 0.1); }
    .editor { background: var(--surface); }
    .regia-team { background: var(--surface-strong); }
    .lim-team { background: rgba(255, 255, 255, 0.12); }
    .loading-bar { background: rgba(124, 92, 240, 0.16); }
    :focus-visible { outline-color: #4f9cf7; }
    ::selection { background: rgba(124, 92, 240, 0.35); }
}

/* ---------- Accessibilità: riduzione movimento ---------- */

@media (prefers-reduced-motion: reduce) {
    .blob, .wave, .coming-emoji, .reveal, .loading-emoji, .loading-bar-fill,
    .lim-question-box, .lim-celebrate, .lim-timer-warn, .lim-timer-done,
    .lim-dice-display.rolling, .lim-modal-emoji { animation: none !important; }
    * { transition-duration: 0.01ms !important; }
}
