/* ===== 디자인 기본값 ===== */
:root {
	--primary: #4f46e5;
	--primary-dark: #4338ca;
	--primary-soft: #eef2ff;
	--ok: #059669;
	--ok-soft: #d1fae5;
	--warn: #d97706;
	--warn-soft: #fef3c7;
	--danger: #dc2626;
	--danger-soft: #fee2e2;
	--text: #0f172a;
	--text-sub: #475569;
	--text-mute: #94a3b8;
	--line: #e2e8f0;
	--line-soft: #f1f5f9;
	--bg: #f6f7fb;
	--card: #fff;
	--radius: 14px;
	--shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
	--shadow-lg: 0 10px 40px rgba(15, 23, 42, .18);
	--mono: "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: var(--text);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
.container { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }

h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
h2 small { font-size: 12px; font-weight: normal; color: var(--text-mute); }
h3 { font-size: 13px; font-weight: 700; color: var(--text-sub); margin: 20px 0 8px; }
.page-sub { color: var(--text-sub); margin: 0 0 20px; }

kbd {
	display: inline-block; min-width: 20px; padding: 1px 6px; font-family: var(--mono); font-size: 11px; text-align: center;
	color: var(--text-sub); background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
}

/* ===== 상단 메뉴 ===== */
.topnav {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; gap: 4px; padding: 0 24px; height: 56px;
	background: rgba(15, 23, 42, .92); backdrop-filter: blur(8px);
}
.topnav .brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 800; margin-right: 20px; letter-spacing: -.01em; }
.topnav .brand::before {
	content: ""; width: 22px; height: 22px; border-radius: 7px;
	background: linear-gradient(135deg, #818cf8, #22d3ee);
}
.topnav a { color: #cbd5e1; text-decoration: none; padding: 7px 14px; border-radius: 8px; font-weight: 500; }
.topnav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.topnav a.active { color: #fff; background: rgba(129, 140, 248, .25); }

/* ===== 카드 ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.cards .card { margin-bottom: 0; }
.card.muted { color: var(--text-sub); }

/* ===== 알림 ===== */
.alert, .notice, .warning-box { padding: 12px 16px; margin-bottom: 16px; border-radius: 10px; border: 1px solid; }
.alert { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.notice { border-color: #c7d2fe; background: var(--primary-soft); color: var(--primary-dark); }
.warning-box { border-color: #fcd34d; background: #fffbeb; color: #78350f; }
.warning-box .warning-title { font-weight: 700; color: #b45309; margin-bottom: 6px; }
.warning-box ul { margin: 8px 0; padding-left: 20px; }
.warning-box form { margin-top: 8px; }

/* ===== 버튼 ===== */
button { font-family: inherit; }
button.small, .btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	padding: 6px 14px; font-size: 13px; font-weight: 600; color: #fff; background: var(--primary);
	border: 0; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none;
	transition: background .15s, transform .05s;
}
button.small:hover, .btn:hover { background: var(--primary-dark); }
button.small:active, .btn:active { transform: translateY(1px); }
button.small:disabled { background: #cbd5e1; cursor: not-allowed; }
button.small.secondary, .btn.secondary { color: var(--text-sub); background: var(--line-soft); }
button.small.secondary:hover, .btn.secondary:hover { background: var(--line); }
button.small.warn, .btn.warn { background: var(--warn); }
button.small.warn:hover, .btn.warn:hover { background: #b45309; }
a.button-link { padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--primary); background: var(--primary-soft); border-radius: 8px; text-decoration: none; }
a.button-link:hover { background: #e0e7ff; }
form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

/* ===== 표 ===== */
table { width: 100%; border-collapse: collapse; }
.kv th, .kv td { padding: 7px 4px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }
.kv th { width: 45%; font-weight: normal; color: var(--text-sub); }
.kv th.group { padding-top: 14px; font-weight: 700; color: var(--text); }

.grid th, .grid td { padding: 10px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
.grid thead th { font-size: 12px; font-weight: 600; color: var(--text-mute); white-space: nowrap; border-bottom: 1px solid var(--line); }
.grid tbody tr { transition: background .1s; }
.grid tbody tr:hover { background: #fafbff; }
.grid .wide { width: 40%; }
.grid .bar-col { width: 160px; }
.grid tr.highlight td { background: #f5f7ff; }
.status-table { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 700; }
.mono { font-family: var(--mono); font-size: 12px; }
.help { color: var(--text-mute); font-size: 12px; margin-top: 4px; }
.error-text { color: var(--danger); word-break: break-all; }

/* ===== 뱃지 ===== */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--line-soft); color: var(--text-sub); }
.badge.pass { background: var(--ok-soft); color: #047857; }
.badge.fail { background: var(--danger-soft); color: #b91c1c; }
.badge.warn { background: var(--warn-soft); color: #b45309; }
.badge.lv-none { background: var(--line-soft); color: var(--text-sub); }
.badge.lv-low { background: var(--danger-soft); color: #b91c1c; }
.badge.lv-min { background: var(--warn-soft); color: #b45309; }
.badge.lv-enough { background: var(--ok-soft); color: #047857; }
.badge.priority { background: var(--line-soft); color: var(--text-mute); font-weight: normal; }

/* ===== 막대 (marker = 기준선) ===== */
.bar { position: relative; height: 8px; background: var(--line-soft); border-radius: 999px; min-width: 120px; }
.bar .fill { height: 100%; background: #818cf8; border-radius: 999px; transition: width .4s; }
.bar.sim .fill { background: #34d399; }
.bar .marker { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--danger); border-radius: 1px; }
.bar .fill.lv-none, .bar .fill.lv-low { background: #f87171; }
.bar .fill.lv-min { background: #fbbf24; }
.bar .fill.lv-enough { background: #34d399; }

/* ===== 분류하기: 검색 ===== */
.hero {
	position: relative; padding: 28px 28px 24px; margin-bottom: 16px; border-radius: 20px; color: #fff; overflow: hidden;
	background: radial-gradient(circle at 85% 0%, rgba(34, 211, 238, .35), transparent 45%),
	linear-gradient(135deg, #312e81, #4f46e5 55%, #6366f1);
	box-shadow: var(--shadow-lg);
}
.hero h1 { color: #fff; }
.hero .page-sub { color: #c7d2fe; margin-bottom: 18px; }
.search { display: flex; gap: 8px; background: #fff; padding: 6px; border-radius: 14px; box-shadow: 0 8px 24px rgba(30, 27, 75, .35); }
.search input { flex: 1; padding: 12px 14px; font-size: 17px; border: 0; outline: 0; background: transparent; color: var(--text); font-family: inherit; }
.search button { padding: 0 26px; font-size: 15px; font-weight: 700; color: #fff; background: var(--primary); border: 0; border-radius: 10px; cursor: pointer; }
.search button:hover { background: var(--primary-dark); }
.hero-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; font-size: 12px; color: #c7d2fe; }
.hero-foot kbd { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); color: #fff; }
.examples { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.examples a { padding: 3px 10px; color: #fff; background: rgba(255, 255, 255, .12); border-radius: 999px; text-decoration: none; }
.examples a:hover { background: rgba(255, 255, 255, .22); }
.field-error { color: #fecaca; margin-top: 8px; font-weight: 600; }

/* 모델 정보 한 줄 */
.model-strip { margin-bottom: 20px; }
.model-strip summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; list-style: none; }
.model-strip summary::-webkit-details-marker { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--text-sub); }
.chip b { color: var(--text); }
.chip.more { color: var(--primary); font-weight: 600; }
.model-strip[open] .chip.more .closed, .model-strip:not([open]) .chip.more .opened { display: none; }
.model-strip .cards { margin-top: 12px; }

/* ===== 분류하기: 결과 ===== */
.result-grid { display: grid; grid-template-columns: 5fr 7fr; gap: 16px; align-items: start; }
.result-grid > .card { margin-bottom: 0; }

.verdict { padding: 24px; }
.verdict-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: #047857; }
.pill.other { background: var(--line-soft); color: var(--text-sub); }
.verdict-name { font-size: 13px; color: var(--text-mute); margin-bottom: 6px; word-break: break-all; }
.verdict-code { font-family: var(--mono); font-size: 13px; color: var(--primary); font-weight: 700; }
.verdict-path { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.3; margin: 4px 0 6px; }
.verdict-crumb { color: var(--text-sub); font-size: 13px; }
.verdict-crumb span + span::before { content: "›"; margin: 0 6px; color: var(--text-mute); }
.verdict-other { color: var(--text-sub); }
.verdict-other b { color: var(--text); }

.gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.gauge { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.gauge-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.gauge-label { font-size: 12px; color: var(--text-sub); }
.gauge-value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge-value.fail { color: var(--danger); }
.gauge .help { margin-top: 6px; }
.verdict-foot { margin-top: 14px; font-size: 12px; color: var(--text-mute); }

/* 정답 고르기 */
.pick h2 { margin-bottom: 4px; }
.pick > .help { margin: 0 0 14px; }
.candidates { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.candidate { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s, background .15s, box-shadow .15s; }
.candidate:hover { border-color: #a5b4fc; background: #fafbff; }
.candidate.top { border-color: #c7d2fe; background: #f8f9ff; }
.candidate.saved { border-color: #6ee7b7; background: #ecfdf5; box-shadow: 0 0 0 3px rgba(16, 185, 129, .15); }
.candidate.saved .cand-pick button { background: var(--ok); }
.cand-key kbd { font-size: 12px; min-width: 24px; padding: 2px 6px; }
.cand-main { min-width: 0; }
.cand-title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cand-title .mono { color: var(--text-mute); font-weight: normal; }
.cand-path { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand-meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--text-mute); flex-wrap: wrap; }
.cand-meta .bar { min-width: 80px; width: 90px; height: 6px; }
.cand-pick { margin: 0; }

.pick-tools { display: grid; gap: 10px; margin-top: 14px; }
.pick-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* 세분류 검색 */
.cat-search { position: relative; }
.cat-search input { width: 100%; padding: 10px 12px 10px 36px; font-size: 14px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; background: #fff; }
.cat-search input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.cat-search::before { content: "⌕"; position: absolute; left: 12px; top: 7px; font-size: 18px; color: var(--text-mute); }
.cat-results { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); max-height: 340px; overflow-y: auto; margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); }
.cat-results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cat-results li.active, .cat-results li:hover { background: var(--primary-soft); }
.cat-results .r-name { font-weight: 600; }
.cat-results .r-path { font-size: 12px; color: var(--text-mute); }
.cat-results mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }
.cat-results .empty { color: var(--text-mute); cursor: default; }

/* 직접 선택 (대 > 중 > 소 > 세분류) */
details.fold { border: 1px solid var(--line); border-radius: 12px; }
details.fold > summary { padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--text-sub); font-size: 13px; }
details.fold[open] > summary { border-bottom: 1px solid var(--line-soft); }
details.fold > .fold-body { padding: 12px 14px; }
.picker { margin: 0; }
.picker-title { display: none; }
.picker-selects { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.picker-selects select { width: 100%; padding: 8px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-family: inherit; }
.picker-selects select:disabled { background: var(--line-soft); color: var(--text-mute); }
.picker-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.picker-status.ok { color: var(--ok); font-weight: 600; }
.picker-status.warn { color: var(--warn); font-weight: 600; }

/* 접는 상세 카드 */
details.card { padding: 0; }
details.card > summary { padding: 16px 20px; cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; color: var(--text-mute); transition: transform .15s; }
details.card[open] > summary::before { transform: rotate(90deg); }
details.card > summary small { font-weight: normal; color: var(--text-mute); font-size: 12px; }
details.card > .fold-body { padding: 0 20px 16px; }
.section-gap { margin-top: 16px; }

/* 빈 화면 */
.empty-state { text-align: center; padding: 36px 20px; color: var(--text-sub); }
.empty-state .steps { display: flex; justify-content: center; gap: 28px; margin-top: 18px; flex-wrap: wrap; }
.empty-state .step b { display: block; font-size: 22px; color: var(--primary); }

/* 토스트 */
.toast-area { position: fixed; right: 24px; bottom: 24px; z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { max-width: 440px; padding: 12px 16px; border-radius: 12px; color: #fff; background: #0f172a; box-shadow: var(--shadow-lg); font-size: 13px; animation: toast-in .2s ease-out; }
.toast.ok { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.hide { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* 충돌 경고 창 */
dialog.modal { width: min(560px, 92vw); padding: 0; border: 0; border-radius: 16px; box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.modal-body { padding: 22px 24px 8px; }
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.modal-title::before { content: "!"; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--warn-soft); color: var(--warn); font-weight: 900; }
.modal-body ul { margin: 12px 0; padding-left: 20px; color: var(--text-sub); }
.modal-body li { margin-bottom: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px 20px; }

/* ===== 세분류 현황 ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; }
.tabs a { padding: 10px 16px; color: var(--text-sub); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); font-weight: 700; border-bottom-color: var(--primary); }
.tabs small { margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--line-soft); color: var(--text-mute); font-weight: 600; }
.tabs a.active small { background: var(--primary-soft); color: var(--primary); }

.summary { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { display: block; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s, transform .1s; }
a.stat:hover { border-color: #a5b4fc; transform: translateY(-1px); }
.stat.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79, 70, 229, .25); }
.stat-label { font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.filters { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters select, .filters input[type=text] { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; background: #fff; }
.filters input[type=text] { width: 260px; }

.pager { display: flex; flex-wrap: wrap; gap: 4px; margin: 16px 0; }
.pager a { padding: 4px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--text-sub); text-decoration: none; background: #fff; }
.pager a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== 피드백 관리 ===== */
h2 .more { margin-left: auto; font-size: 13px; font-weight: 600; text-decoration: none; }
.actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.feedback-extra { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
tr.just-saved td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #d1fae5; } }

/* ===== 학습 관리 ===== */
.train-start { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.compare td.up { color: var(--ok); font-weight: 700; }
.compare td.down { color: var(--danger); font-weight: 700; }
.stepper { display: flex; gap: 6px; margin: 4px 0 12px; flex-wrap: wrap; }
.stepper span { flex: 1; min-width: 70px; white-space: nowrap; padding: 8px 10px; font-size: 12px; text-align: center; border-radius: 10px; background: var(--line-soft); color: var(--text-mute); font-weight: 600; }
.stepper span.done { background: var(--ok-soft); color: #047857; }
.stepper span.current { background: var(--primary); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .65; } }

@media (max-width: 1000px) {
	.summary { grid-template-columns: repeat(4, 1fr); }
	.result-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
	.cards { grid-template-columns: 1fr; }
	.picker-selects { grid-template-columns: 1fr 1fr; }
	.gauges { grid-template-columns: 1fr; }
}
