:root {
  --bg: #f7f4ee;
  --panel: #ffffff;
  --text: #1f2a30;
  --muted: #6a767d;
  --line: #e3ddd0;
  --accent: #1f7a6d;
  --accent-ink: #ffffff;
  --cur: #ffe08a;
  --miss: #d9480f;
  --ok: #2f9e44;
  --done: #8a969c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14191c;
    --panel: #1d2428;
    --text: #eef2f3;
    --muted: #9aa8ae;
    --line: #2b353a;
    --accent: #4cc2b0;
    --accent-ink: #0c1b18;
    --cur: #6b5a14;
    --miss: #ff8a5c;
    --ok: #69db7c;
    --done: #7d8b92;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 18px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 720px; margin: 0 auto; height: 100%; }
.screen {
  min-height: 100%;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.hidden { display: none !important; }
.bar { display: flex; align-items: center; gap: 10px; }
.bar h1 { font-size: 26px; margin: 0; flex: 1; }
.title { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; min-width: 0; }
.title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title small { color: var(--muted); font-weight: 400; font-size: 15px; }
.sub { font-size: 20px; margin: 6px 0 0; color: var(--muted); font-weight: 600; }
.hint { color: var(--muted); margin: 0; }
.notice {
  margin: 0; padding: 8px 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 15px;
}

button { font: inherit; color: inherit; cursor: pointer; }
.icon {
  min-width: 52px; height: 52px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel); font-size: 24px;
}
.icon.small { min-width: 40px; height: 40px; font-size: 18px; position: absolute; top: 8px; right: 8px; }
.btn {
  min-height: 64px; padding: 12px 20px; border-radius: 18px; border: 2px solid var(--line);
  background: var(--panel); font-size: 22px; font-weight: 600; text-align: center;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 46px; font-size: 18px; padding: 6px 16px; align-self: flex-start; border-radius: 14px; }
.btn:active, .icon:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.filebtn { display: flex; align-items: center; justify-content: center; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.book {
  width: 100%; text-align: left; padding: 16px; border-radius: 18px; border: 2px solid var(--line);
  background: var(--panel); display: flex; flex-direction: column; gap: 8px;
}
.book b { font-size: 22px; line-height: 1.25; }
.book small { color: var(--muted); font-size: 16px; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.row { display: flex; align-items: center; gap: 12px; font-size: 20px; min-height: 48px; }
.row input { width: 26px; height: 26px; }
.manage-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.manage-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.manage-item button { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: transparent; }

/* Reader */
#reader { height: 100vh; height: 100dvh; min-height: 0; padding-bottom: 12px; overflow: hidden; }
#reader > * { flex: none; }
#reader > #textWrap { flex: 1 1 0; }
#card { max-height: 40%; overflow-y: auto; }
#textWrap { flex: 1; overflow-y: auto; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
#text { font-size: clamp(26px, 6.2vw, 34px); line-height: 1.75; font-family: Georgia, "Iowan Old Style", serif; }
#text p { margin: 0 0 0.9em; }
.w { border-radius: 6px; padding: 1px 2px; cursor: pointer; transition: background 0.12s; }
.w.done { color: var(--done); }
.w.cur { background: var(--cur); }
.w.missed { color: var(--miss); text-decoration: underline wavy; text-underline-offset: 5px; }
.w.cur.missed { color: var(--text); }

.card {
  position: relative; background: var(--panel); border: 2px solid var(--accent); border-radius: 18px; padding: 16px 52px 16px 16px;
}
.cardword { font-size: 30px; font-weight: 700; }
.cardword .syl { color: var(--accent); letter-spacing: 1px; }
#cardBody { font-size: 20px; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--accent); border-color: var(--accent); background: transparent; }
.lbl { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; }

.status { display: flex; align-items: center; gap: 10px; min-height: 30px; font-size: 20px; color: var(--muted); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); flex: none; }
.dot.listen { background: var(--ok); animation: pulse 1.2s infinite; }
.dot.speak { background: var(--accent); }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: 0.55; } }
.controls { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }

/* Quiz */
.q { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.q h3 { margin: 0; font-size: 24px; line-height: 1.3; }
.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 20%, var(--panel)); }
.opt.wrong { border-color: var(--miss); background: color-mix(in srgb, var(--miss) 18%, var(--panel)); }
.big { font-size: 28px; font-weight: 700; text-align: center; margin: 10px 0; }

/* Progress */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tot { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 8px; text-align: center; }
.tot b { display: block; font-size: 28px; }
.tot small { color: var(--muted); font-size: 15px; }
.days { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.day { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 10px; font-size: 16px; }
.day .bar2 { height: 14px; border-radius: 99px; background: var(--line); overflow: hidden; }
.day .bar2 i { display: block; height: 100%; background: var(--accent); }
.day span:last-child { color: var(--muted); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { min-height: 52px; padding: 8px 16px; border-radius: 99px; border: 2px solid var(--line); background: var(--panel); font-size: 22px; }
.chip small { color: var(--muted); font-size: 15px; margin-left: 6px; }
#practiceCard { padding-right: 52px; }
