/* Only the active mobile workspace panel is exposed. Panels keep their live DOM. */
.workspace-pane-navigation { display: none; }
.workspace-pane-navigation [role="tab"] {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    min-width: 0; min-height: 44px; padding: 8px 12px;
    color: var(--quiet); background: transparent; border: 1px solid transparent;
    border-radius: 7px; font: 600 13px/1.35 var(--body, Inter, sans-serif);
    box-shadow: none; white-space: nowrap;
}
.workspace-pane-navigation [role="tab"] .icon { width: 17px; height: 17px; flex: none; }
.workspace-pane-navigation [role="tab"][aria-selected="true"] {
    color: var(--blue); background: var(--surface); border-color: var(--line);
    box-shadow: inset 0 -2px var(--blue);
}
.workspace-pane-navigation [role="tab"]:focus-visible { outline: 2px solid var(--blue); outline-offset: -3px; }
.learning-notebook-pane { min-width: 0; min-height: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }

@media (max-width: 760px) {
    .learning-workspace {
        display: grid; grid-template-rows: auto auto minmax(0, 1fr);
    }
    .workspace-pane-navigation {
        align-self: stretch; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
        gap: 3px; padding: 4px; min-width: 0;
        background: var(--surface-muted, var(--paper)); border: 1px solid var(--line); border-radius: 11px;
    }
    .workspace-pane-navigation:not([hidden]) { display: grid; }
    .main:has(> .learning-workspace),
    .compact-shell .main:has(> .creation-page[data-workspace]) {
        height: calc(100dvh - 52px); min-height: 0; overflow: hidden;
    }
    .learning-workspace, .compact-shell .creation-page[data-workspace] { height: 100%; min-height: 0; }
    .compact-shell .creation-page[data-workspace] { grid-template-rows: auto minmax(0, 1fr); }
    .compact-shell .creation-page[data-mode="workspace"] { display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
    .learning-workspace .learning-workspace-grid,
    .compact-shell .creation-page[data-workspace] .creation-layout {
        display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; min-height: 0;
    }
    .learning-workspace .lesson-tutor-column,
    .learning-workspace .learning-content-pane,
    .learning-workspace .learning-notebook-pane,
    .compact-shell .creation-page[data-workspace] .creation-chat,
    .creation-page[data-workspace] .creation-layout[data-mode="briefing"] .creation-chat,
    .compact-shell .creation-page[data-workspace] .creation-draft {
        height: 100%; min-height: 0; max-height: none;
    }
    .compact-shell .creation-divider, .learning-workspace .learning-notes-actions { display: none; }
    .learning-workspace .learning-notebook-pane > .learning-notes-dock {
        max-height: none; overflow: visible; border: 0;
    }
}

@media (max-width: 420px) {
    .workspace-pane-navigation [role="tab"] { flex-direction: column; gap: 3px; padding: 7px 3px; font-size: 12px; }
}

/* Keep the Studio splitter operable when a tablet still has room for both panes. */
@media (min-width: 761px) and (max-width: 1050px) {
    .compact-shell .creation-layout[data-mode="workspace"] {
        grid-template-columns: minmax(260px, var(--creation-chat-width)) 10px minmax(0, 1fr);
    }
}

/* A landscape phone or a short desktop window can scroll the whole workbench.
   Its input, consent and review actions consequently have real space to occupy. */
@media (orientation: landscape) and (max-height: 600px) {
    .compact-shell .main:has(> .creation-page[data-workspace]),
    .main:has(> .learning-workspace) {
        height: auto;
        min-height: calc(100dvh - 52px);
        overflow: visible;
    }

    .compact-shell .creation-page[data-workspace],
    .learning-workspace {
        height: auto;
        grid-template-rows: auto auto;
    }

    .compact-shell .creation-page[data-workspace] .creation-layout,
    .learning-workspace .learning-workspace-grid {
        height: auto;
    }

    .compact-shell .creation-page[data-workspace] .creation-chat,
    .compact-shell .creation-page[data-workspace] .creation-draft,
    .creation-page[data-workspace] .creation-layout[data-mode="briefing"] .creation-chat,
    .learning-workspace .lesson-tutor-column,
    .learning-workspace .learning-notebook-pane,
    .learning-workspace .learning-content-pane {
        height: max(32rem, calc(100dvh - 7rem));
        min-height: 0;
    }

    .compact-shell .creation-chat-header,
    .compact-shell .creation-draft-header,
    .learning-workspace .lesson-tutor-chat > h2 {
        min-height: 44px;
        padding-block: 9px;
    }

    .learning-workspace .lesson-tutor-chat > .learning-composer {
        max-height: 60%;
        overflow-y: auto;
        padding-block: 10px;
    }

    .learning-composer-fields { min-height: 4.5rem; }

    .learning-workspace .lesson-learning-content,
    .learning-workspace .learning-dialog-scroll,
    .compact-shell .creation-context-scroll,
    .compact-shell .creation-chat-scroll {
        overscroll-behavior-y: auto;
    }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 760px) {
    .learning-workspace,
    .compact-shell .creation-page[data-mode="workspace"] { grid-template-rows: auto auto minmax(0, 1fr); }
}

/* A tablet retains simultaneous chat/content; only phone widths use workspace tabs. */
@media (min-width: 761px) and (max-width: 860px) {
    .learning-workspace .learning-workspace-grid {
        display: grid;
        grid-template-columns: minmax(260px, 2fr) minmax(0, 3fr);
        gap: 10px;
    }
    .learning-workspace .lesson-tutor-column { grid-row: auto; }
    .learning-content-tools { display: flex; flex-wrap: wrap; }
    .learning-workspace .annotation-toolbar { flex-wrap: wrap; }
}

@media (min-width: 1700px) {
    .creation-page[data-workspace], .learning-workspace {
        width: 100%;
        max-width: 120rem;
        margin-inline: auto;
    }

    .learning-workspace .learning-workspace-grid {
        grid-template-columns: minmax(0, 36%) minmax(0, 1fr);
        gap: 20px;
    }

    .compact-shell .creation-message,
    .learning-workspace .tutor-turn > h3,
    .learning-workspace .tutor-turn > .tutor-reply { max-width: min(94%, 74ch); }

    .learning-workspace .lesson-block-copy,
    .learning-workspace .lesson-body,
    .creation-page[data-workspace] .creation-outline-description { max-width: 80ch; }

    .learning-workspace .lesson-block-content > :is(.lesson-block-callout, .lesson-block-exercise, .lesson-block-checklist) {
        width: min(100%, 80ch);
    }
}

/* Size the workbench from the remaining space after page notices and navigation. */
@media (min-width: 1100px) and (min-height: 601px) {
    body.compact-shell:has(.creation-page[data-workspace], .learning-workspace) {
        display: flex;
        flex-direction: column;
        height: 100dvh;
    }

    .compact-shell .shell:has(.creation-page[data-workspace], .learning-workspace) {
        flex: 1 1 0;
        min-height: 0;
    }

    .compact-shell .shell:has(.creation-page[data-workspace], .learning-workspace) > .rail {
        height: 100%;
    }

    .compact-shell .workspace:has(.creation-page[data-workspace], .learning-workspace) {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        min-height: 0;
    }

    .compact-shell .workspace > .main:has(> .creation-page[data-workspace], > .learning-workspace) {
        height: 100%;
        min-height: 0;
        margin-block: 0;
    }

    .creation-page[data-mode="briefing"] .creation-workspace-toolbar {
        width: min(100%, 860px);
        margin-inline: auto;
        flex-wrap: wrap;
    }

    .creation-page[data-workspace] .creation-layout[data-mode="briefing"] .creation-chat:has(.creation-suggestions:not([hidden])) {
        max-height: 52rem;
        align-self: start;
    }
}

@media (min-width: 1100px) {
    .learning-workspace .asset-block .field:has(> select[name="playbackRate"]) {
        width: min(100%, 15rem);
    }

    .form-grid:has(> .field input[name="passPercent"]),
    .form-grid:has(> .field input[name="durationMinutes"]) {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
        align-items: start;
    }
}

@container course-outline (min-width: 68rem) {
    .creation-page[data-workspace] .creation-outline-modules { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
    .workspace-pane-navigation [role="tab"][aria-selected="true"] .icon {
        animation: workspace-tab-selected 180ms ease-out;
    }
    @keyframes workspace-tab-selected {
        from { transform: translateY(2px) scale(.94); }
        to { transform: translateY(0) scale(1); }
    }
}
