/* 악보 그리기 (score writer): the studio's header and dialogs (studio.css), a
   note-input toolbar, palettes on the left and the score as paper pages. */
body.writer{grid-template-rows:auto auto minmax(0,1fr) auto;--v1:#0065bf;--v2:#007f00;--v3:#c53f00;--v4:#c31989;--paper:#fff;--desk:var(--bg)}

/* Toolbar */
.writer-toolbar{display:flex;align-items:center;gap:3px;flex-wrap:wrap;padding:5px 10px;background:var(--surface);border-bottom:1px solid var(--line)}
.tool{min-width:34px;height:34px;padding:0 6px;white-space:nowrap;flex:none;display:inline-grid;place-items:center;border-radius:7px;font-size:17px;line-height:1;color:var(--ink);position:relative}
.tool.text{font-size:13px;padding:0 9px;font-weight:500}
.tool svg{width:20px;height:20px;fill:currentColor}
.tool[aria-pressed=true]{background:var(--accent-soft);color:var(--accent-text);box-shadow:inset 0 0 0 1px #9fc3ad}
.tool .glyph{font-size:20px;font-family:'Segoe UI Symbol','Noto Music','Apple Symbols',serif}
.tool .glyph.small{font-size:14px;font-weight:700;font-family:inherit}
.tool.input-mode{display:inline-flex;gap:5px;padding:0 10px;font-size:14px;font-weight:600}
.tool.input-mode svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linejoin:round}
.tool.input-mode[aria-pressed=true]{background:var(--v1);color:#fff;box-shadow:none}
.tool-group{display:inline-flex;gap:1px;padding:2px;border-radius:9px;background:var(--raised)}
.tool-group .tool{height:30px;min-width:30px}
.tool-sep{width:1px;height:24px;background:var(--line);margin:0 4px}
.durations .tool svg{width:22px;height:26px}
.durations .tool kbd{position:absolute;right:2px;bottom:1px;font:9px/1 inherit;color:var(--muted);background:none;border:0;padding:0}
.voices .tool{font-size:13px;font-weight:700;width:28px;min-width:28px}
.voices .v1{color:var(--v1)}.voices .v2{color:var(--v2)}.voices .v3{color:var(--v3)}.voices .v4{color:var(--v4)}
.voices .tool[aria-pressed=true]{color:#fff;box-shadow:none}
.voices .v1[aria-pressed=true]{background:var(--v1)}.voices .v2[aria-pressed=true]{background:var(--v2)}.voices .v3[aria-pressed=true]{background:var(--v3)}.voices .v4[aria-pressed=true]{background:var(--v4)}
/* The dark theme lightens the voice colours, so a chosen voice takes dark writing */
:root[data-theme=dark] .voices .tool[aria-pressed=true]{color:#0a0c0f}
.tool.play svg{width:22px;height:22px}
.tool.play.playing{background:var(--accent-soft)}
.tool-field{display:inline-flex;align-items:center;gap:5px;font-size:12px;color:var(--muted);margin:0 4px}
.tool-field select{min-height:30px;padding:2px 4px}
.zoom-value{min-width:54px}
.status-bar .zoom .tool{height:24px;min-width:24px;font-size:14px}.status-bar .zoom .zoom-value{font-size:12px;min-width:48px}
.palette-toggle{font-size:13px;padding:0 10px}

/* Palettes and score */
.writer-main{display:grid;grid-template-columns:232px minmax(0,1fr);min-height:0;position:relative}
.writer-main.palette-closed{grid-template-columns:minmax(0,1fr)}
.writer-main.palette-closed .palette{display:none}
.palette{overflow:auto;background:var(--surface);border-right:1px solid var(--line);padding:6px 8px 20px}
.palette-section{border-bottom:1px solid var(--line);padding:4px 0}
.palette-section>summary{list-style:none;cursor:pointer;font-size:13px;font-weight:700;padding:6px 4px;border-radius:6px;color:var(--ink)}
.palette-section>summary::-webkit-details-marker{display:none}
.palette-section>summary::before{content:'▸';display:inline-block;width:14px;color:var(--faint);transition:transform .15s}
.palette-section[open]>summary::before{transform:rotate(90deg)}
.palette-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:3px;padding:2px 0 6px}
.palette-grid.wide{grid-template-columns:repeat(2,1fr)}
.palette-grid.keys{grid-template-columns:repeat(3,1fr)}
.palette-grid button{min-height:34px;padding:4px 3px;border:1px solid var(--line);border-radius:7px;background:var(--surface-2);font-size:13px;line-height:1.15;text-align:center;color:var(--ink)}
.palette-grid button:hover:not(:disabled){background:var(--raised);border-color:var(--accent-line)}
.palette-grid button .sym{display:block;font-size:19px;font-family:'Segoe UI Symbol','Noto Music','Apple Symbols',serif;line-height:1.1}
.palette-grid button .dyn{font-family:Georgia,'Times New Roman',serif;font-style:italic;font-weight:700;font-size:17px}
.palette-grid.wide button{text-align:left;padding:6px 8px}
.score-area{position:relative;overflow:auto;background:var(--desk);outline:none;-webkit-user-select:none;user-select:none;touch-action:pan-x pan-y pinch-zoom}
.writer-pages{display:flex;flex-direction:column;align-items:center;gap:18px;padding:18px 12px 60px;min-width:max-content}
.writer-pages .page{background:var(--paper);box-shadow:0 2px 10px #1a2b2229;line-height:0;color:#111}
.writer-pages svg{display:block;color:#111}
.score-loading{color:var(--muted);font-size:14px;line-height:1.6;padding:30px}
/* The selection in the voice's colour, as in MuseScore. */
.writer-pages g.sel,.writer-pages g.sel *{fill:var(--v1);stroke:var(--v1)}
.writer-pages g.sel.v2,.writer-pages g.sel.v2 *{fill:var(--v2);stroke:var(--v2)}
.writer-pages g.sel.v3,.writer-pages g.sel.v3 *{fill:var(--v3);stroke:var(--v3)}
.writer-pages g.sel.v4,.writer-pages g.sel.v4 *{fill:var(--v4);stroke:var(--v4)}
.writer-pages g.playing,.writer-pages g.playing *{fill:#d9822b;stroke:#d9822b}
.writer-pages g.note,.writer-pages g.rest,.writer-pages g.mRest,.writer-pages g.chord{cursor:pointer}
.writer-pages g.note.sel{cursor:grab}
.writer-pages g.dragging{opacity:.3}
.range-boxes{position:absolute;left:0;top:0;pointer-events:none}
.range-box{position:absolute;background:#0065bf1f;border:1.5px solid #0065bf99;border-radius:3px}
.writer-caret{position:absolute;width:5px;border-radius:2px;background:var(--v1);opacity:.55;pointer-events:none;animation:caret-blink 1.1s steps(1) infinite}
.writer-caret.v2{background:var(--v2)}.writer-caret.v3{background:var(--v3)}.writer-caret.v4{background:var(--v4)}
@keyframes caret-blink{50%{opacity:.25}}
@media(prefers-reduced-motion:reduce){.writer-caret{animation:none}}
.writer-ghost{position:absolute;pointer-events:none;transform:translate(-50%,-50%)}
.writer-ghost::before{content:'';display:block;width:var(--head,13px);height:var(--head-h,10px);border-radius:50%;background:var(--v1);opacity:.45;transform:rotate(-20deg)}
.writer-ghost span{position:absolute;left:calc(100% + 6px);top:50%;transform:translateY(-50%);font-size:11px;font-weight:700;color:var(--v1);background:#ffffffd9;padding:1px 4px;border-radius:4px;white-space:nowrap}
.inline-edit{position:absolute;z-index:5;min-width:70px;width:auto;padding:3px 6px;border:2px solid var(--v1);border-radius:5px;background:#fff;color:#111;font:15px/1.3 'Noto Sans KR',sans-serif;box-shadow:0 4px 14px #0002}

/* Status bar and input pad */
.status-bar{display:flex;align-items:center;gap:14px;padding:4px 12px;min-height:30px;background:var(--surface);border-top:1px solid var(--line);font-size:12px;color:var(--muted);overflow:hidden;white-space:nowrap}
.status-mode{font-weight:700;color:var(--ink)}
.status-mode.input{color:var(--v1)}
.status-sel{overflow:hidden;text-overflow:ellipsis}
.status-hint{margin-left:auto;overflow:hidden;text-overflow:ellipsis}
.pad-toggle{font-size:12px;padding:4px 10px}
.pad-toggle[aria-pressed=true]{background:var(--accent-soft)}
.input-pad{position:fixed;left:0;right:0;bottom:0;z-index:30;padding:8px 8px calc(8px + env(safe-area-inset-bottom));background:var(--surface);border-top:1px solid var(--line);box-shadow:0 -8px 24px #10241c1f;display:grid;gap:6px}
.pad-row{display:flex;gap:4px;justify-content:center;flex-wrap:wrap}
.pad-row button{min-width:44px;min-height:42px;padding:0 8px;border:1px solid var(--line);border-radius:8px;background:var(--surface-2);font-size:15px}
.pad-row button[aria-pressed=true]{background:var(--accent-soft);border-color:var(--accent-line)}
.pad-notes button{min-width:46px;font-weight:700;font-size:17px}
.pad-notes button small{display:block;font-size:10px;font-weight:500;color:var(--muted)}
body.pad-open .score-area{padding-bottom:140px}

/* Dialogs */
.dialog-row.two{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.dialog-field.stacked input{width:100%}
.parts-list{list-style:none;margin:0 0 12px;padding:0;display:grid;gap:6px}
.parts-list li{display:flex;align-items:center;gap:6px;padding:6px 8px;border:1px solid var(--line);border-radius:8px}
.parts-list input{flex:1;min-width:0;border:1px solid var(--line-strong);border-radius:6px;padding:5px 7px;font-size:14px}
.parts-list select{max-width:130px}
.parts-list button{padding:5px 8px;font-size:13px}
.writer-help h3{font-size:14px;margin:16px 0 6px}
.writer-help dl{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;margin:0}
.writer-help dt{white-space:nowrap}
.writer-help dd{margin:0;color:var(--ink)}
.writer-help kbd{display:inline-block;min-width:20px;padding:1px 5px;border:1px solid var(--line-strong);border-bottom-width:2px;border-radius:5px;background:var(--surface-2);font:12px/1.4 ui-monospace,Consolas,monospace;text-align:center}
.writer-help ul{margin:0;padding-left:20px}
#text-row input:not([type]){flex:1;min-width:0;border:1px solid var(--line-strong);border-radius:6px;padding:6px 8px;font-size:14px}
#chords-text,#lyrics-text{margin-top:8px}

@media (max-width:900px){
 .writer-main{grid-template-columns:minmax(0,1fr)}
 .palette{position:absolute;left:0;top:0;bottom:0;z-index:20;width:min(280px,86vw);box-shadow:8px 0 24px #10241c2e}
 .writer-main:not(.palette-open) .palette{display:none}
 .writer-main.palette-closed.palette-open .palette{display:block}
}
@media (max-width:640px){
 .writer-pages{padding:10px 6px 60px}
 .writer-toolbar{gap:2px;padding:4px 6px;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
 .writer-toolbar::-webkit-scrollbar{display:none}
 .tool-field,#midi-input,#metronome{display:none}
 .status-hint{display:none}
 .dialog-row.two{grid-template-columns:1fr}
}

/* The score stays black on white paper in the dark theme. */
:root[data-theme="dark"] .writer-pages .page{background:#fff;color:#111}
:root[data-theme="dark"] .writer-pages svg{color:#111}
:root[data-theme="dark"] .writer-ghost span{background:#fff;color:var(--v1)}
:root[data-theme="dark"] .inline-edit{background:#fff;color:#111}
