/* One mobile design contract. Components consume these roles rather than
   assigning their own text scale or palette. Desktop/auth/admin never opt in. */
.student-mobile-brand,
.student-font-toggle,
.student-display-controls,
.student-learning-notice {
    display: none;
}

@media (max-width:768px),
(max-height:500px) and (pointer:coarse) {
    body.student-mobile {
        --font-caption: 14px;
        --font-note: 15px;
        --font-control: 16px;
        --font-body: 18px;
        --font-subtitle: 20px;
        --font-title: 24px;
        --font-display: 32px;
        --font-score: 42px;
        --touch-size: 44px;
        --student-space: 16px;
        --student-card-radius: 16px;
        --student-bg: #0b1428;
        --student-surface: #132139;
        --student-surface-raised: #1b304b;
        --student-surface2: #1b304b;
        --student-ink: #edf3ff;
        --student-muted: #a5b6ce;
        --student-line: #25364f;
        --student-accent: #8ab6fb;
        --student-action: #4d8ef3;
        --student-action-ink: #fff;
        --student-button: linear-gradient(110deg, #4d8ef3, #326de0);
        --student-button-ink: #fff;
        --student-accent-surface: #172e50;
        --student-success: #75c7ad;
        --student-danger: #eab58d;
        --student-warning: #e9ce98;
        --student-reading-bg: var(--student-bg);
        --student-reading-surface: var(--student-surface);
        --student-reading-ink: var(--student-ink);
        --student-reading-muted: var(--student-muted);
        --student-reading-line: var(--student-line);
        --student-reading-accent: var(--student-accent);
        --student-reading-accent-surface: var(--student-accent-surface);
        --student-reading-success: var(--student-success);
        --student-reading-success-surface: #193a35;
        --student-reading-danger: var(--student-danger);
        --student-reading-danger-surface: #3c2d30;
        --student-reading-accent-soft: var(--student-reading-accent-surface);
        --student-reading-correct: var(--student-reading-success);
        --student-reading-correct-soft: var(--student-reading-success-surface);
        --student-reading-wrong: var(--student-reading-danger);
        --student-reading-wrong-soft: var(--student-reading-danger-surface);
        color-scheme: dark;
        background: var(--student-bg);
        color: var(--student-ink);
        font-size: var(--font-body);
        line-height: 1.65;
    }

    body.student-mobile[data-student-theme="light"] {
        --student-bg: #f4f7fc;
        --student-surface: #fff;
        --student-surface-raised: #edf4ff;
        --student-surface2: #edf4ff;
        --student-ink: #1b2d47;
        --student-muted: #64748b;
        --student-line: #e1e8f2;
        --student-accent: #376fca;
        --student-accent-surface: #ecf3ff;
        --student-success: #2b7c65;
        --student-danger: #ae6238;
        --student-warning: #805e20;
        --student-reading-success-surface: #e9f3ef;
        --student-reading-danger-surface: #fff1eb;
        color-scheme: light;
    }

    body.student-mobile[data-student-font="small"] {
        --font-caption: 12px;
        --font-note: 13px;
        --font-control: 14px;
        --font-body: 16px;
        --font-subtitle: 18px;
        --font-title: 21px;
        --font-display: 28px;
        --font-score: 36px;
        --student-space: 12px;
        --student-card-radius: 12px;
    }

    body.student-mobile .navbar {
        position: static;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        padding: 16px;
        border: 0;
        background: var(--student-bg);
        color: var(--student-ink);
        box-shadow: none;
        backdrop-filter: none;
    }

    body.student-mobile .nav-brand {
        display: flex;
        flex: 1 1 128px;
        min-width: 0;
        gap: 10px;
        background: none;
        color: var(--student-ink);
        -webkit-text-fill-color: currentColor;
        font-size: var(--font-subtitle);
        font-weight: 700;
    }

    body.student-mobile .nav-brand .logo-icon {
        width: 44px;
        height: 44px;
        object-fit: contain;
        border-radius: 12px;
        background: #fff;
    }

    body.student-mobile .student-mobile-brand {
        display: inline;
    }

    body.student-mobile .student-desktop-brand,
    body.student-mobile .navbar .user-center-entry,
    body.student-mobile .navbar .nav-links {
        display: none;
    }

    body.student-mobile .nav-user {
        display: flex;
        gap: 8px;
        width: auto;
        margin: 0;
        flex: 0 0 auto;
    }

    body.student-mobile .student-display-controls {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex: 0 0 auto;
        gap: 8px;
        max-width: 100%;
    }

    body.student-mobile .student-overlay-display-controls {
        flex-wrap: wrap;
        margin: 0 0 16px;
    }

    body.student-mobile :is(.student-theme-toggle, .student-font-toggle) {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        width: auto;
        min-height: 44px;
        min-width: 64px;
        padding: 8px 10px;
        margin: 0;
        border: 1px solid var(--student-line);
        border-radius: 12px;
        background: var(--student-surface);
        color: var(--student-accent);
        font-size: 14px;
        font-weight: 500;
        line-height: 1.3;
        white-space: nowrap;
        cursor: pointer;
    }

    body.student-mobile .student-font-toggle {
        min-width: 84px;
    }

    body.student-mobile .student-font-toggle>span[aria-hidden] {
        display: none;
    }

    body.student-mobile :is(button, a, input, select, summary):focus-visible {
        outline: 2px solid var(--student-accent);
        outline-offset: 3px;
    }

    body.student-mobile .student-admin-entry {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 48px;
        padding: 10px;
        border: 1px solid var(--student-line);
        border-radius: 12px;
        background: var(--student-surface);
        color: var(--student-ink);
        text-decoration: none;
        font-size: var(--font-control);
    }

    body.student-mobile .student-admin-entry>span {
        flex: 1;
    }

    body.student-mobile .user-center-entry,
    body.student-mobile .logout-link {
        color: var(--student-muted);
        background: transparent;
        border-color: var(--student-line);
    }

    body.student-mobile :is(.ambient-light, .ambient-light-2) {
        display: none;
    }

    body.student-mobile .ui-feedback-dialog__panel {
        background: var(--student-surface);
        color: var(--student-ink);
        border-color: var(--student-line);
    }

    body.student-mobile :is(.ui-feedback-dialog__message, .ui-feedback-dialog__label) {
        color: var(--student-muted);
        font-size: var(--font-control);
    }

    body.student-mobile .ui-feedback-dialog__input {
        color: var(--student-ink);
        background: var(--student-bg);
        border-color: var(--student-line);
        font-size: 16px;
    }

    body.student-mobile .ui-feedback-dialog__close {
        color: var(--student-muted);
        background: var(--student-surface-raised);
    }

    body.student-mobile .student-learning-notice {
        display: block;
        color: var(--student-muted);
        font-size: var(--font-note);
        line-height: 1.75;
        margin: 20px 0 0;
        overflow-wrap: anywhere;
    }
}

@media (min-width:769px) and (min-height:501px),
(min-width:769px) and (pointer:fine) {

    .student-theme-toggle,
    .student-font-toggle {
        display: none;
    }
}
