/* ==========================================================================
   Session runners — flashcards, quiz, key concepts (js/study/pages/session.js)
   A session covers the frame on purpose: one job, nothing else on screen.
   Sits under modals (110) and toasts (120) so both still work over it.
   ========================================================================== */

.st-ses {
    position: fixed;
    inset: 0;
    z-index: 88;
    display: flex;
    flex-direction: column;
    background: var(--st-bg);
    color: var(--st-ink);
}

/* Settings → reduce motion: nothing in a session should move. */
.st-ses--still *,
.st-ses--still *::before,
.st-ses--still *::after {
    transition: none !important;
    animation: none !important;
}

/* --- Chrome -------------------------------------------------------------- */

.st-ses__bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
    padding: 12px 20px;
    background: var(--st-surface-2);
    border-bottom: var(--st-card-border-w) solid var(--st-border);
}
.st-ses__exit {
    padding: 8px 12px;
    min-height: var(--st-tap);
}
.st-ses__id {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.st-ses__id-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.st-ses__id-text strong {
    font-size: 14px;
    font-weight: 700;
}
.st-ses__mode {
    font-size: 12px;
    color: var(--st-ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.st-ses__meter {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    min-width: 0;
}
.st-ses__status {
    font-size: 13px;
    font-weight: 600;
    color: var(--st-ink-2);
    white-space: nowrap;
}
.st-ses__meter .st-progress {
    width: 160px;
    flex: 0 0 auto;
}
.st-ses__aside {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.st-ses__timer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--st-ink-2);
    font-variant-numeric: tabular-nums;
}
.st-ses__help span {
    font-size: 15px;
    font-weight: 700;
}

.st-ses__stage {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 32px 24px 56px;
}
.st-ses__stage:focus {
    outline: none;
}
.st-ses-stage-inner {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}
.st-ses-stage-inner--center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
}
.st-ses-stage-inner--split {
    max-width: 1120px;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

/* Panels share the card shell; they are focus targets, not buttons. */
.st-ses-card,
.st-ses-q,
.st-ses-summary,
.st-ses-concepts__detail {
    background: var(--st-surface);
    border: var(--st-card-border-w) solid var(--st-border);
    border-radius: var(--st-radius-card);
    box-shadow: var(--st-shadow-card);
    padding: 32px;
}
.st-ses-card:focus,
.st-ses-q:focus,
.st-ses-summary:focus,
.st-ses-concepts__detail:focus {
    outline: none;
}

.st-ses-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--st-ink-4);
}

/* --- Flashcards ---------------------------------------------------------- */

.st-ses-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 420px;
}
.st-ses-card__face-slot {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 160px;
}
.st-ses-card__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
}
.st-ses-card__face {
    font-size: 17px;
    line-height: 1.55;
    max-width: 60ch;
}
.st-ses-card__front {
    font-family: var(--st-font-display);
    font-weight: var(--st-display-weight-2);
    letter-spacing: var(--st-display-tracking);
    font-size: 24px;
    line-height: 1.35;
}
.st-ses-card__rule {
    height: 1px;
    background: var(--st-border-soft);
}
.st-ses-card__actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
}
.st-ses-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--st-border-soft);
}

.st-ses-grades-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}
.st-ses-grades__prompt {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--st-ink);
    text-align: center;
}
.st-ses-grades {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.st-ses-grade {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 72px;
    padding: 12px 10px;
    border: 1px solid var(--st-border-strong);
    border-radius: var(--st-radius-input);
    background: var(--st-surface);
    color: var(--st-ink);
    transition: background-color 0.14s ease, border-color 0.14s ease;
    text-align: center;
}
.st-ses-grade__label {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
}
.st-ses-grade.is-selected {
    border-color: currentColor;
    box-shadow: inset 0 0 0 1px currentColor;
}
.st-ses-grade--good.is-selected {
    background: var(--st-accent-soft);
    border-color: var(--st-accent);
    color: var(--st-accent);
}
.st-ses-grade--again.is-selected {
    background: var(--st-danger-soft);
    border-color: var(--st-danger);
    color: var(--st-danger-ink);
}
.st-ses-grade--hard.is-selected {
    background: var(--st-warm-soft);
    border-color: var(--st-warm);
    color: var(--st-warm-ink);
}
.st-ses-grade--again:hover { background: var(--st-danger-soft); border-color: var(--st-danger); color: var(--st-danger-ink); }
.st-ses-grade--hard:hover { background: var(--st-warm-soft); border-color: var(--st-warm); color: var(--st-warm-ink); }
.st-ses-grade--good:hover { background: var(--st-accent-soft); border-color: var(--st-accent); color: var(--st-accent); }

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

.st-ses-q {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.st-ses-q__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.st-ses-q__provenance {
    margin: 0 0 4px;
    line-height: 1.35;
}
.st-ses-q__prompt {
    font-size: 24px;
    line-height: 1.3;
    max-width: 48ch;
}
.st-ses-q__options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.st-ses-q__options--tf {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.st-ses-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 14px 16px;
    text-align: left;
    border: 1px solid var(--st-border-strong);
    border-radius: var(--st-radius-input);
    background: var(--st-surface);
    color: var(--st-ink);
    font-size: 15px;
    line-height: 1.4;
    transition: background-color 0.14s ease, border-color 0.14s ease;
}
.st-ses-opt:hover:not(:disabled) {
    background: var(--st-surface-2);
    border-color: var(--st-ink-3);
}
.st-ses-opt__text {
    flex: 1 1 auto;
}
.st-ses-opt.is-chosen {
    border-color: var(--st-accent);
    background: var(--st-accent-soft);
}
.st-ses-opt.is-correct {
    border-color: var(--st-green);
    background: var(--st-green-soft);
    color: var(--st-green-ink);
}
.st-ses-opt.is-wrong {
    border-color: var(--st-danger);
    background: var(--st-danger-soft);
    color: var(--st-danger-ink);
}
.st-ses-opt:disabled {
    cursor: default;
}
.st-ses-opt:disabled:not(.is-correct):not(.is-wrong) {
    opacity: 0.55;
}
.st-ses-q__options--tf .st-ses-opt {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    min-height: 104px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
}
.st-ses-q__field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.st-ses-q__input {
    font-size: 16px;
}
.st-ses-q__feedback:empty {
    display: none;
}
.st-ses-fb {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border-radius: var(--st-radius-card-sm);
    font-size: 14px;
    line-height: 1.5;
}
.st-ses-fb--right {
    background: var(--st-green-soft);
    color: var(--st-green-ink);
}
.st-ses-fb--wrong {
    background: var(--st-danger-soft);
    color: var(--st-danger-ink);
}
.st-ses-fb--partial {
    background: var(--st-amber-soft, #fef3c7);
    color: var(--st-amber-ink, #92400e);
}
.st-ses-fb--pending {
    background: var(--st-fill);
    color: var(--st-ink-2);
}
.st-ses-fb__head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.st-ses-fb__source {
    font-size: 13px;
}
.st-ses-fb a {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
}
.st-ses-q__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.st-ses-q__actions-end {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.st-ses-q__defer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--st-ink-2);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.st-ses-q__defer input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--st-accent);
    flex: 0 0 auto;
}
.st-ses-q__defer:hover {
    color: var(--st-ink);
}

.st-ses-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding-top: 18px;
    border-top: 1px solid var(--st-border-soft);
}
.st-ses-nav__item {
    position: relative;
    width: 32px;
    height: 32px;
    border: 1px solid var(--st-border-strong);
    border-radius: 8px;
    background: var(--st-surface);
    color: var(--st-ink-2);
    font-size: 12px;
    font-weight: 700;
}
.st-ses-nav__item:hover {
    background: var(--st-fill);
    color: var(--st-ink);
}
.st-ses-nav__item.is-right {
    background: var(--st-green-soft);
    color: var(--st-green-ink);
    border-color: transparent;
}
.st-ses-nav__item.is-wrong {
    background: var(--st-danger-soft);
    color: var(--st-danger-ink);
    border-color: transparent;
}
.st-ses-nav__item.is-partial {
    background: var(--st-amber-soft, #fef3c7);
    color: var(--st-amber-ink, #92400e);
    border-color: transparent;
}
.st-ses-nav__item.is-pending {
    background: var(--st-fill);
    color: var(--st-ink-2);
    border-style: dashed;
}
.st-ses-nav__item.is-answered {
    background: var(--st-fill);
    color: var(--st-ink);
    border-color: var(--st-border-strong);
}
.st-ses-nav__item.is-current {
    border-color: var(--st-ink);
    color: var(--st-ink);
    box-shadow: 0 0 0 1px var(--st-ink) inset;
}
.st-ses-nav__item.is-flagged::after {
    content: "";
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--st-warm);
}
.st-ses-nav__finish {
    margin-left: auto;
}

/* --- Summary ------------------------------------------------------------- */

.st-ses-summary {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.st-ses-summary__score {
    font-family: var(--st-font-display);
    font-weight: var(--st-display-weight);
    letter-spacing: -0.02em;
    font-size: 44px;
    line-height: 1.05;
}
.st-ses-summary__sub {
    font-size: 14px;
    color: var(--st-ink-2);
}
.st-ses-summary__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.st-ses-summary__block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--st-border-soft);
}
.st-ses-summary__delta {
    font-size: 12px;
    font-weight: 700;
    color: var(--st-green);
    font-variant-numeric: tabular-nums;
}
.st-ses-summary__actions {
    padding-top: 8px;
}
.st-ses-dot--danger { background: var(--st-danger); }
.st-ses-dot--warm { background: var(--st-warm); }
.st-ses-dot--accent { background: var(--st-accent); }
.st-ses-dot--green { background: var(--st-green); }

/* --- Key concepts -------------------------------------------------------- */

.st-ses-concepts__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    border-radius: var(--st-radius-card-sm);
    background: var(--st-fill);
    border: 1px solid var(--st-border);
}
.st-ses-concepts__item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
}
.st-ses-concepts__item:hover {
    background: var(--st-surface);
}
.st-ses-concepts__item.is-current {
    background: var(--st-surface);
    border-color: var(--st-border-strong);
    box-shadow: var(--st-shadow-card);
}
.st-ses-concepts__item.is-current .st-ses-concepts__name {
    font-weight: 800;
    color: var(--st-ink);
}
.st-ses-concepts__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--st-ink-2);
}
.st-ses-concepts__bar {
    display: flex;
    align-items: center;
    gap: 8px;
}
.st-ses-concepts__bar .st-progress {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
}
.st-ses-concepts__bar[data-tone="danger"] .st-progress__fill { background: var(--st-danger); }
.st-ses-concepts__bar[data-tone="warm"] .st-progress__fill { background: var(--st-warm); }
.st-ses-concepts__bar[data-tone="green"] .st-progress__fill { background: var(--st-green); }
.st-ses-concepts__pct {
    width: 34px;
    text-align: right;
    font-size: 11px;
    color: var(--st-ink-3);
    font-variant-numeric: tabular-nums;
}
.st-ses-concepts__detail {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.st-ses-concepts__title {
    font-size: 28px;
    line-height: 1.2;
}
.st-ses-concepts__summary {
    font-size: 15px;
    line-height: 1.6;
    color: var(--st-ink-2);
    max-width: 62ch;
}

/* Self-report mastery: real checkbox beside Quiz / Practise, not a ghost button. */
.st-ses-know {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.st-ses-know__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--st-tap);
    padding: 0 4px;
    margin: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--st-ink);
    user-select: none;
}
.st-ses-know__input {
    width: 16px;
    height: 16px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--st-accent);
    cursor: pointer;
}
.st-ses-know__input:disabled {
    cursor: wait;
}
.st-ses-know__input:focus-visible {
    outline: 2px solid var(--st-focus);
    outline-offset: 2px;
}
.st-ses-know__help {
    margin: 0;
    padding-left: 28px;
    max-width: 36ch;
    font-size: 12px;
    line-height: 1.4;
    color: var(--st-ink-4);
}

.st-ses-concepts__block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--st-border-soft);
}

/* Concept asset repair — generating / error (no full-page reload) */
.st-ses-repair {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--st-radius-sm, 8px);
    font-size: 13px;
    font-weight: 600;
    color: var(--st-ink-2);
    background: var(--st-surface-2);
}
.st-ses-repair.is-generating {
    color: var(--st-ink);
}
.st-ses-repair.is-error {
    flex-wrap: wrap;
    color: var(--st-danger);
    background: color-mix(in srgb, var(--st-danger) 8%, var(--st-surface-2));
}
.st-ses-repair__msg {
    margin: 0;
    flex: 1 1 auto;
}
.st-ses-repair__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--st-accent, var(--st-ink));
    flex: 0 0 auto;
    animation: st-ses-repair-pulse 1s ease-in-out infinite;
}
@keyframes st-ses-repair-pulse {
    0%, 100% { opacity: 0.35; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.15); }
}
.st-ses--still .st-ses-repair__dot {
    animation: none;
    opacity: 0.7;
}

/* --- Shortcut sheet ------------------------------------------------------ */

.st-ses-keys {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px 16px;
    align-items: center;
    margin: 0;
    font-size: 14px;
}
.st-ses-keys dt {
    display: flex;
    align-items: center;
    gap: 4px;
}
.st-ses-keys dd {
    margin: 0;
    color: var(--st-ink-2);
}
.st-ses-keys__sep {
    color: var(--st-ink-4);
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 900px) {
    .st-ses-stage-inner--split {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }
    .st-ses-concepts__list {
        max-height: 260px;
    }
}

@media (max-width: 760px) {
    .st-ses__bar {
        flex-wrap: wrap;
        gap: 8px 12px;
        padding: 10px 14px;
    }
    .st-ses__meter {
        order: 3;
        flex: 1 1 100%;
        margin-left: 0;
    }
    .st-ses__meter .st-progress {
        width: auto;
        flex: 1 1 auto;
    }
    .st-ses__exit-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
    .st-ses__stage {
        padding: 20px 14px 40px;
    }
    .st-ses-card,
    .st-ses-q,
    .st-ses-summary,
    .st-ses-concepts__detail {
        padding: 20px;
    }
    .st-ses-card {
        min-height: 0;
        gap: 16px;
    }
    .st-ses-card__front,
    .st-ses-q__prompt {
        font-size: 20px;
    }
    .st-ses-card__face {
        font-size: 16px;
    }
    .st-ses-grades,
    .st-ses-summary__grid {
        grid-template-columns: 1fr;
    }
    .st-ses-grades-wrap {
        gap: 8px;
    }
    .st-ses-grades {
        gap: 8px;
    }
    .st-ses-grade {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        min-height: 52px;
        padding: 12px 14px;
        text-align: left;
    }
    .st-ses-grade__label {
        font-size: 15px;
    }
    .st-ses-grade__key {
        margin-top: 0;
        flex-shrink: 0;
    }
    .st-ses-q__options--tf .st-ses-opt {
        min-height: 84px;
        font-size: 16px;
    }
    .st-ses-opt {
        font-size: 14px;
        padding: 12px 14px;
        min-height: 52px;
    }
    .st-ses-q__actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .st-ses-q__actions-end {
        flex-direction: column;
        align-items: stretch;
    }
    .st-ses-q__actions .st-btn {
        width: 100%;
    }
    .st-ses-q__defer {
        justify-content: center;
        padding: 4px 0;
    }
    .st-ses-summary__score {
        font-size: 32px;
    }
    .st-ses-summary__actions .st-btn {
        flex: 1 1 100%;
    }
    .st-ses-concepts__title {
        font-size: 22px;
    }
}

@media (max-width: 420px) {
    .st-ses__id-text strong { font-size: 13px; }
    .st-ses__timer { font-size: 12px; }
    .st-ses-grade { min-height: 48px; padding: 10px 12px; }
    .st-ses-grade__label { font-size: 14px; }
    .st-ses-nav__item { width: 28px; height: 28px; }
}
