/* The lesson panel shares one paper surface across reading, recording and writing. */
.lesson-desk {
  --practice-accent:#345d50;
  --practice-soft:#eaf1eb;
  --practice-paper:#faf8f2;
  --record-fill:var(--ink);
  --record-text:var(--surface);
  --practice-rule:color-mix(in srgb,var(--ink) 13%,var(--surface));
  --reading:Georgia,"Times New Roman",serif;
}
[data-theme=dark] .lesson-desk {
  --practice-accent:#b1d5be;--practice-soft:#293a34;--practice-paper:#292b29;--record-fill:#eac47c;--record-text:#25231f;
}
.lesson-desk [role=tabpanel]:not(#pane-script) {padding:clamp(16px,4.8cqi,30px);}
.lesson-desk .desk-tabs {background:var(--surface);padding:0 5px;gap:0;border-color:var(--practice-rule);}
.desk-tabs button,.desk-tabs button[aria-selected=true] {border:0;border-radius:0;box-shadow:none;background:transparent;min-height:48px;}
.desk-tabs button[aria-selected=true] {color:var(--practice-accent);box-shadow:inset 0 -3px var(--practice-accent);}
.lesson-desk .voice-modes {display:flex;justify-content:center;width:fit-content;max-width:100%;gap:2px;padding:3px;margin:0 auto 16px;background:var(--paper);border:1px solid var(--practice-rule);border-radius:100px;}
.lesson-desk .voice-modes button {border:0;border-radius:100px;padding:6px clamp(7px,2.4cqi,16px);background:transparent;font-size:.9rem;line-height:1.3;min-height:33px;}
.lesson-desk .voice-modes [aria-pressed=true] {background:var(--practice-soft);color:var(--practice-accent);}
.cue-progress {display:flex;align-items:center;gap:10px;color:var(--secondary);font-size:.85rem;font-variant-numeric:tabular-nums;}
.lesson-desk .cue-progress button {padding:0;width:32px;height:32px;border:1px solid var(--practice-rule);background:var(--surface);border-radius:50%;display:grid;place-items:center;}
.cue-progress [data-step="-1"] .icon {transform:rotate(180deg);}
.cue-progress button:disabled {opacity:.33;}
.cue-progress .icon {width:14px;height:14px;}
.lesson-desk progress {height:4px;border:0;border-radius:4px;appearance:none;overflow:hidden;background:var(--practice-rule);}
.lesson-desk progress::-webkit-progress-bar {background:var(--practice-rule);}
.lesson-desk progress::-webkit-progress-value {background:var(--practice-accent);border-radius:4px;}
.lesson-desk progress::-moz-progress-bar {background:var(--practice-accent);}
.cue-progress progress {flex:1;width:0;}
.lesson-desk .voice-box {margin:14px 0 0;border:0;padding:18px 0 0;background:var(--practice-paper);border-radius:14px;}
.speaking-cue .karaoke {padding:8px clamp(14px,5cqi,32px) 16px;text-align:center;background:transparent;}
.speaking-cue .line {font:normal clamp(24px,6.8cqi,38px)/1.32 var(--reading);letter-spacing:-.025em;text-wrap:pretty;}
.speaking-cue .word .lexeme {font:inherit;display:inline;padding:0;background:transparent;border:none;color:inherit;}
.speaking-cue .translation {font-size:.95rem;font-weight:400;line-height:1.45;margin:12px auto 0;color:var(--secondary);max-width:36em;}
.voice-box .voice-tools {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));align-items:end;gap:2px;margin:0 auto;max-width:360px;padding:12px 10px 0;}
.voice-tools button.voice-action {display:grid;justify-items:center;align-content:end;gap:8px;background:transparent;border:0;border-radius:8px;color:var(--ink);padding:0;box-shadow:none;font-size:.82rem;line-height:1.2;white-space:nowrap;}
.voice-action .disc {width:39px;height:39px;display:grid;place-items:center;border:1px solid var(--practice-rule);border-radius:50%;background:var(--surface);}
.voice-action .disc .icon {width:18px;height:18px;}
.voice-tools button.voice-action.record {align-self:center;align-content:center;min-height:58px;padding:6px 3px;gap:3px;background:var(--record-fill);color:var(--record-text);border:1px solid var(--record-fill);border-radius:10px;}
.voice-action.record .disc {width:22px;height:22px;border:0;background:transparent;color:inherit;}
.voice-action.record .disc .icon {width:21px;height:21px;}
.voice-tools .record:focus-visible {outline:2px solid var(--accent-ink);outline-offset:3px;}
.voice-action.record:enabled:hover .disc {outline:none;}
.voice-tools button.record:enabled:hover {filter:brightness(.92);}
.recording .voice-tools button.record {background:var(--wash);color:var(--accent-ink);border-color:currentColor;}
.voice-action:disabled {opacity:.4;}
.voice-action:enabled:hover .disc {outline:2px solid var(--practice-accent);outline-offset:2px;}
.lesson-desk .voice-caption {display:block;text-align:center;font-size:.8rem;font-weight:450;line-height:1.4;padding:14px 16px 18px;}
.voice-box :is(.voice-take,.voice-state,.rhythm-panel,.voice-result):not(:empty):not([hidden]) {padding:8px 14px 14px;}
.voice-box .voice-take:not([hidden]) {margin:0;border-top:1px solid var(--practice-rule);}
.lesson-desk .practice-side form {gap:14px;margin:18px 0 0;}
.listen-prompt,.listen-footer,.sheet-summary,.sheet-buttons,.sheet-cue {display:flex;align-items:center;justify-content:space-between;gap:10px;}
.listen-prompt label,.sheet-summary strong {font-size:1.15rem;line-height:1.3;}
.listen-prompt [data-hear],.sheet-cue [data-hear],.quiz-card .evidence {border:0;background:var(--practice-soft);color:var(--practice-accent);}
.practice-side [data-hear] {white-space:nowrap;}
.practice-side [data-hear] kbd {font:500 .74rem/1.2 system-ui;opacity:.8;}
.practice-side textarea {font:1.08rem/1.85 var(--reading);border:1px solid var(--practice-rule);border-radius:8px;background:var(--practice-paper);min-height:65px;box-sizing:border-box;}
.practice-side textarea:focus,.practice-side .blank:focus {outline:2px solid var(--practice-accent);outline-offset:2px;}
.listen-footer {align-items:flex-start;}
.listen-footer details {flex:1;font-size:.92rem;color:var(--secondary);}
.listen-footer summary {cursor:pointer;padding:6px 0;width:fit-content;}
.listen-footer .primary,.sheet-buttons .primary {background:var(--practice-accent);border-color:var(--practice-accent);color:var(--surface);}
.lesson-desk .gap-prompt {padding:20px 16px;background:var(--practice-paper);border-radius:8px;font:clamp(21px,5.9cqi,30px)/1.6 var(--reading);}
.gap-prompt input.blank {width:6.2ch;max-width:100%;font:inherit;text-align:center;border:0;border-bottom:2px solid var(--practice-accent);border-radius:0;background:var(--practice-soft);color:var(--ink);}
.sheet-summary span,.sheet-cue small,.sheet-select small {font-size:.82rem;color:var(--secondary);font-variant-numeric:tabular-nums;}
.sheet-progress {width:100%;display:block;margin:8px 0;}
.lesson-desk .sheet-tip {color:var(--secondary);font-size:.88rem;line-height:1.45;margin:0 0 14px;}
.sheet-list {position:relative;max-height:clamp(260px,50vh,530px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;}
.sheet-list button.sheet-select {display:grid;grid-template-columns:24px minmax(0,1fr) auto;align-items:center;gap:8px;border:0;border-bottom:1px solid var(--practice-rule);border-radius:0;background:transparent;text-align:left;padding:12px 6px;width:100%;font-weight:450;}
.sheet-select span:first-child {font:12px ui-monospace,monospace;color:var(--secondary);}
.sheet-select span:nth-child(2) {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.lesson-desk .sheet-active {margin:0;padding:14px;border-radius:9px;background:var(--practice-paper);gap:10px;}
.sheet-cue strong {margin-right:auto;}
.sheet-cue button,.sheet-buttons button {font-size:.86rem;}
.sheet-list textarea {background:var(--surface);}
.sheet-clue:empty,.sheet-status:empty {display:none;}
.sheet-status {padding-top:10px;color:var(--practice-accent);}
.guide-heading .tag {color:var(--practice-accent);}
.lesson-desk .guide-heading h2 {font:600 clamp(23px,6cqi,32px)/1.22 var(--reading);letter-spacing:-.035em;}
.lesson-desk .quiz-card {border:0;border-block:1px solid var(--practice-rule);background:transparent;border-radius:0;margin:16px 0 0;padding:16px 0;}
.quiz-card .exercise-head {color:var(--secondary);font-size:.85rem;}
.quiz-card .exercise-head h3 {font-size:.9rem;font-weight:550;}
.quiz-card h4 {font-size:1.17rem;line-height:1.4;margin:7px 0 12px;}
.quiz-choices {gap:0;border-block:1px solid var(--practice-rule);}
.lesson-desk .quiz-choices button {display:flex;align-items:center;gap:10px;border:0;border-bottom:1px solid var(--practice-rule);border-radius:0;padding:11px 7px;font-weight:450;}
.quiz-choices button:last-child {border:0;}
.choice-letter {display:grid;place-items:center;flex:none;width:23px;height:23px;border-radius:50%;background:var(--paper);border:1px solid var(--practice-rule);font:600 11px system-ui;}
.quiz-choices .correct .choice-letter {background:var(--practice-accent);color:var(--surface);}
.quiz-choices .incorrect .choice-letter {border-color:#b77362;}
.study-detail {border-top:0;}
.study-phrases article {padding:16px 0;gap:4px;}
.study-phrases article>strong {font:600 1.25rem/1.35 var(--reading);}
.study-phrases article>p {font-size:.94rem;line-height:1.45;font-weight:400;}
.study-phrases .phrase-actions {display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr);align-items:stretch;gap:8px;margin-top:7px;}
.study-phrases .phrase-actions button {display:flex;align-items:center;justify-content:center;margin:0;min-height:38px;line-height:1.25;font-size:.88rem;padding:5px;}
.study-phrases .phrase-actions .evidence {background:var(--practice-soft);color:var(--practice-accent);border-color:transparent;}
.controls #autopause {display:inline-flex;align-items:center;gap:6px;}
#autopause::before {content:"";width:21px;height:12px;border-radius:10px;background:radial-gradient(circle at 6px center,var(--surface) 3.5px,transparent 4px),var(--secondary);}
#autopause[aria-pressed=true]::before {background:radial-gradient(circle at 15px center,var(--surface) 3.5px,transparent 4px),var(--accent-ink);}

.focus-head,.focus-nav,.focus-caption,.focus-more,.focus-gap-choices {display:none;}
.focus-sheet {color:var(--ink);background:var(--surface);border:1px solid var(--line);}
@media(max-width:760px){
  body:has(.focus-head) {overflow:hidden;}
  body:has(.focus-head)>:is(header,footer,.rail) {display:none;}
  #app:has(.focus-head) {
    position:fixed;inset:auto 0;top:var(--focus-top,0);height:var(--focus-height,100dvh);width:100%;max-width:none;
    display:grid;grid-template-rows:auto minmax(0,1fr) auto;margin:0;padding:0;overflow:hidden;background:var(--surface);
  }
  #app:has(.focus-head)>:not(.focus-head,.learning,.focus-nav,dialog) {display:none;}
  .focus-head {display:flex;align-items:center;gap:2px;padding:env(safe-area-inset-top) 8px 0;min-height:48px;background:var(--surface);border-bottom:1px solid var(--line);}
  .focus-heading {flex:1;min-width:0;line-height:1.15;}
  .focus-heading small {display:block;font-size:.74rem;color:var(--secondary);}
  .focus-head strong {display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:1.03rem;}
  .focus-head :is(a,button),.focus-sheet-head button {display:grid;place-items:center;width:38px;height:42px;border:0;background:transparent;color:var(--ink);}
  .focus-head a svg {transform:rotate(180deg);}
  .focus-head [aria-pressed=true] svg {fill:var(--accent-ink);stroke:var(--accent-ink);}
  .focus-head .icon,.focus-sheet-head .icon {width:21px;height:21px;}
  #app .learning:has(.lesson-desk) {display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);gap:0;align-items:stretch;min-height:0;}
  .learning:has(.lesson-desk)>div:first-child {min-width:0;background:var(--surface);}
  .learning .frame,.learning[data-activity=listen]:has(textarea:focus) .frame:has(audio) {
    width:100%;height:min(56.25vw,32lvh);aspect-ratio:auto;border-radius:0;background:#151615;
  }
  .learning[data-activity=listen]:has(textarea:focus) .frame:has(audio) img {visibility:visible;}
  .learning .stage>.karaoke,.learning:has(.lesson-desk)>div:first-child>.context:empty,.learning:has(.lesson-desk)>div:first-child>.context:not(#player-status) {display:none;}
  #player-status:not(:empty){margin:0;padding:3px 10px;line-height:1.3;}
  .focus-caption {display:grid;align-content:center;gap:2px;height:62px;padding:4px 15px;text-align:center;background:var(--paper);border-bottom:1px solid var(--line);overflow:auto;}
  .focus-caption span {font:500 1.03rem/1.24 Georgia,serif;}
  .focus-caption small {font-size:.81rem;line-height:1.22;color:var(--secondary);}
  .learning:has(.line.hidden) .focus-caption span,.learning:has(.translation.hidden) .focus-caption small {display:none;}
  .learning:is([data-activity=listen],[data-activity=speak]) .focus-caption {display:none;}
  .lesson-desk {min-height:0;overflow:auto;overscroll-behavior:contain;border:0;border-radius:0;container-type:inline-size;scrollbar-width:thin;}
  .lesson-desk .desk-tabs {display:none;}
  .lesson-desk [role=tabpanel]:not(#pane-script) {padding:12px 14px 14px;}
  #pane-script,.lesson-desk .transcript {height:100%;min-height:0;}
  .lesson-desk .transcript {display:flex;flex-direction:column;}
  .lesson-desk .cues {flex:1;min-height:0;max-height:none;}
  .lesson-desk .cue-filter input {font-size:16px;}
  .focus-nav {display:grid;grid-template-columns:repeat(5,minmax(0,1fr));align-items:center;gap:2px;padding:5px 5px max(5px,env(safe-area-inset-bottom));background:var(--surface);border-top:1px solid var(--line);}
  .focus-nav button {display:block;min-height:43px;background:transparent;color:var(--secondary);border:0;border-radius:10px;padding:3px 1px;font-size:clamp(.76rem,3.35vw,.95rem);font-weight:650;}
  .focus-nav [aria-current=page],.focus-more [aria-pressed=true] {color:var(--surface);background:var(--ink);}
  .lesson-desk .voice-box {padding:12px 0 0;margin-top:8px;}
  .lesson-desk .voice-modes {margin:0 auto 9px;}
  .speaking-cue .karaoke {padding:5px 12px 9px;}
  .speaking-cue .line {font-size:clamp(20px,6.3vw,28px);}
  .speaking-cue {max-height:clamp(75px,22dvh,210px);overflow:auto;}
  .voice-box .voice-tools {padding-top:5px;}
  .lesson-desk .voice-caption {padding:8px 7px 10px;}
  .focus-more,.focus-gap-choices {display:flex;flex-wrap:wrap;gap:6px;}
  .focus-more {margin-bottom:14px;align-items:center;border-bottom:1px solid var(--line);padding:0 0 10px;}
  .focus-more :is(button,a) {padding:5px 9px;font-size:.88rem;}
  .focus-more a {margin-left:auto;color:var(--accent-ink);}
  #pane-guide[data-mobile-part=quiz] .study-phrases,#pane-guide[data-mobile-part=phrases] :is(.quiz-card,.study-detail,.guide-heading) {display:none;}
  .focus-gap-choices {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));}
  .focus-gap-choices button {min-height:38px;overflow-wrap:anywhere;}
  .gap-prompt input.blank {pointer-events:none;}
  .lesson-desk .practice-side form {gap:10px;margin-top:10px;}
  .lesson-desk .sheet-active {margin-top:0;}
  .practice-side [data-hear] kbd {display:none;}
  #pane-listen textarea,.practice-side .blank {font-size:16px;}
  #pane-listen .voice-modes [data-mode=gap] {display:none;}
  .learning[data-listen-mode=gap] #pane-listen>.voice-modes {display:none;}
  .learning[data-listen-mode=gap] .listen-footer>.primary {display:none;}
  .lesson-desk .gap-prompt {font-size:1.32rem;padding:10px 12px;}
  .focus-sheet {position:fixed;inset:auto 0 0;margin:0;width:100%;max-width:none;max-height:78dvh;border-radius:19px 19px 0 0;padding:16px 18px max(18px,env(safe-area-inset-bottom));}
  .focus-sheet::backdrop {background:#10171169;}
  .focus-sheet-head {display:flex;align-items:center;justify-content:space-between;gap:12px;}
  .focus-sheet-head h2 {margin:0;font-size:1.22rem;line-height:1.3;}
  .focus-settings .controls {display:flex;flex-wrap:wrap;gap:8px;margin:12px 0 0;}
  .focus-info p {margin:8px 0;}
  .focus-info small {color:var(--secondary);}
  #app.keyboard-open .focus-head,#app.keyboard-open .focus-nav {display:none;}
  #app.keyboard-open {grid-template-rows:minmax(0,1fr);}
  #app.keyboard-open .learning .frame {height:clamp(48px,calc(var(--focus-height) - 275px),135px);}
  #app.keyboard-open .lesson-desk [role=tabpanel] {padding-block:6px;}
  #app.keyboard-open #pane-listen>.voice-modes,#app.keyboard-open .sheet-tip {display:none;}
  #app.keyboard-open .sheet-list {max-height:calc(var(--focus-height) - 180px);min-height:110px;}
  #app.keyboard-open .practice-side textarea {resize:none;min-height:52px;max-height:84px;}
}
@media(max-width:760px) and (max-height:660px){
  .lesson-desk .voice-caption {padding-block:5px;}
  .speaking-cue .translation {margin-top:4px;}
  .voice-tools button.voice-action.record {min-height:48px;}
  .lesson-desk .voice-box {padding-top:8px;}
}
.focus-words {display:none;}
@media(max-width:760px){
  #pane-guide[data-mobile-part=phrases]>.focus-words {display:block;}
  #pane-guide[data-mobile-part=phrases]>:not(.focus-more,.study-phrases,.focus-words) {display:none;}
  .focus-words article {display:grid;grid-template-columns:1fr auto;align-items:center;padding:12px 0;gap:6px;border-bottom:1px solid var(--line);}
  .focus-words .lexeme {justify-self:start;font:600 1.22rem Georgia,serif;text-decoration:underline;text-underline-offset:3px;}
  .focus-words article p {grid-column:1/-1;color:var(--secondary);}
  .focus-words [data-cue] {display:flex;align-items:center;gap:4px;padding:4px 7px;font-size:.84rem;}
  .focus-words .icon {width:14px;height:14px;}
}
.word-fields {display:flex;align-content:flex-start;flex-wrap:wrap;gap:7px;padding:12px 0;}
.word-fields input {min-width:0;max-width:100%;min-height:37px;border:0;border-bottom:2px solid var(--secondary);border-radius:4px 4px 0 0;background:var(--practice-paper);color:var(--ink);text-align:center;font:1rem/1.3 system-ui;}
.word-fields input:focus {outline:2px solid var(--practice-accent);outline-offset:1px;}
@media(max-width:760px){
  .word-fields {max-height:27dvh;overflow:auto;}
  #app.keyboard-open .lesson-desk:has(#pane-listen:not([hidden])) {display:flex;flex-direction:column;}
  #app.keyboard-open #pane-listen {margin-block:auto 0;width:100%;}
  #app.keyboard-open .practice-side>form {display:flex;flex-direction:column;}
  #app.keyboard-open .practice-side>form :is(.word-fields,textarea) {order:1;margin:0;}
  #app.keyboard-open .word-fields {max-height:clamp(75px,25dvh,150px);}
}
