:root {
  color-scheme: light dark;
  --bg: #f6f5fa; --card: #fff; --text: #1c1a24; --muted: #5f5b6e; --line: #e2dfec;
  --accent: #6d28d9; --accent-text: #6024c4; --accent-soft: #efe9fc; --on-accent: #fff; --rec: #e11d48;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121117; --card: #1c1a24; --text: #efedf5; --muted: #a8a3b8; --line: #34303f;
    --accent: #6d28d9; --accent-text: #c4b5fd; --accent-soft: #2a2145; --rec: #f43f5e; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.65; word-break: keep-all; overflow-wrap: anywhere;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
a { color: var(--accent-text); }
.inner { max-width: 820px; margin: 0 auto; padding: 0 16px; }
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; color: var(--text); text-decoration: none; }
.site-nav { display: flex; gap: 14px; font-size: 14px; }
.site-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.site-nav a:hover { color: var(--accent-text); }
main { padding: 22px 0 40px; }
h1 { font-size: clamp(24px, 6vw, 34px); line-height: 1.25; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 21px; line-height: 1.35; margin: 34px 0 10px; letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 0 16px; font-size: 16px; }
.small { font-size: 13.5px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 0 0 16px; }

/* 녹음 */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg label { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; text-align: center; padding: 10px 4px; border: 1px solid var(--line); border-radius: 10px; font-size: 14.5px; }
.seg input:checked + span { background: var(--accent-soft); border-color: var(--accent-text); color: var(--accent-text); font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.metro-opts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin-top: 12px; }
.mini { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.mini select, .bpm-in input { font: inherit; font-size: 15px; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-height: 40px; }
.bpm-in { display: flex; align-items: center; gap: 6px; }
.bpm-in input { width: 78px; }
.bpm-in small { font-weight: 400; }
.pair { display: flex; gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.stage { position: relative; margin-top: 14px; height: 190px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
#live { position: absolute; inset: 0; width: 100%; height: 100%; }
.live-note { position: absolute; right: 12px; top: 8px; font-size: 26px; font-weight: 800; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.stage-hint { position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; font-size: 14px; color: var(--muted); padding: 0 12px; }
.beats { position: absolute; left: 12px; top: 14px; display: flex; gap: 7px; }
.beats i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-text); opacity: .5; }
.beats i.on { background: var(--accent-text); opacity: 1; }
.rec-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 14px 0 4px; }
.rec-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; text-align: right; padding-right: 16px; }
.rec-btn { width: 84px; height: 84px; border-radius: 50%; border: 4px solid var(--rec); background: var(--card); cursor: pointer; display: grid; place-items: center; padding: 0; }
.rec-btn span { width: 58px; height: 58px; border-radius: 50%; background: var(--rec); transition: all .15s; }
.recording .rec-btn span { width: 30px; height: 30px; border-radius: 6px; }
.recording .rec-btn { animation: pulse 1.4s ease-in-out infinite; }
.recording .rec-time { color: var(--rec); font-weight: 700; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--rec) 18%, transparent); } }
@media (prefers-reduced-motion: reduce) { .recording .rec-btn { animation: none; } }
.busy .rec-btn, .busy #demo, .busy .btn.file { opacity: .45; pointer-events: none; }

.acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.acts .btn { flex: 1; min-width: 130px; }
.btn { display: inline-block; font: inherit; font-weight: 700; text-align: center; text-decoration: none; padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer; }
.btn.sm { padding: 7px 11px; font-size: 13.5px; font-weight: 600; min-height: 40px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.btn.file:focus-within { outline: 3px solid var(--accent-text); outline-offset: 2px; }
input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
#status { font-size: 14px; margin: 10px 0 0; color: var(--accent-text); font-weight: 600; }
#status.err { color: var(--rec); }
#status:empty { display: none; }
.note { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

/* 악보 */
.title-in { display: block; width: 100%; font: inherit; font-size: 19px; font-weight: 800; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; margin: -4px -6px 0; }
.title-in:hover, .title-in:focus { border-color: var(--line); background: var(--bg); }
.meta { margin: 2px 0 10px; font-size: 14px; color: var(--muted); }
.play-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.play-row .btn { flex: 1; min-width: 130px; }
.paper { background: #fff; color: #000; border-radius: 10px; border: 1px solid var(--line); padding: 4px; overflow-x: auto; outline: none; }
.paper:focus-visible { box-shadow: 0 0 0 3px var(--accent-text); }
.paper svg { display: block; }
.paper .abcjs-note, .paper .abcjs-rest { cursor: pointer; }
#print-title { display: none; }
.edit-bar { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-top: 8px; }
.edit-bar button { font: inherit; font-size: 14px; font-weight: 600; padding: 9px 4px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; min-height: 42px; }
.edit-bar button:not(:disabled):hover { border-color: var(--accent-text); color: var(--accent-text); }
.edit-bar button:disabled { opacity: .4; cursor: default; }
.opts-box { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.opts-box summary { cursor: pointer; font-weight: 700; padding: 11px 0; font-size: 15px; }
.opts-box[open] { padding-bottom: 12px; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.opt-grid select { width: 100%; }
#pitchview { display: block; width: 100%; height: 180px; background: var(--bg); border-radius: 8px; }
.exports .btn { min-width: 110px; }

/* 내 멜로디 */
.lib-h { margin: 0 0 8px; font-size: 18px; }
.lib { list-style: none; margin: 0; padding: 0; }
.lib li { display: flex; gap: 6px; border-top: 1px solid var(--line); }
.lib li:first-child { border-top: 0; }
.lib-open { flex: 1; text-align: left; font: inherit; background: none; border: 0; color: inherit; padding: 10px 4px; cursor: pointer; border-radius: 8px; min-width: 0; }
.lib-open strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-open small { color: var(--muted); font-size: 13px; }
.lib-open.on strong { color: var(--accent-text); }
.lib-open:hover { background: var(--bg); }
.lib-del { font: inherit; font-size: 13px; background: none; border: 0; color: var(--muted); padding: 0 10px; cursor: pointer; }
.lib-del:hover { color: var(--rec); }

table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0 14px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 13.5px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.more { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.more a { display: block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px; text-decoration: none; font-size: 14.5px; background: var(--card); }
.install { padding: 6px 12px; font-size: 13.5px; white-space: nowrap; }
.ad-slot { margin: 22px 0; min-height: 100px; }
.ad-slot.preview { border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.ad-label { display: block; font-size: 11px; color: var(--muted); }
.site-footer { border-top: 1px solid var(--line); padding: 22px 0 34px; font-size: 13.5px; color: var(--muted); }
.site-footer p { margin: 0 0 8px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.site-footer a { color: var(--muted); }
@media (max-width: 560px) {
  .site-nav { display: none; }
  .card { padding: 12px; }
  .stage { height: 160px; }
}

@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  #paper, #paper * { visibility: visible; }
  #paper { position: absolute; left: 0; top: 0; width: 100%; border: 0; padding: 0; }
  #print-title { display: block; color: #000; font-size: 20px; margin: 0 0 8px; }
}
