/* ChordTool Play — 모바일 퍼스트. 무대(stage)는 어두운 보라 + 앰버, 나머지는 밝은/다크 테마 토큰 */
:root {
  --bg: #f6f5fa; --surface: #ffffff; --surface-2: #eeecf5; --text: #19152a; --muted: #625c78; --line: #dfdbea;
  --accent: #6d4bd8; --accent-ink: #ffffff; --accent-soft: #ece6ff; --link: #5a3cc4; --amber: #ffcf5a;
  --stage: #1b1430; --stage-2: #261c42; --stage-line: #3a2d5e; --stage-text: #efe9ff; --stage-muted: #a99fc9;
  --radius: 16px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f0c18; --surface: #171223; --surface-2: #211a33; --text: #eeeaf8; --muted: #a59dbd; --line: #2d2542; --accent: #9b7dff; --accent-ink: #120c22; --accent-soft: #2a2047; --link: #b39dff; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #0f0c18; --surface: #171223; --surface-2: #211a33; --text: #eeeaf8; --muted: #a59dbd; --line: #2d2542; --accent: #9b7dff; --accent-ink: #120c22; --accent-soft: #2a2047; --link: #b39dff; 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(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.08rem; }
h2 small { font-size: .78rem; color: var(--muted); font-weight: 600; }
p { margin: 0 0 .8em; }
ul, ol { padding-left: 20px; margin: 0 0 .8em; }
li { margin-bottom: 4px; }
.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
.lead { color: var(--muted); }
.hint { color: var(--muted); font-size: .82rem; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; }

/* 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: 10px; height: 50px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { display: block; height: 32px; width: auto; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-size: 1.02rem; letter-spacing: -.02em; }
.brand-text small { font-size: .68rem; color: var(--accent); font-weight: 800; letter-spacing: .12em; 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(--accent-soft); color: var(--link); }
.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: 6px 0 0; }
.breadcrumb a { color: var(--muted); }
main.wrap { padding-top: 6px; padding-bottom: 32px; }
.tool-h1 { font-size: 1.05rem; margin: 2px 0 8px; }
.tool-h1 small { font-size: .78rem; color: var(--muted); font-weight: 600; margin-left: 4px; }

/* 공통 카드 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.prose li { margin-bottom: 6px; }
.faq details { border-top: 1px solid var(--line); padding: 10px 0; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: 8px 0 0; color: var(--muted); }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; font-size: .92rem; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ===== 메인: 악기 고르기 ===== */
.hero { padding: 14px 0 4px; }
.eyebrow { margin: 0; font-size: .75rem; font-weight: 800; letter-spacing: .14em; color: var(--accent); }
.inst-grid { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 760px) { .inst-grid { grid-template-columns: repeat(3, 1fr); } }
.inst-card { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 16px 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.inst-card.on { background: linear-gradient(160deg, var(--stage), var(--stage-2)); border-color: transparent; color: var(--stage-text); box-shadow: 0 10px 24px rgba(40, 20, 90, .25); }
.inst-card.on:hover { text-decoration: none; transform: translateY(-1px); }
.inst-card.off { opacity: .6; }
.inst-card .ic { font-size: 2rem; line-height: 1.2; }
.inst-card b { font-size: 1.12rem; }
.inst-card .en { font-size: .72rem; letter-spacing: .06em; opacity: .7; }
.inst-card .ds { font-size: .82rem; opacity: .8; margin-top: 4px; }
.inst-card .go { margin-top: auto; padding-top: 10px; font-weight: 800; font-size: .9rem; color: var(--amber); }
.inst-card.off .go { color: var(--muted); }

/* ===== 연주 화면 ===== */
.play { margin: 0 auto 14px; }
.stage { background: linear-gradient(180deg, var(--stage), #150f26); color: var(--stage-text); border-radius: 20px; padding: 10px 8px 12px; box-shadow: 0 12px 30px rgba(20, 10, 50, .25); }
.stage:fullscreen, .stage:-webkit-full-screen { display: flex; flex-direction: column; justify-content: center; border-radius: 0; padding: 16px; overflow: auto; }
.stage-top { display: flex; align-items: center; gap: 8px; padding: 0 4px 8px; min-height: 48px; }
.cur { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.cur b { font-size: 1.9rem; line-height: 1; letter-spacing: -.02em; color: var(--amber); min-width: 1.6em; white-space: nowrap; }
.cur b.long { font-size: 1.25rem; }
.cur-sub { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.cur-sub small { font-size: .78rem; color: var(--stage-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cur-sub small:first-child { color: var(--stage-text); font-weight: 700; letter-spacing: .06em; }
.vbtn { width: 32px; height: 40px; border: 0; border-radius: 10px; background: var(--stage-2); color: var(--stage-text); font-size: 1.3rem; cursor: pointer; }
.stage-actions { display: flex; gap: 4px; }
.tbtn { min-height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--stage-line); background: var(--stage-2); color: var(--stage-text); font-size: .8rem; font-weight: 700; cursor: pointer; }
.tbtn[aria-pressed=true] { background: var(--amber); color: #1b1430; border-color: var(--amber); }
.tap-hint { margin: 8px 6px 0; font-size: .76rem; color: var(--stage-muted); text-align: center; }

/* 지판 */
.board-host { position: relative; }
.fb { display: flex; align-items: flex-start; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.fb-names { flex: 0 0 20px; display: flex; flex-direction: column; }
.fb-names span { height: var(--rowh); display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: var(--stage-muted); }
.fb-scroll { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; scrollbar-width: thin; scrollbar-color: var(--stage-line) transparent; border-radius: 8px; }
.fb-board { position: relative; border-radius: 6px; background:
    linear-gradient(180deg, rgba(0,0,0,.25), transparent 12%, transparent 88%, rgba(0,0,0,.3)),
    repeating-linear-gradient(92deg, rgba(255,255,255,.025) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #5b3a25, #4a2d1b 50%, #573722); }
.fb-fret { position: absolute; top: 0; bottom: 0; width: 3px; background: linear-gradient(90deg, #8d8d8d, #f2f2f2 45%, #9a9a9a); box-shadow: 1px 0 1px rgba(0,0,0,.5); pointer-events: none; }
.fb-fret.nut { width: 6px; background: linear-gradient(90deg, #d8ccb4, #fbf4e6, #cbbd9f); }
.fb-mark { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: radial-gradient(#fff6e6, #d9c9a8); opacity: .8; pointer-events: none; }
.fb-string { position: absolute; left: 0; right: 0; transform: translateY(-50%); background: linear-gradient(180deg, #ffffff, #d9d1c4); box-shadow: 0 1px 2px rgba(0,0,0,.55); pointer-events: none; z-index: 1; }
.fb-string.vib { animation: vib .38s ease-out; }
@keyframes vib { 0% { transform: translateY(-50%) scaleY(2.4); } 18% { transform: translateY(calc(-50% + 1.6px)); } 36% { transform: translateY(calc(-50% - 1.3px)); } 56% { transform: translateY(calc(-50% + .8px)); } 76% { transform: translateY(calc(-50% - .4px)); } 100% { transform: translateY(-50%); } }
.fb-cell { position: absolute; height: var(--rowh); border: 0; padding: 0; margin: 0; background: transparent; cursor: pointer; display: grid; place-items: center; touch-action: pan-x; z-index: 2; border-radius: 6px; }
.fb-cell:focus-visible { outline: 2px solid #8fd3ff; outline-offset: -3px; }
.fb-cell .nm { position: relative; z-index: 2; font-size: 11px; font-weight: 700; color: #fff4dc; background: rgba(10, 6, 20, .55); border-radius: 6px; padding: 0 4px; opacity: 0; transition: opacity .15s; }
.show-names .fb-cell .nm { opacity: .9; }
.fb-cell.on .nm { opacity: 0; }
.fb-cell .dot { position: absolute; z-index: 3; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; color: #1b1430; background: radial-gradient(circle at 35% 30%, #fff1b8, var(--amber) 60%, #e0a92a); box-shadow: 0 0 0 2px rgba(0,0,0,.25), 0 0 14px rgba(255, 207, 90, .55); transform: scale(0); transition: transform .14s; }
.fb-cell.on .dot { transform: scale(1); }
.fb-cell.open.on .dot { width: 22px; height: 22px; background: rgba(20, 12, 40, .6); color: var(--amber); box-shadow: inset 0 0 0 2px var(--amber); font-size: 12px; }
.fb-cell.open.mute .dot { color: #ff7b7b; box-shadow: inset 0 0 0 2px #ff7b7b; }
.fb-cell.hit::after { content: ''; position: absolute; z-index: 4; width: 38px; height: 38px; border-radius: 50%; background: radial-gradient(rgba(255,255,255,.95), rgba(255,207,90,.35) 45%, transparent 70%); animation: hit .42s ease-out forwards; pointer-events: none; }
@keyframes hit { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
.fb-nums { position: relative; height: 20px; }
.fb-nums span { position: absolute; top: 2px; text-align: center; font-size: 11px; color: var(--stage-muted); }
.fb-nums span.mk { color: var(--stage-text); font-weight: 800; }
.fb-strum { flex: 0 0 76px; position: relative; margin: 0 2px 0 6px; border-radius: 12px; overflow: hidden; touch-action: none; cursor: ns-resize; outline: none;
  background: radial-gradient(circle at 50% 50%, #07040d 0 30%, #2e2014 31% 35%, #c9a46a 36% 38%, #6e4b2d 39% 100%); }
.fb-strum:focus-visible { box-shadow: 0 0 0 2px #8fd3ff; }
.fb-strum .lbl { position: absolute; left: 0; right: 0; bottom: 3px; z-index: 2; text-align: center; font-size: 10px; line-height: 1.2; color: #f3e5c8; text-shadow: 0 1px 2px #000; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .fb-string.vib, .fb-cell.hit::after { animation: none; } .fb-cell .dot { transition: none; } }

.strum-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 10px 4px 0; }
.sbtn { touch-action: manipulation; min-height: 54px; border: 0; border-radius: 14px; background: var(--stage-2); color: var(--stage-text); font-size: 1.35rem; font-weight: 800; cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0,0,0,.3); }
.sbtn span { font-size: .85rem; margin-left: 2px; }
.sbtn:active { transform: translateY(1px); background: var(--stage-line); }

/* 패널 */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 12px 0; }
.ph { font-size: .95rem; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.ph .ext { margin-left: auto; font-size: .8rem; font-weight: 600; }
.chord-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.chord-grid.sm { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 8px; }
@media (min-width: 640px) { .chord-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); } .chord-grid.sm { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.chord-btn { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text); cursor: pointer; padding: 4px 2px; opacity: .55; }
.ready .chord-btn { opacity: 1; }
.chord-btn b { font-size: 1.15rem; letter-spacing: -.02em; }
.chord-btn small { font-size: .68rem; color: var(--muted); }
.chord-btn[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px rgba(109, 75, 216, .35); }
.chord-btn[aria-pressed=true] small { color: inherit; opacity: .85; }
.chord-btn:active { transform: translateY(1px); }
.more-btn { margin-top: 8px; width: 100%; min-height: 42px; border: 1px dashed var(--line); border-radius: 12px; background: none; color: var(--link); font-weight: 700; cursor: pointer; }
.picker { margin-top: 8px; }
.pk-roots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
@media (min-width: 640px) { .pk-roots { grid-template-columns: repeat(12, minmax(0, 1fr)); } }
.pk { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-weight: 800; cursor: pointer; }
.pk.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.prog-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.prog-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.chord-btn.step { min-height: 64px; position: relative; }
.chord-btn.step small { position: absolute; top: 4px; left: 8px; }
.chord-btn.step b { font-size: 1.4rem; }
.chord-btn.step.next { box-shadow: inset 0 0 0 2px var(--amber); }

.metro-mini .mrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mb { min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-weight: 800; cursor: pointer; }
.mb.play { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); min-width: 92px; }
.mb.play[aria-pressed=true] { background: var(--text); color: var(--bg); border-color: var(--text); }
.bpm { display: inline-flex; align-items: baseline; gap: 3px; min-width: 70px; justify-content: center; }
.bpm b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.bpm small { font-size: .7rem; color: var(--muted); font-weight: 700; }
.beat-dots { display: flex; gap: 8px; margin-top: 10px; }
.beat-dots i { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); transition: background .06s; }
.beat-dots i.on { background: var(--accent); }
.beat-dots i:first-child.on { background: var(--amber); }

.settings summary { font-weight: 800; cursor: pointer; }
.srow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 0; border: 0; padding: 0; font-size: .92rem; }
.srow legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.srow input[type=range] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.srow label { display: inline-flex; align-items: center; gap: 4px; }

.links { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.links a { display: flex; align-items: center; min-height: 46px; padding: 0 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: .9rem; }
.links a:hover { text-decoration: none; background: var(--accent-soft); }

/* ads · footer */
.ad-slot { margin: 18px 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: .8rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.footer-links a { color: var(--text); font-weight: 600; }
