:root {
  --bg: #f6f6f3;
  --card: #ffffff;
  --ink: #1d1f22;
  --muted: #6b7078;
  --line: #e2e2dc;
  --accent: #2f6fdb;
  --accent-ink: #ffffff;
  --ok: #1f9d55;
  --ok-soft: #d9f2e3;
  --miss: #c2410c;
  --miss-soft: #fde8dc;
  --c0: #ebebe6;
  --c1: #a7c8f5;
  --c2: #2f6fdb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1e2125;
    --ink: #e8e9eb;
    --muted: #9aa0a8;
    --line: #2e3238;
    --accent: #6b9cf0;
    --accent-ink: #0d1117;
    --ok: #4ade80;
    --ok-soft: #173a26;
    --miss: #fb923c;
    --miss-soft: #3d2416;
    --c0: #2a2e33;
    --c1: #2f4f7f;
    --c2: #6b9cf0;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.tabs button.on { background: var(--bg); color: var(--ink); font-weight: 600; }
.account { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

main { max-width: 820px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 16px;
}
h2 { font-size: 17px; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row.end { justify-content: flex-end; }

button {
  border: 1px solid var(--line); background: var(--card); padding: 7px 14px;
  border-radius: 9px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: none; }
button.rec { background: var(--miss); color: #fff; border-color: var(--miss); }
input, select, textarea {
  border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 7px 10px;
}
textarea { width: 100%; resize: vertical; }
.form input { width: 100%; margin-bottom: 8px; }
.form textarea { margin-top: 8px; }

/* 오늘 */
.day-head { display: flex; justify-content: space-between; align-items: baseline; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); }
.timer span { color: var(--ink); font-weight: 700; font-size: 18px; }
.bar { height: 8px; background: var(--c0); border-radius: 4px; overflow: hidden; margin: 8px 0 12px; }
.bar div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.checks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.checks label {
  display: flex; gap: 6px; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; cursor: pointer; font-size: 14px;
}
.checks label.on { background: var(--ok-soft); border-color: var(--ok); }
.checks input { width: 18px; height: 18px; accent-color: var(--ok); }
@media (max-width: 520px) { .checks { grid-template-columns: repeat(2, 1fr); } }

.p-head { display: flex; gap: 8px; align-items: center; }
.p-head select { flex: 1; min-width: 0; }
.p-pos { color: var(--muted); font-size: 13px; white-space: nowrap; }
.step { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.step-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.step-title .n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 12px;
}
.score { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.para { font-size: 18px; line-height: 1.7; margin: 10px 0 4px; white-space: pre-wrap; }
.para.hidden { filter: blur(7px); user-select: none; }
.para .w.ok { background: var(--ok-soft); border-radius: 3px; }
.para .w.next { box-shadow: inset 0 -2px 0 var(--accent); }
.toggle { font-size: 13px; color: var(--muted); display: flex; gap: 4px; align-items: center; margin-left: auto; }
#typing { margin-top: 8px; font-size: 16px; }
.heard { margin-top: 8px; line-height: 1.8; }
.heard .w { padding: 1px 3px; border-radius: 3px; margin-right: 2px; }
.heard .w.ok { background: var(--ok-soft); }
.heard .w.miss { background: var(--miss-soft); color: var(--miss); text-decoration: line-through; }
.myvoice { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.myvoice audio { height: 36px; max-width: 100%; flex: 1 1 220px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* 원문 목록 */
.item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .meta { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s a { color: var(--muted); }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }

/* 기록 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { text-align: center; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .d { aspect-ratio: 1; border-radius: 5px; background: var(--c0); font-size: 11px; color: var(--muted); padding: 3px; }
.cal .d.c1 { background: var(--c1); color: var(--ink); }
.cal .d.c2 { background: var(--c2); color: var(--accent-ink); }
.cal .d.today { outline: 2px solid var(--ink); }
.cal .h { font-size: 11px; color: var(--muted); text-align: center; }
.cal-legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.cal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.cal-legend .c0 { background: var(--c0); } .cal-legend .c1 { background: var(--c1); } .cal-legend .c2 { background: var(--c2); }
.log { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.log th, .log td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.log th { color: var(--muted); font-weight: 500; }

/* 자료 */
.src { padding: 12px 0; border-bottom: 1px solid var(--line); }
.src:last-child { border-bottom: 0; }
.src a { font-weight: 600; color: var(--accent); }
.src p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.lic { font-size: 11px; padding: 1px 7px; border-radius: 10px; margin-left: 6px; }
.lic.free { background: var(--ok-soft); color: var(--ok); }
.lic.nc { background: var(--c0); color: var(--muted); }
.lic.private { background: var(--miss-soft); color: var(--miss); }
.src-group { font-size: 13px; color: var(--muted); margin: 16px 0 0; font-weight: 600; }

.dlg {
  border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  background: var(--card); color: var(--ink); max-width: min(480px, calc(100vw - 32px));
}
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlg ol { padding-left: 20px; margin: 8px 0; }
.dlg li { margin-bottom: 6px; }
.dlg p { margin: 8px 0; }
.mic-level { font: 12px/1.4 ui-monospace, Consolas, monospace; margin-top: 6px; word-break: break-all; }
.diag { font-size: 11px; color: var(--muted); margin-top: 10px; padding: 6px 8px; background: var(--bg); border-radius: 6px; user-select: all; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 10px; font-size: 14px;
}
