/* 메트로놈 화면. 색·간격·곡률·모션은 JDS 토큰만 쓴다 */
:root { --hue: var(--p-sky); --hue-soft: var(--p-sky-soft); --hue-tx: var(--p-sky-tx); }

.mt-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s6); }
.mt-head > * { margin: 0; }
.mt-head .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
@media (max-width: 639.98px) {
    .mt-head .tabs { width: 100%; }
    .mt-head .tab { flex: 1 1 0; padding-inline: 4px; }
    .mt-head .tab .ic { display: none; }
}
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- 메트로놈: 왼쪽 연주판, 오른쪽 메모리 ---------- */
.mt-metro { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: var(--s4); align-items: start; }
.mt-metro > *, .mt-deck > * { margin: 0; min-width: 0; }
@media (max-width: 1023.98px) { .mt-metro { grid-template-columns: minmax(0, 1fr); } }

.mt-deck { display: grid; gap: var(--s4); }
.mt-meter { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.mt-meter > * { margin: 0; }
.mt-lbl { font-size: 13px; color: var(--tx-2); }
#beats + .jds-trigger { width: 88px; }
.mt-meter .mt-lbl:nth-of-type(2) { margin-inline-start: var(--s3); }

/* 세분화 같은 정수 선택: 다크에서도 고른 칸이 바탕과 구분되게 강조색을 쓴다 */
.mt-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; transition: background var(--fx) var(--ease-fx), color var(--fx) var(--ease-fx); }
.mt-seg button[aria-pressed="true"] { background: var(--sky-soft); color: var(--tx); box-shadow: none; font-weight: 600; }
html[data-theme="light"] .mt-seg button[aria-pressed="true"] { background: var(--sf); box-shadow: 0 1px 3px var(--sh); }
.mt-seg .ic--sm { font-size: 11px; }
/* 좁은 화면: 세분화 칸들이 한 줄 폭을 나눠 갖는다 */
@media (max-width: 639.98px) {
    .mt-meter .mt-seg { display: flex; width: 100%; }
    .mt-meter .mt-seg button { flex: 1 1 0; min-width: 0; padding-inline: 2px; }
    .mt-meter .mt-lbl:nth-of-type(2) { margin-inline-start: 0; }
}

/* 박: 크기가 강약(크게·중간·무음)을 말한다. 박 수가 바뀌면 자리를 미끄러지듯 옮기고 새 박은 자라난다 */
.mt-dots {
    --per: 4; container-type: inline-size;
    display: grid; grid-template-columns: repeat(var(--per), minmax(0, 1fr)); justify-items: center; align-items: center;
    row-gap: var(--s4); min-height: 180px; align-content: center; padding-block: var(--s2);
}
.mt-dot {
    --cell: min(96px, calc(100cqw / var(--per)));
    --k: .8;
    position: relative; display: block; width: calc(var(--cell) * var(--k)); aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
    background: color-mix(in oklab, var(--hue) 45%, var(--hue-soft));
    transition: width var(--sp) var(--ease-sp), background var(--fx) var(--ease-fx), transform var(--sp) var(--ease-sp), opacity var(--fx) var(--ease-fx);
}
button.mt-dot { cursor: pointer; }
.mt-dot[data-lv="2"] { --k: .62; background: color-mix(in oklab, var(--hue) 22%, var(--hue-soft)); }
.mt-dot[data-lv="3"] { --k: .46; background: var(--hue-soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--hue-tx) 50%, transparent); }
.mt-dot.is-on { background: var(--hue); transition-duration: 0s; }
/* 밝은 테마: 파스텔이 바탕에 묻히지 않게 진하게 섞고 가는 테두리를 둔다 (앱과 같은 규칙) */
html[data-theme="light"] .mt-dot { background: color-mix(in oklab, var(--hue) 80%, var(--hue-soft)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hue-tx) 25%, transparent); }
html[data-theme="light"] .mt-dot[data-lv="2"] { background: color-mix(in oklab, var(--hue) 50%, var(--hue-soft)); }
html[data-theme="light"] .mt-dot[data-lv="3"] { background: var(--hue-soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--hue-tx) 50%, transparent); }
html[data-theme="light"] .mt-dot.is-on { background: color-mix(in oklab, var(--hue) 60%, var(--hue-tx)); }
.mt-dot[data-lv="3"].is-on { background: color-mix(in oklab, var(--hue) 35%, var(--hue-soft)); }
.mt-dot.is-new { transform: scale(.3); opacity: 0; }
.mt-dot.is-mute { opacity: .3; }
.mt-ring { position: absolute; inset: 0; border-radius: 50%; background: var(--hue); pointer-events: none; opacity: 0; }
button.mt-dot:active { transform: scale(.94); }

/* 빠르기: 큰 숫자. 휠·위아래 끌기로 조절, 누르면 입력 */
/* 숫자 칸은 양옆 버튼 네 개를 뺀 폭에 맞춰 글자 크기를 정한다: 좁아도 버튼과 8px 이상 떨어진다 */
.mt-tempo { container-type: inline-size; display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--s1); }
.mt-tempo > * { margin: 0; }
.mt-bpm { display: grid; justify-items: center; min-width: 0; margin-inline: var(--s2); }
.mt-bpm > * { margin: 0; }
.mt-bpm-num {
    padding: 0; border: 0; border-radius: var(--r-ctl); background: none; color: var(--tx);
    font: 700 clamp(40px, calc((100cqw - 4 * 44px - 4 * var(--s1) - 2 * var(--s2)) / 2.1), 112px)/1 var(--font); letter-spacing: -.03em; font-variant-numeric: tabular-nums; cursor: ns-resize; touch-action: none;
}
/* 아주 좁은 화면(360px 미만): 빠른 조정 «»은 빼고 ±만 둔다 (휠·끌기·입력으로 대신) */
@media (max-width: 359.98px) {
    .mt-tempo { grid-template-columns: auto minmax(0, 1fr) auto; }
    .mt-tempo [data-bpm="fast"], .mt-tempo [data-bpm="-fast"] { display: none; }
    .mt-bpm-num { font-size: clamp(40px, calc((100cqw - 2 * 44px - 2 * var(--s1) - 2 * var(--s2)) / 2.1), 112px); }
}
.mt-bpm-in { width: 4.6ch; font-size: 44px; font-weight: 700; text-align: center; }
.mt-bpm-unit { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--tx-2); }
#bpm_rng { width: 100%; }

.mt-act > * { margin: 0; }
.mt-play { position: relative; width: 100%; min-height: 64px; overflow: hidden; font-size: 22px; }
.mt-play .ic { font-size: 22px; }
.mt-prog { position: absolute; left: 0; bottom: 0; height: 4px; width: calc(var(--left, 1) * 100%); background: color-mix(in srgb, var(--sky-tx) 40%, transparent); }

.mt-tools { display: flex; align-items: center; justify-content: center; gap: var(--s1); }
.mt-tools > * { margin: 0; }
.mt-tools [aria-pressed="true"] { color: var(--sky-a); }
.mt-tap { min-width: 4ch; font-size: 14px; color: var(--tx-2); font-variant-numeric: tabular-nums; }

/* 메모리: 누르면 불러오고, 올리면 덮어쓰기·편집·삭제가 보인다. 끌어서 순서를 바꾼다 */
.mt-mem { display: grid; gap: var(--s3); align-content: start; }
.mt-mem > * { margin: 0; min-width: 0; }
.mt-mem-head { display: flex; align-items: center; gap: var(--s2); }
.mt-mem-head > * { margin: 0; }
.mt-mem-head .jds-trigger { flex: 1 1 auto; min-width: 0; }
.mt-count { font-size: 13px; color: var(--tx-3); font-variant-numeric: tabular-nums; }
.mt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: var(--s2); max-height: 560px; overflow: auto; margin: 0; padding: 0; list-style: none; }
.mt-cards > * { margin: 0; }
.mt-card { position: relative; border-radius: var(--r-card); background: var(--sf-2); transition: background var(--fx) var(--ease-fx), opacity var(--fx) var(--ease-fx); }
.mt-card.is-active { background: var(--sky-soft); }
.mt-card-main {
    display: grid; place-items: center; align-content: center; gap: 4px; width: 100%; aspect-ratio: 1.2; padding: var(--s2);
    border: 0; border-radius: inherit; background: none; color: var(--tx); font: inherit; cursor: pointer;
}
.mt-card-main > * { margin: 0; }
.mt-card-bpm { font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.mt-card-sub { max-width: 100%; overflow: hidden; font-size: 12.5px; color: var(--tx-2); text-overflow: ellipsis; white-space: nowrap; }
.mt-card.is-active :is(.mt-card-bpm, .mt-card-sub) { color: var(--link); }
.mt-card-tm { position: absolute; left: 10px; top: 10px; font-size: 11px; color: var(--tx-3); }
.mt-card-acts { position: absolute; right: 2px; top: 2px; display: flex; opacity: 0; transition: opacity var(--fx) var(--ease-fx); }
.mt-card-acts > * { margin: 0; }
.mt-card:hover .mt-card-acts, .mt-card:focus-within .mt-card-acts { opacity: 1; }
@media (hover: none) { .mt-card-acts { opacity: 1; } }
.mt-del:hover:not(:disabled) { color: var(--err); }
.mt-card-add .mt-card-main { color: var(--tx-3); }
.mt-card-add { background: color-mix(in srgb, var(--sf-2) 50%, transparent); }
:is(.mt-card, .sl-card).is-drag { position: relative; z-index: 5; opacity: .8; box-shadow: 0 12px 32px var(--sh); transition: none; cursor: grabbing; }
:is(.mt-card, .sl-card).is-over { box-shadow: 0 0 0 2px var(--sky-a); }

/* ---------- 줄 목록 (설정, 대화상자, 트레이닝 옵션) ---------- */
.mt-rows { display: grid; }
.mt-rows > * { margin: 0; }
.mt-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 52px; padding-block: var(--s2); }
.mt-row > * { margin: 0; }
.mt-row + .mt-row, .mt-sub { border-top: 1px solid var(--bd); }
.mt-row--col { flex-direction: column; align-items: stretch; justify-content: center; gap: var(--s2); }
.mt-row > input[type="number"], .mt-row > .jds-box { width: 136px; flex: 0 0 auto; }
.mt-row > :is(label, span):first-child { white-space: nowrap; }
.mt-row > select + .jds-trigger, .mt-row-ctl .jds-trigger { width: 200px; }
.mt-row-ctl { display: flex; align-items: center; gap: var(--s2); }
.mt-row-ctl > * { margin: 0; }
.mt-row-ctl :is(input[type="number"], .jds-box) { width: 120px; }
label.mt-row { cursor: pointer; }
.muted { font-size: 13px; color: var(--tx-3); text-align: end; }

.mt-dlg { width: min(460px, calc(100vw - 32px)); }
.mt-form { display: grid; gap: var(--s3); }
.mt-form > * { margin: 0; }
.dialog-foot .grow { flex: 1 1 auto; }

/* ---------- 트레이닝 ---------- */
.mt-train { display: grid; grid-template-columns: 200px minmax(0, 1fr) minmax(280px, 360px); gap: var(--s4); align-items: start; }
.mt-train > * { margin: 0; min-width: 0; }
.tr-modes { display: grid; gap: 2px; padding: var(--s2); }
.tr-modes > * { margin: 0; }
.tr-mode {
    display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s3);
    border: 0; border-radius: var(--r-sm); background: none; color: var(--tx-2); font: inherit; text-align: start; cursor: pointer;
    transition: background var(--fx) var(--ease-fx), color var(--fx) var(--ease-fx);
}
.tr-mode .ic { width: 18px; text-align: center; }
/* 경계 없는 메뉴 항목: 배경 대신 글 아래 막대 (사이트 서랍과 같은 규칙) */
.tr-mode-t { position: relative; }
.tr-mode-t::before {
    content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px; border-radius: 1px; background: var(--sky);
    transform: scaleX(0); transform-origin: right center; transition: transform var(--fx) var(--ease-fx); pointer-events: none;
}
@media (hover: hover) { .tr-mode:hover { color: var(--tx); } .tr-mode:hover .tr-mode-t::before { transform: scaleX(1); transform-origin: left center; } }
.tr-mode[aria-pressed="true"] { color: var(--tx); font-weight: 600; }
.tr-mode[aria-pressed="true"] .tr-mode-t::before { transform: scaleX(1); transform-origin: left center; }
.tr-mode[aria-pressed="true"] .ic { color: var(--sky-a); }
.tr-stage { display: grid; gap: var(--s4); text-align: center; }
.tr-stage > * { margin: 0; }
.tr-bpm { display: grid; justify-items: center; }
.tr-bpm > * { margin: 0; }
#tr_bpm { font-size: clamp(64px, 7vw, 104px); font-weight: 700; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tr-dots { min-height: 140px; }
.tr-seg { display: flex; justify-content: center; gap: 6px; min-height: 6px; }
.tr-seg > * { margin: 0; }
.tr-seg span { width: 22px; height: 6px; border-radius: 3px; background: var(--sf-3); transition: background var(--fx) var(--ease-fx); }
.tr-seg span.is-on { background: var(--sky); }
.tr-next { min-height: 21px; font-size: 14px; color: var(--tx-2); }
.tr-params { display: grid; gap: var(--s2); }
.tr-params > * { margin: 0; }
.tr-subs { display: flex; gap: var(--s1); }
.tr-subs > * { margin: 0; }
.tr-subs .chip { min-width: 40px; justify-content: center; cursor: pointer; font-variant-numeric: tabular-nums; }
.tr-subs .chip[aria-pressed="true"] { background: var(--sky-soft); border-color: var(--sky-a); color: var(--tx); }
@media (max-width: 1023.98px) {
    .mt-train { grid-template-columns: minmax(0, 1fr); }
    .tr-modes { display: flex; overflow-x: auto; }
    .tr-mode { flex: 0 0 auto; }
}

/* ---------- 셋리스트 ---------- */
.mt-sets { display: grid; gap: var(--s4); }
.mt-sets > * { margin: 0; }
.sl-list { display: grid; gap: var(--s2); margin: 0; padding: 0; list-style: none; }
.sl-list > * { margin: 0; }
.sl-card { display: flex; align-items: center; gap: var(--s4); padding: var(--s3) var(--s4); cursor: grab; }
.sl-card > * { margin: 0; }
.sl-card.is-active { border-color: var(--sky-a); }
.sl-text { display: grid; flex: 1 1 auto; gap: 4px; min-width: 0; }
.sl-text > * { margin: 0; }
.sl-name { display: flex; align-items: baseline; gap: var(--s2); min-width: 0; }
.sl-name > * { margin: 0; }
.sl-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-tempos { overflow: hidden; font-size: 13px; color: var(--tx-2); font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.sl-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.sl-acts > * { margin: 0; }
@media (max-width: 639.98px) { .sl-card { flex-direction: column; align-items: stretch; } }

/* ---------- 설정 ---------- */
.mt-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.mt-settings > * { margin: 0; min-width: 0; }
.set-grp { display: grid; gap: var(--s2); }
.set-grp > * { margin: 0; }
@media (max-width: 1023.98px) { .mt-settings { grid-template-columns: minmax(0, 1fr); } }
.hue-pick { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.hue-pick > * { margin: 0; }
.hue-sw { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: var(--c); cursor: pointer; transition: box-shadow var(--fx) var(--ease-fx); }
.hue-sw[aria-checked="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--sky-a); }

/* 화면 플래시 */
.mt-flash { position: fixed; inset: 0; z-index: 70; background: var(--sky); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
    .mt-dot, .mt-card, .tr-mode, .tr-seg span { transition: none; }
}
