:root { color-scheme: light; --bg:#f4f4f6; --paper:#fff; --ink:#17171b; --muted:#74747d; --line:#dedee4; --blue:#2867e8; --red:#d73d4c; --green:#18845b; font-family:Inter,Pretendard,"Noto Sans KR",system-ui,sans-serif; }
* { box-sizing:border-box; }
[hidden] { display:none !important; }
html { background:var(--bg); }
body { min-width:320px; min-height:100svh; margin:0; overflow-x:hidden; background:var(--bg); color:var(--ink); }
button,textarea { font:inherit; }
button { color:inherit; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
.typing-header { position:sticky; top:0; z-index:10; display:grid; grid-template-columns:1fr auto 1fr; align-items:center; min-height:72px; padding:0 clamp(18px,4vw,60px); border-bottom:1px solid rgba(20,20,24,.09); background:rgba(250,250,252,.9); backdrop-filter:blur(18px) saturate(150%); }
.typing-brand { display:inline-flex; align-items:center; gap:10px; justify-self:start; color:inherit; text-decoration:none; }
.typing-brand > span { display:grid; width:38px; height:38px; place-items:center; border-radius:12px; background:var(--ink); color:#fff; font-size:.7rem; font-weight:950; }
.typing-brand strong { font-size:.95rem; letter-spacing:-.03em; }
.typing-nav { display:flex; gap:4px; padding:4px; border-radius:999px; background:#e7e7eb; }
.typing-nav button,.period-tabs button { min-height:40px; padding:0 18px; border:0; border-radius:999px; background:transparent; color:#65656d; font-size:.86rem; font-weight:850; cursor:pointer; }
.typing-nav button.is-active,.period-tabs button.is-selected { background:#fff; color:var(--ink); box-shadow:0 1px 5px rgba(20,20,24,.12); }
.typing-account { justify-self:end; min-width:90px; min-height:40px; }
.typing-main { width:min(1180px,calc(100% - 40px)); margin:0 auto; padding:clamp(38px,6vw,76px) 0 80px; }
.typing-screen { animation:screen-in .18s ease-out; }
@keyframes screen-in { from { opacity:0; transform:translateY(5px); } }
.home-heading p,.practice-head p,.result-head p,.progress-head p { margin:0 0 8px; color:var(--muted); font-size:.72rem; font-weight:900; letter-spacing:.15em; }
.home-heading h1,.practice-head h1,.result-head h1,.progress-head h1 { margin:0; font-size:clamp(2.5rem,6vw,5.3rem); line-height:.95; letter-spacing:-.065em; }
.setup-layout { display:grid; grid-template-columns:minmax(0,1.45fr) minmax(290px,.75fr); gap:20px; margin-top:42px; }
.setup-panel { padding:clamp(22px,3vw,34px); border:1px solid var(--line); border-radius:24px; background:var(--paper); box-shadow:0 12px 36px rgba(25,25,35,.06); }
.setup-panel h2 { margin:0 0 18px; font-size:1rem; letter-spacing:-.03em; }
.mode-list { display:grid; gap:10px; }
.mode-option { display:grid; grid-template-columns:42px 1fr auto; align-items:center; gap:14px; width:100%; min-height:84px; padding:14px 18px; border:1px solid var(--line); border-radius:17px; background:#fafafd; text-align:left; cursor:pointer; }
.mode-option > span { color:#aaaab2; font-size:.72rem; font-weight:900; }
.mode-option strong { font-size:1.15rem; letter-spacing:-.035em; }
.mode-option small { color:var(--muted); }
.mode-option.is-selected { border-color:var(--ink); background:var(--ink); color:#fff; }
.mode-option.is-selected > span,.mode-option.is-selected small { color:#bdbdc5; }
.difficulty-list { display:grid; grid-template-columns:repeat(2,1fr); gap:8px; }
.difficulty-list button { min-height:50px; border:1px solid var(--line); border-radius:14px; background:#f7f7fa; font-weight:850; cursor:pointer; }
.difficulty-list button.is-selected { border-color:var(--blue); background:#edf3ff; color:#174ebd; }
.difficulty-list button:disabled { opacity:.4; cursor:not-allowed; }
.passage-library { display:grid; gap:12px; }
.passage-library label { display:grid; gap:7px; color:var(--muted); font-size:.76rem; font-weight:850; }
.passage-library select { width:100%; min-height:50px; padding:0 42px 0 14px; border:1px solid var(--line); border-radius:14px; background:#f7f7fa; color:var(--ink); font-weight:800; }
.passage-library p { margin:0; color:var(--muted); font-size:.76rem; }
.passage-library .secondary-action { width:100%; }
.selection-summary { margin:28px 0; border-top:1px solid var(--line); }
.selection-summary div { display:flex; justify-content:space-between; padding:15px 0; border-bottom:1px solid var(--line); }
.selection-summary dt { color:var(--muted); }
.selection-summary dd { margin:0; font-weight:850; }
.primary-action,.secondary-action { min-height:52px; padding:0 22px; border-radius:15px; font-weight:900; cursor:pointer; }
.primary-action { border:0; background:var(--ink); color:#fff; }
.secondary-action { border:1px solid var(--line); background:#fff; }
.setup-panel--action > .primary-action { width:100%; }
.text-button { min-height:44px; padding:0 10px; border:0; background:transparent; color:var(--muted); font-weight:800; cursor:pointer; }
button:focus-visible,textarea:focus-visible,a:focus-visible { outline:3px solid rgba(40,103,232,.45); outline-offset:3px; }
.practice-head,.progress-head { display:flex; align-items:end; justify-content:space-between; gap:20px; }
.practice-head h1,.result-head h1,.progress-head h1 { font-size:clamp(2rem,5vw,4rem); }
.live-metrics { display:grid; grid-template-columns:repeat(4,1fr); margin:34px 0 14px; border:1px solid var(--line); border-radius:18px; background:var(--paper); }
.live-metrics div { display:flex; align-items:baseline; justify-content:space-between; gap:8px; min-width:0; padding:16px 18px; border-right:1px solid var(--line); }
.live-metrics div:last-child { border-right:0; }
.live-metrics span { color:var(--muted); font-size:.74rem; font-weight:800; }
.live-metrics strong { font-variant-numeric:tabular-nums; font-size:1.3rem; }
.typing-stage { padding:clamp(22px,4vw,48px); border:1px solid var(--line); border-radius:24px; background:var(--paper); box-shadow:0 16px 44px rgba(25,25,35,.07); }
.typing-stage.is-success { animation:stage-success .22s ease-out; box-shadow:0 0 0 3px rgba(24,132,91,.18),0 16px 44px rgba(25,25,35,.07); }
.target-text { min-height:120px; margin:0 0 28px; font-size:clamp(1.4rem,3vw,2.25rem); font-weight:720; line-height:1.75; letter-spacing:.015em; overflow-wrap:anywhere; white-space:pre-wrap; }
.source-credit { min-height:20px; margin:-18px 0 20px; color:var(--muted); font-size:.75rem; }
.source-credit a { color:inherit; text-underline-offset:3px; }
.target-char { border-radius:3px; color:#9a9aa2; }
.target-char.is-correct { color:var(--ink); }
.target-char.is-wrong { background:#ffe7ea; color:var(--red); text-decoration:underline; text-decoration-thickness:2px; }
.target-char.is-current { background:#e5edff; color:#174ebd; box-shadow:inset 0 -2px var(--blue); }
.typing-input-wrap { display:block; }
/* Keep long-form reading and typing in one viewport; only the text pane scrolls. */
.typing-screen:has(.typing-stage.is-passage) .live-metrics { margin:12px 0 10px; }
.typing-stage.is-passage {
  display:grid;
  grid-template-rows:minmax(0,1fr) auto auto auto;
  gap:10px;
  height:max(260px,calc(var(--typing-viewport-height,100dvh) - var(--typing-stage-top,240px) - 16px));
  padding:16px;
}
.typing-stage.is-passage .target-text {
  min-height:0;
  margin:0;
  overflow-y:auto;
  overflow-anchor:none;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
  font-size:clamp(1.25rem,2.2vw,1.65rem);
  line-height:1.65;
}
.typing-stage.is-passage .source-credit { min-height:0; margin:0; line-height:1.4; }
.typing-stage.is-passage #typingInput { height:clamp(72px,16dvh,120px); min-height:0; resize:none; padding:12px; }
.typing-stage.is-passage .stage-foot { margin:0; }
#typingInput { width:100%; min-height:150px; resize:vertical; padding:20px; border:1px solid #cfcfd6; border-radius:16px; background:#fafafd; color:var(--ink); font-size:1.15rem; line-height:1.65; outline:0; }
#typingInput:focus { border-color:var(--blue); background:#fff; box-shadow:0 0 0 3px rgba(40,103,232,.12); }
.stage-foot { display:flex; align-items:center; justify-content:space-between; min-height:44px; margin-top:8px; color:var(--red); font-size:.82rem; }
.stage-foot .is-success { color:var(--green); font-weight:850; }
.item-feedback { margin-top:12px; padding-top:14px; border-top:1px solid var(--line); }
.item-feedback > div { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; }
.item-feedback > div strong { font-size:.86rem; }
.item-feedback > div span { color:var(--muted); font-size:.7rem; }
.item-feedback ol { display:flex; gap:8px; margin:0; padding:0 0 4px; overflow-x:auto; list-style:none; }
.item-feedback li { display:grid; grid-template-columns:auto auto; gap:2px 10px; min-width:112px; padding:10px 12px; border:1px solid var(--line); border-radius:13px; background:#f7f7fa; font-size:.72rem; }
.item-feedback li strong { grid-row:1 / 3; align-self:center; color:var(--blue); font-size:1.45rem; }
.item-feedback li span { color:var(--muted); white-space:nowrap; }
.item-feedback li.is-latest { border-color:var(--green); background:#f4fff8; animation:record-in .25s ease-out; }
.fall-metrics { display:grid; grid-template-columns:repeat(3,1fr); margin:34px 0 14px; border:1px solid var(--line); border-radius:18px; background:var(--paper); }
.fall-metrics div { display:flex; align-items:baseline; justify-content:space-between; gap:12px; padding:16px 20px; border-right:1px solid var(--line); }
.fall-metrics div:last-child { border-right:0; }
.fall-metrics span { color:var(--muted); font-size:.76rem; font-weight:850; }
.fall-metrics strong { font-size:1.5rem; font-variant-numeric:tabular-nums; }
.fall-stage { padding:18px; border:1px solid var(--line); border-radius:24px; background:var(--paper); box-shadow:0 16px 44px rgba(25,25,35,.07); }
.fall-sky { position:relative; height:clamp(260px,52dvh,520px); overflow:hidden; border:1px solid #cfcfd6; border-radius:18px; background:linear-gradient(#f9f9fb 0 82%,#ececf0 82%); }
.fall-sky::before { content:""; position:absolute; inset:0; opacity:.45; background-image:radial-gradient(circle at 18% 14%,#d8d8de 0 2px,transparent 2px),radial-gradient(circle at 72% 30%,#d8d8de 0 2px,transparent 2px); background-size:120px 110px,150px 130px; }
.fall-words { position:absolute; z-index:2; inset:0; pointer-events:none; }
.fall-word { position:absolute; top:8px; left:50%; max-width:calc(100% - 26px); padding:10px 16px; overflow:hidden; border:2px solid var(--ink); border-radius:999px; background:var(--ink); color:#fff; font-size:clamp(1.05rem,3vw,2rem); font-weight:900; letter-spacing:-.025em; text-overflow:ellipsis; white-space:nowrap; box-shadow:0 8px 20px rgba(20,20,24,.18); will-change:transform; }
.fall-word.is-prefix { border-color:var(--blue); background:#174ebd; box-shadow:0 0 0 4px rgba(40,103,232,.2),0 8px 20px rgba(20,20,24,.18); }
.fall-word.is-danger { background:var(--red); border-color:var(--red); }
.fall-word.is-hit { border-color:var(--green); background:var(--green); animation:word-hit .5s ease-in forwards; }
.fall-sky.is-miss { animation:stage-miss .25s ease-out; }
.fall-ground { position:absolute; right:0; bottom:0; left:0; height:18%; border-top:3px solid var(--ink); background:repeating-linear-gradient(135deg,#e1e1e6 0 12px,#f0f0f3 12px 24px); }
.fall-input-wrap { display:block; margin-top:12px; }
#fallInput { width:100%; min-height:58px; padding:0 18px; border:2px solid #cfcfd6; border-radius:15px; background:#fafafd; color:var(--ink); font-size:1.35rem; font-weight:800; text-align:center; outline:0; }
#fallInput:focus { border-color:var(--blue); background:#fff; box-shadow:0 0 0 3px rgba(40,103,232,.12); }
#fallInput.is-wrong { border-color:var(--red); background:#fff1f2; color:var(--red); }
.fall-result-details { grid-template-columns:repeat(3,1fr); }
.result-head { display:grid; grid-template-columns:1fr auto; align-items:end; }
.result-head p { grid-column:1 / -1; }
#saveState { align-self:center; color:var(--muted); font-size:.8rem; font-weight:800; }
.result-primary { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-top:38px; }
.result-primary div { padding:26px; border-radius:20px; background:var(--ink); color:#fff; }
.result-primary span,.progress-summary span { display:block; margin-bottom:16px; color:#b8b8c0; font-size:.8rem; font-weight:800; }
.result-primary strong { font-size:clamp(2.4rem,6vw,4.4rem); font-variant-numeric:tabular-nums; letter-spacing:-.05em; }
.result-details { display:grid; grid-template-columns:repeat(3,1fr); margin:18px 0 28px; border:1px solid var(--line); border-radius:18px; background:#fff; }
.result-details div { display:flex; justify-content:space-between; padding:18px; border-right:1px solid var(--line); border-bottom:1px solid var(--line); }
.result-details div:nth-child(3n) { border-right:0; }
.result-details div:nth-last-child(-n+3) { border-bottom:0; }
.result-details dt { color:var(--muted); }
.result-details dd { margin:0; font-weight:900; font-variant-numeric:tabular-nums; }
.result-actions { display:flex; flex-wrap:wrap; gap:9px; }
.period-tabs { display:flex; gap:3px; padding:4px; border-radius:999px; background:#e7e7eb; }
.progress-status { margin:44px 0; color:var(--muted); }
.progress-summary { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin:34px 0 18px; }
.progress-summary div { padding:20px; border-radius:18px; background:#fff; border:1px solid var(--line); }
.progress-summary span { margin-bottom:12px; color:var(--muted); }
.progress-summary strong { font-size:1.8rem; font-variant-numeric:tabular-nums; }
.chart-panel,.error-panel,.recent-panel { padding:24px; margin-top:14px; border:1px solid var(--line); border-radius:20px; background:#fff; }
.chart-panel h2,.error-panel h2,.recent-panel h2 { margin:0 0 20px; font-size:1rem; }
.typing-chart { display:flex; align-items:end; gap:10px; min-height:190px; overflow-x:auto; }
.chart-day { display:grid; grid-template-rows:1fr auto auto; align-items:end; gap:6px; min-width:54px; height:170px; text-align:center; }
.chart-day i { display:block; width:100%; min-height:3px; border-radius:8px 8px 2px 2px; background:var(--blue); }
.chart-day b { font-size:.72rem; }
.chart-day span { color:var(--muted); font-size:.68rem; }
.error-panel ul { display:flex; flex-wrap:wrap; gap:8px; margin:0; padding:0; list-style:none; }
.error-panel li { padding:9px 12px; border-radius:999px; background:#f1f1f4; font-size:.82rem; font-weight:800; }
.recent-scroll { overflow-x:auto; }
.recent-panel table { width:100%; min-width:680px; border-collapse:collapse; font-size:.82rem; }
.recent-panel th,.recent-panel td { padding:12px 10px; border-bottom:1px solid var(--line); text-align:right; white-space:nowrap; }
.recent-panel th:first-child,.recent-panel td:first-child,.recent-panel th:nth-child(2),.recent-panel td:nth-child(2) { text-align:left; }
.recent-panel th { color:var(--muted); font-size:.72rem; }
.recent-panel tbody tr:last-child td { border-bottom:0; }
dialog { width:min(390px,calc(100% - 32px)); padding:0; border:0; border-radius:22px; box-shadow:0 30px 90px rgba(0,0,0,.24); }
dialog::backdrop { background:rgba(14,14,18,.54); backdrop-filter:blur(5px); }
dialog section { display:grid; gap:10px; padding:28px; }
dialog h2 { margin:0 0 10px; }
@keyframes stage-success { 50% { transform:scale(1.006); background:#f7fff9; } }
@keyframes word-hit { 60% { filter:brightness(1.8); } to { opacity:0; } }
@keyframes stage-miss { 25% { transform:translateX(-5px); } 60% { transform:translateX(5px); } }
@keyframes record-in { from { opacity:0; transform:translateY(6px); } }
@media (max-width:760px) {
  .typing-header { grid-template-columns:1fr auto; min-height:64px; padding:0 14px; }
  .typing-nav { position:fixed; z-index:12; right:14px; bottom:max(12px,env(safe-area-inset-bottom)); left:14px; justify-content:center; box-shadow:0 8px 30px rgba(0,0,0,.18); }
  .typing-nav button { flex:1; }
  .typing-main { width:min(100% - 28px,600px); padding-top:34px; padding-bottom:100px; }
  .setup-layout { grid-template-columns:1fr; margin-top:28px; }
  .mode-option { grid-template-columns:34px 1fr; }
  .mode-option small { grid-column:2; }
  .live-metrics { grid-template-columns:repeat(2,1fr); }
  .live-metrics div:nth-child(2) { border-right:0; }
  .live-metrics div:nth-child(-n+2) { border-bottom:1px solid var(--line); }
  .target-text { min-height:90px; }
  .fall-sky { height:clamp(220px,40dvh,380px); }
  .result-primary,.result-details,.progress-summary { grid-template-columns:repeat(2,1fr); }
  .result-primary div:last-child { grid-column:1 / -1; }
  .result-details div,.result-details div:nth-child(3n) { border-right:1px solid var(--line); border-bottom:1px solid var(--line); }
  .result-details div:nth-child(2n) { border-right:0; }
  .result-details div:nth-last-child(-n+2) { border-bottom:0; }
  .practice-head,.progress-head { align-items:start; }
}
@media (max-width:430px) {
  .typing-account { min-width:70px; }
  .typing-brand strong { display:none; }
  .setup-panel,.typing-stage { border-radius:19px; padding:19px; }
  .result-primary,.progress-summary { grid-template-columns:1fr; }
  .result-primary div:last-child { grid-column:auto; }
  .result-details { grid-template-columns:1fr; }
  .result-details div,.result-details div:nth-child(2n),.result-details div:nth-child(3n),.result-details div:nth-last-child(-n+2) { border-right:0; border-bottom:1px solid var(--line); }
  .result-details div:last-child { border-bottom:0; }
  .fall-metrics { grid-template-columns:1fr; }
  .fall-metrics div { border-right:0; border-bottom:1px solid var(--line); }
  .fall-metrics div:last-child { border-bottom:0; }
  .fall-result-details { grid-template-columns:1fr; }
  .fall-word { padding:8px 12px; font-size:1rem; }
}
@media (prefers-reduced-motion:reduce) { .typing-screen,.typing-stage.is-success,.fall-word.is-hit,.fall-sky.is-miss,.item-feedback li.is-latest { animation:none; } }

/* Active practice is a task surface, not the selection page's large hero. */
body:is([data-typing-screen="fall"],[data-typing-screen="practice"]) .typing-main { padding-top:12px; }
body:is([data-typing-screen="fall"],[data-typing-screen="practice"]) .practice-head h1 { font-size:28px; line-height:1.1; }
.fall-metrics { grid-template-columns:repeat(3,1fr); margin:12px 0 10px; }
.fall-metrics div { border-bottom:0; border-right:1px solid var(--line); padding:8px 12px; }
.fall-metrics div:last-child { border-right:0; }
.fall-metrics strong { font-size:1.2rem; }
.fall-stage { padding:10px; }
.fall-sky { height:clamp(120px,calc(var(--typing-viewport-height,100dvh) - 290px),460px); }
#fallInput { min-height:48px; }
@media (max-width:760px) {
  body:is([data-typing-screen="fall"],[data-typing-screen="practice"]) .typing-nav { display:none; }
  body:is([data-typing-screen="fall"],[data-typing-screen="practice"]) .typing-header { position:relative; min-height:44px; }
  .practice-head p { margin-bottom:4px; }
  .fall-metrics div { display:grid; gap:2px; padding:5px 8px; }
  .fall-metrics span { font-size:.65rem; }
  .fall-sky { height:clamp(100px,calc(var(--typing-viewport-height,100dvh) - 310px),440px); }
  .fall-input-wrap { margin-top:8px; }
  .live-metrics { margin:10px 0; }
  .live-metrics div { padding:6px 10px; }
  .typing-stage { padding:12px; }
  .target-text { min-height:54px; margin-bottom:20px; font-size:1.3rem; }
  #typingInput { min-height:72px; padding:10px; }
}
