/* 첫믹스 — 검정 위의 계측기.
 *
 * 세로 공간을 늘리지 않는 것이 이 디자인의 첫 제약이다. 믹스 화면은 360x800 에서
 * 크로스페이더까지 들어오는 여유가 30px 뿐이라, 위계를 여백으로 만들 수 없다.
 * 표면 밝기 3단 · 텍스트 3단 · 얇은 선 · 숫자 타이포로만 만든다.
 *
 * 덱 색(A 보라 / B 시안)은 장식이 아니라 기능이다. 사용자가 A와 B를 색으로 읽는다. */
:root {
  --bg: #07070c;

  /* 표면 3단. 같은 밝기 카드만 반복하면 무엇이 중요한지 안 보인다. */
  --panel: #101018;      /* 기본 카드 */
  --panel-2: #171722;    /* 카드 안의 요소·버튼 */
  --panel-3: #20202d;    /* 누를 수 있는 강조 요소 */

  --line: #202030;
  --line-strong: #34344a;

  /* 텍스트 3단 */
  --fg: #f2f2f8;
  --sub: #8e8ea6;
  --dim: #5a5a70;

  --accent: #7c3aed;
  --ok: #22c55e;
  --warn: #f59e0b;

  --radius: 14px;
  --r-sm: 9px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", sans-serif;
  -webkit-font-smoothing: antialiased;
  /* 고정 탭바가 덮는 만큼 아래를 비운다.
   * ★ body 에 height:100% 를 같이 주면 안 된다. box-sizing:border-box 라 박스가 뷰포트 높이에
   *   고정되고, 이 여백은 첫 화면 안쪽에 그려진다. 넘쳐 흐른 내용은 그 여백 바깥으로 나가서
   *   끝까지 내려도 마지막 카드가 탭바에 정확히 탭바 높이만큼 가린다. */
  min-height: 100%;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  overscroll-behavior: none;
}

/* ── 상단 ── */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: baseline; gap: 10px;
  background: rgba(11, 11, 18, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
}
.topbar h1 { margin: 0; font-size: 0.92rem; font-weight: 700; letter-spacing: 0.01em; color: var(--sub); }
.latency { font-size: 0.72rem; color: var(--warn); }

#app { padding: 12px; max-width: 620px; margin: 0 auto; }

/* ── 버튼 ── */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--sub);
  border-radius: 10px; font-size: 0.86rem; font-weight: 700;
  min-height: 44px; padding: 0 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  touch-action: manipulation; user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn:active { transform: translateY(1px); background: var(--panel-3); color: var(--fg); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-ghost { background: none; color: var(--sub); }

/* ── 시작 게이트 ── */
.gate {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(120% 90% at 50% 0%, #241b4a 0%, var(--bg) 60%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-card { text-align: center; max-width: 340px; }
.gate-logo { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; }
.gate-lead { color: var(--sub); margin: 8px 0 26px; }
.gate .btn-primary { width: 100%; min-height: 52px; font-size: 1rem; }
.gate-note { color: var(--sub); font-size: 0.78rem; line-height: 1.7; margin-top: 20px; }
.gate-note b { color: var(--fg); }

/* ── 덱 ── */
.deck {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; margin-bottom: 8px;
  /* 덱 색을 카드 위쪽 실선으로 한 줄 — 어느 덱인지 색으로 읽는 장치를 강화 */
  box-shadow: inset 0 2px 0 -1px var(--accent);
}
.deck-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.deck-tag {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.1em;
  color: var(--accent); border: 1px solid currentColor;
  border-radius: 5px; padding: 2px 5px; flex: none; opacity: 0.9;
}
.deck-name {
  flex: 1; text-align: left; background: none; border: 0; color: var(--fg);
  font-size: 0.92rem; font-weight: 600; padding: 4px 0; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.deck-name::after { content: ' ▾'; color: var(--sub); }
.deck-bpm {
  font-variant-numeric: tabular-nums; font-size: 0.96rem; font-weight: 800;
  letter-spacing: -0.02em; color: var(--fg);
}

.beatgrid { display: block; width: 100%; height: 32px; border-radius: 8px; }

/* 조그휠은 넓은 화면에서만. 폰 세로에는 넣을 자리가 없고, 억지로 넣으면 다른 컨트롤이 밀린다. */
.jogwrap { display: none; }
.jog { display: block; width: 100%; aspect-ratio: 1; touch-action: none; cursor: grab; }
.jog.on { cursor: grabbing; }

.transport { display: flex; gap: 6px; margin-top: 7px; }
.transport .btn { flex: 1; }
.btn-play.on { background: var(--accent); border-color: transparent; color: #fff; }
.btn-nudge { flex: 0 0 56px; font-size: 1rem; }
/* 헤드폰 미리듣기 버튼 — 스플릿 출력이 켜졌을 때만 자리를 차지한다 */
.btn-pfl { display: none; flex: 0 0 50px; font-size: 0.95rem; padding: 0; }
body.split .btn-pfl { display: inline-flex; }
body.split .btn-nudge { flex: 0 0 48px; }
.btn-pfl.on { background: var(--warn); border-color: transparent; color: #241a05; }

/* 켜짐/꺼짐 스위치 */
/* 레슨 목록의 그룹 구분. 기초 넷과 전환 셋은 배우는 결이 다르다. */
.lesson-group {
  margin: 18px 2px 2px; font-size: 0.72rem; font-weight: 700;
  color: var(--dim); letter-spacing: 0.08em; text-transform: uppercase;
}

.switch { width: 100%; margin-top: 12px; }

/* 간단 모드 — 레슨이 가르친 손잡이만 남기고 접는다.
   빼기로 하는 추상화다. 남는 것들은 진짜 손잡이 그대로여야 컨트롤러로 옮겨 간다. */
body.mix-simple .eqs,
body.mix-simple .masterrow,
body.mix-simple .hotcues,
body.mix-simple .btn-cue,
body.mix-simple .looprow { display: none; }
body.mix-simple .xfader { border-top: 0; padding-top: 0; margin-top: 0; }

.modesw { display: inline-flex; gap: 3px; margin-left: 10px; vertical-align: middle; }
.modesw-btn {
  padding: 5px 11px; border-radius: 999px; font-size: 0.68rem; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
}
.modesw-btn.on { background: var(--fg); border-color: transparent; color: var(--bg); }
.mix-syncnote {
  margin-top: 12px; padding: 10px 12px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--dim); font-size: 0.76rem; line-height: 1.5;
}
.mix-nextnote {
  margin-top: 12px; padding: 11px 13px; border-radius: 11px;
  background: rgba(124,58,237,0.12); border: 1px solid rgba(124,58,237,0.4);
  color: var(--sub); font-size: 0.82rem; line-height: 1.5;
}

/* 핫큐 넷. 전송부 바로 아래 — 손이 가는 순서다. */
.hotcues { display: flex; gap: 6px; margin-top: 6px; }
.hotcue {
  flex: 1; min-height: 34px; border-radius: 9px; font-size: 0.72rem; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
}
.hotcue.on { background: rgba(245,158,11,0.16); border-color: rgba(245,158,11,0.6); color: #f59e0b; }

/* 레벨 미터. 게인 스테이징은 눈금이 있어야 배울 수 있다. */
.eqcol-head { display: flex; align-items: center; gap: 8px; }
.meter { flex: 1; height: 8px; border-radius: 3px; display: block; min-width: 0; }
.masterrow { display: flex; align-items: center; gap: 9px; margin-top: 12px; }
.masterrow-tag {
  flex: none; font-size: 0.62rem; font-weight: 700; color: var(--dim); letter-spacing: 0.06em;
}
.masterrow .meter { height: 10px; }
.btn-rec { flex: none; min-width: 66px; padding: 8px 10px; font-size: 0.74rem; font-weight: 700; }
.btn-rec.on { background: #ef4444; border-color: transparent; color: #fff; }

/* 녹음한 세트 */
.mixitem {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px;
}
.mixitem-when { font-size: 0.84rem; font-weight: 600; color: var(--fg); }
.mixitem-len { flex: 1; font-size: 0.74rem; color: var(--sub); font-variant-numeric: tabular-nums; }
.mixitem-btn { flex: none; padding: 7px 10px; font-size: 0.74rem; }
.mixitem-del { color: var(--dim); }

/* 트랙 시트 — 검색·크레이트·정렬. 한 줄 목록으로는 서른 곡을 못 넘긴다. */
.sheet-search {
  width: 100%; margin-top: 10px; padding: 11px 13px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px;
  color: var(--fg); font-size: 0.92rem; font-family: inherit;
}
.sheet-search::placeholder { color: var(--dim); }
.crate-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.crate {
  padding: 7px 12px; border-radius: 999px; font-size: 0.76rem; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--sub);
}
.crate.on { background: var(--accent-app, #7c3aed); border-color: transparent; color: #fff; }
.crate-new { color: var(--fg); }
.crate-add { display: none; gap: 6px; margin-top: 8px; }
.crate-add.on { display: flex; }
.crate-input {
  flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg); font-family: inherit;
}
.crate-ok { flex: none; }
.sort-row { display: flex; gap: 6px; margin-top: 9px; }
.sortbtn {
  flex: 1; padding: 8px; border-radius: 10px; font-size: 0.78rem; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--sub);
}
.sortbtn.on { color: var(--fg); border-color: var(--line-strong); }
/* 목록만 스크롤한다. 검색창이 같이 밀려 올라가면 찾다 말고 다시 내려와야 한다. */
.sheet-list { max-height: 46vh; overflow-y: auto; margin-top: 6px; }
.sheet-crate {
  flex: none; width: 38px; align-self: stretch; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--sub); font-size: 1rem; font-weight: 700;
}
.sheet-crate.on { color: var(--ok); border-color: var(--line-strong); }

/* 언어 고르기. 게이트와 나 화면이 같은 부품을 쓴다. */
.langrow { display: flex; gap: 8px; margin-top: 12px; }
.btn-lang { flex: 1; }
.btn-lang.on { background: var(--fg); border-color: transparent; color: var(--bg); }
.gate .langrow { margin-top: 18px; }
.switch.on { background: var(--ok); border-color: transparent; color: #06210f; }
.btn-nudge.on { background: var(--accent); border-color: transparent; color: #fff; }
.btn-nudge-lg { flex: 1; min-height: 56px; font-size: 1.25rem; }
.nudge-row { display: flex; gap: 10px; margin-top: 10px; }

/* ── 슬라이더 ── */
.sl { display: flex; align-items: center; gap: 9px; margin-top: 5px; }
.sl-label { flex: none; width: 40px; font-size: 0.64rem; font-weight: 700; color: var(--dim); letter-spacing: 0.06em; }
.sl-val {
  flex: none; width: 46px; text-align: right; font-size: 0.74rem; font-weight: 700;
  color: var(--fg); font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.sl-input { flex: 1; min-width: 0; }
.sl-tempo .sl-label { color: var(--fg); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  background: transparent; height: 26px; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px; background: var(--line-strong);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--fg); border: 3px solid var(--panel);
  margin-top: -8px; box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 2px 6px rgba(0,0,0,0.6);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--fg); border: 3px solid var(--panel);
}

/* ── 위상 미터 ── */
.phase {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px 9px; margin-bottom: 8px;
}
.phase-canvas { display: block; width: 100%; height: 34px; }
.phase-caption { font-size: 0.68rem; color: var(--sub); text-align: center; margin-top: 3px; line-height: 1.4; }

/* ── 믹서 ── */
.mixer {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px;
}
.eqs { display: flex; gap: 14px; }
.eqcol { flex: 1; min-width: 0; }
.eqcol-tag {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.12em; color: var(--accent);
  border-bottom: 1px solid var(--line-strong); padding-bottom: 4px;
}
.eqcol .sl-label { width: 30px; }

.xfader { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.xf-end { font-size: 0.68rem; font-weight: 700; color: var(--sub); flex: none; width: 12px; text-align: center; }
.xf-input { flex: 1; min-width: 0; }
.xf-input::-webkit-slider-thumb { width: 30px; height: 30px; margin-top: -13px; }

/* ── 훈련 ── */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px; margin-bottom: 10px;
}
.card-intro { background: linear-gradient(140deg, #1d1738, var(--panel)); }
.card-title { margin: 0 0 7px; font-size: 0.95rem; }
.card-body { margin: 0 0 6px; color: var(--sub); font-size: 0.86rem; line-height: 1.65; }
.card-links { display: flex; gap: 14px; margin: 10px 0 0; }
.card-links a { color: var(--accent); font-size: 0.82rem; text-decoration: none; }
.tips { margin: 0; padding-left: 18px; color: var(--sub); font-size: 0.83rem; line-height: 1.7; }
.tips li { margin-bottom: 7px; }

.lessons { display: flex; flex-direction: column; gap: 8px; }
.lesson {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; cursor: pointer; color: var(--fg);
}
.lesson-no {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 700; color: var(--sub);
}
.lesson.done .lesson-no { background: var(--ok); border-color: transparent; color: #06210f; }
.lesson.locked { opacity: 0.42; cursor: default; }
.lesson-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lesson-title { font-size: 0.92rem; font-weight: 600; }
.lesson-sub { font-size: 0.76rem; color: var(--sub); }

.lesson-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.btn-back { min-height: 34px; padding: 0 6px; font-size: 0.82rem; }
.lesson-h { margin: 0; font-size: 1.05rem; }
.lesson-lead { margin: 0 0 6px; font-size: 0.9rem; line-height: 1.6; }
.lesson-hint { margin: 0 0 14px; font-size: 0.8rem; color: var(--sub); line-height: 1.6; }
.nowrow { display: flex; gap: 8px; margin-bottom: 10px; }
.chip {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 10px; font-size: 0.76rem;
}
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.chip-tag { font-weight: 700; color: var(--accent); flex: none; }
.chip-name { color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-controls .btn-ghost { width: 100%; }
.btn-stop { margin-top: 12px; min-height: 38px; font-size: 0.8rem; }

.lesson-controls {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.lesson-status {
  text-align: center; margin-top: 14px; font-size: 0.86rem; color: var(--sub);
  min-height: 22px; font-variant-numeric: tabular-nums;
}
.lesson-status.hold { color: var(--warn); font-weight: 700; }
.lesson-status.ok { color: var(--ok); font-weight: 700; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.lesson-status .btn { width: 100%; }

.tapper {
  width: 100%; min-height: 148px; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--panel-2); color: var(--fg);
  font-size: 1.05rem; font-weight: 700; line-height: 1.5; white-space: pre-line;
  cursor: pointer; touch-action: manipulation; user-select: none;
  margin-bottom: 10px;
}
.tapper.hit { border-color: var(--ok); background: #10261a; }
.tapper.miss { border-color: var(--warn); background: #2a2011; }

/* ── 트랙 선택 시트 ── */
.sheet-back {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.6); display: flex; align-items: flex-end;
}
.sheet {
  width: 100%; max-width: 620px; margin: 0 auto;
  background: var(--panel); border-radius: 18px 18px 0 0;
  padding: 16px 14px calc(18px + env(safe-area-inset-bottom));
}
.sheet-title { margin: 0 0 10px; font-size: 0.9rem; color: var(--sub); }
.sheet-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 12px; padding: 13px; margin-bottom: 7px; cursor: pointer;
}
.sheet-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.sheet-name { flex: 1; text-align: left; font-size: 0.9rem; font-weight: 600; }
.sheet-bpm { font-size: 0.78rem; color: var(--sub); font-variant-numeric: tabular-nums; }
.sheet .btn-ghost { width: 100%; margin-top: 4px; }
.sheet-sub { margin: 16px 0 8px; font-size: 0.78rem; color: var(--sub); font-weight: 700; letter-spacing: 0.03em; }
.sheet-empty { margin: 0 0 8px; font-size: 0.8rem; color: var(--sub); line-height: 1.6; }
.sheet-row-user { padding: 0; overflow: hidden; }
.sheet-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: var(--fg); padding: 13px; cursor: pointer;
}
.sheet-edit {
  flex: none; align-self: stretch; background: none; border: 0;
  border-left: 1px solid var(--line); color: var(--sub);
  font-size: 0.76rem; font-weight: 600; padding: 0 14px; cursor: pointer;
}
.sheet-add { width: 100%; margin-top: 10px; }
.hidden-file { display: none; }
.sheet-status { margin: 8px 0 0; font-size: 0.8rem; color: var(--sub); text-align: center; min-height: 18px; }
.sheet-status.bad { color: var(--warn); }

/* BPM·첫박 보정 */
.correct-readout { text-align: center; padding: 6px 0 14px; }
.correct-big { display: block; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.correct-sub { display: block; font-size: 0.78rem; color: var(--sub); margin-top: 4px; font-variant-numeric: tabular-nums; }
.correct-note { display: block; font-size: 0.74rem; color: var(--warn); margin-top: 6px; min-height: 16px; }
.correct-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.correct-label { flex: none; width: 46px; font-size: 0.72rem; color: var(--sub); font-weight: 700; }
.correct-btn { flex: 1; min-width: 0; padding: 0 4px; font-size: 0.8rem; }
.btn-danger { width: 100%; margin-top: 12px; color: #f87171; border-color: #4a2130; background: #22131a; }

/* 나 탭 보관함 */
.libitem {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 10px; padding: 11px 12px; margin-top: 7px; cursor: pointer;
}
.libitem-name { flex: 1; text-align: left; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.libitem-bpm { flex: none; font-size: 0.76rem; color: var(--sub); font-variant-numeric: tabular-nums; }

/* ── 탭바 ── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: rgba(11,11,18,0.94); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 11px; color: var(--sub); font-size: 0.68rem;
}
.tab-icon { font-size: 1.05rem; line-height: 1; }
.tab { color: var(--dim); }
.tab.on { color: var(--fg); font-weight: 800; }
.tab.on .tab-icon { color: var(--accent); }

/* ── 태블릿 ──────────────────────────────────────────
 * 폰 레이아웃을 늘리지 않고 방향별로 쌓는 축을 바꾼다.
 *   세로: 위아래로 쌓되 폭을 다 쓰고 조그휠을 넣는다
 *   가로: 덱을 좌우로 벌리고 믹서를 가운데 (실제 컨트롤러 배치)
 *
 * 폭만 보고 분기하면 안 된다. 폰 가로(932x430)가 min-width:900 에 걸려
 * 3열+큰 조그휠을 받으면 화면 밖으로 다 밀려난다. 높이 조건을 같이 건다. */
@media (min-width: 700px) {
  #app { max-width: 760px; padding: 16px; }
  .beatgrid { height: 40px; }
  .deck { padding: 14px; }
  .phase-canvas { height: 44px; }
  .lesson-controls { padding: 18px; }
  /* 아이패드에서 탭바가 화면 끝까지 벌어지면 손이 닿지 않는다. 가운데로 모은다. */
  .tabbar { justify-content: center; }
  .tab { flex: 0 0 140px; }
}

/* 조그휠은 진짜 태블릿에서만. 폰 가로는 높이가 모자라 넣을 수 없다. */
@media (min-width: 900px) and (min-height: 700px) {
  .jogwrap { display: block; width: min(240px, 62%); margin: 6px auto 12px; }
}

@media (min-width: 900px) and (min-height: 600px) and (orientation: landscape) {
  #app.screen-mix { max-width: 1240px; min-height: calc(100vh - 149px); }
  .screen-mix {
    display: grid;
    grid-template-columns: 1.24fr 0.72fr 1.24fr;
    /* 위아래 빈 행이 여백을 먹어 가운데 열(미터+믹서)이 서로 붙은 채로 세로 중앙에 온다.
       행을 auto 두 개만 두면 미터가 자기 행에서 따로 떠서 덱과 중심이 어긋난다. */
    grid-template-rows: 1fr auto auto 1fr;
    grid-template-areas:
      "deckA .     deckB"
      "deckA meter deckB"
      "deckA mixer deckB"
      "deckA .     deckB";
    gap: 14px;
    align-items: center;
  }
  .screen-mix .deck { display: flex; flex-direction: column; }
  .screen-mix .deck-a { grid-area: deckA; }
  .screen-mix .deck-b { grid-area: deckB; }
  .screen-mix .phase  { grid-area: meter; }
  .screen-mix .mixer  { grid-area: mixer; }
  .screen-mix .deck,
  .screen-mix .phase { margin-bottom: 0; }
  .screen-mix .jogwrap { width: min(420px, 92%); margin: 12px auto 16px; }
  .screen-mix .beatgrid { height: 56px; }
  .screen-mix .phase-canvas { height: 62px; }
  .screen-mix .transport .btn { min-height: 56px; }
  .screen-mix .eqs { gap: 20px; }
  .screen-mix .xfader { margin-top: 18px; padding-top: 16px; }
  .screen-mix .eqcol .sl { margin-top: 14px; }
}

/* 아이패드 세로. 컨트롤이 위아래로 다 쌓이므로 조그휠을 키우면 크로스페이더가 화면 밖으로 밀린다. */
@media (min-width: 900px) and (min-height: 1100px) and (orientation: portrait) {
  #app { max-width: 860px; }
  .screen-mix .jogwrap { width: min(180px, 34%); }
  .screen-mix .beatgrid { height: 48px; }
  .screen-mix .transport .btn { min-height: 50px; }
}

/* ── 오늘의 도전 ── */
.daily-card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: linear-gradient(135deg, #22163f, #14141f);
  border: 1px solid #3a2a6b; border-radius: var(--radius);
  padding: 15px; margin-bottom: 10px; color: var(--fg);
}
.daily-card.done { border-color: #1f4d33; background: linear-gradient(135deg, #14301f, #14141f); }
.daily-head { display: flex; align-items: baseline; gap: 8px; }
.daily-tag { font-size: 0.9rem; font-weight: 700; }
.daily-date { font-size: 0.74rem; color: var(--sub); }
.daily-lead { margin: 7px 0 12px; font-size: 0.84rem; color: var(--sub); line-height: 1.6; }
.daily-foot { display: flex; align-items: center; justify-content: space-between; }
.daily-streak {
  font-size: 0.72rem; font-weight: 700; color: var(--warn);
  border: 1px solid #4a3a12; background: #241c08; border-radius: 999px; padding: 3px 9px;
}
.daily-card.done .daily-streak { color: var(--ok); border-color: #1f4d33; background: #0d2317; }
.daily-go { font-size: 0.8rem; font-weight: 700; color: var(--accent); }

.lesson-status.warn { color: var(--warn); font-weight: 700; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.score-big { font-size: 2.1rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.score-sub { font-size: 0.78rem; color: var(--sub); font-weight: 400; }
.score-note { font-size: 0.78rem; color: var(--warn); font-weight: 700; }

/* ── 실제 기기에 맞춘 컨트롤 ── */
.deck-time { font-size: 0.72rem; color: var(--sub); font-variant-numeric: tabular-nums; flex: none; }
.btn-loop { flex: 0 0 52px; font-size: 0.72rem; padding: 0; }
.btn-loop.on { background: var(--warn); border-color: transparent; color: #241a05; }
.btn-range { flex: none; min-height: 30px; padding: 0 8px; font-size: 0.68rem; font-weight: 700; }

/* 길이 고르기는 자리가 넉넉한 태블릿에서만. 폰은 전송부의 LOOP 하나로 충분하다. */
/* 라이브용 손잡이(핫큐·트림·미터·마스터 줄)는 태블릿 가로에서만 나온다.
 * 폰과 태블릿 세로는 크로스페이더까지 들어오는 세로 여유가 없다 —
 * 루프 길이 줄을 갈라 둔 것과 같은 이유다. 그리고 "기기 대신 쓰는" 자리가 태블릿 가로다. */
.looprow { display: flex; gap: 6px; margin-top: 7px; }
.btn-loopn { flex: 1; min-height: 40px; font-size: 0.76rem; padding: 0; }
.btn-loopn.on { background: var(--warn); border-color: transparent; color: #241a05; }


.card-note { margin: 8px 0 0; font-size: 0.76rem; color: var(--sub); line-height: 1.6; }
.sl-cuemix { margin-top: 14px; }
.sl-cuemix .sl-label { width: 68px; color: var(--fg); }

/* 컨트롤이 한 줄 늘었다. 슬라이더 행을 조금 조여 크로스페이더가 화면 안에 남게 한다. */
.eqcol .sl { margin-top: 4px; }
.eqcol input[type="range"] { height: 24px; }
.eqcol input[type="range"]::-webkit-slider-thumb { margin-top: -7px; }
.eqcol .sl-label { width: 38px; font-size: 0.6rem; }

/* ── 사용 안내 ── */
.intro-guide {
  width: 100%; margin-top: 10px; min-height: 38px;
  font-size: 0.8rem; color: var(--accent); border-color: #3a2a6b;
}
.card-guide {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  cursor: pointer; color: var(--fg); flex-wrap: wrap;
}
.card-guide-title { font-size: 0.95rem; font-weight: 700; flex: none; }
.card-guide-sub { flex: 1 1 100%; order: 3; font-size: 0.78rem; color: var(--sub); }
.card-guide-go { margin-left: auto; font-size: 0.8rem; font-weight: 700; color: var(--accent); }

.guide-sec {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 8px; overflow: hidden;
}
.guide-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; background: none; border: 0; color: var(--fg);
  padding: 14px 15px; cursor: pointer; text-align: left;
}
.guide-title { font-size: 0.92rem; font-weight: 700; }
.guide-caret { color: var(--sub); transition: transform 0.15s; font-size: 0.9rem; }
.guide-sec.open .guide-caret { transform: rotate(180deg); }
.guide-body { display: none; padding: 0 15px 14px; }
.guide-sec.open .guide-body { display: block; }

.guide-steps { margin: 0; padding-left: 20px; color: var(--sub); font-size: 0.84rem; line-height: 1.7; }
.guide-steps li { margin-bottom: 9px; }
.guide-steps li::marker { color: var(--accent); font-weight: 700; }

.guide-pair { padding: 9px 0; border-top: 1px solid var(--line); }
.guide-pair:first-child { border-top: 0; padding-top: 0; }
.guide-term { display: block; font-size: 0.83rem; font-weight: 700; margin-bottom: 3px; }
.guide-desc { display: block; font-size: 0.82rem; color: var(--sub); line-height: 1.65; }

.guide-meterrow { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.guide-meterrow:first-child { border-top: 0; padding-top: 0; }
.mini-meter { flex: none; width: 120px; height: 22px; border-radius: 5px; }
.guide-metertext { min-width: 0; }

.guide-go { width: 100%; margin-top: 6px; }

/* ── 배우기 ── */
.learn-sec {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-top: 10px; overflow: hidden;
}
.learn-count {
  margin-left: auto; margin-right: 8px;
  font-size: 0.72rem; font-weight: 700; color: var(--sub);
  font-variant-numeric: tabular-nums;
}
.learn-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 11px; padding: 12px; margin-bottom: 7px; cursor: pointer;
}
.learn-item:last-child { margin-bottom: 0; }
.learn-dot {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: var(--sub);
}
.learn-item.done .learn-dot { background: var(--ok); border-color: transparent; color: #06210f; }
.learn-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.learn-title { font-size: 0.86rem; font-weight: 600; }
.learn-sub { font-size: 0.74rem; color: var(--sub); }

.article {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px; margin-bottom: 10px;
}
.article-p { margin: 0 0 12px; font-size: 0.86rem; line-height: 1.75; color: var(--fg); }
.article .guide-pair:first-of-type { border-top: 1px solid var(--line); padding-top: 9px; margin-top: 2px; }

.practice {
  background: linear-gradient(140deg, #1d1738, var(--panel));
  border: 1px solid #3a2a6b; border-radius: var(--radius);
  padding: 15px; margin-bottom: 10px;
}
.practice-tag {
  display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 5px; padding: 2px 6px;
}
.practice-body { margin: 9px 0 12px; font-size: 0.84rem; line-height: 1.7; color: var(--sub); }
.practice .btn { width: 100%; }
.learn-done { width: 100%; }

/* 배우기 안의 트랙 듣기 줄 */
.trackrow {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.trackrow-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; }
.trackrow-text { flex: 1; min-width: 0; }
.trackrow-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.trackrow-name { font-size: 0.84rem; font-weight: 700; }
.trackrow-bpm { font-size: 0.72rem; color: var(--sub); font-variant-numeric: tabular-nums; }
.trackrow-go { flex: none; min-height: 34px; padding: 0 11px; font-size: 0.74rem; align-self: center; }

/* ── 위계 정리 ──
 * 한 화면에 강조는 하나. 인트로는 정보라 눌러 두고, 지금 할 행동(오늘의 도전 · 다음 레슨)만 살린다. */
.card-intro {
  background: var(--panel);
  border-color: var(--line);
}
.intro-guide { color: var(--sub); border-color: var(--line); }

.lesson.next {
  background: var(--panel-2);
  border-color: var(--line-strong);
}
.lesson.next .lesson-no {
  background: var(--accent); border-color: transparent; color: #fff;
}
.lesson.next .lesson-title { color: var(--fg); }
.lesson-title { color: var(--sub); }
.lesson.done .lesson-title { color: var(--sub); }

.guide-title { font-weight: 700; color: var(--sub); }
.learn-sec .guide-title, .guide-sec .guide-title { font-size: 0.88rem; }

/* 카드 제목과 본문의 단차를 벌린다 */
.card-title { letter-spacing: -0.01em; }
.card-body { color: var(--sub); }

/* ── 시작 게이트 ──
 * 아이콘 모티프를 화면 안으로 가져온다. 앱과 아이콘이 한 몸으로 읽히게. */
.gate {
  background:
    radial-gradient(90% 60% at 50% 8%, rgba(124,58,237,0.22) 0%, transparent 62%),
    radial-gradient(70% 50% at 50% 100%, rgba(6,182,212,0.10) 0%, transparent 60%),
    var(--bg);
}
.gate-mark {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  height: 78px; margin-bottom: 22px;
}
.gm { display: block; border-radius: 999px; }
.gm-a1 { width: 7px; height: 30px; background: #7c3aed; opacity: 0.45; }
.gm-a2 { width: 7px; height: 46px; background: #7c3aed; }
.gm-b2 { width: 7px; height: 46px; background: #06b6d4; }
.gm-b1 { width: 7px; height: 30px; background: #06b6d4; opacity: 0.45; }
.gm-mid { width: 13px; height: 70px; background: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .gm { animation: gm-in 620ms cubic-bezier(.2,.8,.2,1) both; }
  .gm-a1 { animation-delay: 0ms; }
  .gm-a2 { animation-delay: 70ms; }
  .gm-b2 { animation-delay: 70ms; }
  .gm-b1 { animation-delay: 0ms; }
  .gm-mid { animation-delay: 160ms; }
  @keyframes gm-in {
    from { transform: scaleY(0.15); opacity: 0; }
    to   { transform: scaleY(1); }
  }
}

.gate-logo { font-size: 2.05rem; font-weight: 800; letter-spacing: -0.035em; }
.gate-lead { color: var(--sub); margin: 8px 0 28px; font-size: 0.92rem; }
.gate-note { color: var(--dim); }
.gate-note b { color: var(--sub); }

/* 상단·하단 바를 새 배경색에 맞춘다 */
.topbar { background: rgba(7, 7, 12, 0.92); }
.tabbar { background: rgba(7, 7, 12, 0.94); }

/* ── 성공 순간 ──
 * 통과와 점수는 이 앱에서 가장 기쁜 지점인데 아무 일도 안 일어나고 있었다. */
.lesson-status.ok { color: var(--ok); }
@media (prefers-reduced-motion: no-preference) {
  .lesson-status.ok,
  .score-big { animation: pop-in 320ms cubic-bezier(.2,.9,.25,1) both; }
  @keyframes pop-in {
    from { transform: scale(0.94); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
  }
}
.score-big { letter-spacing: -0.03em; }
.score-sub { color: var(--sub); }

/* 진도 스탯 — 숫자가 문장에 묻히지 않게 세 칸으로 */
.stats { display: flex; gap: 8px; margin-top: 4px; }
.stat {
  flex: 1; min-width: 0; text-align: center;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 4px 9px;
}
.stat-value {
  display: block; font-size: 1.02rem; font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: var(--fg);
}
.stat-label {
  display: block; margin-top: 3px;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; color: var(--dim);
}

/* 끝난 판의 컨트롤 — 물러나되 무엇이었는지는 보이게 */
.lesson-controls.spent { opacity: 0.35; pointer-events: none; }
.lesson-status.ok, .lesson-status.warn { margin-top: 4px; margin-bottom: 14px; }
