/* 위: 진행률 띠 / 왼쪽: 탭·찾기·조건이 붙은 전체 목록 (따로 스크롤) / 오른쪽: 고른 줄의 검수 카드. 좁은 화면에서는 카드가 위, 목록이 아래 */
:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f0f2f5; --fg: #1b1e24; --muted: #667085; --line: #e1e4ea;
  --accent: #3b5bdb; --accent-soft: #e7ecfd; --accent-fg: #ffffff;
  --wave: #b9c3d6; --wave-played: #3b5bdb;
  --ok: #157a55; --ok-bg: #dcf3e8; --fixed: #8a5a00; --fixed-bg: #fbefd4; --excluded: #b42d3a; --excluded-bg: #fbe3e5;
  --warn: #8a5a00; --warn-bg: #fdf3dc;
  --held: #6941c6; --held-bg: #efe9fb;
  --series-1: #2a78d6; --series-2: #eb6834; --grid: #e6e8ec;
  --radius: 12px;
  --font: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --surface: #1a1d24; --surface-2: #22262f; --fg: #e8eaef; --muted: #98a0b0; --line: #2d323d;
    --accent: #8fa7ff; --accent-soft: #252d4d; --accent-fg: #111318;
    --wave: #444c5e; --wave-played: #8fa7ff;
    --ok: #5ed3a8; --ok-bg: #133328; --fixed: #f0c066; --fixed-bg: #3a2d12; --excluded: #ff8e98; --excluded-bg: #43191f;
    --warn: #f0c066; --warn-bg: #3a2d12;
    --held: #b9a3f5; --held-bg: #2c2342;
    --series-1: #3987e5; --series-2: #d95926; --grid: #2a2f39;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--excluded); margin: 0; min-height: 1.4em; font-size: 14px; }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); background: var(--surface); white-space: nowrap; }

/* 버튼·입력 */
.btn { font: inherit; font-size: 14px; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 13px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; line-height: 1.2; touch-action: manipulation; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary kbd { background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 40%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn.big { padding: 12px 18px; font-size: 15px; }
.btn.icon { width: 34px; justify-content: center; padding: 6px 0; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0; }
:is(.btn, input, select, textarea, canvas, summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 로그인 */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card .btn { justify-content: center; padding: 11px; }

/* 위 띠 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; white-space: nowrap; }
.overall { flex: 1; min-width: 0; max-width: 520px; }
.overall-text { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 3px; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.me { display: flex; align-items: center; gap: 4px; margin-left: auto; font-size: 13px; white-space: nowrap; }

/* 본문 */
.layout { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 16px; align-items: start; padding: 14px 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); max-width: 1500px; margin: 0 auto; }
.work { position: sticky; top: 70px; min-width: 0; }

/* 목록 */
.list-pane { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column;
  position: sticky; top: 70px; height: calc(100vh - 86px); height: calc(100dvh - 86px); min-height: 360px; overflow: hidden; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); }
.tabs button { font: inherit; font-size: 13.5px; padding: 10px 4px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.filters { padding: 10px 12px 0; display: flex; flex-direction: column; gap: 8px; }
.filters input[type=search] { width: 100%; }
.filters summary { cursor: pointer; font-size: 13px; color: var(--muted); list-style: none; display: inline-flex; gap: 6px; align-items: center; padding: 2px 0; }
.filters summary::-webkit-details-marker { display: none; }
.filters summary::before { content: "▸"; }
.filters details[open] summary::before { content: "▾"; }
#filterCount { color: var(--accent); font-weight: 600; }
.filters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 8px; }
.filters-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
.filters-grid input, .filters-grid select { width: 100%; padding: 6px 8px; font-size: 13.5px; }
.filters-foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.list-count { padding: 8px 14px 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line); }
.rows { list-style: none; margin: 0; padding: 4px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.row { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 1px 9px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.row:hover { background: var(--surface-2); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row[aria-current="true"] { background: var(--accent-soft); }
.row .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; border: 1.5px solid var(--muted); }
.row .dot.ok { background: var(--ok); border-color: var(--ok); }
.row .dot.fixed { background: var(--fixed); border-color: var(--fixed); }
.row .dot.excluded { background: var(--excluded); border-color: var(--excluded); }
.row .dot.held { background: var(--held); border-color: var(--held); }
.row .t { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t.gone { color: var(--muted); text-decoration: line-through; }
.row .len { font: 12px var(--mono); color: var(--muted); align-self: center; }
.row .m { grid-column: 2 / 4; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.rows-more { text-align: center; color: var(--muted); font-size: 13px; padding: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.empty { text-align: center; color: var(--muted); padding: 48px 18px; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.who .muted { font-size: 13px; font-variant-numeric: tabular-nums; }
.pos { margin-left: auto; font-size: 13px; font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.fixed { color: var(--fixed); background: var(--fixed-bg); }
.badge.excluded { color: var(--excluded); background: var(--excluded-bg); }
.badge.held { color: var(--held); background: var(--held-bg); }
.save-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.hold:hover { color: var(--held); border-color: var(--held); background: var(--held-bg); }
.warn { margin: 12px 0 0; padding: 8px 12px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); font-size: 13.5px; }

.player { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.btn.play { width: 52px; height: 52px; border-radius: 50%; justify-content: center; padding: 0; flex: none; background: var(--accent); border-color: var(--accent); }
.play-icon { width: 0; height: 0; border-style: solid; border-width: 9px 0 9px 15px; border-color: transparent transparent transparent var(--accent-fg); margin-left: 4px; }
.btn.play.playing .play-icon { width: 14px; height: 18px; border: 0; margin: 0; border-left: 5px solid var(--accent-fg); border-right: 5px solid var(--accent-fg); }
.wave-wrap { flex: 1; min-width: 0; }
#wave { display: block; width: 100%; height: 72px; cursor: crosshair; border-radius: 8px; background: var(--surface-2); touch-action: none; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 8px; }
.cut-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
#selInfo { font-variant-numeric: tabular-nums; }
.cuts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; padding: 8px 10px; border-radius: 9px; background: var(--excluded-bg); font-size: 13px; }
.cuts .muted { color: var(--excluded); font-weight: 600; }
.cuts-list { display: contents; }
.cuts-list button { font: 12px var(--mono); padding: 2px 8px; border-radius: 99px; border: 1px solid var(--excluded); background: var(--surface); color: var(--excluded); cursor: pointer; }
.cuts-list button:hover { background: var(--excluded); color: #fff; }
.wave-time { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--muted); margin-top: 3px; }
.speed { display: flex; gap: 4px; margin-left: auto; }
.speed button { font: 12px var(--mono); padding: 3px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.speed button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.orig { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 6px; font-size: 14px; flex-wrap: wrap; }
.orig-label { font: 600 11px var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }
#origText { color: var(--muted); flex: 1; min-width: 0; overflow-wrap: anywhere; }
textarea#text { width: 100%; font-size: 21px; line-height: 1.45; padding: 12px 14px; resize: vertical; min-height: 96px; }

.lang { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lang button { font: inherit; font-size: 13.5px; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.lang button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.lang select { font-size: 13.5px; padding: 4px 8px; border-radius: 99px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 18px; }
.exclude { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.exclude .btn { font-size: 13px; padding: 6px 10px; }
.exclude .btn:hover { color: var(--excluded); border-color: var(--excluded); background: var(--excluded-bg); }
.nav { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* 알림 */
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 10px;
  background: var(--fg); color: var(--bg); padding: 9px 10px 9px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / .2); max-width: calc(100% - 32px); }
.toast .btn.ghost { color: var(--bg); font-weight: 600; }
.toast .btn.ghost:hover { background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); }
.toast.err { background: var(--excluded); color: #fff; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--fg); padding: 22px; width: min(520px, calc(100% - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 18px; font-size: 14px; }
dialog dt { white-space: nowrap; }
dialog dd { margin: 0; color: var(--muted); }

/* 화면 바꾸기 (검수 / 통계) */
.views { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.views button { font: inherit; font-size: 13.5px; padding: 4px 12px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.views button[aria-pressed="true"] { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

/* 통계 */
.stats { max-width: 1200px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 16px; }
.stats-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stats h1 { margin: 0; font-size: 20px; }
.range { display: flex; gap: 4px; }
.stats-head h1 { margin-right: auto; }
.who-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.who-pick select { padding: 4px 8px; font-size: 13.5px; max-width: 220px; }
.linkish { all: unset; cursor: pointer; color: var(--accent); }
.linkish:hover { text-decoration: underline; }
.linkish:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.stats tr.picked td { background: var(--accent-soft); }
.range button { font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.range button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tile .k { font-size: 13px; color: var(--muted); }
.tile .v { font-size: clamp(20px, 5.2vw, 26px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 2px; }
.tile .s { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel h2 { margin: 0; font-size: 15px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head p { margin: 2px 0 0; font-size: 12.5px; }
.panels-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
details.panel summary { cursor: pointer; list-style: none; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary h2::before { content: "▸ "; color: var(--muted); }
details.panel[open] summary h2::before { content: "▾ "; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 11.5px var(--font); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit:focus { fill: color-mix(in srgb, var(--fg) 5%, transparent); outline: none; }
.chart .hit.area:hover, .chart .hit.area:focus { fill: transparent; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .label { fill: var(--fg); font-weight: 600; }
.tip { position: fixed; z-index: 30; pointer-events: none; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 11px; font-size: 13px; box-shadow: 0 6px 20px rgb(0 0 0 / .14); min-width: 150px; font-variant-numeric: tabular-nums; }
.tip .d { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tip .r span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.tip .r i { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
.tip .r b { font-weight: 700; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
.stats table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.stats th, .stats td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats th { font-weight: 600; color: var(--muted); font-size: 12.5px; }
.stats tr:last-child td { border-bottom: 0; }
.stats td .bar { margin-top: 4px; height: 4px; }
.empty-note { color: var(--muted); text-align: center; padding: 28px 0; font-size: 14px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .work { position: static; order: -1; }
  .list-pane { position: static; height: 70vh; }
  .top { flex-wrap: wrap; gap: 6px 12px; }
  .overall { order: 3; flex-basis: 100%; max-width: none; }
  #todayText { display: none; }
  kbd { display: none; }
  .save-group { width: 100%; }
  .actions .btn.big { flex: 1; justify-content: center; }
  .card { padding: 14px; }
}

/* 통계 그래프의 계열 색 (SVG에는 CSS 변수를 속성으로 못 넣어서 클래스로 칠해요) */
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .line1 { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot1 { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.legend i.s1, .tip i.s1 { background: var(--series-1); }
.legend i.s2, .tip i.s2 { background: var(--series-2); }
