:root {
  color-scheme: light;
  --ink: #1E2733; --ink2: #3A4553; --muted: #6B7685; --faint: #98A1AD;
  --line: #DDE2E8; --soft: #F6F7F9; --soft2: #ECEFF3; --brand: #34507A; --brand2: #2B4366;
  --ok: #1E7B45; --ok-bg: #E7F5EC; --bad: #B3261E; --bad-bg: #FBEAEA; --info-bg: #EAF1FB;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: #FFFFFF; color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
#app { max-width: 720px; margin: 0 auto; padding: 12px 16px 48px; display: flex; flex-direction: column; gap: 12px; }
h2 { font-size: 1.5rem; margin: 0; }
h3 { font-size: 1.15rem; margin: 8px 0 0; }
p { margin: 0; }
.caption { font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 머리 · 메뉴 */
.header { display: flex; align-items: center; gap: 10px; }
.header h2 { flex: 1; white-space: nowrap; }
select, input, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: #FFFFFF;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%;
}
.header select { width: 160px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; min-height: 44px; padding: 6px 2px; background: #FFFFFF; white-space: nowrap; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: #FFFFFF; font-weight: 600; }

/* 버튼 */
button {
  font: inherit; font-size: 15px; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--soft); color: var(--brand);
}
button:hover { background: var(--soft2); }
button.primary { background: var(--brand); color: #FFFFFF; border-color: var(--brand); }
button.primary:hover { background: var(--brand2); }
button.wide { width: 100%; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices button { min-height: 68px; font-size: 1.05rem; color: var(--ink); background: #FFFFFF; }

/* 안내 상자 */
.msg { border-radius: 10px; padding: 12px 14px; }
.msg.info { background: var(--info-bg); }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.bad { background: var(--bad-bg); color: var(--bad); }

/* 진행 막대 · 설정 */
.progress { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.bar { height: 8px; background: var(--soft2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--brand); }
details { border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
details[open] { padding-bottom: 12px; }
summary { cursor: pointer; padding: 10px 0; }
details > *:not(summary) + * { margin-top: 10px; }
.gear { position: relative; border: 0; padding: 0; }
.gear > summary { list-style: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
.gear > summary::-webkit-details-marker { display: none; }
.gear > .panel {
  position: absolute; right: 0; top: 44px; z-index: 5; width: 250px; background: #FFFFFF;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: 0 6px 20px rgba(30, 39, 51, .12);
  display: flex; flex-direction: column; gap: 10px;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink2); }
label.check { flex-direction: row; align-items: center; gap: 8px; }
label.check input { width: auto; }
form { display: flex; flex-direction: column; gap: 10px; }

/* 작문 비교 */
.mine-diff { color: var(--bad); font-weight: 700; }
.model-diff { color: var(--ok); font-weight: 700; }

/* 대화 빈칸 · 약점 보기 */
.blank { color: var(--brand); font-weight: 700; }
.sub-h { display: block; margin-top: 16px; }
.chart { display: flex; align-items: stretch; gap: 4px; height: 130px; }
.chart .col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chart .stack { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; background: var(--soft); border-radius: 4px; overflow: hidden; }
.chart .day { font-size: 11px; color: var(--muted); text-align: center; }
.right { background: var(--brand); }
.wrong { background: #D9822B; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.hbar { display: grid; grid-template-columns: 76px 1fr 84px; gap: 8px; align-items: center; font-size: 14px; }
.hbar .track { height: 10px; background: var(--soft2); border-radius: 99px; overflow: hidden; }
.hbar .track > div { height: 100%; background: var(--brand); }
.hbar .n { text-align: right; color: var(--muted); font-size: 13px; }

/* 표 · 숫자 */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { background: var(--soft); border-radius: 12px; padding: 10px; }
.metric .num { font-size: 1.5rem; font-weight: 700; }
.metric .lbl { font-size: 12px; color: var(--muted); word-break: keep-all; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; font-size: 14px; white-space: nowrap; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--soft); position: sticky; top: 0; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }

/* 학습 카드 (card.py) */
.card { perspective: 1200px; cursor: default; }
.card.flippable { cursor: pointer; }
.inner { display: grid; transition: transform .45s ease; transform-style: preserve-3d; }
.card.flipped .inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: #FFFFFF; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 6px 20px rgba(30, 39, 51, .07);
  min-height: 220px; padding: 22px 22px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 8px;
}
.back { transform: rotateY(180deg); }
.chip { align-self: flex-start; font-size: 12px; color: var(--brand); background: var(--soft2); border-radius: 999px; padding: 3px 10px; margin-bottom: auto; }
.title { font-size: 34px; font-weight: 700; line-height: 1.25; word-break: keep-all; overflow-wrap: anywhere; }
.title.small { font-size: 24px; }
.sub { font-size: 15px; color: var(--muted); }
.line { font-size: 16px; color: var(--ink2); }
.line.em { font-style: italic; color: #556070; }
.dialog { align-self: stretch; text-align: left; background: var(--soft); border-radius: 12px; padding: 10px 14px; margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.dialog .en { font-size: 15px; }
.dialog .ko { font-size: 13px; color: var(--muted); }
.hint { font-size: 12px; color: var(--faint); margin-top: auto; }
.speak { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.speak button { font-size: 14px; padding: 7px 14px; }
.actions { display: none; gap: 10px; margin-top: 12px; }
.card.flipped + .actions { display: flex; }
.actions button { flex: 1; padding: 11px; }
.actions .knew { background: var(--brand); color: #FFFFFF; border-color: var(--brand); }
.wc.enter { animation: enter .25s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
