/* ==========================================================
   components.css: 버튼, 입력, 패널, 목록, 복습 카드, 차트 등
   ========================================================== */

/* 버튼 */
.btn { appearance: none; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 18px; font: 600 .9375rem/1.2 var(--font); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--text); background: transparent; min-height: 44px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.outline-light { border-color: rgba(255, 255, 255, .5); color: #fff; }
.btn.outline-light:hover { background: rgba(255, 255, 255, .08); }
.btn.ghost { border-color: var(--line); background: var(--surface); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.ghost-dark { border-color: rgba(255, 255, 255, .25); color: #fff; }
.btn.pill { border-radius: 999px; }
.btn.lg { min-height: 52px; padding: 12px 24px; font-size: 1.0625rem; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: .875rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; filter: none; }
.btn.danger { color: var(--danger); }
.link { appearance: none; background: none; border: 0; padding: 8px 0; color: var(--text-2); font: 500 .875rem var(--font); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link.danger { color: var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 입력 */
label { display: block; font-size: .875rem; font-weight: 600; color: var(--text-2); margin: 0 0 14px; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; font: 400 1rem/1.5 var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; line-height: 1.75; }
input[type=checkbox], input[type=radio] { display: inline-block; width: 18px; height: 18px; flex: none; margin: 2px 10px 0 0; accent-color: var(--primary); }
input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--primary); }
input[type=file] { padding: 8px; }
output { font-weight: 700; color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select { margin-top: 0; }
.filters input { flex: 1 1 220px; }
.filters select { flex: 0 1 auto; width: auto; min-width: 0; }
.check-row { display: flex; align-items: flex-start; color: var(--text); font-weight: 500; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

/* 패널 */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { font-size: 1.25rem; }
.panel-head h3 { font-size: 1.0625rem; }
.sub-h { font-size: .875rem; color: var(--text-2); margin: 18px 0 8px; }
.sub-h:first-of-type { margin-top: 0; }
.more { background: none; border: 0; color: var(--text-3); font-size: .8125rem; font-weight: 600; cursor: pointer; padding: 4px 0; }
.more:hover { color: var(--primary); }
@media (max-width: 760px) { .panel { padding: 18px 16px; } }

/* 과목별 복습 목록 */
.subj-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.subj-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 14px; background: var(--surface-2); border: 1px solid var(--line-2); border-left: 5px solid var(--c); border-radius: 10px; cursor: pointer; text-align: left; color: var(--text); }
.subj-list button:hover { border-color: var(--c); }
.subj-list .nm { flex: 1; font-weight: 600; min-width: 0; }
.subj-list .tot { font-size: .8125rem; color: var(--text-3); white-space: nowrap; }
.due { min-width: 40px; text-align: center; background: var(--c); color: #fff; font-weight: 700; font-size: .875rem; border-radius: 999px; padding: 2px 10px; font-variant-numeric: tabular-nums; }
.due.zero { background: var(--line); color: var(--text-3); }
@media (max-width: 480px) { .subj-list { grid-template-columns: 1fr; } }

/* 게시판형 목록 */
.board-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--text); }
.board-list li { border-bottom: 1px solid var(--line-2); }
.board-list button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; background: none; border: 0; padding: 13px 2px; text-align: left; cursor: pointer; color: var(--text); }
.board-list button:hover .tt { color: var(--primary); text-decoration: underline; }
.board-list .tt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .dt { color: var(--text-3); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.board-empty { border-top: 2px solid var(--text); padding: 18px 2px; margin: 0; color: var(--text-3); font-size: .9375rem; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }

/* 타이머 */
.timer { display: flex; gap: 10px; align-items: center; }
.timer select { margin: 0; flex: 1; }
.timer.on { justify-content: space-between; background: var(--surface-2); border: 1px solid var(--line-2); border-left: 5px solid var(--c); border-radius: 10px; padding: 12px 14px; }
.timer-subj { margin: 0; font-size: .875rem; color: var(--text-2); }
.timer-clock { margin: 0; font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.25; letter-spacing: -0.02em; }

/* 막대 그래프 */
.bars { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; height: 128px; margin-bottom: 12px; }
.bar { display: flex; flex-direction: column; height: 100%; gap: 4px; min-width: 0; }
.track { flex: 1; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.stack { width: 100%; max-width: 26px; display: flex; flex-direction: column; border-radius: 4px 4px 0 0; overflow: hidden; }
.stack .s1 { background: var(--stage1); }
.stack .s2 { background: var(--stage2); }
.bl { font-size: .6875rem; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }
.bl.today { color: var(--text); font-weight: 700; }
.split-bar { position: relative; height: 10px; background: var(--line-2); border-radius: 5px; display: flex; }
.split-bar .s1 { background: var(--stage1); border-radius: 5px 0 0 5px; }
.split-bar .s2 { background: var(--stage2); border-radius: 0 5px 5px 0; }
.target { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--text); transform: translateX(-1px); }
.split-legend { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: .8125rem; margin-top: 10px; color: var(--text-2); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.sw.s1 { background: var(--stage1); }
.sw.s2 { background: var(--stage2); }
.advice { margin: 12px 0 0; font-size: .875rem; color: var(--text-2); background: var(--surface-2); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 0 6px 6px 0; }
.banner { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px; font-size: .9375rem; color: var(--text-2); margin-bottom: 24px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner p { margin: 0; }

/* 복습 카드 */
.progress { font-size: .8125rem; color: var(--text-3); margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.note { background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--c); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px 26px; }
.note-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.note-body { font-size: 1.1875rem; line-height: 1.9; font-weight: 500; }
.back { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line); font-size: 1.0625rem; line-height: 1.85; color: var(--text-2); }
.blank { display: inline-block; min-width: 3.2em; padding: 0 .35em; border-bottom: 2px solid var(--primary); color: var(--primary); font-size: .8em; font-weight: 700; line-height: 1.5; text-align: center; }
mark.ans { background: linear-gradient(transparent 50%, var(--hl) 50%); color: inherit; padding: 0 .1em; font-weight: 800; }
:root[data-theme="dark"] mark.ans { background: var(--hl); color: #14203A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) mark.ans { background: var(--hl); color: #14203A; } }
.cause { margin: 14px 0 0; font-size: .875rem; color: var(--danger); font-weight: 600; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.grade { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 9px 4px; cursor: pointer; font: 700 .9375rem var(--font); display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 60px; }
.grade:hover { border-color: var(--primary); }
.grade small { font-weight: 500; font-size: .75rem; color: var(--text-3); }
.grade.g-again { border-color: var(--danger); color: var(--danger); }
.reveal { margin-top: 16px; }
.note-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
.keys { font-size: .75rem; color: var(--text-3); margin-top: 8px; }
@media (hover: none) { .keys { display: none; } }

/* 과목 칩 + 카드 목록 */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; margin-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 7px 14px; font: 600 .875rem var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip.on { background: var(--c); border-color: var(--c); color: #fff; }
.chip.on i { background: #fff; }
.count { font-size: .875rem; color: var(--text-3); margin: 0 0 8px; }
.clist { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--text); }
.crow { appearance: none; font: inherit; color: inherit; text-align: left; display: block; width: 100%; padding: 14px 6px; border: 0; border-bottom: 1px solid var(--line-2); cursor: pointer; background: none; }
.crow:hover .crow-txt { color: var(--primary); }
.crow-top { display: flex; gap: 6px 10px; font-size: .75rem; color: var(--text-3); margin-bottom: 4px; flex-wrap: wrap; align-items: center; }
.crow-top .bad { color: var(--danger); font-weight: 700; }
.crow-txt { font-size: 1rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.more-btn { margin-top: 14px; }

/* 비어 있음 */
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px 22px; }
.empty h2 { font-size: 1.1875rem; margin-bottom: 6px; }
.empty p { margin: 0 0 16px; color: var(--text-2); }

/* 2차 답안 */
.essay-bar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--header-h)); z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.etimer { font-size: 1.625rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-left: auto; letter-spacing: -0.02em; }
.etimer.warn { color: var(--warn); }
.etimer.over { color: var(--danger); }
.qbox { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.qbox summary { cursor: pointer; font-weight: 700; }
.qtext { line-height: 1.85; white-space: pre-wrap; margin: 10px 0 0; }
#e-answer { min-height: 55vh; font-size: 1.0625rem; line-height: 1.9; }
.checks { list-style: none; padding: 0; margin: 0 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.checks li + li { border-top: 1px solid var(--line-2); }
.checks label { display: flex; align-items: flex-start; padding: 12px 16px; margin: 0; color: var(--text); font-size: .9375rem; font-weight: 500; cursor: pointer; }
.facts { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: .9375rem; color: var(--text-2); margin: 0 0 16px; }
.facts b { color: var(--text); }
.readback { white-space: pre-wrap; line-height: 1.85; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 12px 14px; margin: 8px 0 0; }
details > summary { cursor: pointer; }
.hist { list-style: none; padding: 0; margin: 0; border-top: 2px solid var(--text); }
.hist button { appearance: none; font: inherit; color: inherit; text-align: left; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line-2); padding: 12px 4px; cursor: pointer; display: grid; gap: 2px; }
.hist .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .m { font-size: .8125rem; color: var(--text-3); }

/* 기록 */
.mock-sum { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.mock-title { margin: 0; font-weight: 700; }
.verdict { font-size: 1.1875rem; font-weight: 800; margin: 4px 0 0; letter-spacing: -0.02em; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--danger); }
.scores { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 18px; }
.scores li { display: flex; align-items: center; gap: 4px; font-size: .9375rem; border-bottom: 1px solid var(--line-2); padding: 7px 0; }
.scores b { margin-left: auto; font-variant-numeric: tabular-nums; }
.scores b.bad { color: var(--danger); }
.chart { display: block; width: 100%; height: auto; margin-top: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8125rem; color: var(--text-2); margin: 6px 0 14px; }
.mlist { list-style: none; padding: 0; margin: 8px 0 0; }
.mlist li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: .875rem; flex-wrap: wrap; }
.mlist .nm { flex: 1; }
.hbars { list-style: none; padding: 0; margin: 0 0 6px; }
.hbars li { display: grid; grid-template-columns: 8.5em 1fr 3em; gap: 10px; align-items: center; font-size: .875rem; padding: 5px 0; }
.hbar { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--c, var(--primary)); }
.hbars .n { text-align: right; font-variant-numeric: tabular-nums; }
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.score-grid label { border-left: 4px solid var(--c); padding-left: 8px; }
.seg { display: flex; gap: 18px; margin-bottom: 14px; }
.seg label { display: flex; align-items: center; margin: 0; color: var(--text); font-size: 1rem; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
@media (max-width: 480px) { .score-grid { grid-template-columns: 1fr; } }

/* 대화상자 + 알림 */
dialog.sheet { border: 0; padding: 0; border-radius: 16px; width: min(640px, calc(100vw - 20px)); max-height: calc(100dvh - 40px); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(5, 10, 25, .35); }
dialog.sheet::backdrop { background: rgba(8, 14, 30, .55); }
.sheet-in { padding: 22px 20px 20px; overflow: auto; max-height: calc(100dvh - 40px); }
.sheet-in > h2 { margin: 0 44px 16px 0; font-size: 1.25rem; }
.sheet-close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border: 0; background: none; color: var(--text-2); font-size: 1.5rem; line-height: 1; cursor: pointer; border-radius: 8px; }
.sheet-close:hover { background: var(--surface-2); }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: .9375rem; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); width: max-content; box-shadow: var(--shadow); }
.toast.show { opacity: 1; }
@media (max-width: 760px) { .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); } }

/* 로그인 */
.login { max-width: 440px; margin: 0 auto; }
.login-msg { color: var(--danger); font-weight: 600; font-size: .9375rem; margin: 0 0 12px; }
