/* 말씀 암송 — 사이트 공통 디자인 토큰(뷰어/1독표와 동일) 위에 구성 */

:root {
  --bg: #fafafa;
  --panel-bg: rgba(255, 255, 255, 0.95);
  --panel-border: rgba(200, 200, 200, 0.3);
  --text: #1a1a1a;
  --text-muted: #888888;
  --line: #eaeaea;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-subtle: rgba(37, 99, 235, 0.1);
  --button: #f4f4f5;
  --button-hover: #e4e4e7;
  --input-bg: #ffffff;
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.03);
  --shadow-md: 0 10px 40px rgba(0,0,0,0.08);
  --ok: #15803d;
  --ok-subtle: rgba(21, 128, 61, 0.1);
  --miss: #dc2626;
  --radius: 12px;
  --header-height: 56px;
  --font-family: 'Noto Sans KR', 'Inter', -apple-system, sans-serif;
}

:root[data-theme=dark] {
  --bg: #0f1115; --panel-bg: rgba(20,22,28,0.95); --panel-border: rgba(255,255,255,0.08);
  --text: #e2e8f0; --text-muted: #64748b; --line: #1e293b;
  --accent: #3b82f6; --accent-hover: #60a5fa; --accent-subtle: rgba(59,130,246,0.15);
  --button: #1e293b; --button-hover: #334155; --input-bg: #0f1115;
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.4); --shadow-md: 0 10px 40px rgba(0,0,0,0.5);
  --ok: #4ade80; --ok-subtle: rgba(74,222,128,0.14); --miss: #f87171;
}
:root[data-theme=sepia] {
  --bg: #f4ece1; --panel-bg: rgba(244,236,225,0.97); --panel-border: rgba(160,130,100,0.2);
  --text: #3b2a1a; --text-muted: #8a6e58; --line: #d9c9b5;
  --accent: #8b4513; --accent-hover: #6d3410; --accent-subtle: rgba(139,69,19,0.1);
  --button: #ede0d0; --button-hover: #dfd0bc; --input-bg: #faf4ec;
  --shadow-sm: 0 4px 12px rgba(100,60,20,0.06); --shadow-md: 0 10px 40px rgba(100,60,20,0.12);
  --ok: #4d7c2f; --ok-subtle: rgba(77,124,47,0.12); --miss: #a8341f;
}
:root[data-theme=forest] {
  --bg: #121f14; --panel-bg: rgba(16,28,18,0.95); --panel-border: rgba(80,140,80,0.15);
  --text: #c8dfc0; --text-muted: #6a9468; --line: #1e3323;
  --accent: #5fa854; --accent-hover: #7cc070; --accent-subtle: rgba(95,168,84,0.15);
  --button: #1a2e1c; --button-hover: #253e28; --input-bg: #121f14;
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.4); --shadow-md: 0 10px 40px rgba(0,0,0,0.5);
  --ok: #86efac; --ok-subtle: rgba(134,239,172,0.14); --miss: #f0917d;
}
:root[data-theme=slate] {
  --bg: #1a2235; --panel-bg: rgba(22,28,46,0.95); --panel-border: rgba(100,130,180,0.15);
  --text: #c8d6ea; --text-muted: #6e8aaa; --line: #243048;
  --accent: #60a5fa; --accent-hover: #7ebcff; --accent-subtle: rgba(96,165,250,0.15);
  --button: #243048; --button-hover: #2e3e5e; --input-bg: #1a2235;
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.4); --shadow-md: 0 10px 40px rgba(0,0,0,0.5);
  --ok: #7dd3a0; --ok-subtle: rgba(125,211,160,0.14); --miss: #f28b82;
}

:root.font-noto  { --font-family: 'Noto Sans KR', 'Inter', -apple-system, sans-serif; }
:root.font-nanum { --font-family: 'Nanum Gothic', -apple-system, sans-serif; }
:root.font-ibm   { --font-family: 'IBM Plex Sans KR', -apple-system, sans-serif; }
:root.font-serif { --font-family: 'Noto Serif KR', Georgia, serif; }
:root.font-large .verse, :root.font-large .diff { font-size: 24px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  line-height: 1.6;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
textarea, select, input { font-family: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── 헤더 ─────────────────────────────── */
#safe-area-fill {
  position: fixed; top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top);
  background: var(--panel-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  z-index: 41; pointer-events: none;
}
header {
  position: sticky; top: env(safe-area-inset-top); z-index: 40;
  background: var(--panel-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--panel-border);
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; height: var(--header-height);
}
.icon-btn {
  background: transparent; color: var(--text);
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.2s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--button-hover); }
.header-title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; flex: 1; }
.user-bar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1.5px solid var(--line); }
.user-link {
  font-size: 12px; color: var(--text-muted); text-decoration: none;
  padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line);
  transition: background 0.15s;
}
.user-link:hover { background: var(--button-hover); }

main { max-width: 680px; margin: 0 auto; padding: 24px 16px 80px; }

/* ── 통계 ─────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.stat {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px 12px; text-align: center;
}
.stat b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.stat span { font-size: 11px; color: var(--text-muted); }
.stat.hot b { color: var(--accent); }

/* ── 탭 ───────────────────────────────── */
.tabs { display: flex; gap: 6px; margin-bottom: 22px; }
.tab {
  flex: 1; padding: 10px 8px; font-size: 14px; font-weight: 500; color: var(--text-muted);
  background: var(--button); border: 1px solid transparent; border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: var(--button-hover); color: var(--text); }
.tab.on { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }
.tab .cnt { font-size: 11px; font-weight: 700; margin-left: 5px; }

/* ── 카드 ─────────────────────────────── */
.paper {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px 18px; position: relative;
}
.stage-tag {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--accent); background: var(--accent-subtle);
  padding: 4px 10px; border-radius: 999px;
}
.ref { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; margin: 10px 0 0; }
.rule { height: 1px; background: var(--line); margin: 16px 0; }
.lbl {
  display: block; font-size: 12px; font-weight: 500; color: var(--text-muted);
  margin: 20px 0 8px;
}

/* ── 본문 / 빈칸 ──────────────────────── */
.verse { font-size: 19px; line-height: 1.95; word-break: keep-all; white-space: pre-wrap; letter-spacing: -0.01em; }
.verse.loading { color: var(--text-muted); font-size: 14px; }
.blank { display: inline; padding: 1px 2px; border-radius: 4px; cursor: pointer; transition: background 0.15s; }
.blank:hover { background: var(--accent-subtle); }
.blank.open { background: var(--accent-subtle); }
.blank .hid { color: var(--text-muted); letter-spacing: 0.06em; }

.levels { display: flex; gap: 6px; margin-top: 16px; }
.levels button {
  flex: 1; padding: 9px 4px; font-size: 13px; color: var(--text-muted);
  background: var(--button); border-radius: 8px; transition: background 0.15s, color 0.15s;
}
.levels button:hover { background: var(--button-hover); color: var(--text); }
.levels button.on { background: var(--accent); color: #fff; font-weight: 500; }

/* ── 입력 ─────────────────────────────── */
.ta {
  width: 100%; background: var(--input-bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 15px; color: var(--text);
  line-height: 1.75; resize: vertical; min-height: 96px;
  transition: border-color 0.15s;
}
.ta:focus { border-color: var(--accent); outline: none; }
.ta::placeholder { color: var(--text-muted); }
.ta.note { min-height: 68px; }

.grade {
  margin-top: 14px; padding: 14px; border-radius: 10px;
  background: var(--accent-subtle); font-size: 13px; color: var(--text-muted);
}
.grade.good { background: var(--ok-subtle); }
.grade .pct { font-size: 26px; font-weight: 700; color: var(--accent); margin-right: 8px; letter-spacing: -0.03em; }
.grade.good .pct { color: var(--ok); }
.diff { font-size: 17px; line-height: 1.9; margin-top: 10px; word-break: keep-all; color: var(--text); }
.diff .hit { color: var(--text); }
.diff .miss { color: var(--miss); font-weight: 500; }
.diff .extra { color: var(--text-muted); text-decoration: line-through; }

/* ── 버튼 ─────────────────────────────── */
.row { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.btn {
  padding: 12px 18px; border-radius: 10px; font-size: 14px; font-weight: 500;
  background: var(--button); color: var(--text); transition: background 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--button-hover); }
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-seal { background: var(--accent); color: #fff; flex: 1; min-width: 150px; }
.btn-seal:hover { background: var(--accent-hover); }
.btn-sage { background: var(--accent); color: #fff; flex: 1; }
.btn-sage:hover { background: var(--accent-hover); }
.btn-ghost { flex: 1; }
.btn-quiet, .btn-line { background: var(--button); }
.btn-line { border: 1px solid var(--line); }

/* ── 완료 도장 ────────────────────────── */
.seal-mark {
  position: absolute; top: 14px; right: 14px; width: 44px; height: 44px;
  border: 2px solid var(--accent); border-radius: 12px; color: var(--accent);
  font-size: 22px; font-weight: 700;
  display: grid; place-items: center; opacity: 0.9; transform: rotate(-7deg);
  background: var(--accent-subtle);
}
@keyframes stamp {
  0% { transform: rotate(-7deg) scale(2.2); opacity: 0; }
  55% { transform: rotate(-7deg) scale(0.92); opacity: 1; }
  100% { transform: rotate(-7deg) scale(1); opacity: 0.9; }
}
.seal-mark.fresh { animation: stamp 0.42s cubic-bezier(.2,.9,.3,1.2); }

/* ── 복습 ─────────────────────────────── */
.rev-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.box-tag {
  font-size: 12px; color: var(--accent); background: var(--accent-subtle);
  padding: 4px 10px; border-radius: 999px;
}
.rev-head .n { font-size: 12px; color: var(--text-muted); }

/* ── 진도 ─────────────────────────────── */
.stage {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px 16px 18px; margin-bottom: 12px;
}
.stage-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.stage-name { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.stage-num { font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.jump {
  font-size: 12px; color: var(--accent); background: var(--accent-subtle);
  padding: 4px 10px; border-radius: 8px; transition: background 0.15s;
}
.jump:hover { background: var(--accent); color: #fff; }
.stage-when { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.grid { display: flex; flex-wrap: wrap; gap: 3px; }
.cell { width: 9px; height: 9px; border-radius: 2px; background: var(--button); }
.cell.done { background: var(--accent); }
.cell.now { background: var(--text); box-shadow: 0 0 0 2px var(--accent-subtle); }

/* 직접 고르기 */
.section-card {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px; margin-bottom: 12px;
}
.picker { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.picker select {
  flex: 1; min-width: 88px; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 13px;
}
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text);
  background: var(--button); border-radius: 999px; padding: 6px 8px 6px 12px;
}
.chip button { color: var(--text-muted); font-size: 15px; line-height: 1; padding: 0 4px; }
.chip button:hover { color: var(--miss); }

/* ── 공통 조각 ────────────────────────── */
.quote {
  margin: 22px 0 0; padding: 16px 18px;
  border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-subtle);
  font-size: 14px; line-height: 1.85; color: var(--text); word-break: keep-all;
}
.quote cite { display: block; font-style: normal; font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.note-blk { font-size: 13px; line-height: 1.85; color: var(--text-muted); word-break: keep-all; }
.note-blk b { color: var(--text); font-weight: 600; }
.empty { color: var(--text-muted); font-size: 14px; line-height: 1.8; word-break: keep-all; }
.done-msg {
  text-align: center; padding: 48px 16px; color: var(--text-muted); font-size: 14px; line-height: 1.85;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.done-msg .big { display: block; font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.hint-line { font-size: 12px; color: var(--text-muted); margin-top: 12px; text-align: center; }
.version-footer { margin-top: 40px; text-align: center; color: var(--text-muted); font-size: 12px; }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 24px;
  font-size: 14px; white-space: nowrap; max-width: calc(100% - 40px); overflow: hidden;
  text-overflow: ellipsis; opacity: 0; pointer-events: none; z-index: 200;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
