/* Score editor. Same palette as style.css, laid out as a full-window app. */
:root {
    --bg: #fbf8f3;
    --panel: #ffffff;
    --panel-hi: #f4efe7;
    --line: #e4dbd0;
    --line-soft: #efe8df;
    --grid: rgba(43, 37, 32, 0.07);
    --text: #2b2520;
    --muted: #857a6d;
    --accent: #c2500c;
    --accent-soft: rgba(194, 80, 12, 0.08);
    --accent-line: #edc8a8;
    --danger: #b3261e;

    --osc-bg: #f7dfca;
    --osc-line: #d9884f;
    --noise-bg: #e9e3d9;
    --noise-line: #a3947f;
    --file-bg: #d7e8ec;
    --file-line: #5b93a1;

    --lp0: #c2500c;
    --lp1: #2f7d6d;
    --lp2: #5560b0;
    --lp3: #a0458a;

    /* --head-w, --lane-h, --ruler-h are set from editor.js */
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

.app {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    height: 100vh;
}

button {
    font: inherit;
    font-weight: 550;
    color: var(--text);
    background: var(--panel-hi);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    white-space: nowrap;
}

button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.45; cursor: default; border-color: var(--line); }

button.primary, button.play {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

button.primary:hover, button.play:hover { filter: brightness(1.08); }

button.play { min-width: 70px; }

button.play.is-playing {
    background: var(--panel-hi);
    border-color: var(--line);
    color: var(--text);
}

button.danger { color: var(--danger); }

select, input[type="text"] {
    font: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 3px 7px;
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

label.inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}

/* ---- top bar ---- */

.topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 9px 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    gap: 7px;
    align-items: baseline;
    min-width: 0;
}

.brand a { color: var(--muted); text-decoration: none; }
.brand a:hover { color: var(--accent); }
.brand .sep { color: var(--line); }

#scoreTitleLabel {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-left: auto;
}

.group {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ---- transport ---- */

.transport {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 8px 14px;
    background: var(--panel-hi);
    border-bottom: 1px solid var(--line);
}

.time {
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    font-weight: 500;
    min-width: 120px;
}

.hands-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hands-label {
    color: var(--muted);
    cursor: help;
    border-bottom: 1px dotted var(--muted);
}

.hands {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.hand {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
}

.hand input[type="range"] {
    width: 74px;
    accent-color: var(--accent);
}

.hand output {
    font-variant-numeric: tabular-nums;
    color: var(--text);
    min-width: 22px;
    text-align: right;
}

.midi {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

/* ---- main split ---- */

.main {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 0;
}

#panel {
    overflow-y: auto;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 0 14px 30px;
}

#scroller {
    overflow: auto;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

#canvas {
    position: relative;
    min-height: 100%;
}

/* ---- ruler ---- */

.ruler {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    height: var(--ruler-h);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.ruler .corner {
    position: sticky;
    left: 0;
    z-index: 7;
    flex: none;
    width: var(--head-w);
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.ruler-body {
    position: relative;
    flex: none;
    cursor: text;
    overflow: hidden;
}

.tick {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px solid var(--line);
    padding: 5px 0 0 4px;
    font-size: 10.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}

.tick.minor {
    top: auto;
    height: 6px;
    padding: 0;
}

.ruler-end {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    background: repeating-linear-gradient(135deg, transparent 0 5px, var(--grid) 5px 6px);
    border-left: 1.5px solid var(--muted);
    pointer-events: none;
}

/* ---- lanes ---- */

.lane {
    display: flex;
    height: var(--lane-h);
    border-bottom: 1px solid var(--line-soft);
}

.lane.group-start { border-top: 1px solid var(--line); }
.lane.group-start:first-of-type { border-top: 0; }

.lane-head {
    position: sticky;
    left: 0;
    z-index: 4;
    flex: none;
    width: var(--head-w);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px 0 0;
    background: var(--panel);
    border-right: 1px solid var(--line);
    cursor: pointer;
}

.lane.focus .lane-head { background: #fdf1e7; }

.lp-tag {
    flex: none;
    width: 22px;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}

.lp0 .lp-tag { background: var(--lp0); }
.lp1 .lp-tag { background: var(--lp1); }
.lp2 .lp-tag { background: var(--lp2); }
.lp3 .lp-tag { background: var(--lp3); }

.lane-head .pair {
    font-weight: 600;
    font-size: 12.5px;
    flex: 1;
    min-width: 0;
}

.lane-head .cc {
    font-size: 10.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.ms {
    padding: 0;
    width: 19px;
    height: 19px;
    font-size: 10px;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
}

.ms.on { background: var(--text); border-color: var(--text); color: #fff; }
.ms.solo.on { background: #d8a200; border-color: #d8a200; }

.lane-body {
    position: relative;
    flex: none;
    background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px);
}

.lp1 .lane-body, .lp3 .lane-body { background-color: rgba(43, 37, 32, 0.018); }

.lane.quiet .lane-body > * { opacity: 0.4; }
.lane.quiet .lane-head .pair { color: var(--muted); }

.end-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    background: repeating-linear-gradient(135deg, transparent 0 5px, var(--grid) 5px 6px);
    border-left: 1.5px solid var(--muted);
    pointer-events: none;
}

/* ---- clips ---- */

.clip {
    position: absolute;
    top: 3px;
    bottom: 3px;
    z-index: 1;
    border-radius: 5px;
    border: 1px solid;
    overflow: hidden;
    cursor: grab;
}

.clip.t-osc { background: var(--osc-bg); border-color: var(--osc-line); }
.clip.t-noise { background: var(--noise-bg); border-color: var(--noise-line); }
.clip.t-file { background: var(--file-bg); border-color: var(--file-line); }
.clip.t-silence {
    background: repeating-linear-gradient(135deg, rgba(255,255,255,0.7) 0 4px, rgba(43,37,32,0.05) 4px 8px);
    border-style: dashed;
    border-color: #c8bcae;
    color: var(--muted);
}

.clip.sel {
    border: 2px solid var(--text);
    z-index: 2;
}

.clip.dragging { opacity: 0.85; box-shadow: 0 3px 10px rgba(43, 37, 32, 0.18); cursor: grabbing; }
.clip.ghost { opacity: 0.6; border-style: dashed; }

.clip-text {
    padding: 5px 7px;
    font-size: 11.5px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.clip-text .src { font-weight: 650; }
.clip-text .mod { color: rgba(43, 37, 32, 0.6); }

.edge {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 7px;
    cursor: col-resize;
    z-index: 1;
}

.edge-l { left: 0; }
.edge-r { right: 0; }

.fh {
    position: absolute;
    top: 0;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid var(--text);
    cursor: ew-resize;
    z-index: 2;
    display: none;
}

.clip:hover .fh, .clip.sel .fh { display: block; }

.fade {
    position: absolute;
    top: 3px;
    height: calc(100% - 6px);
    z-index: 3;
    pointer-events: none;
    overflow: visible;
}

.fade .fa { fill: rgba(43, 37, 32, 0.12); }
.fade .fl { fill: none; stroke: rgba(43, 37, 32, 0.6); stroke-width: 1.25; }

#playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1.5px solid var(--accent);
    z-index: 5;
    pointer-events: none;
}

#playhead::before {
    content: "";
    position: absolute;
    top: 0;
    left: -6px;
    border: 5.5px solid transparent;
    border-top: 7px solid var(--accent);
}

#marquee {
    position: absolute;
    display: none;
    z-index: 5;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    pointer-events: none;
}

/* ---- side panel ---- */

.panel-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel);
    padding: 14px 0 10px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.panel-head .hint { margin: 3px 0 0; }

.hint { color: var(--muted); font-size: 12px; }

#panel section {
    padding: 12px 0 6px;
    border-bottom: 1px solid var(--line-soft);
}

#panel section:last-child { border-bottom: 0; }

#panel h3 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 8px;
}

#panel section > .hint { margin: -3px 0 8px; }

.row {
    display: grid;
    grid-template-columns: 92px 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.row.pair { grid-template-columns: 92px 1fr 1fr; }

.row.pair.head {
    margin-bottom: 2px;
    font-size: 11px;
    color: var(--muted);
}

.row > label { color: var(--muted); }

.cell {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.cell select { width: 100%; }

.inp {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
}

.inp input[type="text"] {
    width: 100%;
    min-width: 0;
    font-variant-numeric: tabular-nums;
    padding-right: 34px;
}

.inp .unit {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--muted);
    pointer-events: none;
}

.hz {
    flex: none;
    font-size: 10.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    min-width: 44px;
}

.row.pair .cell { flex-direction: column; align-items: stretch; gap: 1px; }
.row.pair .hz { text-align: right; min-width: 0; }
.row.pair .hz:empty { display: none; }

.btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 8px;
}

.lib-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--line-soft);
}

.lib-row .nm {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 550;
}

.lib-row .meta {
    font-size: 11px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.lib-row button { padding: 1px 7px; }

ol.steps {
    padding-left: 18px;
    margin: 0 0 8px;
}

ol.steps li { margin-bottom: 5px; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11.5px;
    background: var(--panel-hi);
    padding: 1px 4px;
    border-radius: 4px;
}

dl.keys {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    margin: 0 0 8px;
}

dl.keys dt {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    white-space: nowrap;
}

dl.keys dd { margin: 0; color: var(--muted); }

/* ---- status bar ---- */

.statusbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 14px;
    font-size: 12px;
    color: var(--muted);
    background: var(--panel);
    border-top: 1px solid var(--line);
    min-height: 25px;
}

#status {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#statusRight { white-space: nowrap; }

/* ---- drop overlay ---- */

#dropOverlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 22vh;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(251, 248, 243, 0.55);
    border: 3px dashed var(--accent);
    pointer-events: none;
}

#dropOverlay.on { display: flex; }

@media (max-width: 760px) {
    .main { grid-template-columns: 1fr; grid-template-rows: 40vh 1fr; }
    #panel { border-right: 0; border-bottom: 1px solid var(--line); }
    .midi { margin-left: 0; }
}
