/* A reading desk in landscape; the compact sentence card remains on phones. */
.practice-stage,.practice-reading,.practice-reading-body{display:contents}
.practice-companion,.practice-reading-head{display:none}
#sentenceText{font-family:Georgia,"Times New Roman",serif}
body.practice-landscape .sentence-panel{
  padding:clamp(16px,3vw,36px) clamp(58px,6vw,96px);
  grid-template-rows:auto minmax(260px,1fr) auto auto auto;
  gap:16px;overflow-y:auto;
  background:radial-gradient(ellipse at 0 30%,color-mix(in srgb,var(--purple) 12%,transparent),transparent 60%),#f3f5f8;
}
body.practice-landscape .sentence-card-top{grid-row:1;gap:10px;max-width:1280px;width:100%;margin:auto}
body.practice-landscape .sentence-card-top>button{min-height:44px;font:inherit;font-size:14px}
body.practice-landscape .card-practice-tabs{margin-left:auto}
body.practice-landscape .card-practice-tabs button{min-height:44px;font:inherit;font-size:16px;font-weight:700}
body.practice-landscape .study-toolbar button{min-height:40px;font-size:14px}
body.practice-landscape #saveHint{font-size:14px!important;line-height:1.4;flex:1 1 260px;color:#5d6470}
body.practice-landscape .practice-stage{grid-row:2;display:grid;grid-template-columns:210px minmax(0,1fr);gap:28px;min-height:0;max-width:1280px;width:100%;margin:0 auto}
body.practice-landscape .practice-companion{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;min-width:0;padding:16px 0}
body.practice-landscape #practicePortraitSlot{width:100%;max-width:190px}
body.practice-landscape .sei-practice-face{display:block;width:100%;height:clamp(160px,32dvh,300px);padding:0;border-radius:28px;background:white;box-shadow:0 12px 32px color-mix(in srgb,var(--purple) 15%,transparent);border:5px solid white;cursor:pointer}
body.practice-landscape .sei-practice-face .sei-portrait{border-radius:23px}
body.practice-landscape #practiceFriendName{font-size:20px;color:var(--purple);text-align:center}
body.practice-landscape #practiceGuideSlot{width:100%;max-width:230px}
body.practice-landscape #practiceGuideSlot #sentenceGuide{display:block;margin:0;text-align:center;font-size:16px;line-height:1.65;color:#525966;word-break:keep-all}
body.practice-landscape .practice-reading{display:flex;flex-direction:column;min-width:0;min-height:0;background:#fff;border:1px solid color-mix(in srgb,var(--purple) 18%,#e4e8ed);border-top:4px solid var(--purple);border-radius:24px;box-shadow:0 14px 44px #2233440b;overflow:hidden}
body.practice-landscape .practice-reading-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;padding:20px 28px;border-bottom:1px solid #edf0f4;color:#69717e;font-size:14px}
body.practice-landscape #sentenceCount{padding:6px 12px;border-radius:20px;background:var(--purple2);color:var(--purple);font-size:16px;font-weight:700;white-space:nowrap}
body.practice-landscape .practice-reading-body{display:flex;align-items:center;flex:1;min-height:0;overflow:auto;padding:24px clamp(22px,3.5vw,56px)}
body.practice-landscape #sentenceText{display:block!important;width:100%;max-width:850px;min-height:0;margin:auto;padding:0;font-size:clamp(1.7rem,2.8vw,2.65rem);line-height:1.55;text-align:left;color:#262c38;overflow-wrap:anywhere;touch-action:pan-y}
body.practice-landscape #sentenceText.long-sentence{font-size:clamp(1.5rem,2.3vw,2.2rem);line-height:1.6}
body.practice-landscape #sentenceText.very-long-sentence{font-size:clamp(1.3rem,2vw,1.85rem);line-height:1.65}
body.practice-landscape .sentence-progress{display:block;grid-row:3;width:100%;max-width:1280px;height:5px;margin:0 auto;background:#dfe5eb}
body.practice-landscape .sentence-listen{grid-row:4;max-width:1280px;gap:10px;margin:0 auto;padding:14px 18px;border:1px solid #e0e6ed;border-radius:20px;background:white;justify-content:flex-start;box-shadow:0 5px 20px #22334406}
body.practice-landscape .sentence-listen>button{min-height:46px;padding:10px 16px;font-size:16px}
body.practice-landscape .sentence-listen #speed{min-height:46px;font-size:16px}
body.practice-landscape .sentence-listen>#sentenceGuide{display:block;flex:0 0 100%;margin:0 0 4px;text-align:left;font-size:16px;line-height:1.5}
body.practice-landscape .sentence-listen>#sentenceGuide.speak-now{color:#a53d32}
body.practice-landscape .sentence-listen .sei-voice-status{font-size:14px}
body.practice-landscape #recordControls{grid-row:5;margin:0 auto;width:100%;max-width:1280px}
body.practice-landscape button:focus-visible{outline:3px solid var(--purple);outline-offset:3px}
@media(max-width:900px){
  body.practice-landscape .practice-stage{grid-template-columns:150px minmax(0,1fr);gap:18px}
  body.practice-landscape .practice-reading-head{padding:12px 18px}
  body.practice-landscape #practiceFriendName{font-size:17px}
}
@media(max-height:540px){
  body.practice-landscape .sentence-panel{padding:10px 54px max(10px,env(safe-area-inset-bottom));gap:8px;grid-template-rows:auto minmax(90px,1fr) auto auto auto}
  body.practice-landscape .sentence-card-top{gap:6px}
  body.practice-landscape .card-practice-tabs button{font-size:14px;padding:6px 10px;min-height:40px}
  body.practice-landscape .practice-stage{grid-template-columns:112px minmax(0,1fr);gap:14px}
  body.practice-landscape .practice-companion{display:grid;grid-template-rows:minmax(0,1fr) auto;justify-items:center;gap:8px;padding:0;min-height:0}
  body.practice-landscape #practicePortraitSlot{width:auto;max-width:100%;height:100%;max-height:130px;min-height:0;aspect-ratio:418/500;overflow:hidden}
  body.practice-landscape .sei-practice-face{height:100%;border-radius:18px;border-width:3px}
  body.practice-landscape #practiceFriendName{font-size:14px}
  body.practice-landscape #practiceGuideSlot{display:none}
  body.practice-landscape #saveHint{display:none}
  body.practice-landscape .practice-reading-head{padding:8px 16px}
  body.practice-landscape .practice-reading-head>span{display:none}
  body.practice-landscape .practice-reading-body{padding:14px 22px}
  body.practice-landscape #sentenceText,body.practice-landscape #sentenceText.long-sentence{font-size:1.4rem;line-height:1.5}
  body.practice-landscape #sentenceText.very-long-sentence{font-size:1.2rem}
  body.practice-landscape .sentence-listen{padding:8px 12px;gap:6px}
  body.practice-landscape .sentence-listen>button{min-height:40px;padding:8px 10px;font-size:14px}
}
@media(max-width:580px){
  body.practice-landscape .sentence-panel{padding:12px 50px max(12px,env(safe-area-inset-bottom));grid-template-rows:auto minmax(90px,1fr) auto auto auto}
  body.practice-landscape .practice-stage{grid-template-columns:minmax(0,1fr)}
  body.practice-landscape .practice-companion{display:none}
  body.practice-landscape .card-practice-tabs{width:100%;margin:0}
  body.practice-landscape .card-practice-tabs button{flex:1;padding:8px 4px;font-size:14px}
  body.practice-landscape .practice-reading-body{padding:18px}
}
/* Error-only save controls must stay hidden even when moved into the practice header. */
#saveBtn[hidden],#saveHint[hidden],.result-actions[hidden],#original[hidden]{display:none!important}

/* Fullscreen dvh can differ from the actual visible viewport on Android. */
body.practice-landscape .result{height:var(--sei-viewport-height,100dvh)}
body.practice-landscape #sentencePanel{height:100%;min-height:0}

/* Keep the landscape reading area clear once practice is complete. */
body.practice-landscape .sentence-listen.practice-progress-complete>#sentenceGuide,
body.practice-landscape .sentence-listen.practice-progress-complete .semantic-practice-player>.sentence-guide{display:none}

/* Shadow controls leave the reading card room; overflow starts at the first line. */
body.practice-landscape #sentencePanel:has([data-card-practice="shadow"].active) #recordStatus:has(>.record-idle-hint){display:none}
body.practice-landscape #sentencePanel:has([data-card-practice="shadow"].active) .practice-reading-body{align-items:flex-start}
body.practice-landscape #sentencePanel:has([data-card-practice="shadow"].active) #sentenceText{flex-shrink:0;min-height:0;margin:0 auto}

/* Suppress only redundant playback/recording prose in landscape shadow. */
body.practice-landscape #sentencePanel:has([data-card-practice="shadow"].active) .shadow-redundant-status{display:none}

/* Landscape shadow keeps only the recording buttons in this controls area. */
body.practice-landscape #sentencePanel:has([data-card-practice="shadow"].active) #recordControls>.hide-words{display:none}

/* Keep the fixed viewport, but let the practice panel scroll when its rows cannot fit. */
html body.practice-landscape #result > #sentencePanel {
  overflow-y: auto;
  grid-template-rows: auto minmax(96px, 1fr) auto auto auto;
}
html body.practice-landscape #result > #sentencePanel .practice-reading-body {
  overscroll-behavior-y: auto;
}

/* WebView may keep a portrait viewport after the user opens landscape practice. */
@media (orientation: portrait) {
  html body.practice-landscape #result > #sentencePanel {
    grid-template-rows: auto max-content auto auto auto;
  }
  html body.practice-landscape #result > #sentencePanel .practice-reading-body {
    flex: 0 0 auto;
    overflow: visible;
  }
}

/* Phones use the visible height for reading; the tablet desk stays unchanged. */
@media (orientation:landscape) and (max-width:1000px) and (max-height:540px){
  html body.practice-landscape{overflow:hidden}
  html body.practice-landscape #result{top:var(--sei-viewport-top,0px);bottom:auto;height:var(--sei-viewport-height,100dvh);overflow:hidden}
  html body.practice-landscape #sentencePanel{height:100%;min-height:0;max-height:100%;overflow:hidden;padding:max(4px,env(safe-area-inset-top)) max(50px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(50px,env(safe-area-inset-left));grid-template-rows:auto minmax(0,1fr) 3px auto auto;gap:4px}
  body.practice-landscape .practice-stage{grid-template-columns:minmax(0,1fr);gap:0}
  body.practice-landscape .practice-companion{display:none}
  html body.practice-landscape #sentencePanel .sentence-card-top{gap:4px;flex-wrap:nowrap}
  html body.practice-landscape #sentencePanel #exitSentence{width:44px;min-width:44px;padding:4px;font-size:0}
  body.practice-landscape #exitSentence::before{content:'←';font-size:1.25rem}
  html body.practice-landscape #sentencePanel .card-practice-tabs{width:auto;margin-left:auto;flex-wrap:nowrap;padding:2px;gap:2px}
  html body.practice-landscape #sentencePanel .card-practice-tabs button{padding:4px 6px;min-height:44px;font-size:.85rem}
  html body.practice-landscape #sentencePanel .study-toolbar{display:flex;gap:4px}
  html body.practice-landscape #sentencePanel .study-toolbar{flex-wrap:nowrap}
  html body.practice-landscape #sentencePanel .study-toolbar button{width:44px;min-width:44px;min-height:44px;padding:4px;font-size:0}
  body.practice-landscape .study-toolbar button::before{content:'단어';font-size:.75rem}
  body.practice-landscape .study-toolbar button:last-child::before{content:'질문'}
  body.practice-landscape .practice-reading{border-radius:14px;border-top-width:3px}
  body.practice-landscape .practice-reading-head{flex:0 0 auto;padding:2px 12px;gap:4px}
  body.practice-landscape .practice-reading-head:not(:has(.translation-progress:not([hidden]))){display:none}
  body.practice-landscape #sentenceCount{padding:2px 8px}
  body.practice-landscape .practice-reading-body{display:block;flex:1;min-height:0;padding:8px 14px;overflow:auto;overscroll-behavior:contain;scroll-padding-block:8px;scrollbar-gutter:stable}
  html body.practice-landscape #sentencePanel #sentenceText{height:auto;min-height:0;max-height:none;margin:0;overflow:visible;flex-shrink:0}
  body.practice-landscape #sentenceText mark{scroll-margin-block:8px}
  body.practice-landscape .sentence-progress{height:3px}
  html body.practice-landscape #sentencePanel .sentence-listen{min-width:0;padding:4px 8px;gap:4px;border-radius:12px}
  html body.practice-landscape #sentencePanel .sentence-listen>button{flex:0 0 auto;min-width:44px;min-height:44px;padding:4px 8px;font-size:.85rem}
  html body.practice-landscape #sentencePanel .sentence-listen .sentence-listen-main{flex:1 1 auto;width:auto;min-width:0}
  body.practice-landscape .sentence-listen #speed{min-height:44px;padding:4px;font-size:.85rem}
  html body.practice-landscape #sentencePanel .sentence-listen>#sentenceGuide,
  html body.practice-landscape #sentencePanel .sentence-listen .sei-voice-status{flex:1 0 100%;margin:0;font-size:.75rem;line-height:1.25;max-height:2.5em;overflow:auto}
  body.practice-landscape .sentence-listen .semantic-practice-player{display:contents}
  body.practice-landscape .sentence-listen .semantic-practice-player>.sentence-guide{display:none}
  html body.practice-landscape #sentencePanel #recordControls{margin:0;gap:4px;padding:0}
  html body.practice-landscape #sentencePanel #recordControls button{min-height:44px;padding:4px 8px;font-size:.85rem}
}
