@charset "utf-8";
/* ============================================================
   한자능력검정 문제은행 - 스타일시트
   한지(韓紙)와 먹(墨)에서 가져온 절제된 색조 + 현대적 카드 UI
   ============================================================ */

/* --------------------------------------------------- 디자인 토큰 */

:root {
  --bg:            #f7f4ee;
  --bg-soft:       #efeae1;
  --surface:       #ffffff;
  --surface-2:     #fbf9f5;
  --line:          #e2dcd1;
  --line-strong:   #cfc7b8;

  --text:          #1e2227;
  --text-soft:     #5c6570;
  --text-faint:    #8b939d;

  --accent:        #b03a2e;   /* 인주 붉은색 */
  --accent-soft:   #f4e3e0;
  --accent-text:   #ffffff;
  --ink:           #2f3a45;   /* 먹빛 */
  --info:          #2c5f7c;
  --info-soft:     #e2eef4;
  --ok:            #2f7d54;
  --ok-soft:       #e3f2e9;
  --warn:          #9a6b12;
  --warn-soft:     #fbf0d8;
  --bad:           #b3352c;
  --bad-soft:      #fbe7e5;

  --radius:        14px;
  --radius-sm:     9px;
  --radius-lg:     22px;
  --shadow:        0 1px 2px rgba(30, 34, 39, .05), 0 6px 18px rgba(30, 34, 39, .06);
  --shadow-lg:     0 10px 40px rgba(30, 34, 39, .12);

  --wrap:          1160px;
  --header-h:      62px;

  --font-sans: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
               "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --font-han:  "Noto Serif KR", "Nanum Myeongjo", "Apple SD Gothic Neo", "Batang",
               "SimSun", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

html[data-theme="dark"],
:root:has(#theme-dark:checked) {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg:          #13161a;
    --bg-soft:     #1a1e24;
    --surface:     #1c2027;
    --surface-2:   #22272f;
    --line:        #2c323b;
    --line-strong: #3b434e;

    --text:        #e8eaed;
    --text-soft:   #a8b0ba;
    --text-faint:  #79828d;

    --accent:      #e0715c;
    --accent-soft: #37231f;
    --accent-text: #1a0f0d;
    --ink:         #c6d0da;
    --info:        #6fb3d6;
    --info-soft:   #17262e;
    --ok:          #63c290;
    --ok-soft:     #14261d;
    --warn:        #e0b45f;
    --warn-soft:   #2a2214;
    --bad:         #ef7a6e;
    --bad-soft:    #2c1917;

    --shadow:      0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .28);
    --shadow-lg:   0 14px 44px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

html[data-theme="dark"] {
  --bg:          #13161a;
  --bg-soft:     #1a1e24;
  --surface:     #1c2027;
  --surface-2:   #22272f;
  --line:        #2c323b;
  --line-strong: #3b434e;

  --text:        #e8eaed;
  --text-soft:   #a8b0ba;
  --text-faint:  #79828d;

  --accent:      #e0715c;
  --accent-soft: #37231f;
  --accent-text: #1a0f0d;
  --ink:         #c6d0da;
  --info:        #6fb3d6;
  --info-soft:   #17262e;
  --ok:          #63c290;
  --ok-soft:     #14261d;
  --warn:        #e0b45f;
  --warn-soft:   #2a2214;
  --bad:         #ef7a6e;
  --bad-soft:    #2c1917;

  --shadow:      0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .28);
  --shadow-lg:   0 14px 44px rgba(0, 0, 0, .45);
}

/* ------------------------------------------------------- 기본 요소 */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -.02em; font-weight: 700; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem); }
h2 { font-size: 1.28rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 .8em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, canvas { max-width: 100%; }

hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

code, kbd { font-family: var(--font-mono); font-size: .88em; }
code {
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: .1em .38em; border-radius: 5px;
}

.wrap { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }
main.wrap { padding: 1.75rem 0 3.5rem; }

.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); font-size: .88rem; }
.mono  { font-family: var(--font-mono); }
.han   { font-family: var(--font-han); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2.25rem; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-text);
  padding: .6rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------- 헤더 */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex; align-items: center; gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--text); font-weight: 800; font-size: 1.05rem;
  text-decoration: none; flex: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text);
  font-family: var(--font-han); font-size: 1.15rem; font-weight: 700;
}

.site-nav { display: flex; gap: .15rem; margin-right: auto; flex-wrap: wrap; }
.site-nav a {
  display: inline-block; padding: .45rem .8rem; border-radius: 999px;
  color: var(--text-soft); font-weight: 600; font-size: .93rem;
  text-decoration: none; transition: background .15s, color .15s;
}
.site-nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.site-nav a.is-active { background: var(--accent-soft); color: var(--accent); }

.header-side { display: flex; align-items: center; gap: .5rem; flex: none; }
/* 메뉴가 없을 때(로그인 전) 오른쪽 영역을 밀어 준다 */
.nav-spacer { margin-right: auto; }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--text-soft);
  cursor: pointer; font-size: 1rem;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }

.nav-toggle {
  display: none; flex-direction: column; gap: 4px; justify-content: center;
  width: 36px; height: 34px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; }

/* 사용자 메뉴 */
.user-chip { position: relative; }
.user-chip-btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .25rem .6rem .25rem .25rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
  cursor: pointer; font: inherit; font-size: .9rem; font-weight: 600;
}
.user-chip-btn:hover { background: var(--bg-soft); }
.avatar {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: var(--surface);
  font-size: .82rem; font-weight: 700;
}
.user-menu {
  position: absolute; right: 0; top: calc(100% + .5rem);
  min-width: 210px; padding: .4rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: none; z-index: 60;
}
.user-chip.is-open .user-menu { display: block; }
.user-menu-head {
  padding: .55rem .7rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .35rem;
  display: grid; gap: .1rem;
}
.user-menu-head span { color: var(--text-faint); font-size: .82rem; }
.user-menu a {
  display: block; padding: .5rem .7rem; border-radius: var(--radius-sm);
  color: var(--text); font-size: .92rem; font-weight: 500; text-decoration: none;
}
.user-menu a:hover { background: var(--bg-soft); text-decoration: none; }
.user-menu a.danger { color: var(--bad); }

/* --------------------------------------------------------- 푸터 */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 2rem 0 2.5rem;
  margin-top: auto;
}
.footer-inner {
  display: flex; gap: 1.5rem; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap;
}
.footer-inner p { max-width: 56ch; font-size: .88rem; margin-top: .35rem; }
.footer-meta { display: flex; gap: .8rem; color: var(--text-faint); font-size: .82rem; }

/* -------------------------------------------------------- 알림 */

.flash-area { display: grid; gap: .5rem; padding-top: 1rem; }
.flash {
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: .93rem;
}
.flash-ok   { background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 30%, transparent);   color: var(--ok); }
.flash-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.flash-error{ background: var(--bad-soft);  border-color: color-mix(in srgb, var(--bad) 30%, transparent);  color: var(--bad); }
.flash-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info); }
.flash a { color: inherit; text-decoration: underline; }

.alert {
  padding: 1.1rem 1.25rem; border-radius: var(--radius);
  background: var(--surface); border: 1px dashed var(--line-strong);
  color: var(--text-soft);
}

/* ------------------------------------------------------- 페이지 헤드 */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1.25rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.page-head .eyebrow {
  display: inline-block; margin-bottom: .3rem;
  color: var(--accent); font-size: .78rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}
.page-head p { color: var(--text-soft); margin-top: .35rem; }

/* ---------------------------------------------------------- 히어로 */

.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2rem;
  padding: 2.5rem;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.hero h1 { margin: .35rem 0 .7rem; }
.hero p { color: var(--text-soft); max-width: 46ch; }
.hero .actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.25rem; }
.hanja-orb {
  display: grid; place-items: center;
  width: 148px; height: 148px; border-radius: 50%;
  background: var(--ink); color: var(--surface);
  font-family: var(--font-han); font-size: 5rem; line-height: 1;
  box-shadow: var(--shadow-lg);
  user-select: none;
}

/* --------------------------------------------------------- 버튼 */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .62rem 1.15rem;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-size: .94rem; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: filter .15s, background .15s, border-color .15s;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { filter: brightness(.95); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.btn.ghost {
  background: transparent; color: var(--text);
  border-color: var(--line-strong);
}
.btn.ghost:hover { background: var(--bg-soft); }

.btn.subtle { background: var(--bg-soft); color: var(--text); }
.btn.subtle:hover { background: var(--line); }

.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: .38rem .8rem; font-size: .85rem; }
.btn.block { width: 100%; }

/* --------------------------------------------------------- 폼 */

input[type="text"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%;
  padding: .58rem .8rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .94rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input::placeholder { color: var(--text-faint); }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%),
                    linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
  background-position: right 1rem center, right .72rem center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.1rem;
}
label { font-size: .88rem; font-weight: 600; color: var(--text-soft); }

.field { display: grid; gap: .35rem; margin-bottom: .9rem; }
.field-row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; }
.field-row > .field { flex: 1 1 180px; margin-bottom: 0; }

.check {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .9rem; font-weight: 500; color: var(--text); cursor: pointer;
}
.check input { width: auto; accent-color: var(--accent); }

.filter-bar {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
  padding: .9rem 1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.filter-bar select, .filter-bar input { width: auto; min-width: 140px; }
.filter-bar .grow { flex: 1 1 200px; min-width: 160px; }

/* ------------------------------------------------------- 카드/그리드 */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card > h2, .card > h3 { margin-bottom: .6rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.section { margin-top: 2.25rem; }
.section > h2 { margin-bottom: .9rem; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap;
}

/* 통계 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stats > div {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.stats b { display: block; font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.stats span { display: block; color: var(--text-soft); font-size: .85rem; margin-top: .15rem; }
.stats .sub { color: var(--text-faint); font-size: .78rem; }

/* 급수 카드 */
.grade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.grade-card {
  display: grid; gap: .1rem; align-content: start;
  padding: .95rem 1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); text-decoration: none;
  transition: transform .12s, border-color .15s, box-shadow .15s;
}
.grade-card:hover {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: var(--shadow); text-decoration: none;
}
.grade-card strong { font-size: 1.06rem; }
.grade-card span { color: var(--text-soft); font-size: .85rem; }
.grade-card small { color: var(--text-faint); font-size: .78rem; }

/* 한자 카드 */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.char-card {
  display: grid; gap: .2rem; justify-items: center; text-align: center;
  padding: 1rem .75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); text-decoration: none;
  transition: transform .12s, border-color .15s, box-shadow .15s;
}
.char-card:hover {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: var(--shadow); text-decoration: none;
}
.char-card .glyph {
  font-family: var(--font-han); font-size: 2.9rem; line-height: 1.15;
  color: var(--ink);
}
.char-card strong { font-size: .95rem; font-weight: 700; }
.char-card span { color: var(--text-faint); font-size: .78rem; }

/* 배지 */
.badge {
  display: inline-block; padding: .12rem .5rem;
  border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: var(--bg-soft); color: var(--text-soft);
  border: 1px solid var(--line);
}
.badge.lv-beginner { background: var(--ok-soft);   color: var(--ok);     border-color: transparent; }
.badge.lv-basic    { background: var(--info-soft); color: var(--info);   border-color: transparent; }
.badge.lv-mid      { background: var(--warn-soft); color: var(--warn);   border-color: transparent; }
.badge.lv-high     { background: var(--accent-soft);color: var(--accent);border-color: transparent; }
.badge.lv-master   { background: var(--ink);       color: var(--surface);border-color: transparent; }
.badge.ok   { background: var(--ok-soft);  color: var(--ok);  border-color: transparent; }
.badge.bad  { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft);color: var(--warn);border-color: transparent; }

/* 한자어 목록 */
.word-list { display: grid; gap: .7rem; }
.word-list article {
  display: grid; gap: .25rem;
  padding: 1rem 1.15rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.word-list .word-head { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.word-list .word-head b {
  font-family: var(--font-han); font-size: 1.5rem; letter-spacing: .06em; color: var(--ink);
}
.word-list .word-head strong { font-size: 1.02rem; color: var(--accent); }
.word-list p { color: var(--text-soft); font-size: .93rem; margin: 0; }
.word-list .word-meta { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .2rem; }

/* --------------------------------------------------------- 퀴즈 */

.quiz-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }

.quiz {
  display: grid; gap: 1rem;
  padding: 1.75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.quiz-meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.quiz-prompt {
  font-size: clamp(1.2rem, 1rem + 1vw, 1.7rem); font-weight: 700;
  line-height: 1.45; margin: 0;
  word-break: keep-all;
}
.quiz-prompt .glyph {
  font-family: var(--font-han); font-size: 1.6em; vertical-align: -.12em;
  color: var(--ink); margin-right: .1em;
}
.quiz-answer { display: flex; gap: .6rem; flex-wrap: wrap; }
.quiz-answer input { flex: 1 1 220px; font-size: 1.05rem; padding: .7rem .9rem; }

.choice-list { display: grid; gap: .55rem; }
.choice {
  display: flex; align-items: center; gap: .7rem;
  padding: .8rem 1rem;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 1rem; text-align: left; width: 100%;
  font-family: inherit; color: var(--text);
  transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--accent); background: var(--surface); }
.choice .num {
  display: grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-soft); color: var(--text-soft);
  font-size: .8rem; font-weight: 700;
}
.choice.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.is-wrong   { border-color: var(--bad); background: var(--bad-soft); }
.choice:disabled { cursor: default; }

.result {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .95rem 1.15rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2);
}
.result b { font-size: 1.05rem; }
.result.ok  { background: var(--ok-soft);  border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.result.ok b { color: var(--ok); }
.result.no  { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.result.no b { color: var(--bad); }
.result .answer-text { font-family: var(--font-han); font-size: 1.15rem; }

.quiz-side { display: grid; gap: 1rem; }
.score-box {
  display: grid; gap: .3rem; padding: 1.15rem 1.25rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.score-box .big { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.progress {
  height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* ------------------------------------------------------- 필순(획순) */

.stroke-view { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-start; }

.stroke-figure { margin: 0; display: grid; gap: .4rem; justify-items: center; }
.stroke-figure figcaption {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: center;
  font-size: .82rem;
}

.stroke-svg {
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.stroke-grid { stroke: var(--line); fill: none; }
.stroke-svg .st-base { fill: var(--ink); }
.stroke-svg .st-dim  { fill: color-mix(in srgb, var(--text-faint) 45%, transparent); }
.stroke-svg .st-mark { fill: var(--accent); }
.stroke-svg .st-hidden { display: none; }
.stroke-svg .st-new  { fill: var(--accent); }

.stroke-steps {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: .5rem; flex: 1 1 320px; min-width: 0;
}
.stroke-steps .stroke-figure figcaption { font-size: .72rem; }

/* 시험 결과의 자기채점 블록 */
.self-check {
  display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: center;
  padding: 1rem; margin-top: .35rem;
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--radius);
}
.self-check-draw { margin: 0; display: grid; gap: .35rem; justify-items: center; }
.self-check-draw img {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
.self-check .big-answer {
  display: grid; place-items: center;
  width: 150px; height: 150px;
  font-size: 4.5rem; line-height: 1; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
.self-check-actions { display: grid; gap: .5rem; align-content: center; }
.self-check-actions p { margin: 0; }

/* 손글씨 문제에서 채점 전에 펼쳐 보는 모범 답안 */
.answer-reveal { display: grid; gap: .6rem; justify-items: start; }
.answer-reveal-body { display: flex; align-items: center; gap: .9rem; }
.answer-reveal-body[hidden] { display: none; }
.answer-reveal-body .big-answer {
  display: grid; place-items: center;
  min-width: 110px; height: 110px; padding: 0 .5rem;
  font-family: var(--font-han); font-size: 3.4rem; line-height: 1; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.exam-item.is-pending { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.verdict.warn { color: var(--warn); }

/* 손글씨 캔버스 */
.canvas-wrap { display: grid; gap: .6rem; justify-items: start; }
.canvas-board {
  position: relative;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 50% / 100% 50%,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 50% 0 / 50% 100%,
    var(--surface-2);
  overflow: hidden;
  touch-action: none;
}
.canvas-board canvas { display: block; cursor: crosshair; touch-action: none; }
.canvas-tools { display: flex; gap: .45rem; flex-wrap: wrap; }

/* 자기채점 */
.self-grade { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------------------------------- 모의시험 */

.exam-toolbar {
  position: sticky; top: var(--header-h); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  padding: .8rem 1.1rem; margin-bottom: 1.25rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.timer { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 700; }
.timer.is-urgent { color: var(--bad); }

.exam-list { display: grid; gap: .8rem; counter-reset: qno; }
.exam-item {
  display: grid; gap: .55rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.exam-item .qno {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: var(--surface);
  font-size: .8rem; font-weight: 700; flex: none;
}
.exam-item .q-line { display: flex; align-items: baseline; gap: .6rem; }
.exam-item h3 { font-size: 1.05rem; font-weight: 600; word-break: keep-all; }
.exam-item h3 .glyph { font-family: var(--font-han); font-size: 1.4em; vertical-align: -.1em; color: var(--ink); }
.exam-item.is-correct { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.exam-item.is-wrong   { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.exam-item .verdict { font-size: .9rem; font-weight: 600; }
.exam-item .verdict.good { color: var(--ok); }
.exam-item .verdict.bad  { color: var(--bad); }

.score-card {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 1.5rem 1.75rem; margin-bottom: 1.25rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.score-card .score-main { font-size: 2.6rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.score-card .score-sub { color: var(--text-soft); }
.pass-mark { font-size: 1rem; font-weight: 700; padding: .3rem .8rem; border-radius: 999px; }
.pass-mark.pass { background: var(--ok-soft); color: var(--ok); }
.pass-mark.fail { background: var(--bad-soft); color: var(--bad); }

/* ------------------------------------------------------- 오답노트 */

.note-list { display: grid; gap: .7rem; }
.note-item {
  display: grid; gap: .4rem;
  padding: 1rem 1.15rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.note-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.note-body { font-size: 1.02rem; word-break: keep-all; }
.note-body .glyph { font-family: var(--font-han); font-size: 1.35em; vertical-align: -.1em; color: var(--ink); }
.note-answer { font-family: var(--font-han); font-size: 1.05rem; color: var(--accent); }
.note-meta { display: flex; gap: .6rem; flex-wrap: wrap; color: var(--text-faint); font-size: .82rem; }
.note-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* --------------------------------------------------------- 테이블 */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 640px; }
table.data th, table.data td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); }
table.data th {
  background: var(--surface-2); color: var(--text-soft);
  font-size: .8rem; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap; position: sticky; top: 0;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { white-space: nowrap; text-align: right; }

/* -------------------------------------------------------- 페이지네이션 */

.pagination { display: flex; gap: .3rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }
.pagination a, .pagination span {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 34px; padding: 0 .5rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-soft);
  font-size: .88rem; font-weight: 600; text-decoration: none;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .is-current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pagination .gap { border: 0; background: transparent; }

/* --------------------------------------------------------- 인증 */

.auth-page {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(90% 80% at 50% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 65%),
    var(--bg);
}
.auth-card {
  width: min(100%, 420px);
  padding: 2.25rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}

/* ------------------------------------------- 로그인 화면 배경 그림
   가로 화면은 bgl.webp, 세로 화면은 bgp.webp 를 쓴다.
   그림이 밝은 한지색이라 어두운 테마에서는 먹빛 막을 덧씌운다. */

.auth-page.has-bg {
  position: relative;
  min-height: 100dvh;
  background: var(--bg) url("images/bgl.webp") center / cover no-repeat;
}
@media (orientation: portrait) {
  .auth-page.has-bg { background-image: url("images/bgp.webp"); }
}
.auth-page.has-bg::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(72% 58% at 50% 50%, rgba(255, 255, 255, .42), transparent 72%);
  pointer-events: none;
}
.auth-page.has-bg > * { position: relative; }

.auth-page.has-bg .auth-card {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  border-color: color-mix(in srgb, var(--line) 70%, transparent);
}
/* backdrop-filter 미지원 브라우저에서는 불투명 카드로 되돌린다 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .auth-page.has-bg .auth-card { background: var(--surface); }
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .auth-page.has-bg::before { background: rgba(12, 15, 18, .62); }
}
html[data-theme="dark"] .auth-page.has-bg::before { background: rgba(12, 15, 18, .62); }
.auth-card .brand-mark { width: 44px; height: 44px; font-size: 1.5rem; border-radius: 12px; }
.auth-head { display: grid; gap: .35rem; justify-items: center; text-align: center; margin-bottom: 1.5rem; }
.auth-head h1 { font-size: 1.4rem; }
.auth-head p { color: var(--text-soft); font-size: .9rem; }
.auth-card .btn { margin-top: .35rem; }
.auth-foot { margin-top: 1.25rem; text-align: center; color: var(--text-faint); font-size: .82rem; }

/* --------------------------------------------------------- 설치 */

.install-steps { display: grid; gap: .5rem; margin: 1.25rem 0; }
.install-step {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .8rem 1rem;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: .92rem;
}
.install-step .dot {
  display: grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-soft); color: var(--text-soft);
  font-size: .75rem; font-weight: 700;
}
.install-step.done .dot { background: var(--ok); color: #fff; }
.install-step.fail .dot { background: var(--bad); color: #fff; }

.log-box {
  max-height: 340px; overflow: auto;
  padding: 1rem 1.15rem;
  background: var(--ink); color: #e6edf3;
  border-radius: var(--radius); font-family: var(--font-mono); font-size: .82rem;
  line-height: 1.7; white-space: pre-wrap; word-break: break-all;
}

/* --------------------------------------------------------- 관리자 */

.admin-tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.admin-tabs a {
  padding: .45rem .9rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-soft); font-size: .9rem; font-weight: 600; text-decoration: none;
}
.admin-tabs a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.admin-tabs a.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.admin-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 330px;
  gap: 1.25rem; align-items: start;
}

.type-check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.type-check {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem .8rem;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer; font-size: .9rem;
}
.type-check:hover { border-color: var(--accent); }
.type-check input { width: auto; accent-color: var(--accent); }
/* 급수에 문제가 없는 유형은 숨기고, 있는 유형에는 보유 문제 수를 붙인다 */
.type-check[hidden] { display: none; }
.type-check .type-count { margin-left: auto; font-style: normal; font-size: .8rem; white-space: nowrap; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .92rem; }
.kv dt { color: var(--text-soft); }
.kv dd { margin: 0; font-weight: 600; }

/* --------------------------------------------------------- 상세 */

.char-detail {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2rem; align-items: start;
  padding: 2rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.char-detail .big-glyph {
  font-family: var(--font-han); font-size: 8rem; line-height: 1; color: var(--ink);
  padding: 1rem 1.5rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 50% / 100% 50%,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 50% 0 / 50% 100%,
    var(--surface-2);
}
.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ------------------------------------------------------- 반응형 */

@media (max-width: 900px) {
  /* 1fr 은 최소값이 min-content 라 넓은 표가 들어오면 화면을 밀어낸다.
     minmax(0, 1fr) + min-width:0 으로 자식이 줄어들 수 있게 한다. */
  .quiz-layout  { grid-template-columns: minmax(0, 1fr); }
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .quiz-layout > *, .admin-layout > * { min-width: 0; }
  .char-detail { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .char-detail .big-glyph { font-size: 6rem; }
}

@media (max-width: 780px) {
  .nav-toggle { display: flex; }
  .site-nav {
    display: none; order: 10;
    width: 100%; flex-direction: column; gap: .1rem;
    padding: .5rem 0 .9rem;
    border-top: 1px solid var(--line); margin-top: .2rem;
  }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding: .6rem .9rem; }
  .header-inner { flex-wrap: wrap; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 1.75rem; text-align: left; }
  .hanja-orb { width: 96px; height: 96px; font-size: 3.2rem; justify-self: start; }
  .user-name { display: none; }
  main.wrap { padding-top: 1.25rem; }
}

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .char-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .char-card .glyph { font-size: 2.3rem; }
  .quiz { padding: 1.25rem; }
  .filter-bar { padding: .75rem; }
  .filter-bar select, .filter-bar input { min-width: 0; width: 100%; }
  .filter-bar .grow { flex: 1 1 100%; min-width: 0; width: 100%; }
  .filter-bar .btn { width: 100%; }
  .score-card { padding: 1.15rem; }
  .card { padding: 1rem; }
}

@media print {
  .site-header, .site-footer, .filter-bar, .exam-toolbar, .btn { display: none !important; }
  body { background: #fff; }
  .exam-item { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ============================================================
   유틸리티 클래스
   CSP(style-src 'self')를 지키기 위해 인라인 style="" 을 쓰지 않는다.
   새 화면을 만들 때도 인라인 스타일 대신 아래 클래스를 쓸 것.
   ============================================================ */

.mb-1 { margin-bottom: .75rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.25rem; }
.mb-4 { margin-bottom: 1.5rem; }

.ml-auto  { margin-left: auto; }
.w-auto   { width: auto; }
.d-block  { display: block; }
.text-sm  { font-size: .9rem; }
.text-xs  { font-size: .68rem; }
.text-bad { color: var(--bad); }

/* 버튼을 가로로 늘어놓는 줄 */
.btn-row { display: flex; gap: .55rem; flex-wrap: wrap; }
.btn-row--center { align-items: center; }
.inline-form { display: inline; }

/* 좁은 설정 카드 */
.card-narrow { max-width: 620px; }
.card-narrow--wide { max-width: 640px; }
.auth-card--wide { width: min(100%, 680px); }

/* 테두리 없는 표 컨테이너 */
.table-wrap--plain { border: 0; }
.data--fit { min-width: 0; }

.word-title { font-size: 1.15rem; }
.badge--mini { font-size: .68rem; }

/* 손글씨 캔버스 크기 */
.canvas-board--lg, .canvas-board--lg canvas { width: 280px; height: 280px; }
.canvas-board--md, .canvas-board--md canvas { width: 230px; height: 230px; }

/* 진행 막대 — 5% 단위 클래스로 폭을 준다 */
.progress--slim { width: 180px; margin-top: .35rem; }
.bar-0 { width: 0%; }
.bar-5 { width: 5%; }
.bar-10 { width: 10%; }
.bar-15 { width: 15%; }
.bar-20 { width: 20%; }
.bar-25 { width: 25%; }
.bar-30 { width: 30%; }
.bar-35 { width: 35%; }
.bar-40 { width: 40%; }
.bar-45 { width: 45%; }
.bar-50 { width: 50%; }
.bar-55 { width: 55%; }
.bar-60 { width: 60%; }
.bar-65 { width: 65%; }
.bar-70 { width: 70%; }
.bar-75 { width: 75%; }
.bar-80 { width: 80%; }
.bar-85 { width: 85%; }
.bar-90 { width: 90%; }
.bar-95 { width: 95%; }
.bar-100 { width: 100%; }

/* 계정 화면의 일별 학습량 막대그래프.
   막대 높이는 아래 .h-* 클래스(5% 단위)로 준다. */
.daily-chart { display: flex; align-items: flex-end; gap: 4px; height: 130px; margin-top: 1rem; }
.daily-col   { flex: 1; display: grid; grid-template-rows: 1fr auto; gap: .25rem; justify-items: center; height: 100%; }
.daily-bar   {
  width: 100%; min-height: 3px;
  background: var(--accent); border-radius: 4px 4px 0 0;
  align-self: end;
}
.h-0 { height: 0%; }
.h-5 { height: 5%; }
.h-10 { height: 10%; }
.h-15 { height: 15%; }
.h-20 { height: 20%; }
.h-25 { height: 25%; }
.h-30 { height: 30%; }
.h-35 { height: 35%; }
.h-40 { height: 40%; }
.h-45 { height: 45%; }
.h-50 { height: 50%; }
.h-55 { height: 55%; }
.h-60 { height: 60%; }
.h-65 { height: 65%; }
.h-70 { height: 70%; }
.h-75 { height: 75%; }
.h-80 { height: 80%; }
.h-85 { height: 85%; }
.h-90 { height: 90%; }
.h-95 { height: 95%; }
.h-100 { height: 100%; }

/* DB 연결 실패 등 레이아웃 없는 오류 화면 */
.fatal-page {
  min-height: 100vh; display: grid; place-items: center;
  padding: 2rem 1rem; background: var(--bg);
}
.fatal-page .card { width: min(100%, 44rem); }
.fatal-page h1 { font-size: 1.4rem; margin-bottom: .75rem; }


/* ------------------------------------------------- 모바일 안전장치
   그리드·플렉스 자식의 기본 최소 크기(min-content)가 넓은 표나 긴 낱말
   때문에 화면을 밀어내는 것을 막는다. 넘치는 내용은 각자 스크롤한다. */
.admin-layout > *, .quiz-layout > *, .grid-2 > *, .grid-3 > *, .stats > * { min-width: 0; }
.table-wrap { max-width: 100%; }
.log-box, pre { max-width: 100%; overflow-x: auto; }
.card, .quiz, .exam-item { overflow-wrap: anywhere; }

@media (max-width: 420px) {
  /* 작은 화면에서는 손글씨 캔버스를 화면 폭에 맞춘다 */
  .canvas-board--lg, .canvas-board--lg canvas,
  .canvas-board--md, .canvas-board--md canvas {
    width: min(280px, 74vw); height: min(280px, 74vw);
  }
  .exam-toolbar { flex-wrap: wrap; gap: .6rem; }
  .progress--slim { width: 100%; }
  .btn-row .btn { width: 100%; }
  .page-head { flex-wrap: wrap; gap: .75rem; }
}
