/* ChordTool Drum — 모바일 퍼스트. 테마: 드럼 셸 레드 · 배경 블루 · 심벌 골드 */
:root {
  --bg: #f7f8fb; --surface: #ffffff; --surface-2: #eef1f7; --text: #161b26; --muted: #5d6679; --line: #dde2ec;
  --accent: #d62839; --accent-ink: #ffffff; --accent-soft: #fde8ea;
  --blue: #1f5fd6; --blue-soft: #e5edfc; --gold: #d99a1b;
  --step-off: #e6eaf2; --step-on: #1f5fd6; --step-acc: #d62839; --now: #ffd24d;
  --radius: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131b; --surface: #171c27; --surface-2: #202737; --text: #eef1f7; --muted: #9aa3b5; --line: #2b3345;
    --accent: #ff4d5e; --accent-ink: #14080a; --accent-soft: #3a1419; --blue: #6b9bff; --blue-soft: #16264a; --gold: #f2b640;
    --step-off: #252c3d; --step-on: #6b9bff; --step-acc: #ff4d5e; --now: #f2c94c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f131b; --surface: #171c27; --surface-2: #202737; --text: #eef1f7; --muted: #9aa3b5; --line: #2b3345;
  --accent: #ff4d5e; --accent-ink: #14080a; --accent-soft: #3a1419; --blue: #6b9bff; --blue-soft: #16264a; --gold: #f2b640;
  --step-off: #252c3d; --step-on: #6b9bff; --step-acc: #ff4d5e; --now: #f2c94c; color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; word-break: keep-all; overflow-wrap: anywhere; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h1 small { font-size: .9rem; color: var(--muted); font-weight: 600; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; margin-top: 1em; }
p { margin: 0 0 .8em; }
code, pre, kbd { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.wrap { width: 100%; max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.lead { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; }
[hidden] { display: none !important; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); }
.header-bar { display: flex; align-items: center; gap: 12px; height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { display: block; height: 32px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-size: 1.05rem; letter-spacing: -.02em; }
.brand-text small { font-size: .72rem; color: var(--accent); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.header-nav { display: none; margin-left: auto; gap: 4px; }
.header-nav a { padding: 8px 12px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: .95rem; }
.header-nav a[aria-current] { background: var(--blue-soft); color: var(--blue); }
.icon-btn { margin-left: auto; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--text); border-radius: 10px; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.header-menu { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 12px; }
.header-menu a { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: .92rem; }
@media (min-width: 760px) { .header-nav { display: flex; } .icon-btn { margin-left: 4px; } }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: .8rem; color: var(--muted); padding: 10px 0 2px; }
.breadcrumb a { color: var(--muted); }
main.wrap { padding-top: 10px; padding-bottom: 32px; }

/* Buttons */
button { font: inherit; }
.btn, .chip-btn, .step-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; touch-action: manipulation; }
.chip-btn { min-height: 40px; font-size: .9rem; }
.chip-btn[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.chip-btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip-btn.danger { color: var(--accent); }
.chip-btn:disabled { opacity: .45; cursor: default; }
.btn:hover { text-decoration: none; border-color: var(--blue); }
.btn-big { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; min-width: 104px; padding: 0 18px; border-radius: 14px; border: 0; background: var(--surface-2); color: var(--text); font-weight: 800; font-size: 1rem; cursor: pointer; touch-action: manipulation; }
.btn-big svg { width: 20px; height: 20px; fill: currentColor; }
.btn-big.play { background: var(--blue); color: #fff; }
.btn-big.play.on { background: var(--text); color: var(--bg); }
.btn-big.rec i { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); display: inline-block; }
.btn-big.rec.on { background: var(--accent); color: #fff; animation: pulse 1s infinite; }
.btn-big.rec.on i { background: #fff; }
@keyframes pulse { 50% { opacity: .75; } }
.step-btn { min-width: 44px; padding: 0 10px; }
.step-btn.tap.hit { background: var(--gold); color: #1b1300; }
.mini-field { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); font-weight: 600; }
.mini-field select, .sheet input { height: 40px; padding: 0 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .95rem; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.check input { width: 20px; height: 20px; }

/* Tool common */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin: 8px 0 14px; }
.tool-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.tool-title { font-size: 1.25rem; margin: 0; }
.status { min-height: 1.4em; color: var(--muted); font-size: .9rem; margin: 8px 0; }
.bpm-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bpm-box { display: inline-flex; align-items: baseline; gap: 4px; padding: 0 10px; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); }
.bpm-box input { width: 64px; border: 0; background: none; color: var(--text); font: 800 1.4rem/48px ui-monospace, Menlo, Consolas, monospace; text-align: center; outline: none; -moz-appearance: textfield; }
.bpm-box input::-webkit-outer-spin-button, .bpm-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bpm-box small { color: var(--muted); font-weight: 700; font-size: .75rem; }
input[type=range] { width: 100%; accent-color: var(--blue); height: 32px; }

/* Drum pads — 엄지로 누르기 쉬운 큰 영역 */
.pad-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pad-grid-extra { margin-top: 10px; }
.pad { position: relative; min-height: clamp(76px, 19vw, 120px); border-radius: 16px; border: 0; cursor: pointer; color: #fff; font-weight: 800; font-size: 1rem; letter-spacing: .02em;
  background: linear-gradient(160deg, var(--c1), var(--c2)); box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; transition: transform .05s; }
.pad .pad-name { pointer-events: none; }
.pad kbd { position: absolute; top: 8px; right: 10px; font-size: .7rem; font-weight: 700; opacity: .75; pointer-events: none; }
.pad.hit, .pad.down { animation: padhit .14s ease-out; }
.pad.down { transform: scale(.97); }
@keyframes padhit { 0% { transform: scale(.95); filter: brightness(1.35); } 100% { transform: scale(1); filter: none; } }
.pad-kick { --c1: #d62839; --c2: #a31427; }
.pad-snare { --c1: #1f5fd6; --c2: #1646a3; }
.pad-closed_hat, .pad-open_hat { --c1: #d99a1b; --c2: #b27a0c; }
.pad-crash, .pad-ride { --c1: #c78b12; --c2: #9b6a07; }
.pad-tom_high, .pad-tom_mid, .pad-tom_low { --c1: #8a3ad6; --c2: #6a24ab; }
.pad-clap, .pad-rim, .pad-cowbell { --c1: #10a37f; --c2: #0b7d61; }
.pad-more { width: 100%; margin-top: 10px; min-height: 44px; border-radius: 12px; border: 1.5px dashed var(--line); background: none; color: var(--muted); font-weight: 700; cursor: pointer; }
@media (min-width: 600px) { .pad-grid { grid-template-columns: repeat(4, 1fr); } }

.home-ctl { margin-top: 12px; display: grid; gap: 10px; }
.home-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.keys-hint { display: none; margin: 10px 0 0; }
@media (pointer: fine) { .keys-hint { display: block; } }
.big-link { display: flex; flex-direction: column; align-items: center; padding: 16px; margin: 10px 0; border-radius: 16px; background: var(--blue); color: #fff; }
.big-link:hover { text-decoration: none; filter: brightness(1.05); }
.big-link b { font-size: 1.1rem; }
.big-link span { font-size: .85rem; opacity: .9; }
.cards { display: grid; gap: 10px; grid-template-columns: 1fr; margin: 10px 0; }
@media (min-width: 600px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card-link { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 10px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.card-link:hover { text-decoration: none; border-color: var(--blue); }
.card-link .ico { grid-row: span 2; font-size: 1.8rem; display: grid; place-items: center; }
.card-link small { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card > :last-child { margin-bottom: 0; }
.prose ul { padding-left: 1.2em; }
.my-list { list-style: none; padding: 0; margin: 0; }
.my-list a { display: flex; justify-content: space-between; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); color: var(--text); font-weight: 700; }
.my-list li:last-child a { border-bottom: 0; }
.my-list small { color: var(--muted); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 700; border: 1px solid var(--line); }
.chip:hover { text-decoration: none; border-color: var(--blue); }
.more-link { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Machine */
.machine .bpm-row { margin-top: 8px; }
.machine .bpm-row .bpm-box { flex: 1; justify-content: center; max-width: 180px; }
.settings-panel { margin: 4px 0 8px; border: 1px solid var(--line); border-radius: 12px; }
.settings-panel summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; cursor: pointer; font-weight: 800; list-style: none; }
.settings-panel summary::-webkit-details-marker { display: none; }
.settings-panel summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.settings-panel[open] summary::after { content: '▴'; }
.settings-panel summary small { color: var(--muted); font-weight: 600; }
.settings-panel > div { padding: 0 12px 12px; }
.settings-panel .tempo .bpm-row input[type=range] { flex: 1; }
.machine .transport { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.machine .transport .btn-big { min-width: 88px; padding: 0 14px; }
.machine .transport .chip-btn { min-height: 52px; }
.machine .tempo { margin-top: 6px; }
.machine .settings { display: flex; flex-wrap: wrap; gap: 10px 14px; margin: 8px 0; align-items: center; }
.machine .swing { flex: 1 1 260px; }
.machine .swing input[type=range] { flex: 1; min-width: 100px; }
.machine .swing b { color: var(--text); min-width: 36px; }
.bar-tabs { display: flex; gap: 6px; margin: 6px 0; }
.bar-tabs button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; }
.bar-tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
/* 스텝 그리드: 모바일은 가로 스크롤, 악기 이름은 고정 */
.seq-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px 6px; overscroll-behavior-x: contain; }
.seq { display: grid; gap: 4px; width: max-content; min-width: 100%; }
.seq-row { display: grid; grid-template-columns: 76px repeat(var(--cols, 16), 36px); gap: 4px; align-items: center; }
@media (min-width: 760px) { .seq-row { grid-template-columns: 92px repeat(var(--cols, 16), minmax(36px, 1fr)); } .seq { width: 100%; } }
.seq-label { position: sticky; left: -14px; z-index: 2; height: 40px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 800; font-size: .78rem; cursor: pointer; padding: 0 4px; box-shadow: 6px 0 6px -4px var(--surface); }
.seq-label.muted { opacity: .45; text-decoration: line-through; }
.seq-label.solo { outline: 2px solid var(--gold); }
.seq-head .seq-label { background: none; box-shadow: none; }
.seq-num { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 800; height: 18px; border-radius: 4px; }
.seq-num.now { background: var(--now); color: #1b1300; }
.step { height: 40px; border-radius: 8px; border: 0; background: var(--step-off); color: transparent; font-size: .8rem; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; position: relative; }
.step.beat { box-shadow: inset 2px 0 0 var(--line); }
.step[data-state="off"] { color: var(--muted); opacity: .75; }
.step[data-state="on"] { background: var(--step-on); color: #fff; }
.step[data-state="accent"] { background: var(--step-acc); color: #fff; }
.step.now { outline: 3px solid var(--now); outline-offset: -3px; }
.step:focus-visible, .seq-label:focus-visible { outline: 3px solid var(--gold); }
.seq-tools, .file-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.rec-panel { background: var(--accent-soft); border-radius: 12px; padding: 12px; margin: 10px 0; }
.q-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.q-row > span { font-weight: 800; margin-right: 4px; }
.pad-area { margin-top: 12px; }
.machine .pad { min-height: 64px; font-size: .9rem; }
.mixer { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.mix-rows { display: grid; gap: 4px; }
.mix-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; font-size: .9rem; font-weight: 700; }
.ms-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ms-row { display: flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 700; }
.ms-row span { flex: 1; }
.ms { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font-weight: 800; cursor: pointer; }
.ms[data-ms="m"][aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.ms[data-ms="s"][aria-pressed="true"] { background: var(--gold); color: #1b1300; border-color: var(--gold); }

/* Patterns / practice */
.pattern-list, .level-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.pattern-list a, .level-list a { display: grid; gap: 4px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.pattern-list a:hover, .level-list a:hover { text-decoration: none; border-color: var(--blue); }
.pl-name small { color: var(--muted); font-weight: 600; }
.pl-meta { font-size: .82rem; color: var(--muted); }
.pl-notation, .notation { margin: 6px 0 0; padding: 10px; border-radius: 10px; background: var(--surface-2); font-size: .78rem; line-height: 1.5; overflow-x: auto; }
.level-list .lv { font-size: .75rem; font-weight: 800; color: var(--accent); letter-spacing: .05em; }
.level-list small { color: var(--muted); }
.practice-ctl { display: grid; gap: 10px; }
.practice-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.result { background: var(--blue-soft); border-radius: 12px; padding: 14px; margin: 10px 0; }
.res-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin-bottom: 8px; }
.res-grid div { background: var(--surface); border-radius: 10px; padding: 8px 4px; }
.res-grid b { display: block; font-size: 1.4rem; }
.res-grid span { font-size: .8rem; color: var(--muted); }
.prev-next { display: flex; gap: 8px; margin: 14px 0; }
.prev-next a { flex: 1; text-align: center; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; }
.pattern-head { margin-top: 4px; }

/* Share / sheet / toast / ads */
.share-bar { display: flex; gap: 8px; margin: 4px 0 10px; }
.share-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; font-size: .9rem; cursor: pointer; }
.share-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.share-btn.kakao { background: #fee500; border-color: #fee500; color: #191919; }
.share-btn.kakao svg { fill: #191919; stroke: none; }
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 80vh; overflow: auto; background: var(--surface); border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; background: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.sheet-msg { font-weight: 700; margin: 8px 0 16px; }
.sheet-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.sheet-form label { display: grid; gap: 6px; font-weight: 700; }
.sheet input { width: 100%; }
.load-list { list-style: none; padding: 0; margin: 0 0 12px; }
.load-list li { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.load-item { flex: 1; display: flex; flex-direction: column; align-items: flex-start; padding: 10px 2px; border: 0; background: none; color: var(--text); font-weight: 700; cursor: pointer; text-align: left; }
.load-item small { color: var(--muted); font-weight: 500; }
.load-del { border: 0; background: none; color: var(--accent); font-weight: 700; cursor: pointer; padding: 0 8px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: .9rem; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.ad-slot { margin: 16px 0; min-height: 100px; text-align: center; overflow: hidden; }
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }

.site-footer { border-top: 1px solid var(--line); padding: 20px 0 36px; color: var(--muted); font-size: .82rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.footer-links a { color: var(--text); font-weight: 600; }
body:not(.audio-ready) .pad::after { content: "준비 중"; position: absolute; bottom: 6px; left: 0; right: 0; font-size: .65rem; opacity: .7; }
