:root {
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #f0f0ec; --fg: #1c1c1e; --muted: #6b6b70;
  --line: #e2e2dd; --accent: #2f6fde; --accent-fg: #ffffff; --accent-soft: #e8f0fd;
  --ok: #1f8a4c; --ok-soft: #e5f5ec; --err: #c4352b; --err-soft: #fbeae8; --warn: #a86400;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131315; --surface: #1c1c1f; --surface-2: #26262a; --fg: #f2f2f4; --muted: #a0a0a8;
    --line: #2f2f34; --accent: #6b9dff; --accent-fg: #0d1526; --accent-soft: #1b2740;
    --ok: #4cc47f; --ok-soft: #15301f; --err: #ff7a6e; --err-soft: #3a1b18; --warn: #f0a640;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #131315; --surface: #1c1c1f; --surface-2: #26262a; --fg: #f2f2f4; --muted: #a0a0a8;
  --line: #2f2f34; --accent: #6b9dff; --accent-fg: #0d1526; --accent-soft: #1b2740;
  --ok: #4cc47f; --ok-soft: #15301f; --err: #ff7a6e; --err-soft: #3a1b18; --warn: #f0a640;
  --shadow: none;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg); line-height: 1.55;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 15px; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.3px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* 상단 바 */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; height: 56px; }
.brand { font-weight: 800; font-size: 18px; color: var(--fg); letter-spacing: -.4px; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--fg); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 820px) { .g2, .g3 { grid-template-columns: 1fr; } .who .name { display: none; } }

/* 폼 */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 72px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline > * { flex: 1 1 140px; }
.inline > .btn { flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--err); }
.btn.link { border: 0; background: none; padding: 0; color: var(--muted); font-weight: 500; }
.btn.link:hover { color: var(--fg); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: wait; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--err-soft); color: var(--err); }

/* 표 */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.lv-초 { background: #fff3d6; color: #8a5a00; }
.pill.lv-중 { background: #e3f4ea; color: #1f7a45; }
.pill.lv-고 { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill.lv-초 { background: #3a2c0c; color: #f3c25a; }
  :root:not([data-theme="light"]) .pill.lv-중 { background: #12301f; color: #63d391; }
}

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--fg); margin-bottom: 4px; }

/* 탭 */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs a { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--fg); }
.tabs a.on { background: var(--fg); border-color: var(--fg); color: var(--bg); }

/* 막대 그래프 */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr minmax(56px, auto); gap: 10px; align-items: center; font-size: 13px; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { display: block; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar .val { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

.stat { padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }

.policy { display: grid; gap: 12px; }
.policy .item { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; }
.policy .item p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.ai-box { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 14px; font-size: 14px; min-height: 48px; }
.heat td.num { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* 로그인 */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; padding: 32px 28px; }
.auth .brand { font-size: 26px; display: block; text-align: center; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* 점수 입력 표 */
.score-grid input { padding: 7px 9px; }
.score-grid td { padding: 6px 4px; }

svg.trend { width: 100%; height: 220px; display: block; }
svg.trend text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- 시험·채점 ---------- */
.pill.warn { background: #fff1d6; color: #8a5a00; }
.bad-text { color: var(--err); }
.ok-text { color: var(--ok); }
.bar .fill.bad { background: var(--err); }
.bar .fill.mid { background: var(--warn); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.warn { background: #3a2c0c; color: #f3c25a; } }

.choice-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 16px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; margin: 0; color: var(--fg); font-weight: 400; font-size: 14px; }
.choice input { width: auto; margin-top: 3px; }
.choice strong { display: block; margin-bottom: 2px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.job { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.spinner { width: 28px; height: 28px; flex: none; border: 3px solid var(--surface-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

details > summary { cursor: pointer; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumbs a { display: block; width: 120px; text-align: center; font-size: 12px; color: var(--muted); }
.thumbs img { width: 100%; height: 160px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.thumbs.big a { width: 100%; }
.thumbs.big img { height: auto; max-height: 80vh; object-fit: contain; }

.toolbar { margin-bottom: 12px; }
.q-table td { padding: 6px 4px; vertical-align: top; }
.q-table input, .q-table select, .q-table textarea { padding: 6px 8px; font-size: 14px; }
.q-table .w-num { width: 64px; }
.q-table .w-ans { width: 76px; font-weight: 700; }
.q-table .w-unit { width: 150px; }
.q-table .q-text { min-width: 260px; white-space: normal; }
.q-table textarea { min-height: 34px; font-size: 13px; }
.missing { border-color: var(--err) !important; background: var(--err-soft) !important; }

.ans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.ans-cell { display: flex; flex-direction: column; gap: 3px; margin: 0; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.ans-cell .no { font-size: 12px; color: var(--muted); font-weight: 700; }
.ans-cell input { padding: 6px; text-align: center; font-weight: 700; font-size: 16px; }
.ans-cell.ai { background: #fff6d6; border-color: #e6c35a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ans-cell.ai { background: #3a2f0c; border-color: #8a6a10; } }
.tips { padding-left: 18px; margin: 0 0 14px; }

.omr { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.omr .cell { display: grid; justify-items: center; padding: 6px 2px; border-radius: 8px; font-size: 12px; color: var(--fg); }
.omr .cell:hover { text-decoration: none; filter: brightness(.97); }
.omr .cell.ok { background: var(--ok-soft); }
.omr .cell.no { background: var(--err-soft); }
.omr .no { color: var(--muted); font-weight: 700; }
.omr .mk { font-size: 18px; font-weight: 800; line-height: 1.2; }
.omr .ok .mk { color: var(--ok); }
.omr .no .mk { color: var(--err); }
.omr .sm { font-variant-numeric: tabular-nums; }

.wrong { border: 1px solid var(--line); border-left: 4px solid var(--err); border-radius: 10px; padding: 14px 16px; }
.wrong.done { border-left-color: var(--ok); opacity: .75; }
.wrong header { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.wrong header > div { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.wrong .q { margin: 6px 0; white-space: pre-wrap; }
.wrong .choices { margin: 4px 0 8px; padding-left: 22px; font-size: 14px; }
.wrong .choices li.key { color: var(--ok); font-weight: 700; }
.wrong .choices li.mine:not(.key) { color: var(--err); text-decoration: line-through; }
.wrong .ans { display: flex; gap: 18px; font-size: 14px; margin-bottom: 8px; }
.wrong .ai-box { margin-bottom: 8px; }
.wrong-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note-form { display: flex; gap: 6px; flex: 1 1 280px; }
.note-form input { padding: 5px 9px; font-size: 13px; }

/* ---------- 로그인·가입 화면 ---------- */
.auth-body { background: var(--bg); }
.auth2 { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.hero {
  position: relative; overflow: hidden; color: #fff; display: flex; align-items: center; justify-content: center; padding: 48px 40px;
  background:
    radial-gradient(600px 400px at 85% 10%, rgba(143, 180, 255, .35), transparent 60%),
    radial-gradient(500px 380px at 10% 95%, rgba(242, 154, 58, .22), transparent 60%),
    linear-gradient(155deg, #0f1f47 0%, #18337a 55%, #2f6fde 100%);
}
.hero-inner { width: 100%; max-width: 520px; }
.hero-brand { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.4px; }
.hero-brand span { color: #ffd27a; }
.hero-brand:hover { text-decoration: none; }
.hero-title { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.25; letter-spacing: -1px; margin: 28px 0 10px; font-weight: 800; }
.hero-sub { color: rgba(255,255,255,.75); margin: 0 0 8px; font-size: 15px; }
.hero-art { width: 100%; height: auto; display: block; margin: 18px 0 12px; }
.hero-feats { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.hero-feats li { display: inline-flex; gap: 6px; align-items: center; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(4px); }

.hero-art .mark { stroke-dasharray: 70; stroke-dashoffset: 70; animation: draw .5s ease-out forwards; }
.hero-art .m1 { animation-delay: .4s; } .hero-art .m2 { animation-delay: .7s; } .hero-art .m3 { animation-delay: 1s; } .hero-art .m4 { animation-delay: 1.3s; }
.hero-art .bars rect { transform-box: fill-box; transform-origin: bottom; transform: scaleY(0); animation: grow .7s cubic-bezier(.2,.8,.2,1) forwards; }
.hero-art .bars rect:nth-child(2) { animation-delay: .1s; } .hero-art .bars rect:nth-child(3) { animation-delay: .2s; }
.hero-art .bars rect:nth-child(4) { animation-delay: .3s; } .hero-art .bars rect:nth-child(5) { animation-delay: .45s; }
.hero-art .trend { stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw 1s ease-out .8s forwards; }
.hero-art .tip { opacity: 0; animation: fade .4s ease-out 1.6s forwards; }
.hero-art .pin { animation: bob 3s ease-in-out infinite; }
.hero-art .p2 { animation-delay: .6s; } .hero-art .p3 { animation-delay: 1.2s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes grow { to { transform: scaleY(1); } }
@keyframes fade { to { opacity: 1; } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@media (prefers-reduced-motion: reduce) {
  .hero-art .mark, .hero-art .trend { stroke-dashoffset: 0; animation: none; }
  .hero-art .bars rect { transform: none; animation: none; }
  .hero-art .tip { opacity: 1; animation: none; }
  .hero-art .pin { animation: none; }
}

.panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.panel-card { width: 100%; max-width: 420px; }
.panel-title { font-size: 24px; margin: 0 0 4px; letter-spacing: -.5px; }
.panel-sub { color: var(--muted); margin: 0 0 24px; }
.panel-foot { color: var(--muted); font-size: 12px; margin-top: 28px; }
.btn.big { width: 100%; padding: 12px 16px; font-size: 15px; border-radius: 10px; }
.btn.outline { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn.outline:hover { background: var(--accent-soft); }
.center { text-align: center; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 22px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 8px; cursor: pointer; }
.pw-toggle:hover { color: var(--fg); }
.hint { font-weight: 400; color: var(--muted); }
.err-list { margin: 0; padding-left: 18px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.consent { margin: 4px 0 18px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.consent summary { list-style: none; }
.consent summary::-webkit-details-marker { display: none; }
.consent p { margin: 6px 0 0; }
.check { display: inline-flex; gap: 8px; align-items: center; margin: 0; color: var(--fg); font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; }
.check span::after { content: " ▾"; color: var(--muted); font-weight: 400; }

@media (max-width: 900px) {
  .auth2 { grid-template-columns: 1fr; }
  .hero { padding: 22px 16px 20px; }
  .hero-title { font-size: 22px; margin: 10px 0 4px; }
  .hero-title br, .hero-sub br { display: none; }
  .hero-sub { font-size: 13px; margin: 0; }
  .hero-art, .hero-feats { display: none; }
  .panel { padding: 24px 16px 40px; justify-content: flex-start; }
}

/* 관리자: 가입 신청 */
.nav .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--err); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.req { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.req + .req { margin-top: 10px; }
.req dl { display: grid; grid-template-columns: 70px 1fr; gap: 4px 10px; margin: 8px 0 12px; font-size: 14px; }
.req dt { color: var(--muted); }
.req dd { margin: 0; word-break: break-all; }
.req-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.req-actions form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.req-actions select, .req-actions input { width: auto; padding: 6px 8px; font-size: 13px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.status-dot.ok { background: var(--ok); } .status-dot.bad { background: var(--err); } .status-dot.off { background: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
