:root {
  --purple: #5a1fa8;
  --purple-soft: rgba(90, 31, 168, 0.12);
  --indigo: #4b45c9;
  --indigo-soft: rgba(88, 86, 214, 0.15);
  --bg: #ffffff;
  --fg: #16141c;
  --muted: #7a7684;
  --line: #e6e3ec;
  --card: #f5f3f8;
  --sheet: #ffffff;
  --danger: #d6303a;
  --orange: #f08a00;
  --font-size: 20px;
}
:root[data-theme='dark'] {
  --bg: #000000;
  --fg: #f2f0f6;
  --muted: #9a96a6;
  --line: #2a2830;
  --card: #18161d;
  --sheet: #121016;
  --purple-soft: rgba(160, 120, 240, 0.2);
  --indigo: #8f8bff;
  --indigo-soft: rgba(143, 139, 255, 0.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }

.app {
  height: 100dvh;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  position: relative;
}

/* ── 머리말 ── */
.top { display: flex; align-items: center; gap: 8px; padding: 8px 16px 4px; }
.logo { height: 30px; width: auto; }
:root[data-theme='dark'] .logo { filter: invert(1); }
.badge {
  background: var(--purple); color: #fff; font-size: 11px; font-weight: 800;
  padding: 3px 8px; border-radius: 99px; letter-spacing: 0.04em;
}
.pair {
  margin-left: auto; font-size: 13px; font-weight: 600; padding: 6px 12px;
  border-radius: 99px; background: var(--card); max-width: 55%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.notice {
  margin: 6px 16px 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.45;
  background: #fff3e0; color: #7a4200;
}
:root[data-theme='dark'] .notice { background: #3a2600; color: #ffd08a; }

/* ── 자막 ── */
.subs {
  flex: 1; overflow-y: auto; padding: 12px 16px; -webkit-overflow-scrolling: touch;
  font-size: var(--font-size); font-weight: 500; line-height: 1.5;
}
.line { margin: 0 0 0.7em; overflow-wrap: anywhere; }
.w { border-radius: 4px; cursor: pointer; }
.w:active, .w.on { background: var(--purple-soft); }
.term { color: var(--indigo); background: var(--indigo-soft); border-radius: 4px; }
.interim { color: var(--muted); overflow-wrap: anywhere; }
.tail { height: calc(var(--font-size) * 1.8); }
.empty { color: var(--muted); font-size: 15px; line-height: 1.6; text-align: center; padding: 40px 12px; }

.latest {
  position: absolute; right: 16px; bottom: 170px; z-index: 2;
  background: var(--purple); color: #fff; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 99px; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── 아래 조작부 ── */
.controls { border-top: 1px solid var(--line); padding: 6px 16px 10px; }
.reflog { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-height: 0; }
.reflog:empty { display: none; }
.reflog::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font-size: 12px; padding: 3px 8px; border-radius: 99px;
  background: var(--indigo-soft); white-space: nowrap; margin-bottom: 6px;
}
.chip b { background: var(--indigo); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 99px; margin-right: 4px; }

.listen { display: flex; justify-content: center; gap: 0; margin: 2px 0 8px; }
.listen button {
  font-size: 13px; font-weight: 600; padding: 6px 14px; background: var(--card); color: var(--muted);
  border: 1px solid var(--line);
}
.listen button:first-child { border-radius: 99px 0 0 99px; }
.listen button:last-child { border-radius: 0 99px 99px 0; border-left: 0; }
.listen button.sel { background: var(--purple); color: #fff; border-color: var(--purple); }
.listen .cap { align-self: center; font-size: 12px; color: var(--muted); margin-right: 8px; }

.row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.timer { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.timer.live { color: var(--danger); }
.play { display: flex; gap: 14px; }
.btn-play {
  width: 52px; height: 52px; border-radius: 50%; background: var(--purple); color: #fff;
  display: grid; place-items: center; position: relative; box-shadow: 0 3px 10px rgba(90,31,168,0.35);
}
.btn-play.live::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2.5px solid rgba(214,48,58,0.6);
  animation: pulse 1.3s ease-out infinite;
}
@keyframes pulse { from { transform: scale(1); opacity: 0.5; } to { transform: scale(1.45); opacity: 0; } }
.btn-play svg { width: 20px; height: 20px; fill: currentColor; }
.tools { display: flex; justify-content: flex-end; gap: 18px; color: var(--muted); }
.tool svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool:disabled { opacity: 0.35; }

/* ── 아래에서 올라오는 창 ── */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-width: 820px; margin: 0 auto;
  background: var(--sheet); border-radius: 18px 18px 0 0; max-height: 82dvh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
}
.sheet-head { display: flex; align-items: center; padding: 14px 16px 6px; }
.sheet-head h2 { font-size: 18px; margin: 0; flex: 1; overflow-wrap: anywhere; }
.close { font-size: 18px; color: var(--muted); padding: 4px 8px; }
.sheet-body { overflow-y: auto; padding: 4px 16px 20px; font-size: 15px; line-height: 1.5; }

.means { margin: 4px 0 12px; padding: 0; list-style: none; }
.means li { display: flex; gap: 10px; padding: 7px 0; font-size: 17px; border-bottom: 1px solid var(--line); }
.means li span { color: var(--muted); font-weight: 600; min-width: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.link { color: var(--purple); font-weight: 600; text-decoration: none; }
:root[data-theme='dark'] .link { color: #b89aff; }

.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input[type='text'], .field select {
  width: 100%; font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
}
.field input[type='range'] { width: 100%; accent-color: var(--purple); }
.btn {
  display: inline-block; font-weight: 700; padding: 10px 18px; border-radius: 10px;
  background: var(--purple); color: #fff;
}
.btn:disabled { opacity: 0.4; }
.btn.ghost { background: var(--card); color: var(--fg); }
.btn.danger { background: none; color: var(--danger); padding: 10px 0; }

.terms { list-style: none; padding: 0; margin: 8px 0; }
.terms li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.terms li .t { flex: 1; overflow-wrap: anywhere; }
.terms li .alias { display: block; font-size: 12px; color: var(--muted); }
.terms li button { font-size: 13px; color: var(--muted); padding: 4px 6px; }

.pro {
  margin: 14px 0; padding: 14px; border-radius: 14px;
  background: linear-gradient(135deg, #5a1fa8, #7d3fe0); color: #fff;
}
.pro h3 { margin: 0 0 6px; font-size: 16px; }
.pro p { margin: 0 0 10px; font-size: 13px; line-height: 1.5; opacity: 0.92; }
.pro a { display: inline-block; background: #fff; color: #5a1fa8; font-weight: 800; padding: 8px 14px; border-radius: 99px; text-decoration: none; font-size: 14px; }
.lock { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.lock b { font-size: 11px; color: #fff; background: var(--purple); padding: 2px 7px; border-radius: 99px; }
.section { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 0 4px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { padding: 8px 12px; border-radius: 10px; background: var(--card); font-size: 14px; }
.seg button.sel { background: var(--purple); color: #fff; }
.pairlist { list-style: none; padding: 0; margin: 0; }
.pairlist button { width: 100%; text-align: left; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 16px; }
.pairlist button.sel { color: var(--purple); font-weight: 700; }
:root[data-theme='dark'] .pairlist button.sel { color: #b89aff; }
