/* ===== 팝송 500 — 디자인 토큰 ===== */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e3e6eb;
  --text: #14171c; --text-2: #4a5160; --text-3: #8b93a1;
  --accent: #4f46e5; --accent-2: #4338ca; --accent-weak: #eef0ff; --on-accent: #fff;
  --ok: #15803d; --ok-weak: #e7f6ec; --warn: #b45309; --warn-weak: #fdf3e2;
  --bad: #c62828; --bad-weak: #fdecec; --info: #0e7490; --info-weak: #e3f5f9;
  --st-new: #8b93a1; --st-learning: #d97706; --st-memorized: #15803d; --st-long: #6d28d9;
  --series-1: #4f46e5; --series-2: #eb6834;
  --heat-0: #eceff3; --heat-1: #c7d2fe; --heat-2: #a5b4fc; --heat-3: #6366f1; --heat-4: #3730a3;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --radius: 14px; --radius-sm: 10px;
  --font: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014; --surface: #161a20; --surface-2: #1d222a; --border: #2a303a;
    --text: #e8eaee; --text-2: #aab1bd; --text-3: #6f7785;
    --accent: #8b8cf8; --accent-2: #a5a6fb; --accent-weak: #23244a; --on-accent: #0e1014;
    --ok: #4ade80; --ok-weak: #12301d; --warn: #fbbf24; --warn-weak: #33270d;
    --bad: #f87171; --bad-weak: #3a1717; --info: #38bdf8; --info-weak: #0d2a36;
    --st-new: #6f7785; --st-learning: #fbbf24; --st-memorized: #4ade80; --st-long: #c4b5fd;
    --series-1: #7a7cf0; --series-2: #d95926;
    --heat-0: #1d222a; --heat-1: #2e3170; --heat-2: #3f43a3; --heat-3: #6366f1; --heat-4: #a5b4fc;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014; --surface: #161a20; --surface-2: #1d222a; --border: #2a303a;
  --text: #e8eaee; --text-2: #aab1bd; --text-3: #6f7785;
  --accent: #8b8cf8; --accent-2: #a5a6fb; --accent-weak: #23244a; --on-accent: #0e1014;
  --ok: #4ade80; --ok-weak: #12301d; --warn: #fbbf24; --warn-weak: #33270d;
  --bad: #f87171; --bad-weak: #3a1717; --info: #38bdf8; --info-weak: #0d2a36;
  --st-new: #6f7785; --st-learning: #fbbf24; --st-memorized: #4ade80; --st-long: #c4b5fd;
  --series-1: #7a7cf0; --series-2: #d95926;
    --heat-0: #1d222a; --heat-1: #2e3170; --heat-2: #3f43a3; --heat-3: #6366f1; --heat-4: #a5b4fc;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
small, .muted { color: var(--text-3); }
.t2 { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.hide-sm { }

/* ===== 버튼·입력 ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn.on { background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }
.ib { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; }
.ib:hover { background: var(--surface-2); }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); outline: none; }
textarea.input { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 10px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }

/* ===== 배지 ===== */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.acc-US { background: #e8f0ff; color: #1d4ed8; } .badge.acc-UK { background: #fdeaea; color: #b91c1c; }
.badge.acc-AU { background: #e6f6ee; color: #047857; } .badge.acc-IN { background: #fff1e0; color: #c2410c; }
:root[data-theme="dark"] .badge.acc-US, :root:not([data-theme="light"]) .badge.acc-US { }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge[class*="acc-"] { background: var(--surface-2); } }
:root[data-theme="dark"] .badge[class*="acc-"] { background: var(--surface-2); }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--st-new); }
.st.learning::before { background: var(--st-learning); } .st.memorized::before { background: var(--st-memorized); } .st.long::before { background: var(--st-long); }
.lv { font-size: 12px; color: var(--text-3); letter-spacing: 1px; }

/* ===== 레이아웃 ===== */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--border); background: var(--surface); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.brand b { display: block; font-size: 15px; } .brand small { display: block; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); font-weight: 600; }
.nav a i { font-style: normal; width: 20px; text-align: center; color: var(--text-3); }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--accent-weak); color: var(--accent); } .nav a.on i { color: var(--accent); }
.side-live { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.side-live b { font-size: 18px; }
.main { padding: 28px 32px 140px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .row > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi .label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--text-3); }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.empty { padding: 32px; text-align: center; color: var(--text-3); }
.note { padding: 12px 14px; border-radius: 10px; background: var(--info-weak); color: var(--text); font-size: 13px; }
.note.warn { background: var(--warn-weak); }
.note.ok { background: var(--ok-weak); }
.note.bad { background: var(--bad-weak); }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ===== 로그인 ===== */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 420px; }
.login-box .brand-mark { width: 56px; height: 56px; font-size: 18px; border-radius: 16px; margin-bottom: 14px; }
.profile-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 650; }
.profile-btn:hover { border-color: var(--accent); }

/* ===== 오늘 ===== */
.ring { position: relative; width: 150px; height: 150px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .c b { font-size: 30px; font-weight: 800; display: block; line-height: 1; }
.todo { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--border); }
.todo + .todo { margin-top: 8px; }
.todo .ti { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-weak); color: var(--accent); font-weight: 800; flex: none; }
.steps { display: flex; gap: 3px; }
.steps i { width: 14px; height: 6px; border-radius: 3px; background: var(--surface-2); }
.steps i.done { background: var(--accent); }

/* ===== 곡 목록 ===== */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input { width: auto; height: 36px; }
.filters .search { flex: 1; min-width: 180px; }
.songs { width: 100%; border-collapse: collapse; }
.songs th { text-align: left; font-size: 12px; color: var(--text-3); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.songs td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.songs tr { cursor: pointer; }
.songs tbody tr:hover { background: var(--surface-2); }
.songs .tt b { display: block; font-weight: 650; }
.songs .tt small { display: block; }
.songs .n { width: 48px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ===== 학습 화면 ===== */
.study { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; align-items: start; }
.study-left { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }
.player-slot { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: #000; }
.ctrls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; font-weight: 650; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button .ok { color: var(--ok); }
.lyrics { display: flex; flex-direction: column; gap: 2px; }
.ly { display: grid; grid-template-columns: 46px 1fr auto; gap: 8px; align-items: start; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.ly:hover { background: var(--surface-2); }
.ly .tm { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; padding-top: 3px; }
.ly .tx { font-size: 17px; line-height: 1.5; }
.ly .ko { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.ly.cur { background: var(--accent-weak); }
.ly.cur .tx { font-weight: 650; }
.ly .acts { display: flex; gap: 2px; opacity: 0; }
.ly:hover .acts, .ly.cur .acts { opacity: 1; }
.ly .acts button { font-size: 13px; width: 28px; height: 28px; }
.ly .acts button.on { color: var(--warn); }
.w { border-radius: 4px; padding: 0 1px; }
.w:hover { background: var(--accent-weak); color: var(--accent); }
.w.rare { text-decoration: underline dotted var(--text-3); text-underline-offset: 4px; }
.w.saved { color: var(--accent); font-weight: 650; }
.big-line { font-size: 26px; line-height: 1.45; font-weight: 650; min-height: 2.9em; }
.big-ko { font-size: 15px; color: var(--text-2); min-height: 1.5em; }
.ctx-line { font-size: 14px; color: var(--text-3); min-height: 1.4em; }
.countdown { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.countdown > span { display: block; height: 100%; width: 0; background: var(--accent); }
.diff { font-size: 16px; line-height: 1.9; }
.diff .eq { }
.diff .del { color: var(--bad); text-decoration: underline wavy var(--bad); text-underline-offset: 3px; background: var(--bad-weak); border-radius: 4px; padding: 0 2px; }
.diff .ins { color: var(--text-3); text-decoration: line-through; }
.score { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score.pass { color: var(--ok); } .score.fail { color: var(--warn); }
.cloze { font-size: 17px; line-height: 2.3; }
.cloze .ln { margin-bottom: 4px; }
.cloze input { border: 0; border-bottom: 2px solid var(--border); background: var(--surface-2); border-radius: 4px 4px 0 0; padding: 0 4px; outline: none; font-size: 16px; text-align: center; }
.cloze input:focus { border-bottom-color: var(--accent); background: var(--accent-weak); }
.cloze input.right { border-bottom-color: var(--ok); color: var(--ok); }
.cloze input.wrong { border-bottom-color: var(--bad); color: var(--bad); }
.cloze .ans { font-size: 12px; color: var(--bad); margin-left: 2px; }
.pop { position: fixed; z-index: 60; width: min(360px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 14px; }
.pop .def { font-size: 13.5px; color: var(--text-2); margin: 4px 0; }

/* ===== 듣기 ===== */
.q-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.q-item:hover { background: var(--surface-2); }
.q-item.cur { background: var(--accent-weak); }
.q-item .n { width: 32px; font-size: 12px; color: var(--text-3); text-align: right; }

/* ===== 달력 ===== */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 12px; color: var(--text-3); text-align: center; font-weight: 650; }
.cal .d { min-height: 78px; border-radius: 10px; padding: 6px 8px; background: var(--heat-0); cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; border: 2px solid transparent; }
.cal .d.out { opacity: .35; }
.cal .d.today { border-color: var(--accent); }
.cal .d.sel { outline: 2px solid var(--text); }
.cal .d .dn { font-size: 12px; font-weight: 700; }
.cal .d .dm { font-size: 13px; font-weight: 750; font-variant-numeric: tabular-nums; }
.cal .d .ds { font-size: 11px; }
.cal .d.h1 { background: var(--heat-1); } .cal .d.h2 { background: var(--heat-2); }
.cal .d.h3 { background: var(--heat-3); color: #fff; } .cal .d.h4 { background: var(--heat-4); color: #fff; }
:root[data-theme="dark"] .cal .d.h4 { color: #0e1014; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cal .d.h4 { color: #0e1014; } }
.legend { display: flex; gap: 4px; align-items: center; font-size: 12px; color: var(--text-3); }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }

/* ===== 플레이어 도크 ===== */
.dock { position: fixed; right: 16px; bottom: 16px; width: 356px; z-index: 40; background: #000; border-radius: 14px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.28); }
.dock-video { width: 100%; aspect-ratio: 16 / 9; }
.dock-video iframe, #yt { width: 100%; height: 100%; display: block; border: 0; }
.dock-bar { display: flex; align-items: center; gap: 6px; background: var(--surface); padding: 4px 6px 4px 12px; }
.dock-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-btns { display: flex; }
.dock.attached { border-radius: 12px; box-shadow: none; z-index: 5; }
.dock.attached .dock-bar { display: none; }

.idle { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 10px; background: var(--warn-weak); border: 1px solid var(--warn); color: var(--text); border-radius: 12px; padding: 8px 8px 8px 14px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); width: max-content; max-width: calc(100vw - 24px); }
.modal-bg { position: fixed; inset: 0; z-index: 70; background: rgba(10,12,16,.45); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; padding: 20px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); animation: tin .2s ease-out; max-width: 92vw; }
.toast.ok { background: var(--ok); color: #fff; } .toast.bad { background: var(--bad); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }
.celebrate { text-align: center; padding: 18px; }
.celebrate .big { font-size: 46px; }

/* ===== 반응형 ===== */
@media (max-width: 1100px) {
  .study { grid-template-columns: 1fr; }
  /* 작은 화면: 영상 → 재생 조작 → 가사·학습 탭 → 나머지 순서 */
  .study-left { display: contents; }
  .study-left > :nth-child(1) { order: 1; }
  .study-left > :nth-child(2) { order: 2; }
  .study > .card { order: 3; }
  .study-left > :nth-child(n+3) { order: 4; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 50; flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); }
  .brand, .side-live { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 0; padding: 6px 4px; font-size: 11px; flex: 1; text-align: center; }
  .nav a i { font-size: 17px; }
  .main { padding: 16px 16px 150px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g4.keep2, .g3.keep2, .g2.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dock { right: 8px; left: 8px; bottom: calc(64px + env(safe-area-inset-bottom)); width: auto; }
  .dock.attached { left: auto; right: auto; }
  .hide-sm { display: none !important; }
  .songs .hide-sm { display: none; }
  .cal .d { min-height: 58px; padding: 4px 5px; }
  .cal .d .ds { display: none; }
  .big-line { font-size: 21px; }
  .ly { grid-template-columns: 1fr auto; }
  .ly .tm { display: none; }
}

/* ===== 차트 툴팁 ===== */
.tip { position: fixed; z-index: 95; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 8px 24px rgba(0,0,0,.16); color: var(--text); white-space: nowrap; }
.tip b { font-weight: 700; }
.tip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart .hit { fill: transparent; cursor: default; }
.chart .mark:hover, .chart .hit:hover + .mark { opacity: .85; }
