/* transU — docs/DESIGN.md 기준: 대시보드형, 60-30-10, OKLCH 토큰, 다크모드, 접근성 */

/* ---- 디자인 토큰 (OKLCH) ---- */
:root {
  --bg:        oklch(98% 0.006 250);   /* 60% 배경 */
  --surface:   oklch(100% 0 0);        /* 30% 표면 */
  --surface-2: oklch(96% 0.008 250);
  --border:    oklch(90% 0.01 250);
  --text:      oklch(28% 0.02 260);
  --text-dim:  oklch(52% 0.02 260);
  --primary:   oklch(55% 0.16 260);    /* 10% CTA/강조 */
  --primary-ink: oklch(99% 0 0);
  --accent:    oklch(62% 0.15 155);
  --warn:      oklch(62% 0.15 70);
  --danger:    oklch(58% 0.19 25);
  --radius: 14px;
  --shadow: 0 1px 2px oklch(50% 0.03 260 / 0.06), 0 6px 20px oklch(50% 0.03 260 / 0.06);
  --font-body: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --font-num: "Montserrat", "Pretendard", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] { color-scheme: dark; }
}
:root[data-theme="auto"] { }
:root[data-theme="dark"], :root[data-theme="auto"][data-scheme="dark"] {
  --bg:        oklch(20% 0.02 260);
  --surface:   oklch(25% 0.02 260);
  --surface-2: oklch(29% 0.02 260);
  --border:    oklch(35% 0.02 260);
  --text:      oklch(94% 0.01 260);
  --text-dim:  oklch(72% 0.02 260);
  --primary:   oklch(70% 0.15 260);
  --primary-ink: oklch(18% 0.02 260);
  --accent:    oklch(72% 0.14 155);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: oklch(20% 0.02 260); --surface: oklch(25% 0.02 260); --surface-2: oklch(29% 0.02 260);
    --border: oklch(35% 0.02 260); --text: oklch(94% 0.01 260); --text-dim: oklch(72% 0.02 260);
    --primary: oklch(70% 0.15 260); --primary-ink: oklch(18% 0.02 260); --accent: oklch(72% 0.14 155);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; }
b { font-weight: 700; }

/* ---- 접근성 ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--primary); color: var(--primary-ink); padding: 8px 14px; border-radius: 8px; transition: top .15s; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---- 앱바 ---- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; background: color-mix(in oklch, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) { .appbar { background: var(--surface); } }
.brand-mark { font-family: var(--font-num); font-weight: 600; font-size: 1.35rem; letter-spacing: -.02em; }
.brand-mark b { color: var(--primary); font-weight: 800; }
.tagline { margin: 0; color: var(--text-dim); font-size: .9rem; }
.appbar-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  background: transparent; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---- 레이아웃 (대시보드: 사이드 + 결과) ---- */
.layout { display: grid; grid-template-columns: minmax(300px, 340px) 1fr; gap: 20px; padding: 20px; max-width: 1240px; margin: 0 auto; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; align-self: start; position: sticky; top: 76px; box-shadow: var(--shadow);
}
.panel-title { margin: 0 0 6px; font-size: 1.05rem; }
.privacy-note { display: flex; gap: 7px; align-items: flex-start; font-size: .82rem; color: var(--text-dim); background: var(--surface-2); padding: 9px 11px; border-radius: 10px; margin: 0 0 16px; }
.privacy-note svg { flex: none; margin-top: 2px; color: var(--accent); }

/* ---- 모드 탭 ---- */
.mode-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.mode-tab { flex: 1; min-height: 40px; border: 0; background: transparent; color: var(--text-dim); font: inherit; font-weight: 600; border-radius: 9px; cursor: pointer; }
.mode-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---- 폼 ---- */
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; font-weight: 600; color: var(--text-dim); }
.mini select { min-height: 40px; }
.badge.met { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 45%, var(--border)); }
.badge.notmet { color: var(--danger); border-color: color-mix(in oklch, var(--danger) 45%, var(--border)); }
.badge.na { color: var(--text-dim); }

/* 생기부 업로드 */
.opt-tag { font-size: .68rem; font-weight: 600; color: var(--primary); background: color-mix(in oklch, var(--primary) 12%, transparent); padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.record-upload { border: 1px dashed var(--border); border-radius: 12px; padding: 12px; }
.warn-note { display: flex; gap: 7px; align-items: flex-start; font-size: .78rem; color: var(--text-dim); background: color-mix(in oklch, var(--warn) 8%, transparent); padding: 9px 11px; border-radius: 10px; margin: 6px 0; }
.warn-note svg { flex: none; margin-top: 2px; color: var(--warn); }
.file-input { width: 100%; font: inherit; font-size: .85rem; }
.file-input::file-selector-button { font: inherit; margin-right: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; }
.record-head { display: grid; grid-template-columns: 1fr 46px 40px 40px 20px; gap: 5px; margin: 8px 0 4px; font-size: .7rem; color: var(--text-dim); font-weight: 600; }
.record-head span { text-align: center; }
.record-head span:first-child { text-align: left; }
.record-table { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.record-row { display: grid; grid-template-columns: 1fr 46px 40px 40px 20px; gap: 5px; align-items: center; font-size: .8rem; }
.record-row input, .record-row select { min-height: 32px; padding: 4px 5px; font-size: .78rem; text-align: center; }
.record-row select.rt { padding: 4px 2px; }
.record-row input.rn { text-align: left; }
.scope-note { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin: 8px 0 0; }
.record-row .rm { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 1rem; }
.record-row.jinro input:not(.rn) { opacity: .5; }
.add-subject-btn { width: 100%; margin-top: 8px; min-height: 40px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; font: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; }
.add-subject-btn:hover { background: var(--surface); border-color: var(--primary); }
.field label, .field legend { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; }
input[type="number"], select {
  width: 100%; padding: 10px 12px; min-height: 44px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; font: inherit;
}
input[type="number"] { font-family: var(--font-num); }
.inquiry-set { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.inquiry-row { display: grid; grid-template-columns: 90px 1fr; gap: 8px; margin-bottom: 8px; }
.hint { font-size: .78rem; color: var(--text-dim); margin: 6px 0 0; }
.btn-primary {
  width: 100%; min-height: 46px; margin-top: 6px;
  background: var(--primary); color: var(--primary-ink); border: 0; border-radius: 11px;
  font-weight: 700; font-size: 1rem; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.form-error { color: var(--danger); font-size: .85rem; margin: 10px 0 0; }
.save-opt { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-dim); margin-top: 14px; }
.save-opt input { width: 18px; height: 18px; }

/* ---- 결과 ---- */
.results { min-height: 60vh; }
.verify-banner { display: flex; gap: 10px; align-items: flex-start; background: color-mix(in oklch, var(--danger) 12%, var(--surface)); border: 1px solid color-mix(in oklch, var(--danger) 45%, var(--border)); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: .85rem; line-height: 1.5; }
.verify-banner svg { flex: none; margin-top: 1px; color: var(--danger); }
.verify-banner b { color: var(--danger); }
.vbadge { display: inline-block; font-size: .64rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.vbadge.ok { color: var(--accent); background: color-mix(in oklch, var(--accent) 14%, transparent); }
.vbadge.warn { color: var(--warn); background: color-mix(in oklch, var(--warn) 14%, transparent); }
.empty-state { display: grid; place-items: center; min-height: 40vh; color: var(--text-dim); text-align: center; }

/* 요약 Bento */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .k { font-size: .8rem; color: var(--text-dim); }
.stat .v { font-family: var(--font-num); font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; margin-top: 3px; }
.stat .v small { font-size: .95rem; color: var(--text-dim); font-weight: 600; }

/* 결과 테이블 */
.result-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.result-table th, .result-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.result-table th { font-size: .8rem; color: var(--text-dim); font-weight: 600; background: var(--surface-2); }
.result-table tbody tr { cursor: pointer; }
.result-table tbody tr:hover { background: var(--surface-2); }
.result-table tbody tr:last-child td { border-bottom: 0; }
.rank { font-family: var(--font-num); color: var(--text-dim); width: 40px; }
.uni-name { font-weight: 600; }
.uni-track { font-size: .8rem; color: var(--text-dim); }
.score { font-family: var(--font-num); font-weight: 700; font-size: 1.1rem; text-align: right; }
.score small { font-weight: 600; font-size: .78rem; color: var(--text-dim); }
.col-score { text-align: right; }
.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); }
.badge.pending { color: var(--warn); border-color: color-mix(in oklch, var(--warn) 40%, var(--border)); }
.badge.partial { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 40%, var(--border)); }

/* 스켈레톤 */
.skeleton { display: grid; gap: 10px; }
.skeleton .row { height: 46px; border-radius: 10px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton .row { animation: none; } .btn-primary:active { transform: none; } .skip-link { transition: none; } }

/* 상세 다이얼로그 */
.detail { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; max-width: 560px; width: 92vw; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.detail::backdrop { background: oklch(20% 0.02 260 / 0.5); }
.detail-inner { padding: 22px; position: relative; }
.dialog-close { position: absolute; top: 14px; right: 14px; }
.detail h3 { margin: 0 6px 2px 0; padding-right: 40px; }
.detail .src { font-size: .82rem; color: var(--text-dim); margin: 4px 0 16px; }
.detail .src a { color: var(--primary); }
.track-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.track-card h4 { margin: 0 0 6px; font-size: .95rem; }
.ratio-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin: 8px 0; border: 1px solid var(--border); }
.ratio-bar span { display: block; }
.ratio-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .78rem; color: var(--text-dim); }
.ratio-legend b { color: var(--text); font-family: var(--font-num); }
.dl-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; font-size: .85rem; }
.dl-btn:hover { background: var(--surface-2); }

.site-footer { max-width: 1240px; margin: 8px auto 40px; padding: 0 20px; color: var(--text-dim); font-size: .82rem; }

/* ---- 모바일 ---- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 14px; gap: 14px; }
  .panel { position: static; }
  #menuToggle { display: inline-grid !important; }
  .tagline { display: none; }
  .summary { grid-template-columns: 1fr; }
  .panel.collapsed { display: none; }
  .result-table thead { display: none; }
  .result-table, .result-table tbody, .result-table tr, .result-table td { display: block; width: 100%; }
  .result-table tr { border-bottom: 1px solid var(--border); padding: 6px 4px; }
  .result-table td { border: 0; padding: 4px 12px; }
  .result-table td.col-score { text-align: left; }
}
