/* =====================================================================
   style.css — 화면 모양
   - 색·간격·둥글기는 맨 위 :root 의 변수(--이름)만 바꾸면 전체가 바뀐다.
     (색을 바꿀 때는 라이트 모드 :root 와 다크 모드 @media 안의 :root 두 군데를 같이 고친다)
   - 다크 모드는 기기 설정을 따라 자동으로 바뀐다.
   - 글꼴은 Pretendard (index.html 에서 불러옴). 숫자는 폭이 같은 숫자(tabular)로.
   ===================================================================== */

/* ---------- 색 (라이트 모드): 흰 바탕 + 먹색, 포인트 색 없음 ---------- */
/*   역할 나눔
     --primary : 주요 버튼 (먹색). 화면을 차분하게 잡아준다
     --accent  : 포인트 자리 (큰 숫자·진행 막대·입력 테두리). 지금은 먹색. 색을 넣고 싶으면 여기만 바꾼다
     --accent-ink : 포인트 자리의 작은 글자 / --accent-soft : 포인트 자리의 옅은 바탕 (지금은 회색) */
:root {
  --bg: #ffffff;          /* 바탕 */
  --surface: #ffffff;     /* 상자 바탕 (테두리로만 구분) */
  --sunken: #f4f4f5;      /* 입력칸·탭·막대 바탕 */
  --text: #111113;        /* 기본 글자 */
  --muted: #66666e;       /* 흐린 글자 */
  --line: #e6e6e9;        /* 테두리·구분선 */
  --primary: #111113;     /* 주요 버튼 */
  --primary-hover: #2c2c31;
  --on-fill: #ffffff;     /* 색이 칠해진 버튼 위 글자 */
  --accent: #111113;      /* 포인트 없음 = 먹색 */
  --accent-ink: #111113;
  --accent-soft: #f4f4f5;
  --danger: #e11d48;      /* 모름·오답·삭제 */
  --danger-soft: #ffe9ee;
  --ok: #15803d;          /* 앎·정답 */
  --ok-soft: #e8f6ed;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: light dark;
}

/* ---------- 색 (다크 모드): 버튼과 포인트 자리는 흰색으로 뒤집힘 ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --surface: #141416;
    --sunken: #1e1e21;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --line: #2a2a2e;
    --primary: #f4f4f5;
    --primary-hover: #d4d4d8;
    --on-fill: #0b0b0c;
    --accent: #f4f4f5;
    --accent-ink: #f4f4f5;
    --accent-soft: #1e1e21;
    --danger: #fb7185;
    --danger-soft: #3a1720;
    --ok: #4ade80;
    --ok-soft: #10301d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 18px rgb(0 0 0 / 0.3);
  }
}

/* ---------- 기본 ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* display:flex 등이 hidden 을 덮어쓰지 않도록 */

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line) transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: keep-all;        /* 한국어 단어 중간에서 줄바꿈하지 않기 */
  overflow-wrap: anywhere;     /* 긴 영어 단어는 넘치지 않게 */
  -webkit-tap-highlight-color: transparent;
}
::selection { background: color-mix(in srgb, var(--text) 16%, transparent); color: var(--text); }
input, textarea { caret-color: var(--accent); accent-color: var(--accent); }

main { max-width: 640px; margin: 0 auto; padding: 20px 16px 96px; }
h1 { font-size: 1.75rem; line-height: 1.25; letter-spacing: -0.025em; margin: 4px 0 6px; text-wrap: balance; }
.panel + h1, details + h1 { margin-top: 32px; } /* 학생 홈: 위 상자들과 "세트" 제목 사이 띄우기 */
h2 { font-size: 1.15rem; line-height: 1.35; letter-spacing: -0.015em; margin: 36px 0 12px; }
a { color: var(--text); text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
b { font-weight: 700; }

.muted { color: var(--muted); }
.lead { margin: 0 0 4px; }
.meta { color: var(--muted); font-size: 0.9rem; margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.small-note { margin: 4px 0 0; font-size: 0.9rem; color: var(--muted); }
.center { text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 36px 12px; list-style: none; }

/* 아이콘: 글자 크기에 맞춰 커지고, 글자와 같은 색 */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }

/* 뒤로 가기 링크 */
.back {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; margin-left: -6px; padding: 0 6px;
  color: var(--muted); font-weight: 600; text-decoration: none; border-radius: var(--radius-sm);
}
.back:hover { color: var(--text); }

/* ---------- 헤더 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); /* 내용이 지나갈 때 헤더 글자가 묻히지 않게 */
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.03em; color: var(--text); text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px;
  color: var(--muted); font-weight: 600; text-decoration: none; border-radius: 999px;
}
.nav-link:hover { color: var(--text); }
.nav-link[aria-current="page"] { color: var(--text); background: var(--sunken); }
.chip {
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.92rem; font-weight: 600;
  cursor: pointer;
}

/* ---------- 버튼 (손가락으로 누르기 쉽게 최소 48px) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-fill); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { min-height: 40px; min-width: 44px; padding: 0 12px; font-size: 0.92rem; }
.btn.big { min-height: 58px; font-size: 1.1rem; width: 100%; }
.btn:disabled, .icon-btn:disabled { opacity: 0.35; cursor: default; transform: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; }

/* 글자만 있는 가벼운 버튼 (목록 안 "수정", "삭제") */
.text-btn {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--muted); font: inherit; font-size: 0.92rem; font-weight: 600; text-decoration: none; cursor: pointer;
}
.text-btn:hover { background: var(--sunken); color: var(--text); }
.text-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.text-btn.accent { color: var(--accent-ink); }
.card-actions > .text-btn:first-child { margin-left: -10px; } /* 글자 버튼이 맨 앞이면 본문과 왼쪽 줄 맞춤 */
h2 .small-note { font-weight: 400; }

/* 아이콘만 있는 버튼 (목록 안 위/아래 이동) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }

/* 키보드로 이동할 때 보이는 테두리 */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: none; }

/* ---------- 상자 / 폼 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 16px 0;
}
.stack { display: flex; flex-direction: column; gap: 16px; }

/* 접고 펴는 상자의 제목 줄: 오른쪽에 꺾쇠 */
details > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 32px; font-weight: 700; cursor: pointer; list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
}
details[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
details[open].panel > summary { margin-bottom: 16px; }

label { display: block; font-weight: 700; font-size: 0.95rem; }
label .muted { font-weight: 400; font-size: 0.88rem; }
label > input, label > textarea { display: block; margin-top: 6px; }
.req { color: var(--danger); font-size: 0.78rem; font-weight: 600; margin-left: 2px; }
input, textarea {
  width: 100%;
  min-height: 48px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font: inherit; font-weight: 400; letter-spacing: 0;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
textarea { resize: vertical; }
.help { margin: 0; color: var(--muted); font-size: 0.93rem; }

/* ---------- 탭 ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 18px; background: var(--sunken); border-radius: var(--radius-sm); }
.tab {
  flex: 1; min-height: 42px; padding: 0 8px;
  border: 0; border-radius: 8px;
  background: none; color: var(--muted); font: inherit; font-size: 0.95rem; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

/* ---------- 묶음 목록: 한 상자 안에 구분선으로 나눈 줄들 ---------- */
.group {
  list-style: none; padding: 0; margin: 0;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.group > li + li { border-top: 1px solid var(--line); }
.group > li.empty { border: 0; }
.row-link {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 14px 16px 18px;
  color: var(--text); text-decoration: none;
}
.row-link:hover { background: color-mix(in srgb, var(--sunken) 55%, transparent); }
.row-link > .icon { color: var(--muted); }
.row-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.row-text .meta { margin: 2px 0 0; }
.row-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }

/* 카드 한 장 줄 */
.card-item { padding: 16px 18px; }
.front { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.meaning { margin-top: 1px; }
.example { color: var(--muted); font-style: italic; margin-top: 6px; line-height: 1.55; }
.note { color: var(--muted); font-size: 0.88rem; margin-top: 6px; }
.card-actions { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.spacer { flex: 1; }

/* ---------- 붙여넣기 미리보기 표 ---------- */
.summary { margin: 0; }
.ok { color: var(--ok); }
.bad-text { color: var(--danger); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
/* 폰에서는 표를 좌우로 밀어서 본다 (단어가 글자 단위로 쪼개지지 않게 최소 폭 지정) */
.preview { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 0.9rem; overflow-wrap: normal; }
.preview th, .preview td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.preview th { background: var(--sunken); white-space: nowrap; font-weight: 700; }
.preview tr:last-child td { border-bottom: 0; }
.preview tr.bad td { background: var(--danger-soft); }
.preview td:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 프로필 선택 ---------- */
.who { padding-top: 12vh; text-align: center; }
.who h1 { font-size: 2rem; }
.who-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
.who-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 24px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  font: inherit; cursor: pointer;
}
.who-btn:hover { border-color: var(--text); }
.who-name { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }

/* ---------- 큰 숫자 (학생 홈 "오늘 복습", 결과, 진도) ---------- */
.today { text-align: center; padding: 26px 18px 20px; }
.big-num {
  font-size: 4.25rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.big-label { margin-top: 8px; font-size: 1.05rem; font-weight: 700; }
.today .muted { margin: 6px 0 18px; font-size: 0.95rem; }
.done-msg { font-size: 1.15rem; font-weight: 700; margin: 8px 0; }
a.btn.big { margin-top: 12px; }

/* ---------- 세트의 학습 버튼들 ---------- */
.study-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 8px; }
.study-btn {
  display: flex; flex-direction: column; gap: 2px;
  min-height: 72px; padding: 14px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none;
}
.study-btn b { font-size: 1.08rem; }
.study-btn span { font-size: 0.86rem; color: var(--muted); }
.study-btn:hover { border-color: var(--text); }
.study-btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-fill); }
.study-btn.primary span { color: color-mix(in srgb, var(--on-fill) 72%, transparent); }
.study-btn.primary:hover { background: var(--primary-hover); }
.study-btn.wide { grid-column: 1 / -1; }

/* ---------- 학습 화면 공통 ---------- */
.banner {   /* 선생님 확인용 표시 */
  display: flex; align-items: center; justify-content: center;
  margin: 0 0 8px; padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent-ink); font-size: 0.92rem; font-weight: 700;
}
.study-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-variant-numeric: tabular-nums; }
.study-top .muted { font-size: 0.92rem; }

/* 암기 카드 */
.flash {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  width: 100%; min-height: 320px; margin: 8px 0 12px; padding: 32px 22px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  font: inherit; text-align: center; cursor: pointer;
}
.flash > span { display: block; }
.flash-front { font-size: 2.3rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.03em; }
.flash-back { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; width: 100%; }
.flash-back > span { display: block; }
.flash-meaning { font-size: 1.3rem; font-weight: 700; }
.flash-example { font-size: 1.08rem; font-style: italic; color: var(--muted); line-height: 1.55; }
.flash-note { font-size: 0.92rem; color: var(--muted); }
.flash-hint { font-size: 0.88rem; color: var(--muted); }
.speak { width: 100%; }
.answer-row { display: flex; gap: 10px; margin-top: 12px; }
.answer-row .btn { flex: 1; }
.btn.no { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); background: var(--surface); }
.btn.no:hover { background: var(--danger-soft); }
.btn.yes { background: var(--ok); border-color: var(--ok); color: var(--on-fill); }

/* 리콜·스펠링·테스트 문제 */
.dir-toggle { margin: 6px 0 4px; color: var(--muted); }
.prompt {
  position: relative;
  margin: 12px 0; padding: 24px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 1.3rem; font-weight: 700; text-align: center;
}
.prompt-word { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; }
.prompt-example { font-size: 1.2rem; font-weight: 500; line-height: 1.6; text-align: left; }
.speak-q { position: absolute; top: 8px; right: 8px; min-width: 40px; padding: 0 8px; color: var(--muted); }
.prompt:has(.speak-q) { padding-left: 56px; padding-right: 56px; } /* 긴 단어가 스피커 버튼과 겹치지 않게 */
.masked { margin: -4px 0 14px; color: var(--muted); font-style: italic; text-align: center; font-size: 1.05rem; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 12px;
  min-height: 58px; padding: 12px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: 1.05rem; text-align: left; cursor: pointer;
}
.choice:hover:not(:disabled) { border-color: var(--text); }
.choice:disabled { cursor: default; }
.choice-num {   /* 보기 앞 번호 (키보드 1~4) */
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--sunken); font-size: 0.88rem; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.choice.right { border-color: var(--ok); background: var(--ok-soft); color: var(--text); font-weight: 700; }
.choice.right .choice-num { background: var(--ok); color: var(--on-fill); }
.choice.wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--text); }
.choice.wrong .choice-num { background: var(--danger); color: var(--on-fill); }
.typed { font-size: 1.3rem; text-align: center; min-height: 58px; }
.verdict {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 1.25rem; font-weight: 800; margin: 12px 0 10px;
}
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.compare > div {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 1.15rem;
}
.compare > div .muted { font-size: 0.82rem; }
.compare.small { margin-top: 12px; }
.compare.small > div { font-size: 1rem; background: var(--bg); }
.reveal { margin: 12px 0; }

/* ---------- 진도·통계 ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat { text-align: center; margin: 0; padding: 22px 12px 18px; }
.stat .big-num { font-size: 3rem; }
.stat-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.stat-side { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex: none; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; vertical-align: 0.15em; }
.tag.hard { background: var(--danger-soft); color: var(--danger); }

.days { list-style: none; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.days li { display: grid; grid-template-columns: 5.5em 1fr auto; align-items: center; gap: 12px; }
.day-name { font-size: 0.88rem; color: var(--muted); white-space: nowrap; }
.day-bar, .progress-bar { display: block; height: 8px; background: var(--sunken); border-radius: 999px; overflow: hidden; }
.day-bar > span, .progress-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.day-num { font-size: 0.88rem; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }

.set-progress > summary { align-items: flex-start; }
.set-progress .sum-text { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.set-progress .muted { font-weight: 400; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.progress-bar { margin-top: 6px; }
.card-stats { list-style: none; padding: 0; margin: 0; }
.card-stats li { padding: 12px 0; border-top: 1px solid var(--line); }
.card-stats .text-btn { margin: 6px 0 0 -10px; }

/* ---------- 확인 창 ---------- */
dialog {
  width: min(420px, calc(100% - 32px));
  padding: 22px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
#confirm-msg { margin: 0 0 20px; white-space: pre-line; } /* \n 을 줄바꿈으로 보여준다 */
dialog .row { justify-content: flex-end; }

/* ---------- 알림 ---------- */
#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-size: 0.95rem; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease-out;
}
#toast.show { opacity: 1; }

/* 움직임을 줄이도록 설정한 기기에서는 전환 효과 끔 */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
