:root {
    color-scheme: dark;
    --bg: #0f1923;
    --bg-deep: #09121a;
    --surface: #162430;
    --surface-raised: #1a2c3a;
    --surface-soft: rgba(22, 36, 48, 0.74);
    --glass-border: rgba(212, 165, 74, 0.14);
    --text: #e8edf2;
    --text-muted: #93a4b7;
    --text-dim: #8799ac;
    --gold: #d4a54a;
    --gold-light: #e5c06b;
    --gold-glow: rgba(212, 165, 74, 0.15);
    --baldr: #e8a87c;
    --baldr-soft: rgba(232, 168, 124, 0.14);
    --teal: #5bc6c6;
    --success: #79c99e;
    --danger: #e77c79;
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --shadow: 0 24px 70px rgba(2, 8, 13, 0.28);
    --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-width: 320px;
    background: var(--bg-deep);
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 12% -10%, rgba(232, 168, 124, 0.13), transparent 34rem),
        radial-gradient(circle at 95% 12%, rgba(66, 209, 209, 0.07), transparent 30rem),
        linear-gradient(155deg, var(--bg) 0%, var(--bg-deep) 72%);
}

button,
select,
textarea {
    font: inherit;
}

button,
select {
    touch-action: manipulation;
}

a {
    color: inherit;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 0.75rem;
    left: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--bg-deep);
    background: var(--gold-light);
    font-weight: 750;
    transform: translateY(-180%);
    transition: transform 180ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.site-shell {
    width: min(1540px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 1rem clamp(1rem, 2.5vw, 2.5rem) 1.5rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    min-height: 76px;
    margin-bottom: 1rem;
    padding: 0.75rem 0.25rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 0;
    text-decoration: none;
}

.brand__mark {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(232, 168, 124, 0.45);
    border-radius: 50%;
    color: var(--baldr);
    background: var(--baldr-soft);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.35rem;
    box-shadow: 0 0 28px rgba(232, 168, 124, 0.1);
}

.brand__text {
    display: grid;
    gap: 0.08rem;
    min-width: 0;
}

.brand__name {
    overflow: hidden;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1rem, 2vw, 1.18rem);
    font-weight: 700;
    letter-spacing: 0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand__home {
    color: var(--text-muted);
    font-size: 0.76rem;
    letter-spacing: 0.04em;
}

.viewer-state {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 38px;
    padding: 0.45rem 0.55rem 0.45rem 0.75rem;
    border: 1px solid rgba(232, 168, 124, 0.2);
    border-radius: 999px;
    color: var(--text-muted);
    background: rgba(9, 18, 26, 0.44);
    font-size: 0.76rem;
    white-space: nowrap;
}

.viewer-state[hidden] {
    display: none;
}

.viewer-state strong {
    color: var(--text);
    font-size: 0.8rem;
}

.viewer-state a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0.3rem 0.62rem;
    border-radius: 999px;
    color: var(--baldr);
    background: var(--baldr-soft);
    font-weight: 800;
    text-decoration: none;
}

.viewer-state a:hover,
.viewer-state a:focus-visible {
    color: var(--text);
    background: rgba(212, 165, 74, 0.18);
}

.sync-state {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 38px;
    padding: 0.55rem 0.8rem;
    border: 1px solid rgba(147, 164, 183, 0.15);
    border-radius: 999px;
    color: var(--text-muted);
    background: rgba(9, 18, 26, 0.44);
    font-size: 0.78rem;
    white-space: nowrap;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.session-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0.55rem 0.8rem;
    border: 1px solid rgba(147, 164, 183, 0.15);
    border-radius: 999px;
    color: var(--text-muted);
    background: rgba(9, 18, 26, 0.44);
    cursor: pointer;
    font-size: 0.78rem;
    text-decoration: none;
    transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.session-button--reconnect {
    border-color: rgba(212, 165, 74, 0.42);
    color: var(--gold-light);
}

.session-button:hover,
.session-button:focus-visible {
    border-color: rgba(212, 165, 74, 0.5);
    color: var(--text);
    background: rgba(212, 165, 74, 0.08);
}

.session-button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.sync-state__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    box-shadow: 0 0 0 4px rgba(102, 121, 140, 0.12);
}

.sync-state[data-state="synced"] .sync-state__dot {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(121, 201, 158, 0.12);
}

.sync-state[data-state="syncing"] .sync-state__dot {
    background: var(--gold-light);
    box-shadow: 0 0 0 4px var(--gold-glow);
}

.sync-state[data-state="offline"] .sync-state__dot {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(231, 124, 121, 0.12);
}

.course-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    min-height: calc(100vh - 150px);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    background: rgba(9, 18, 26, 0.58);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.library-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: clamp(1.35rem, 2.5vw, 2rem);
    border-right: 1px solid var(--glass-border);
    background:
        linear-gradient(180deg, rgba(26, 44, 58, 0.65), rgba(15, 25, 35, 0.44)),
        var(--surface-soft);
}

.library-panel__intro h1 {
    max-width: 12ch;
    margin: 0.45rem 0 0.85rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    line-height: 1.06;
    letter-spacing: -0.035em;
}

.library-panel__intro > p:last-child {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.65;
}

.eyebrow {
    margin: 0;
    color: var(--baldr);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.course-progress {
    margin: 1.75rem 0;
    padding: 1rem;
    border: 1px solid rgba(232, 168, 124, 0.14);
    border-radius: var(--radius);
    background: rgba(9, 18, 26, 0.42);
}

.course-progress > div:first-child {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.course-progress__label {
    color: var(--text-muted);
    font-size: 0.76rem;
}

.course-progress strong {
    color: var(--baldr);
    font-variant-numeric: tabular-nums;
}

.course-progress__track {
    height: 5px;
    margin: 0.8rem 0 0.65rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(147, 164, 183, 0.12);
}

.course-progress__track span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--baldr), var(--gold-light));
    transition: width 350ms var(--ease);
}

.course-progress p {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.72rem;
}

.course-nav {
    display: grid;
    align-content: start;
    gap: 0.7rem;
    min-height: 180px;
}

.library-empty {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.9rem;
    padding: 0.95rem;
    border: 1px dashed rgba(147, 164, 183, 0.2);
    border-radius: var(--radius);
    color: var(--text-muted);
}

.library-empty__number {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--text-dim);
    background: rgba(147, 164, 183, 0.07);
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.library-empty strong {
    display: block;
    margin-bottom: 0.22rem;
    color: var(--text);
    font-size: 0.84rem;
}

.library-empty p {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.45;
}

.week-group {
    border: 1px solid rgba(147, 164, 183, 0.12);
    border-radius: var(--radius);
    background: rgba(9, 18, 26, 0.26);
}

.week-group__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.78rem 0.9rem 0.65rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.week-group__heading h2 {
    margin: 0;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
}

.week-group__lessons {
    display: grid;
    gap: 0.3rem;
    padding: 0 0.45rem 0.45rem;
}

.lesson-link {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    min-height: 58px;
    padding: 0.55rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text-muted);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.lesson-link:hover {
    color: var(--text);
    background: rgba(147, 164, 183, 0.07);
}

.lesson-link[aria-current="true"] {
    border-color: rgba(232, 168, 124, 0.24);
    color: var(--text);
    background: var(--baldr-soft);
}

.lesson-link__index {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    color: var(--text-dim);
    background: rgba(147, 164, 183, 0.08);
    font-size: 0.69rem;
    font-variant-numeric: tabular-nums;
}

.lesson-link[aria-current="true"] .lesson-link__index {
    color: var(--baldr);
    background: rgba(232, 168, 124, 0.13);
}

.lesson-link__copy {
    display: grid;
    gap: 0.16rem;
    min-width: 0;
}

.lesson-link__copy strong,
.lesson-link__copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lesson-link__copy strong {
    color: inherit;
    font-size: 0.78rem;
}

.lesson-link__copy span {
    color: var(--text-dim);
    font-size: 0.66rem;
}

.lesson-link__progress {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(147, 164, 183, 0.2);
}

.lesson-link__progress[data-state="progress"] {
    background: var(--gold-light);
}

.lesson-link__progress[data-state="complete"] {
    background: var(--success);
}

.lesson-panel {
    min-width: 0;
    padding: clamp(1.25rem, 3vw, 2.6rem);
    scroll-margin-top: 1rem;
    background: linear-gradient(145deg, rgba(15, 25, 35, 0.72), rgba(9, 18, 26, 0.58));
}

.lesson-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.25rem;
}

.lesson-heading__context {
    margin: 0 0 0.36rem;
    color: var(--baldr);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.lesson-heading h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.55rem, 3vw, 2.35rem);
    line-height: 1.1;
    letter-spacing: -0.025em;
}

.lesson-heading > div > p:last-child {
    max-width: 68ch;
    margin: 0.55rem 0 0;
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.55;
}

.lesson-status {
    flex: 0 0 auto;
    margin-top: 0.2rem;
    padding: 0.45rem 0.68rem;
    border: 1px solid rgba(147, 164, 183, 0.16);
    border-radius: 999px;
    color: var(--text-muted);
    background: rgba(147, 164, 183, 0.06);
    font-size: 0.68rem;
    font-weight: 750;
}

.lesson-status--progress {
    border-color: rgba(212, 165, 74, 0.22);
    color: var(--gold-light);
    background: var(--gold-glow);
}

.lesson-status--complete {
    border-color: rgba(121, 201, 158, 0.22);
    color: var(--success);
    background: rgba(121, 201, 158, 0.1);
}

.player-stage:fullscreen {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100vw;
    height: 100vh;
    padding: clamp(1rem, 2.4vw, 2.25rem);
    overflow: auto;
    background: #050b10;
}

.player-stage:fullscreen .player-card {
    flex: 1 1 auto;
    min-height: 0;
    aspect-ratio: auto;
    border-radius: var(--radius);
}

.player-stage:fullscreen .player-tools,
.player-stage:fullscreen .resume-prompt,
.player-stage:fullscreen .media-error {
    flex: 0 0 auto;
    width: 100%;
    margin-top: 0;
}

.player-card {
    position: relative;
    display: grid;
    aspect-ratio: 16 / 9;
    width: 100%;
    overflow: hidden;
    border: 1px solid rgba(232, 168, 124, 0.16);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 50% 40%, rgba(232, 168, 124, 0.1), transparent 30%),
        #050b10;
    box-shadow: 0 18px 50px rgba(1, 5, 8, 0.35);
}

.training-video {
    width: 100%;
    height: 100%;
    background: #000;
    object-fit: contain;
}

.player-card.player-card--reading {
    aspect-ratio: auto;
    min-height: 0;
}

.lesson-reading {
    max-height: 65vh;
    min-height: 260px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: clamp(1.25rem, 3vw, 2.5rem);
    color: var(--text);
    font-size: clamp(1rem, 1.3vw, 1.25rem);
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.lesson-reading section + section { margin-top: 1.7em; }
.lesson-reading h3 { margin: 0 0 0.6em; line-height: 1.4; }
.lesson-reading p { margin: 0.7em 0; }
.lesson-reading ul, .lesson-reading ol { padding-left: 1.5em; }
.lesson-reading li + li { margin-top: 0.5em; }
.player-stage:fullscreen .lesson-reading { max-height: 100%; min-height: 0; }

.player-placeholder {
    display: grid;
    place-content: center;
    justify-items: center;
    padding: 2rem;
    text-align: center;
}

.player-placeholder__monogram {
    display: grid;
    place-items: center;
    width: clamp(56px, 8vw, 82px);
    height: clamp(56px, 8vw, 82px);
    margin-bottom: 1.15rem;
    border: 1px solid rgba(232, 168, 124, 0.32);
    border-radius: 50%;
    color: var(--baldr);
    background: rgba(232, 168, 124, 0.08);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.65rem, 4vw, 2.4rem);
    box-shadow: 0 0 50px rgba(232, 168, 124, 0.1);
}

.player-placeholder strong {
    margin-top: 0.55rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.1rem, 2.4vw, 1.65rem);
}

.player-placeholder span {
    margin-top: 0.45rem;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.resume-prompt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.85rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(212, 165, 74, 0.18);
    border-radius: var(--radius);
    background: var(--gold-glow);
}

.resume-prompt > div:first-child {
    display: grid;
    gap: 0.2rem;
}

.resume-prompt strong {
    font-size: 0.82rem;
}

.resume-prompt span {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.resume-prompt__actions {
    display: flex;
    gap: 0.5rem;
}

.autoplay-prompt strong {
    font-size: 1rem;
}

.autoplay-prompt span {
    font-size: 0.88rem;
    overflow-wrap: anywhere;
}

.autoplay-prompt .button {
    min-height: 52px;
    min-width: 100px;
    font-size: 0.9rem;
}

.autoplay-prompt .resume-prompt__actions {
    flex-shrink: 0;
}

#autoplay-button[aria-pressed="true"] {
    color: var(--gold-light);
    border-color: var(--gold-light);
    background: var(--gold-glow);
}

.button,
.tool-button {
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms ease;
}

.button:active,
.tool-button:active {
    transform: translateY(1px);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.85rem;
    font-size: 0.76rem;
    font-weight: 750;
    text-decoration: none;
}

.button--primary {
    color: #1b130a;
    background: var(--gold-light);
}

.button--quiet {
    border-color: rgba(147, 164, 183, 0.16);
    background: rgba(9, 18, 26, 0.45);
}

.player-tools {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    margin-top: 0.8rem;
}

.media-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.85rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(231, 124, 121, 0.24);
    border-radius: var(--radius);
    background: rgba(231, 124, 121, 0.08);
}

.media-error > div:first-child {
    display: grid;
    gap: 0.2rem;
}

.media-error strong {
    font-size: 0.82rem;
}

.media-error span {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.media-error__actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.5rem;
}

.player-tools__group {
    display: flex;
    gap: 0.45rem;
}

.player-tools__group--primary {
    align-items: stretch;
}

.player-tools__group--end {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tool-button {
    min-width: 46px;
    padding: 0.52rem 0.7rem;
    border-color: rgba(147, 164, 183, 0.14);
    background: rgba(22, 36, 48, 0.7);
    font-size: 0.74rem;
    font-weight: 720;
}

.player-tools__group--primary .tool-button {
    min-width: 104px;
    min-height: 56px;
    padding-inline: 1rem;
    font-size: 0.86rem;
}

.tool-button--play {
    min-width: 132px !important;
    border-color: rgba(212, 165, 74, 0.45);
    color: #1b130a;
    background: var(--gold-light);
    font-weight: 800;
}

.tool-button--play:hover {
    border-color: var(--gold-light);
    color: #100b06;
    background: #eccb83;
}

.tool-button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.tool-button:hover,
.button--quiet:hover {
    border-color: rgba(232, 168, 124, 0.3);
    color: var(--baldr);
    background: var(--baldr-soft);
}

.tool-button--wide {
    min-width: auto;
}

.speed-control {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.speed-control select {
    min-height: 42px;
    padding: 0.45rem 1.9rem 0.45rem 0.7rem;
    border: 1px solid rgba(147, 164, 183, 0.14);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: var(--surface);
}

.lesson-details {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(280px, 1.15fr);
    gap: 1rem;
    margin-top: 1.4rem;
}

.detail-card {
    min-width: 0;
    padding: 1rem;
    border: 1px solid rgba(147, 164, 183, 0.12);
    border-radius: var(--radius);
    background: rgba(22, 36, 48, 0.48);
}

.detail-card__heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.detail-card h3 {
    margin: 0.28rem 0 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
}

.detail-card__hint {
    color: var(--text-dim);
    font-size: 0.64rem;
    text-align: right;
}

.chapters {
    display: grid;
    gap: 0.4rem;
}

.chapter-button {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.7rem;
    width: 100%;
    min-height: 42px;
    padding: 0.58rem 0.68rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: rgba(9, 18, 26, 0.28);
    text-align: left;
    cursor: pointer;
}

.chapter-button:hover {
    border-color: rgba(232, 168, 124, 0.2);
    color: var(--text);
}

.chapter-button[aria-current="true"] {
    border-color: rgba(232, 168, 124, 0.46);
    color: var(--text);
    background: var(--baldr-soft);
}

.chapter-button time {
    color: var(--baldr);
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
}

.chapter-button span {
    overflow: hidden;
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quiet-copy {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.74rem;
    line-height: 1.5;
}

textarea {
    width: 100%;
    min-height: 148px;
    resize: vertical;
    padding: 0.8rem;
    border: 1px solid rgba(147, 164, 183, 0.14);
    border-radius: var(--radius-sm);
    outline: none;
    color: var(--text);
    background: rgba(9, 18, 26, 0.45);
    font-size: 0.78rem;
    line-height: 1.55;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.notes-label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
}

textarea::placeholder {
    color: var(--text-dim);
}

textarea:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 0.25rem 0;
    color: var(--text-dim);
    font-size: 0.68rem;
}

.toast {
    position: fixed;
    z-index: 90;
    right: 1rem;
    bottom: 1rem;
    max-width: min(360px, calc(100vw - 2rem));
    padding: 0.8rem 1rem;
    border: 1px solid rgba(232, 168, 124, 0.22);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: rgba(9, 18, 26, 0.96);
    box-shadow: var(--shadow);
    font-size: 0.76rem;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

:focus-visible {
    outline: 3px solid var(--gold-light);
    outline-offset: 3px;
}

.player-card:focus-visible,
.tool-button:focus-visible,
.button:focus-visible,
.lesson-link:focus-visible,
.chapter-button:focus-visible,
.speed-control select:focus-visible {
    border-color: var(--gold-light);
    outline: 4px solid var(--gold-light);
    outline-offset: 4px;
    box-shadow: 0 0 0 7px rgba(5, 11, 16, 0.88);
}

.tool-button:focus-visible,
.button--quiet:focus-visible,
.lesson-link:focus-visible,
.chapter-button:focus-visible {
    color: var(--text);
    background: rgba(212, 165, 74, 0.18);
}

@media (min-width: 1280px) and (min-height: 700px) {
    .viewer-state,
    .sync-state,
    .session-button {
        min-height: 48px;
        font-size: 0.88rem;
    }

    .viewer-state a {
        min-height: 36px;
        padding-inline: 0.8rem;
    }

    .lesson-link {
        min-height: 68px;
        font-size: 1rem;
    }

    .player-tools__group--primary .tool-button {
        min-width: 124px;
        min-height: 64px;
        font-size: 1rem;
    }

    .tool-button--play {
        min-width: 158px !important;
    }

    .player-tools__group--end .tool-button,
    .speed-control select {
        min-height: 52px;
        font-size: 0.86rem;
    }
}

@media (max-width: 980px) {
    .course-layout {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .library-panel {
        border-right: 0;
        border-bottom: 1px solid var(--glass-border);
    }

    .library-panel__intro h1 {
        max-width: 20ch;
    }

    .course-nav {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 900px) {
    .player-tools {
        grid-template-columns: auto 1fr;
    }

    .player-tools__group--primary {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .player-tools__group--primary .tool-button,
    .tool-button--play {
        min-width: 0 !important;
    }

    .player-tools__group--end {
        grid-column: 1 / -1;
        justify-content: stretch;
    }

    .player-tools__group--end .tool-button {
        flex: 1;
    }

    .speed-control {
        justify-content: flex-end;
    }
}

@media (max-width: 720px) {
    .site-shell {
        padding: 0.65rem;
    }

    .topbar {
        align-items: flex-start;
        min-height: 68px;
        padding-inline: 0.25rem;
    }

    .brand__home {
        display: none;
    }

    .sync-state {
        min-height: 34px;
        padding: 0.45rem 0.6rem;
    }

    .sync-state span:last-child {
        max-width: 118px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar__actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.4rem;
    }

    .viewer-state > span:first-child {
        display: none;
    }

    .course-layout {
        min-height: auto;
        border-radius: var(--radius);
    }

    .library-panel,
    .lesson-panel {
        padding: 1rem;
    }

    .library-panel__intro h1 {
        font-size: 1.8rem;
    }

    .lesson-heading {
        gap: 1rem;
    }

    .lesson-status {
        display: none;
    }

    .player-card {
        margin-inline: -0.35rem;
        width: calc(100% + 0.7rem);
        border-radius: var(--radius);
    }

    .player-placeholder {
        padding: 1rem;
    }

    .resume-prompt {
        align-items: stretch;
        flex-direction: column;
    }

    .media-error {
        align-items: stretch;
        flex-direction: column;
    }

    .media-error__actions .button {
        flex: 1;
    }

    .resume-prompt__actions .button {
        flex: 1;
    }

    .lesson-details {
        grid-template-columns: 1fr;
    }

    .site-footer {
        align-items: flex-start;
        flex-direction: column;
        padding-inline: 0.5rem;
    }
}

@media (max-width: 460px) {
    .brand__mark {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .brand__name {
        max-width: 180px;
    }

    .sync-state {
        width: 34px;
        justify-content: center;
        padding: 0;
    }

    .viewer-state {
        padding-left: 0.55rem;
    }

    .sync-state span:last-child {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .detail-card__hint {
        display: none;
    }

    .tool-button--wide {
        font-size: 0.68rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (forced-colors: active) {
    .sync-state__dot,
    .lesson-link__progress,
    .course-progress__track span {
        border: 1px solid currentColor;
    }

    .lesson-link[aria-current="true"],
    .chapter-button[aria-current="true"] {
        outline: 2px solid Highlight;
    }
}
