/* Shared palette covers every surface, native control, and feedback state. */
:root { color-scheme: light; --text: #202936; --page: #f6f7f9; --surface: #fff; --border: #dce1e7; --divider: #e5e9ee; --muted: #596574; --input-border: #bac4cf; --subtle: #eef1f5; --accent: #365d88; --accent-hover: #294c73; --link: #285886; --link-hover: #153c62; --focus: #82a8d3; --video: #111; --success-bg: #e5f1e9; --success: #286142; --danger-bg: #fff0ed; --danger: #9c352c; --danger-border: #ecd1cc; --info-bg: #e5edf9; --track: #e6ebf1; --progress: #7896b7; --selected: #f1f5fa; --shadow: #20293618; }
:root[data-theme="dark"] { color-scheme: dark; --text: #e3e9f1; --page: #111720; --surface: #1b2330; --border: #374354; --divider: #303c4c; --muted: #afbdce; --input-border: #637389; --subtle: #263242; --accent: #a0c5f2; --accent-hover: #bfdbff; --link: #a0c5f2; --link-hover: #c6dfff; --focus: #8bbcf7; --video: #080b10; --success-bg: #203d30; --success: #91d7ac; --danger-bg: #422b2b; --danger: #ffb2a9; --danger-border: #79504d; --info-bg: #263d58; --track: #344359; --progress: #8caacb; --selected: #293c53; --shadow: #0004; }
:root { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--page); line-height: 1.6; font-size: 16px; accent-color: var(--accent); }
:root { overflow-y: scroll; }
* { box-sizing: border-box; }
body { max-width: 78rem; margin: 0 auto; padding: 1.5rem 2rem 4rem; }
header { padding-bottom: 1rem; margin-bottom: 2rem; border-bottom: 1px solid var(--border); }
nav a { font-weight: 650; color: var(--text); text-decoration: none; }
h1, h2 { line-height: 1.25; letter-spacing: -.025em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.35rem); margin: 0 0 .75rem; overflow-wrap: anywhere; }
h2 { font-size: 1.2rem; margin: 0 0 1rem; }
p { margin: .65rem 0 1rem; }
main > p, small, caption { color: var(--muted); }
a { color: var(--link); text-underline-offset: .2em; }
a:hover { color: var(--link-hover); }
section { margin-block: 2rem; }
.forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 23rem), 1fr)); gap: 1.25rem; }
.forms form { min-width: 0; }
fieldset { min-width: 0; height: 100%; margin: 0; padding: 1.25rem 1.5rem 1.5rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
legend { padding: 0 .4rem; font-weight: 650; }
fieldset p { font-size: .875rem; color: var(--muted); }
label { display: block; margin: .5rem 0 .4rem; font-size: .9rem; font-weight: 600; }
input, select, button { font: inherit; }
input:not([type="hidden"]), select { width: 100%; max-width: 100%; min-height: 2.65rem; padding: .55rem .75rem; border: 1px solid var(--input-border); border-radius: .35rem; background: var(--surface); color: inherit; }
input[type="file"] { padding: .35rem; font-size: .875rem; }
input::file-selector-button { font: inherit; padding: .35rem .6rem; margin-right: .6rem; border: 1px solid var(--border); border-radius: .25rem; background: var(--subtle); color: var(--text); cursor: pointer; }
button { border: 1px solid var(--accent); border-radius: .35rem; background: var(--accent); color: var(--surface); padding: .6rem 1rem; font-weight: 600; cursor: pointer; }
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; }
caption { text-align: left; padding: 1rem; font-size: .85rem; border-bottom: 1px solid var(--divider); }
th, td { padding: 1rem; vertical-align: top; }
th { background: var(--subtle); font-size: .8rem; font-weight: 650; color: var(--muted); }
td { border-top: 1px solid var(--divider); }
td:first-child { min-width: 12rem; font-weight: 550; }
td:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.video-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; align-items: start; }
.video-column { min-width: 0; }
.lesson-panel { padding: 1.25rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
.video-layout p { font-size: .9rem; }
video { display: block; width: 100%; max-height: 70vh; border: 1px solid var(--input-border); border-radius: .65rem; overflow: hidden; background: var(--video); }
.transcript { min-height: 8rem; max-height: 45vh; overflow-y: auto; padding-right: .75rem; scrollbar-gutter: stable; }
.transcript [hidden] { display: none; }
.job-status { max-width: 34rem; }
td .job-status { min-width: 12rem; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 1rem; background: var(--subtle); color: var(--muted); font-size: .75rem; font-weight: 650; }
.badge-ready { background: var(--success-bg); color: var(--success); }
.badge-failed { background: var(--danger-bg); color: var(--danger); }
.badge-processing { background: var(--info-bg); color: var(--link); }
.status-copy { display: block; margin: .4rem 0; font-size: .82rem; color: var(--muted); }
progress { display: block; appearance: none; width: 100%; height: .5rem; margin: .7rem 0 .4rem; border: 0; border-radius: 1rem; overflow: hidden; background: var(--track); }
progress::-webkit-progress-bar { background: var(--track); border-radius: 1rem; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 1rem; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 1rem; }
progress:not([value]) { background: linear-gradient(90deg, var(--track) 25%, var(--progress) 50%, var(--track) 75%); background-size: 200% 100%; animation: pending 1.8s linear infinite; }
progress:not([value])::-webkit-progress-bar { background: transparent; }
@keyframes pending { to { background-position: -200% 0; } }
[role="alert"] { padding: .8rem 1rem; border: 1px solid var(--danger-border); border-radius: .35rem; background: var(--danger-bg); color: var(--danger); }
.submission-progress { margin-top: 1rem; font-size: .85rem; }
@media (prefers-reduced-motion: reduce) { progress:not([value]) { animation: none; } }
@media (max-width: 48rem) { body { padding: 1rem 1rem 3rem; } .video-layout { grid-template-columns: minmax(0, 1fr); gap: 0; } .transcript { max-height: none; } fieldset { padding: 1rem; } }
.library-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1.75rem; align-items: start; }
.library-layout > section { min-width: 0; margin-top: 1.25rem; }
.importer { background: var(--surface); border: 1px solid var(--border); border-radius: .65rem; padding: 1.25rem; }
.source-switch { display: flex; gap: .25rem; padding: .25rem; margin-bottom: 1.25rem; height: auto; border: 0; background: var(--subtle); border-radius: .4rem; }
.source-switch label { display: flex; align-items: center; justify-content: center; gap: .4rem; flex: 1; margin: 0; padding: .45rem; border-radius: .25rem; cursor: pointer; font-weight: 500; }
.source-switch label:has(input:checked) { background: var(--surface); box-shadow: 0 1px 3px var(--shadow); }
.source-switch input[type="radio"] { width: .9rem; min-height: 0; height: .9rem; padding: 0; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Both panels contribute to the shared row height; only one is interactive. */
.importer { display: grid; grid-template-columns: minmax(0, 1fr); }
.importer > h2 { grid-area: 1 / 1; }
.importer > .source-switch { grid-area: 2 / 1; }
.youtube-panel, .upload-panel { grid-area: 3 / 1; min-width: 0; }
.upload-panel { visibility: hidden; }
.importer:has(#source-upload:checked) .youtube-panel { visibility: hidden; }
.importer:has(#source-upload:checked) .upload-panel { visibility: visible; }
.importer form > button { display: block; width: 100%; margin-top: 1rem; }
.importer small { display: block; margin-top: .4rem; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; }
.section-heading > a { font-size: .85rem; }
td:last-child { white-space: normal; }
td .job-status { min-width: 9rem; }
@media (max-width: 62rem) { .library-layout { gap: 1rem; } }
@media (max-width: 48rem) { .library-layout { grid-template-columns: minmax(0, 1fr); } }
/* Stretch each source form to the shared panel height and anchor its action. */
.youtube-panel > form, .upload-panel > form { display: flex; flex-direction: column; height: 100%; }
.importer form > button { margin-top: auto; }
.youtube-panel input, .upload-panel small { margin-bottom: 1rem; }
/* Keep active status compact: one label and one inline progress bar. */
.job-status:is([data-state="queued"], [data-state="processing"], [data-state="receiving"]) {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: .6rem;
}
.job-status:is([data-state="queued"], [data-state="processing"], [data-state="receiving"]) > .status-copy,
.job-status:is([data-state="queued"], [data-state="processing"], [data-state="receiving"]) > small { display: none; }
.job-status > .badge { flex-shrink: 0; }
.job-status > progress { flex: 0 0 4rem; width: 4rem; height: .35rem; margin: 0; }
.video-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); overflow: hidden; }
.video-item { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; padding: 1.25rem; }
.video-item + .video-item { border-top: 1px solid var(--divider); }
.video-summary { min-width: 0; flex: 1; }
h2.video-title { font-size: 1rem; font-weight: 600; line-height: 1.5; letter-spacing: normal; margin: 0 0 .4rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.video-title > a, .video-title > span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.video-title a { color: var(--text); text-decoration: none; }
.video-title a:hover { color: var(--link); text-decoration: underline; }
.video-title [aria-disabled] { color: var(--muted); }
.video-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; color: var(--muted); font-size: .8rem; }
.video-meta [data-video-duration] { font-variant-numeric: tabular-nums; }
.video-meta [data-video-duration]:empty, .job-status[data-state="ready"] { display: none; }
.remove-button { background: transparent; border-color: transparent; color: var(--muted); font-size: .8rem; font-weight: 500; padding: .4rem .55rem; }
.remove-button:hover { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.video-item > form { flex: 0 0 auto; }
.video-meta .status-copy { margin: 0; }
@media (max-width: 30rem) { .video-item { padding: 1rem; gap: .5rem; } }

.lesson-panel { min-width: 0; }
/* Give the recording all of its column; align both playback panels at the top. */
.video-layout { margin-top: 1.5rem; }
.video-layout .lesson-panel { margin: 0; }
.video-item { padding-block: .8rem; }
.video-summary { display: flex; align-items: center; gap: .8rem; }
h2.video-title { flex: 1; min-width: 0; margin: 0; }
.video-duration { flex-shrink: 0; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.video-duration:empty { display: none; }
@media (max-width: 48rem) { .video-layout { gap: 1.5rem; } }


.page-header { margin-bottom: 1rem; padding-bottom: 1rem; }
.breadcrumbs { display: flex; align-items: baseline; gap: .8rem; list-style: none; padding: 0; margin: 0; font-size: 1rem; }
.breadcrumbs li { display: flex; align-items: baseline; gap: .8rem; min-width: 0; }
.breadcrumbs li:first-child { flex-shrink: 0; }
.breadcrumbs h1 { margin: 0; font-size: inherit; font-weight: 600; letter-spacing: normal; line-height: 1.5; overflow-wrap: anywhere; }
.breadcrumbs a { font-weight: 500; color: var(--muted); white-space: nowrap; }
.breadcrumbs a:hover { color: var(--link); text-decoration: underline; }
.breadcrumb-separator { color: var(--muted); }
.page-header + main .video-layout { margin-top: 0; }
.page-header + main .library-layout > section { margin-top: 0; }
/* Fill the space below the breadcrumb; scroll transcript content inside the panel. */
body:has(.lesson-panel) { height: 100dvh; display: flex; flex-direction: column; padding-bottom: 1.5rem; }
body:has(.lesson-panel) > .page-header { flex-shrink: 0; }
body:has(.lesson-panel) > main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body:has(.lesson-panel) > main > :not(.video-layout) { flex-shrink: 0; }
body:has(.lesson-panel) .video-layout { flex: 1; min-height: 0; }
.video-layout .lesson-panel { align-self: stretch; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.transcript-panel { display: flex; flex-direction: column; }
.transcript-panel .transcript { flex: 1; min-height: 0; max-height: none; overflow-y: auto; }
@media (max-width: 48rem) {
  body:has(.lesson-panel) { height: auto; min-height: 100dvh; }
  body:has(.lesson-panel) .video-layout { flex: none; }
  .video-layout .lesson-panel { height: max(20rem, calc(100dvh - 5rem)); }
}
.translation-status { flex-shrink: 0; margin: 0 0 .75rem; font-size: .8rem; }
.interactive-panel { display: flex; flex-direction: column; }
.activity-feed { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding-right: .5rem; }
.activity-card { padding: 0; }
.activity-card:first-of-type { padding-top: 0; }
.activity-card[hidden], .activity-card [hidden] { display: none; }
.activity-heading { display: flex; align-items: baseline; gap: .75rem; justify-content: space-between; }
.activity-heading h2 { font-size: 1rem; line-height: 1.5; margin: 0; letter-spacing: normal; }
.activity-heading small { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.activity-options { padding: 0; border: 0; height: auto; margin-bottom: 1rem; }
.activity-options label { display: flex; align-items: baseline; gap: .5rem; font-weight: 400; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: .35rem; cursor: pointer; }
.activity-options input[type="radio"] { flex-shrink: 0; width: auto; min-height: 0; padding: 0; }
.activity-options label:has(input:checked) { border-color: var(--accent); background: var(--selected); }
.activity-card button { font-size: .85rem; padding: .4rem .7rem; }
.activity-feedback { margin-bottom: .4rem; }
.activity-feedback[data-correct="true"] { color: var(--success); }
.activity-explanation { color: var(--muted); }
.order-items { padding: 0; list-style-position: inside; }
.order-items li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem; border-bottom: 1px solid var(--divider); font-size: .9rem; }
.order-actions { display: flex; flex-shrink: 0; gap: .25rem; }
.order-actions button { color: var(--accent); background: var(--selected); border-color: var(--border); }
.order-actions button:disabled { cursor: default; opacity: .35; }
.activity-card input[type="range"] { border: 0; padding: 0; min-height: 1.75rem; }
.activity-card output { font-variant-numeric: tabular-nums; }
.explorer-result { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.explorer-result output { font-size: 1.25rem; font-weight: 600; }
.activity-card meter { width: 100%; height: .7rem; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-header > nav { min-width: 0; padding-top: .35rem; }
.header-controls { display: flex; gap: .4rem; flex-shrink: 0; margin-left: auto; }
.icon-toggle { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: 0; border-color: var(--border); background: var(--surface); color: var(--text); font-size: 1.25rem; line-height: 1; }
.icon-toggle:hover { background: var(--subtle); }
@media (max-width: 30rem) { .page-header { gap: .5rem; } .breadcrumbs { flex-wrap: wrap; gap: .25rem .5rem; } }

.topic-navigation { flex-shrink: 0; margin-bottom: 1rem; }
.topic-row { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr) 2.25rem; align-items: center; gap: .4rem; }
.topic-picker { position: relative; min-width: 0; }
.topic-title { display: block; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: center; font-size: .95rem; font-weight: 600; }
.topic-dropdown-icon { display: block; flex: 0 0 1rem; width: 1rem; height: 1rem; fill: none; stroke: var(--muted); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.topic-row button { display: grid; place-items: center; padding: 0; width: 2.25rem; height: 2.5rem; line-height: 1; border-color: transparent; background: transparent; color: var(--text); }
.topic-row button svg { display: block; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.topic-row button:hover:not(:disabled) { background: var(--subtle); }
.topic-row button:disabled { cursor: default; opacity: .3; }
[data-topic-page][hidden] { display: none; }
.transcript-line { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: baseline; gap: .7rem; width: 100%; text-align: left; color: var(--text); background: transparent; border: 0; border-left: 3px solid transparent; border-radius: .35rem; padding: .4rem .55rem; margin-bottom: .15rem; font-size: .9rem; font-weight: 400; line-height: 1.55; }
.transcript-time { min-width: 3.25rem; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transcript-text { min-width: 0; overflow-wrap: anywhere; }
.coarse-timing { display: block; color: var(--muted); }
.transcript-line:hover { background: var(--subtle); }
.transcript-line.is-current { background: var(--selected); border-left-color: var(--accent); }
.transcript-line:focus-visible { outline-offset: -3px; }

/* Topic navigation and transcript belong to the video; exercises stay alongside. */
.video-column { align-self: stretch; display: flex; flex-direction: column; min-height: 0; gap: 1rem; }
.video-browser { flex-shrink: 0; min-width: 0; overflow: visible; border: 1px solid var(--input-border); border-radius: .75rem; background: var(--surface); box-shadow: 0 2px 8px var(--shadow); }
.video-browser > .topic-navigation { margin: 0; padding: .35rem .45rem; border-bottom: 1px solid var(--border); }
.video-browser > video { aspect-ratio: 16 / 9; height: auto; max-height: min(45dvh, 28rem); object-fit: contain; border: 0; border-radius: 0; }
.video-browser > p { padding: .75rem 1rem; }
.video-column > .transcript-panel { flex: 1; min-height: 8rem; margin: 0; overflow: hidden; padding: 1rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
@media (max-width: 48rem) {
  .video-column > .transcript-panel { flex: none; height: max(16rem, 40dvh); }
  .video-browser > video { max-height: 60dvh; }
}

.video-layout .activity-empty { font-size: 1rem; }



/* Activity navigation expands upward from its persistent footer controls. */
.activity-browser { display: flex; flex-direction: column; flex: 0 1 auto; min-width: 0; min-height: 3.25rem; max-height: 33.333%; overflow: hidden; border-top: 1px solid var(--divider); background: var(--page); }
.activity-browser ol { list-style: none; margin: 0; padding: 0; }
.activity-browser a { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr); align-items: baseline; gap: .5rem; padding: .4rem .6rem; border-radius: .35rem; font-size: .9rem; font-weight: 400; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.activity-browser a:hover { background: var(--subtle); }
.activity-browser a[aria-current="true"] { background: var(--selected); color: var(--accent); font-weight: 600; }
.activity-browser a:focus-visible { outline-offset: -3px; }

.sidebar-tabs { display: grid; grid-template-columns: 1fr 1fr; flex-shrink: 0; border-bottom: 1px solid var(--divider); background: var(--page); }
.sidebar-tabs button { margin: 0; padding: .85rem 1rem; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); font-size: .9rem; }
.sidebar-tabs button[aria-selected="true"] { background: var(--surface); border-bottom-color: var(--accent); color: var(--text); }
.sidebar-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar-view[hidden] { display: none; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding: .25rem .5rem .5rem 0; }
.chat-message { width: fit-content; max-width: 95%; margin: 0 0 1rem; padding: .65rem .8rem; border-radius: .65rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.chat-message--assistant { background: var(--subtle); }
.chat-message--user { margin-left: auto; background: var(--selected); }
#chat-error[hidden] { display: none; }
.chat-typing { display: flex; gap: 5px; width: fit-content; margin: 0 0 1rem; padding: 6px 2px; }
.chat-typing span:not(.visually-hidden) { width: 7px; height: 7px; background: var(--muted); border-radius: 50%; --dot-delay: 280ms; --idle-animation: typing-idle-left; animation: typing-drop 420ms linear var(--dot-delay) 1 both, var(--idle-animation) 1400ms linear 980ms infinite; }
.chat-typing span:nth-child(3) { --dot-delay: 140ms; --idle-animation: typing-idle-middle; }
.chat-typing span:nth-child(4) { --dot-delay: 0ms; --idle-animation: typing-idle-right; }
.chat-typing--exiting span:not(.visually-hidden) { animation: typing-lift 420ms linear var(--dot-delay) both; }

@keyframes typing-drop {
  0% {
    opacity: 0;
    transform: translateY(-7px) scale(.92);
    animation-timing-function: cubic-bezier(.42, 0, .72, .3);
  }
  58% {
    opacity: .68;
    transform: translateY(.75px) scale(1.04, .92);
    animation-timing-function: cubic-bezier(.2, .85, .3, 1.12);
  }
  80% {
    opacity: .56;
    transform: translateY(-.5px) scale(.98, 1.025);
    animation-timing-function: ease-out;
  }
  100% { opacity: .48; transform: translateY(0) scale(1); }
}

@keyframes typing-lift {
  0% { opacity: .48; transform: translateY(0) scale(1); }
  18% {
    opacity: .62;
    transform: translateY(.5px) scale(1.04, .92);
    animation-timing-function: cubic-bezier(.15, .7, .25, 1);
  }
  100% { opacity: 0; transform: translateY(-7px) scale(.92); }
}

@keyframes typing-idle-right {
  0%, 30%, 100% { opacity: .48; transform: translateY(0) scale(1); }
  7% { transform: translateY(.5px) scale(1.03, .94); }
  16% { opacity: .82; transform: translateY(-2px) scale(.98, 1.025); }
}

@keyframes typing-idle-middle {
  0%, 40%, 100% { opacity: .48; transform: translateY(0) scale(1); }
  17% { transform: translateY(.5px) scale(1.03, .94); }
  26% { opacity: .82; transform: translateY(-2px) scale(.98, 1.025); }
}

@keyframes typing-idle-left {
  0%, 50%, 100% { opacity: .48; transform: translateY(0) scale(1); }
  27% { transform: translateY(.5px) scale(1.03, .94); }
  36% { opacity: .82; transform: translateY(-2px) scale(.98, 1.025); }
}


@media (prefers-reduced-motion: reduce) { .chat-message, .chat-typing span:not(.visually-hidden) { animation: none; } }

/* One sidebar surface: mode switch, working area, and a quiet navigation footer. */
.video-layout .interactive-panel { padding: 0; }
.sidebar-tabs button:hover { background: var(--subtle); }
.sidebar-tabs button:focus-visible { outline-offset: -4px; }
.sidebar-view > .activity-feed { padding: 1.25rem; }
.sidebar-view > p, .sidebar-view > form:not(.chat-composer) { margin: 1rem 1.25rem; }
.activity-group + .activity-group { margin-top: .65rem; }
.activity-group h3 { margin: 0 0 .25rem; padding: 0 .6rem; font-size: .75rem; line-height: 1.4; font-weight: 600; color: var(--muted); }
.activity-index { font-size: .75rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.activity-browser a[aria-current="true"] .activity-index { color: var(--accent); }
#chat-view .chat-messages { padding: 1.25rem; }
#chat-view #chat-error { margin: .5rem 1rem; }

#chat-view .chat-composer { flex-shrink: 0; padding: .75rem 1rem 1rem; }
.chat-input-shell { display: flex; align-items: flex-end; gap: .5rem; width: 100%; padding: .4rem; border: 1px solid var(--input-border); border-radius: 1rem; background: var(--surface); }
.chat-input-shell:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--selected); }
.chat-input-shell textarea { display: block; flex: 1; min-width: 0; min-height: 2.25rem; max-height: 10rem; resize: none; overflow-y: auto; border: 0; outline: none; background: transparent; color: var(--text); padding: .4rem .5rem; font: inherit; font-size: .95rem; line-height: 1.5; }
.chat-input-shell textarea::placeholder { color: var(--muted); }
.chat-input-shell button { display: grid; place-items: center; flex-shrink: 0; width: 2.25rem; height: 2.25rem; padding: 0; border-radius: .7rem; }
.chat-input-shell button svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#activities-view > .activity-feed { min-width: 0; padding: 1rem; }
.activity-browser a { grid-template-columns: 1rem minmax(0, 1fr); gap: .35rem; padding: .4rem; font-size: .8rem; }
.activity-group h3 { padding-inline: .4rem; }

.activity-rail { display: flex; align-items: center; gap: .4rem; flex: 0 0 3.25rem; padding: .5rem .75rem; }
.activity-rail button { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 0; background: transparent; color: var(--text); }
.activity-rail button:hover:not(:disabled), .activity-rail button[aria-expanded="true"] { background: var(--selected); color: var(--accent); }
.activity-rail button:disabled { opacity: .3; cursor: default; }
.activity-rail svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.activity-browser > #activity-list { flex: 1; min-width: 0; overflow-y: auto; min-height: 0; padding: .75rem; scrollbar-gutter: stable; }
.activity-browser > #activity-list[hidden] { display: none; }

#activity-previous { margin-left: auto; }
.activity-browser:has(#activity-expand[aria-expanded="true"]) .activity-rail { border-top: 1px solid var(--divider); }

.video-icon-slot { display: inline-flex; align-items: center; flex-shrink: 0; color: var(--muted); }
.video-icon { display: block; width: 1.15rem; height: 1.15rem; }
.breadcrumbs .video-icon-slot { align-self: center; margin-right: -.3rem; }

.video-item { gap: .75rem; padding: .5rem .75rem .5rem .5rem; }
.video-item-icon { display: grid; place-items: center; width: 2.75rem; aspect-ratio: 1; border-radius: .4rem; background: var(--page); }
.video-item-icon .video-icon { width: 1.2rem; height: 1.2rem; opacity: .7; }
.video-item:has(.job-status[data-lesson-pending="true"]) .video-item-icon .video-icon { display: none; }
.video-item:has(.job-status[data-lesson-pending="true"]) .video-item-icon::after { content: ""; width: 1.1rem; height: 1.1rem; border: 2px solid var(--border); border-top-color: var(--muted); border-radius: 50%; animation: lesson-working .8s linear infinite; }
.video-list .job-status:is([data-state="queued"], [data-state="processing"], [data-state="receiving"]) { display: none; }
@media (prefers-reduced-motion: reduce) { .video-item .video-item-icon::after { animation: none !important; } }

a.video-item-icon { text-decoration: none; }
a.video-item-icon:hover { background: var(--subtle); color: var(--accent); }
a.video-item-icon:hover .video-icon { opacity: 1; }

.topic-row #topic-trigger { display: flex; align-items: center; justify-content: center; gap: .4rem; width: 100%; height: auto; min-height: 2.65rem; padding: .45rem .65rem; border-radius: .45rem; line-height: 1.5; }
.topic-row #topic-trigger[aria-expanded="true"] { background: var(--selected); }
.topic-row #topic-trigger .topic-dropdown-icon { width: 1rem; height: 1rem; color: var(--muted); }
.topic-menu { position: absolute; z-index: 20; top: calc(100% + .5rem); left: 0; right: 0; max-height: min(50dvh, 24rem); overflow-y: auto; padding: .35rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); box-shadow: 0 8px 24px var(--shadow); }
.topic-menu[hidden] { display: none; }
.topic-row .topic-menu button { display: grid; grid-template-columns: 3rem minmax(0, 1fr); gap: .6rem; align-items: baseline; justify-items: stretch; width: 100%; height: auto; padding: .65rem .6rem; text-align: left; font-size: .875rem; font-weight: 400; line-height: 1.45; }
.topic-menu time { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.topic-menu button[aria-current="true"] { background: var(--selected); color: var(--accent); font-weight: 600; }
.topic-menu button:focus-visible { outline-offset: -2px; }
.video-browser > video { border-radius: 0 0 .7rem .7rem; }

#topic-trigger .topic-title { text-align: center; }

.topic-menu button > [data-i18n] { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.topic-menu time { white-space: nowrap; }

.transcript-topic + .transcript-topic { margin-top: 1.25rem; }
.transcript-topic-heading { margin: 0 0 .45rem; padding: .4rem .7rem; border-radius: .35rem; background: var(--subtle); color: var(--muted); font-size: .8rem; font-weight: 600; line-height: 1.5; }

.transcript-panel { position: relative; }
#lesson-transcript { overflow-anchor: none; }
.transcript-resume { position: absolute; z-index: 2; left: 0; right: 0; width: 100%; border: 0; border-radius: 0; color: #202936; font-size: .85rem; font-weight: 600; text-align: center; }
.transcript-resume[data-direction="up"] { top: 0; padding: .7rem .5rem 1.8rem; background: linear-gradient(to bottom, #fffffff2 0%, #ffffffcc 45%, #ffffff00); }
.transcript-resume[data-direction="down"] { bottom: 0; padding: 1.8rem .5rem .7rem; background: linear-gradient(to top, #fffffff2 0%, #ffffffcc 45%, #ffffff00); }
.transcript-resume:hover { text-decoration: underline; }
.transcript-resume:focus-visible { outline-offset: -4px; }
.transcript-resume[hidden] { display: none; }

.video-item { display: block; padding: 0; }
.video-row { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem .5rem .5rem; }
.video-row > form { flex-shrink: 0; }
.video-topics-toggle { display: grid; place-items: center; flex-shrink: 0; width: 1.75rem; height: 2rem; padding: 0; background: transparent; border: 0; color: var(--muted); }
.video-topics-toggle:hover:not(:disabled) { background: var(--subtle); color: var(--text); }
.video-topics-toggle:disabled { opacity: .35; cursor: default; }
.video-topics-toggle svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.video-topics-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.library-topic-list { list-style: none; margin: 0; padding: .25rem .75rem .75rem .5rem; }
.library-topic-list[hidden] { display: none; }
.library-topic-list a { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr); gap: .75rem; align-items: baseline; padding: .35rem 0; border-radius: .35rem; font-size: .85rem; text-align: left; text-decoration: none; color: var(--text); }
.library-topic-list a > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.library-topic-list a:hover { background: var(--subtle); }
.library-topic-list time { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }

.login-form { max-width: 24rem; margin: 8vh auto; padding: 1.5rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
.login-form h1 { font-size: 1.4rem; }
.login-form > button { margin-top: 1rem; width: 100%; }
.logout-button { height: 2.5rem; padding: .4rem .65rem; background: transparent; color: var(--muted); border-color: var(--border); font-size: .8rem; }
.logout-button:hover { background: var(--subtle); }

:root[data-theme="dark"] .transcript-resume { color: #f3f4f6; }
:root[data-theme="dark"] .transcript-resume[data-direction="up"] { background: linear-gradient(to bottom, #111720f2 0%, #111720cc 45%, #11172000); }
:root[data-theme="dark"] .transcript-resume[data-direction="down"] { background: linear-gradient(to top, #111720f2 0%, #111720cc 45%, #11172000); }

.chat-suggestions { flex-shrink: 1; min-height: 0; max-height: 35%; overflow-y: auto; padding: 0 1rem; }
.chat-suggestions [data-chat-topic] { display: flex; flex-direction: column; gap: .4rem; }
.chat-suggestions [hidden] { display: none; }
.chat-suggestions button { padding: .5rem .7rem; border: 1px solid var(--border); border-radius: .65rem; background: transparent; color: var(--muted); font-size: .85rem; line-height: 1.4; font-weight: 400; text-align: left; }
.chat-suggestions button:hover:not(:disabled) { background: var(--selected); color: var(--text); border-color: var(--input-border); }
.chat-suggestions button:disabled { cursor: wait; opacity: .5; }

.chat-message--assistant { white-space: normal; }
.chat-message--assistant > :first-child { margin-top: 0; }
.chat-message--assistant > :last-child { margin-bottom: 0; }
.chat-message--assistant p, .chat-message--assistant ul, .chat-message--assistant ol { margin: .6em 0; }
.chat-message--assistant ul, .chat-message--assistant ol { padding-left: 1.5em; }
.chat-message--assistant h1, .chat-message--assistant h2, .chat-message--assistant h3 { font-size: 1.05em; margin: 1em 0 .5em; }
.chat-message--assistant pre { white-space: pre; overflow-x: auto; max-width: 100%; padding: .6em; background: var(--surface); border-radius: .35rem; }
.chat-message--assistant code { font-size: .9em; }
.chat-message--assistant blockquote { margin: .6em 0; padding-left: .8em; border-left: 2px solid var(--border); color: var(--muted); }
.chat-message--assistant table { display: block; overflow-x: auto; border-collapse: collapse; }
.chat-message--assistant th, .chat-message--assistant td { padding: .35em .6em; border: 1px solid var(--border); }

.lesson-loading { max-width: 34rem; margin: 1rem auto 1.5rem; padding: 1.1rem 1.25rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); }
.lesson-loading[hidden] { display: none; }
.lesson-loading-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.lesson-loading-heading > span { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-loading > progress { display: block; width: 100%; height: .35rem; margin: .8rem 0 1rem; accent-color: var(--accent); }
.lesson-loading-steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: .9rem; list-style: none; margin: 0; padding: 0; }
.lesson-loading-step { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.lesson-loading-step small { margin-left: auto; color: var(--muted); font-size: .75rem; }
.lesson-loading-step > span:first-child { display: grid; place-items: center; flex: 0 0 1rem; height: 1rem; line-height: 1; text-align: center; color: var(--muted); }
[data-step-state="processing"] .lesson-loading-step > span:first-child { color: var(--accent); }
.lesson-loading-detail, .lesson-loading-connection { color: var(--muted); font-size: .8rem; margin: .4rem 0 0 1.5rem; overflow-wrap: anywhere; }
.lesson-loading form { margin: .5rem 0 0 1.5rem; }
.lesson-loading form button { padding: .25rem .6rem; font-size: .8rem; }
@media (max-width: 650px) { .lesson-loading-steps { grid-template-columns: 1fr; } }
main:has(> #pending-lesson) { min-height: calc(100dvh - 10rem); display: grid; align-content: center; }
main:has(> #pending-lesson) > .lesson-loading { width: min(100%, 34rem); }

.lesson-loading-step { column-gap: .6rem; }
.lesson-loading-step small { white-space: nowrap; font-variant-numeric: tabular-nums; }
.loading-spinner { display: block; width: .9rem; height: .9rem; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: lesson-working .8s linear infinite; }
@keyframes lesson-working { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-spinner { animation: none; } }
