/* Shared surface chrome — one class, one rule. @see docs/ui-surface-truth-model.md */

.ll-surface {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

.ll-surface__header {
    align-items: center;
    box-sizing: border-box;
    display: grid;
    flex-shrink: 0;
    gap: 0.5rem;
    grid-template-columns: auto 1fr auto;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
}

/* Fullscreen / transient stack topbar — wins over generic .ll-surface__header (loads after style.css). */
.ll-surface__header.app-route-fullscreen-topbar.ll-header-bar--centered-title {
    align-items: center;
    column-gap: 8px;
    grid-template-columns: minmax(44px, auto) minmax(0, 1fr) minmax(44px, auto);
    padding:
        max(var(--ll-toolbar-padding-y, 0.5rem), env(safe-area-inset-top, 0px))
        max(var(--space-4, 1rem), env(safe-area-inset-right, 0px))
        var(--ll-toolbar-padding-y, 0.5rem)
        max(var(--space-4, 1rem), env(safe-area-inset-left, 0px));
    row-gap: 0;
}

.ll-surface__header.app-route-fullscreen-topbar.ll-header-bar--centered-title > :is(
    .ll-stack-shell__back,
    .ll-back-action,
    .dialog-header-back
) {
    align-items: center;
    align-self: center;
    display: inline-flex;
    justify-content: center;
    justify-self: start;
    margin-top: 0;
    padding-top: 0;
    position: relative;
    top: auto;
    right: auto;
}

.ll-surface__header.app-route-fullscreen-topbar.ll-header-bar--centered-title > :is(
    .ll-stack-shell__back,
    .ll-back-action,
    .dialog-header-back
) i {
    display: block;
    line-height: 1;
}

.ll-surface__header.app-route-fullscreen-topbar.ll-header-bar--centered-title > .ll-surface__title {
    align-self: center;
    justify-self: center;
}

.ll-surface__title {
    font-size: var(--ll-type-title-size);
    font-weight: var(--ll-type-title-weight);
    line-height: var(--ll-type-title-line);
    letter-spacing: var(--ll-type-title-tracking);
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Stack / route topbar titles (Phase 6 — was .app-route-fullscreen-title). */
.ll-header-bar--centered-title > .ll-surface__title {
    font-size: var(--ll-type-title-size);
    font-weight: var(--ll-type-title-weight);
    line-height: var(--ll-type-title-line);
    letter-spacing: var(--ll-type-title-tracking);
    color: var(--text-primary, var(--ink));
}

.ll-surface__back {
    align-items: center;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    justify-content: center;
    min-height: 2.25rem;
    min-width: 2.25rem;
    padding: 0;
}

.ll-surface__back:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.ll-surface__header-spacer {
    display: block;
    min-height: 2.25rem;
    min-width: 2.25rem;
}

.ll-surface__body {
    box-sizing: border-box;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

/* Route stack screens: body-inner owns scroll; do not compete with .ll-surface__body overflow. */
.ll-surface__body.app-route-fullscreen-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ll-surface__footer {
    box-sizing: border-box;
    flex-shrink: 0;
    padding: 0.75rem;
}

/*
 * Confirm sheet (layout: confirm) — compact card on dialog overlay.
 * Target ≤600px tall @ 360×700; top-aligned host (surface-sheet.css).
 */
.dialog-content.ll-surface--sheet-confirm {
    animation: slideUp var(--motion-base) var(--ease-standard);
    height: auto;
    max-height: min(
        600px,
        calc(100dvh - var(--dialog-top-offset) - var(--ll-modal-gutter-y-bottom) - var(--ll-space-4))
    );
    max-height: min(
        600px,
        calc(100vh - var(--dialog-top-offset) - var(--ll-modal-gutter-y-bottom) - var(--ll-space-4))
    );
    overflow-x: hidden;
    overflow-y: auto;
    padding: var(--ll-space-4);
}

.dialog-content.ll-surface--sheet-confirm .ll-surface__header {
    border-bottom: 0;
    display: block;
    min-height: 0;
    padding: 0;
}

.dialog-content.ll-surface--sheet-confirm .ll-surface__title {
    color: var(--text-primary);
    font-size: clamp(1.05rem, 4.2vw, 1.2rem);
    font-weight: var(--weight-semibold);
    line-height: var(--line-tight);
    margin: 0 0 8px;
    text-align: left;
    white-space: normal;
}

.dialog-content.ll-surface--sheet-confirm .ll-surface__body {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
}

.dialog-content.ll-surface--sheet-confirm .ll-surface__body .dialog-message {
    font-size: 0.92rem;
    line-height: 1.4;
    margin-bottom: 0;
}

.dialog-content.ll-surface--sheet-confirm .ll-surface__footer {
    flex-shrink: 0;
    padding: 0;
}

.dialog-content.ll-surface--sheet-confirm .ll-surface__footer.dialog-buttons {
    margin-top: 12px;
}

/* Player+ body — feature-specific; chrome stays on confirm variant above. */
.dialog-content.ll-surface--sheet-confirm .dialog-message .player-plus-upgrade-dialog {
    gap: 10px;
}

.dialog-content.ll-surface--sheet-confirm .player-plus-upgrade-dialog__beta-note {
    font-size: 0.85rem;
    line-height: 1.35;
    padding: 8px 10px;
}

.dialog-content.ll-surface--sheet-confirm .player-plus-upgrade-dialog > p:not([class]) {
    font-size: inherit;
    line-height: inherit;
}

.dialog-content.ll-surface--sheet-confirm .player-plus-upgrade-dialog__plans {
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dialog-content.ll-surface--sheet-confirm .player-plus-upgrade-dialog__plan {
    padding: 10px 12px;
}

.dialog-content.ll-surface--sheet-confirm .player-plus-upgrade-dialog__plan strong {
    font-size: 1.3rem;
}

.dialog-content.ll-surface--sheet-confirm .player-plus-upgrade-dialog__features {
    font-size: 0.88rem;
    gap: 3px;
    line-height: 1.35;
}

@media (max-width: 560px) {
    .dialog-content.ll-surface--sheet-confirm .dialog-buttons--three-way {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .dialog-content.ll-surface--sheet-confirm .dialog-buttons--three-way .dialog-action-spacer {
        display: none;
    }

    .dialog-content.ll-surface--sheet-confirm .dialog-buttons--three-way .dialog-action-group--wrap {
        display: flex;
        flex: 1 1 100%;
        flex-wrap: wrap;
        gap: 8px;
        margin-left: 0;
        width: 100%;
    }

    .dialog-content.ll-surface--sheet-confirm .dialog-buttons--three-way .dialog-button {
        flex: 1 1 calc(50% - 4px);
        min-height: 40px;
        width: auto;
    }

    /* First action on its own row (e.g. Maybe Later / Cancel). */
    .dialog-content.ll-surface--sheet-confirm .dialog-buttons--three-way .dialog-action-group--wrap > .dialog-button:first-child:not(:only-child) {
        flex: 1 1 100%;
    }
}

.dialog-content.ll-surface--sheet-confirm .ll-surface__body .dialog-input {
    margin: 0 0 12px;
    width: 100%;
}

.dialog-input--prompt {
    min-width: 0;
    width: 100%;
    max-width: none;
    font-size: var(--ll-type-body-size);
}

.dialog-content.ll-surface--sheet-confirm .ll-surface__body .dialog-stacked-fields {
    margin-top: 4px;
}

@media (min-width: 768px) {
    .ll-surface--screen-stack.ll-surface--constrained .ll-surface__body {
        margin-inline: auto;
        max-width: 42rem;
        width: 100%;
    }
}

/* Dismiss-back rich sheets (weather detail, session summary, …) */
.dialog-content.dialog-content--dismiss-icon .ll-surface__header.dialog-header-with-dismiss {
    align-items: flex-start;
    display: flex;
    gap: 10px;
    grid-template-columns: unset;
    min-height: 0;
    padding: var(--space-4) var(--space-4) 8px;
    position: relative;
}

.dialog-content.dialog-content--dismiss-icon .ll-surface__header .ll-surface__back.ll-back-action--has-label {
    align-items: flex-start;
    flex: 1 1 auto;
    height: auto;
    justify-content: flex-start;
    max-width: none;
    min-height: 0;
    min-width: 0;
    text-align: left;
}

.dialog-content.dialog-content--dismiss-icon .ll-surface__header .ll-back-action__label {
    line-height: 1.35;
    text-wrap: balance;
    white-space: normal;
}

.dialog-content.dialog-content--dismiss-icon .ll-surface__header .ll-surface__title.ll-header-title-merged {
    border: 0;
    clip: rect(0, 0, 0, 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    pointer-events: none;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.dialog-content.dialog-content--weather-detail.ll-surface--sheet-overlay {
    border: none;
    max-height: min(88dvh,
        calc(100dvh - var(--dialog-top-offset) - max(var(--space-4), env(safe-area-inset-bottom)) - var(--space-4)));
    max-height: min(88vh,
        calc(100vh - var(--dialog-top-offset) - max(var(--space-4), env(safe-area-inset-bottom)) - var(--space-4)));
    max-width: min(92vw, 440px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0;
    width: min(100%, 440px);
}

.dialog-content.dialog-content--weather-detail .ll-surface__body {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
    padding: 0;
}

.dialog-content.dialog-content--weather-detail .ll-surface__body .dialog-message--rich {
    margin: 0;
    padding: 0;
}

.dialog-overlay.ll-surface-host.ll-surface-host--weather-detail {
    align-items: flex-start;
    justify-content: center;
    padding-top: var(--dialog-top-offset, 0);
}

.dialog-overlay.ll-surface-host.ll-surface-host--weather-detail > .dialog-content.dialog-content--weather-detail {
    align-self: flex-start;
    flex-shrink: 0;
    margin: 0;
}

/* Weather day detail — one card; theme accents live on inner .weather-detail-dialog--* */
.dialog-content.dialog-content--weather-detail {
    background: var(--surface-card-strong);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.dialog-content.dialog-content--weather-detail .ll-surface__header.dialog-header-with-dismiss {
    background: transparent;
    border-bottom: 1px solid color-mix(in srgb, var(--border-default) 55%, transparent);
    padding: var(--space-3) var(--space-4);
}

.dialog-content.dialog-content--weather-detail .ll-surface__header .ll-surface__back,
.dialog-content.dialog-content--weather-detail .ll-surface__header .ll-back-action__label {
    color: var(--text-primary);
    text-shadow: none;
}

.dialog-content.dialog-content--weather-detail .ll-surface__header .ll-surface__back i {
    color: inherit;
    opacity: 0.85;
}

@media (max-width: 560px) {
    .dialog-content.dialog-content--weather-detail .ll-surface__header.dialog-header-with-dismiss {
        padding: var(--space-3);
    }
}

/* Persona picker — scrollable list inside transient stack screen body.
   Markup uses stack + surface on the same root (not nested). */
.lessonlink-sandbox-persona-surface.lessonlink-sandbox-persona-stack,
.lessonlink-sandbox-persona-surface .lessonlink-sandbox-persona-stack {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    position: relative;
}

.lessonlink-stack-host.lessonlink-stack-host--screen .ll-surface--screen-stack {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.lessonlink-stack-host.lessonlink-stack-host--screen .ll-surface--screen-stack > .ll-surface__body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lessonlink-stack-host.lessonlink-stack-host--screen .ll-stack-shell__content > .lessonlink-sandbox-persona-surface {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lessonlink-sandbox-persona-overlay .dialog-content.lessonlink-sandbox-persona-dialog > .lessonlink-sandbox-persona-surface {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lessonlink-sandbox-persona-surface .lessonlink-sandbox-persona-list-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.lessonlink-sandbox-persona-surface .lessonlink-sandbox-persona-list-panel > .lessonlink-sandbox-persona-list,
.lessonlink-sandbox-persona-surface .lessonlink-sandbox-persona-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
}

.lessonlink-sandbox-persona-list-more-wrap {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem 0.75rem;
    text-align: center;
}

.lessonlink-sandbox-persona-list-more-wrap[hidden] {
    display: none;
}

.lessonlink-sandbox-persona-list-more {
    background: none;
    border: none;
    color: var(--accent, #2563eb);
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    text-decoration: underline;
}

.lessonlink-sandbox-persona-list-more:hover,
.lessonlink-sandbox-persona-list-more:focus-visible {
    text-decoration: none;
}

.lessonlink-sandbox-persona-list-empty {
    color: var(--text-muted, #6b7280);
    font-size: 0.9375rem;
    margin: 0.75rem 0 0;
    padding: 0 0.25rem;
    text-align: center;
}

/* Persona picker fallback — full overlay sheet (no navigator) */
.lessonlink-sandbox-persona-overlay--full.ll-surface--sheet-overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

.lessonlink-sandbox-persona-overlay--full .ll-surface__panel {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
}

.lessonlink-sandbox-persona-overlay--full .lessonlink-sandbox-persona-stack,
.lessonlink-sandbox-persona-overlay--full .lessonlink-sandbox-persona-surface.lessonlink-sandbox-persona-stack {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.lessonlink-sandbox-persona-overlay--full .lessonlink-sandbox-persona-list-panel {
    flex: 1 1 auto;
    min-height: 0;
}

.lessonlink-sandbox-persona-overlay--full .lessonlink-sandbox-persona-list-panel > .lessonlink-sandbox-persona-list,
.lessonlink-sandbox-persona-overlay--full .lessonlink-sandbox-persona-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

/* Phase 3 — embedded full-bleed overlay sheets (lesson workspace, upload readers) */
.ll-surface-host[data-ll-surface-host='embedded'].email-panel-overlay--global-modal-full > .ll-surface--sheet-overlay {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: var(--ll-space-4);
    min-height: 0;
    overflow: hidden;
}

.ll-surface--sheet-overlay > .ll-surface__header {
    align-items: flex-start;
    display: flex;
    flex-shrink: 0;
    gap: 10px;
    grid-template-columns: unset;
    min-height: 0;
    padding: 0;
}

.ll-surface--sheet-overlay > .ll-surface__header .ll-surface__back {
    align-items: flex-start;
    flex-shrink: 0;
    margin-top: 2px;
    min-height: 0;
    padding-top: 0;
}

.ll-surface--sheet-overlay .ll-surface__header-main {
    flex: 1 1 auto;
    min-width: 0;
}

.ll-surface--sheet-overlay .ll-surface__title {
    font-size: clamp(1.05rem, 2.6vw, 1.35rem);
    font-weight: var(--weight-semibold);
    letter-spacing: -0.02em;
    line-height: var(--line-tight);
    text-align: left;
    white-space: normal;
}

.ll-surface--sheet-overlay .ll-surface__subtitle {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    line-height: var(--line-normal);
    margin: 4px 0 0;
}

.ll-surface--sheet-overlay > .ll-surface__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.ll-surface--sheet-overlay > .ll-surface__footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 0;
}

.email-panel-overlay.ll-surface-host[hidden],
[data-ll-surface-host='embedded'][hidden] {
    display: none !important;
}
