:root {
  --ink: #1b1b22;
  --muted: #6e6e7a;
  --faint: #9a9aa6;
  --line: #e6e6ec;
  --bg: #f6f6f8;
  --card: #ffffff;
  --accent: #6741d9;
  --accent-600: #5a35c8;
  --accent-50: #f6f3ff;
  --accent-100: #ece6fd;
  --accent-200: #cfc2f7;
  --sheet: #e9e9ee;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Pretendard, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1060px; margin: 0 auto; padding: 0 20px; height: 52px; display: flex; align-items: center; gap: 36px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.brand-icon { width: 24px; height: 24px; stroke-width: 1.6; }
.tabs { display: flex; gap: 8px; height: 100%; align-items: stretch; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 0 6px; margin: 0 4px; font-size: 13px; font-weight: 600;
  color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab svg { width: 14px; height: 14px; }
.guide-link { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 13px; }
.guide-link:hover, .guide-link.active { color: var(--accent); }

/* ---------- page ---------- */
.view { max-width: 1060px; margin: 0 auto; padding: 28px 20px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin: 0 0 4px; }
.page-head p { margin: 0; color: var(--muted); font-size: 12.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; font-size: 12.5px; font-weight: 600;
  background: #fff; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink);
}
.btn:hover:not(:disabled) { border-color: #c9c9d3; background: #fafafb; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { height: 30px; font-size: 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-600); border-color: var(--accent-600); }
.btn.block { width: 100%; height: 38px; font-size: 13.5px; margin-top: 16px; }
.caret { font-size: 10px; color: var(--muted); }

.icon-btn { background: none; border: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 5px; padding: 0; color: var(--muted); }
.icon-btn:hover { background: #f0f0f4; color: var(--ink); }
.icon-btn.sm { width: 22px; height: 22px; font-size: 15px; }
.icon-btn svg { width: 14px; height: 14px; }

/* ---------- studio layout ---------- */
.studio { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 16px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.panel-head { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 14.5px; font-weight: 700; margin: 0; }
.panel-icon { width: 22px; height: 22px; border-radius: 5px; background: var(--accent-50); color: var(--accent); display: grid; place-items: center; }
.panel-icon svg { width: 13px; height: 13px; }
.panel-body { padding: 18px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; cursor: pointer;
  padding: 22px 12px 20px; border: 1px dashed var(--accent-200); border-radius: 6px; background: var(--accent-50);
  transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.drag, .dropzone:focus-visible { background: var(--accent-100); border-color: var(--accent); outline: none; }
.dz-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--accent-100); color: var(--accent); display: grid; place-items: center; margin-bottom: 12px; }
.dz-icon svg { width: 18px; height: 18px; }
.dropzone strong { font-size: 12.5px; font-weight: 600; }
.dropzone span { font-size: 11.5px; color: var(--muted); }
.dropzone em { font-style: normal; color: var(--accent); font-weight: 700; }
.dropzone small { font-size: 10.5px; color: var(--faint); margin-top: 8px; }

.label { font-size: 12px; font-weight: 700; margin: 20px 0 8px; }
.audio-card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px 8px; }
.audio-top { display: flex; align-items: center; gap: 8px; }
.file-icon { width: 20px; height: 20px; border-radius: 4px; background: var(--accent-50); color: var(--accent); display: grid; place-items: center; }
.file-icon svg { width: 12px; height: 12px; }
.file-name { font-size: 12px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 10px; color: var(--muted); background: #f2f2f5; border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.waveform { display: block; width: 100%; height: 44px; margin: 10px 0 4px; cursor: pointer; background: var(--accent-50); border-radius: 3px; }
.player { display: flex; align-items: center; gap: 6px; }
.player .time { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.player .right { margin-left: auto; }
.player .icon-btn { width: 20px; height: 20px; }
.player .icon-btn svg { width: 12px; height: 12px; }

.divider { height: 1px; background: var(--line); margin: 20px 0 16px; }
.settings-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12.5px; margin-bottom: 12px; }
.settings-title svg { width: 14px; height: 14px; }
.auto-all { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fafafb; color: var(--ink);
  cursor: pointer; user-select: none; transition: background .15s, border-color .15s, color .15s; }
.auto-all.on { border-color: var(--accent); background: rgba(103,65,217,.07); color: var(--accent); }
.auto-all svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.auto-all-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.auto-all-text b { font-size: 13px; }
.auto-all-text small { font-size: 11.5px; color: var(--muted); }
.switch { position: relative; flex: none; width: 40px; height: 22px; padding: 0; border: none; border-radius: 11px;
  background: #cfcfd8; cursor: pointer; transition: background .18s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field.locked { opacity: .55; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); margin-bottom: 14px; }
.field select, .field input[type=number], .field input[type=text] {
  font: inherit; font-size: 12.5px; color: var(--ink); height: 32px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 5px; background: #fff; width: 100%;
}
.field select { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239a9aa6' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; padding-right: 28px; }
.field select:focus, .field input:focus { outline: 2px solid var(--accent-100); border-color: var(--accent); }
.field input[type=range] { accent-color: var(--accent); }
.desc { font-size: 10.5px; color: var(--muted); line-height: 1.55; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .field input { margin-top: 4px; }
details.sub summary { font-size: 11.5px; color: var(--muted); cursor: pointer; margin-bottom: 10px; list-style: none; }
details.sub summary::-webkit-details-marker { display: none; }
details.sub summary::before { content: "▸ "; font-size: 9px; }
details.sub[open] summary::before { content: "▾ "; }
.error { margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: #fdecec; color: #a12a2a; font-size: 12px; }

/* ---------- preview ---------- */
.preview { display: flex; flex-direction: column; overflow: hidden; }
.status { margin-left: auto; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.status.idle { background: #f1f1f4; color: var(--muted); }
.status.working { background: #fff4e0; color: #a96300; }
.status.done { background: var(--accent-100); color: var(--accent); }
.status.fail { background: #fdecec; color: #a12a2a; }
.preview-bar { display: flex; align-items: center; gap: 14px; height: 34px; padding: 0 16px; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.text-btn { background: none; border: none; padding: 0; display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11.5px; }
.text-btn:hover:not(:disabled) { color: var(--ink); }
.text-btn:disabled { opacity: .5; cursor: not-allowed; }
.position { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.zoom { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.zoom #zoom-val { min-width: 36px; text-align: center; }
.zoom .sep { width: 1px; height: 14px; background: var(--line); margin: 0 4px; }
.sheet-scroll {
  position: relative; height: clamp(560px, calc(100vh - 250px), 940px);
  overflow: hidden; background: var(--sheet); padding: 16px;
}
#score { display: flex; justify-content: center; align-items: flex-start; height: 100%; }
#score > div { display: none; flex: none; position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.05); }
#score > div.current { display: block; animation: pagein .18s ease-out; }
@keyframes pagein { from { opacity: .4; } to { opacity: 1; } }
.hl-band { position: absolute; background: rgba(103, 65, 217, .10); border-radius: 2px; pointer-events: none; }
.hl-line { position: absolute; width: 2px; background: rgba(103, 65, 217, .75); border-radius: 1px; pointer-events: none; }
.pager .icon-btn:disabled { opacity: .35; cursor: default; background: none; }
#score svg { width: auto; height: auto; fill: initial; stroke: initial; stroke-width: initial; display: block; }
.empty, .busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--muted); font-size: 12.5px; }
.empty svg { width: 40px; height: 40px; color: var(--faint); stroke-width: 1.2; margin-bottom: 6px; }
.empty strong, .busy strong { color: var(--ink); font-size: 14px; }
.busy { background: var(--sheet); z-index: 2; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--accent-100); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: 240px; height: 5px; background: #fff; border-radius: 99px; overflow: hidden; margin-top: 6px; }
#busy-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.preview-foot { display: flex; align-items: center; gap: 12px; height: 50px; padding: 0 14px; border-top: 1px solid var(--line); }
.pager { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.score-meta { font-size: 11px; color: var(--faint); margin-left: 6px; }
.menu-wrap { margin-left: auto; position: relative; }
.menu { position: absolute; right: 0; bottom: 36px; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 8px 24px rgba(0,0,0,.1); padding: 4px; min-width: 180px; z-index: 5; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 10px; border-radius: 5px; font-size: 12.5px; }
.menu button:hover { background: var(--accent-50); color: var(--accent); }

.preview:fullscreen { border-radius: 0; }
.preview:fullscreen .sheet-scroll { height: auto; flex: 1; }

/* ---------- library ---------- */
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.lib-card { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.lib-card h3 { font-size: 14px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card .meta { color: var(--muted); font-size: 11.5px; }
.lib-card .row { display: flex; gap: 6px; margin-top: 8px; }
.lib-card .row .btn { flex: 1; }
.btn.danger:hover { color: #a12a2a; border-color: #e7b8b8; }
.empty-lib { padding: 48px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }
.empty-lib strong { color: var(--ink); font-size: 15px; }
.empty-lib .btn { margin-top: 8px; }

/* ---------- guide ---------- */
.guide { max-width: 760px; }
.guide h3 { font-size: 15px; margin: 18px 0 6px; }
.guide h3:first-child { margin-top: 0; }
.guide p, .guide li { color: #44444e; font-size: 13.5px; line-height: 1.75; }
.guide ul { padding-left: 18px; }

@media (max-width: 860px) {
  .studio { grid-template-columns: 1fr; }
  .sheet-scroll { padding: 14px; height: 560px; }
  .topbar-inner { gap: 18px; }
}

@media print {
  @page { margin: 0; }
  body { background: #fff; }
  .topbar, .page-head, .studio > .panel:first-child, .panel-head, .preview-bar, .preview-foot, .busy, .empty { display: none !important; }
  .view { padding: 0; max-width: none; }
  .studio { display: block; }
  .panel { border: none; }
  .sheet-scroll { height: auto; overflow: visible; background: #fff; padding: 0; }
  #score { display: block; height: auto; }
  #score > div { display: block !important; box-shadow: none; break-after: page; animation: none; }
  .hl-band, .hl-line { display: none; }
}
