@font-face {
    font-family: "BMW1";
    src: url("../fonts/BMW1__.TTF") format("truetype");
}

@font-face {
    font-family: "BMW2";
    src: url("../fonts/BMW2__.TTF") format("truetype");
}

@font-face {
    font-family: "BMW3";
    src: url("../fonts/BMW3__.TTF") format("truetype");
}

@font-face {
    font-family: "BMW4";
    src: url("../fonts/BMW4__.TTF") format("truetype");
}

@font-face {
    font-family: "BMW5";
    src: url("../fonts/BMW5__.TTF") format("truetype");
}

@font-face {
    font-family: "BMW6";
    src: url("../fonts/BMW6__.TTF") format("truetype");
}

@font-face {
    font-family: "BMW7";
    src: url("../fonts/BMW7__.TTF") format("truetype");
}

@font-face {
    font-family: "BMW8";
    src: url("../fonts/BMW8__.TTF") format("truetype");
}

:root {
    --paper: #f6f0df;
    --paper-shadow: rgba(92, 59, 23, 0.18);
    --ink: #221915;
    --muted: #685745;
    --accent: #8f3d1f;
    --accent-strong: #672910;
    --panel: rgba(255, 248, 235, 0.88);
    --bg-top: #d9d0b5;
    --bg-bottom: #baac87;
    --success: #1e6a46;
    --warning: #9a6a00;
    --warning-bg: rgba(246, 214, 93, 0.18);
    --danger: #8a3517;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    min-height: 100%;
    color: var(--ink);
    font-family: "Book Antiqua", "Palatino Linotype", "Georgia", serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.35), transparent 28%),
        linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select,
input[type="number"],
input[type="file"],
textarea {
    border: 1px solid rgba(66, 46, 26, 0.26);
    border-radius: 12px;
    background: rgba(255, 251, 244, 0.94);
    color: var(--ink);
}

button {
    cursor: pointer;
    padding: 0.72rem 1rem;
    background: linear-gradient(180deg, #a94925, #7a3015);
    color: #fff6ec;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: transform 140ms ease, filter 140ms ease;
}

button:hover,
button:focus-visible {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

button.secondary {
    background: linear-gradient(180deg, #eadfc5, #d9c7a0);
    color: var(--ink);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
}

input[type="range"] {
    padding: 0;
    accent-color: var(--accent);
}

.app-shell {
    display: grid;
    grid-template-columns: minmax(320px, 380px) 1fr;
    height: 100vh;
    overflow: hidden;
}

.control-panel {
    padding: 1.5rem;
    border-right: 1px solid rgba(60, 43, 27, 0.15);
    overflow: auto;
    background:
        linear-gradient(180deg, rgba(255, 248, 236, 0.92), rgba(242, 231, 207, 0.9)),
        repeating-linear-gradient(
            0deg,
            rgba(106, 75, 46, 0.05),
            rgba(106, 75, 46, 0.05) 1px,
            transparent 1px,
            transparent 14px
        );
}

.panel-block {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 22px;
    background: var(--panel);
    box-shadow: 0 10px 24px var(--paper-shadow);
    backdrop-filter: blur(5px);
}

.brand-block {
    background:
        linear-gradient(140deg, rgba(255, 253, 246, 0.98), rgba(247, 233, 205, 0.92)),
        radial-gradient(circle at top right, rgba(143, 61, 31, 0.16), transparent 30%);
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.brand-block h1,
.sheet-toolbar h2,
.editor-header h2,
.panel-block h2 {
    margin: 0.25rem 0 0.4rem;
    font-family: "Palatino Linotype", "Book Antiqua", serif;
}

.brand-subtitle {
    margin: -0.1rem 0 0.45rem;
    color: var(--muted);
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.lede,
.sheet-meta,
.editor-header p,
.status-block p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.field-label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.inline-controls,
.transport-row,
.field-grid,
.badge-row {
    display: grid;
    gap: 0.75rem;
}

.inline-controls {
    grid-template-columns: 1fr auto;
}

.transport-row {
    grid-template-columns: repeat(3, 1fr);
}

.field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.voice-grid {
    display: grid;
    gap: 0.85rem;
}

.stacked-buttons {
    display: grid;
    gap: 0.75rem;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.85rem;
    color: var(--muted);
    font-weight: 700;
}

.toggle input {
    width: auto;
    margin: 0;
}

.loop-selection-row {
    margin-top: 0.75rem;
}

.loop-selection-status {
    margin: 0.6rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.4;
}

.warning-list {
    margin: 0.75rem 0 0;
    padding-left: 1.2rem;
    color: var(--warning);
    background: var(--warning-bg);
    border: 1px solid rgba(154, 106, 0, 0.24);
    border-radius: 0.75rem;
    padding: 0.8rem 1rem 0.8rem 2rem;
}

.workspace {
    --editor-pane-height: 25vh;
    --splitter-size: 16px;
    display: grid;
    grid-template-rows: minmax(260px, 1fr) var(--splitter-size) minmax(220px, var(--editor-pane-height));
    gap: 0;
    min-height: 0;
    padding: 1.5rem;
    overflow: hidden;
}

.sheet-panel,
.editor-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 28px;
    background: rgba(255, 248, 234, 0.88);
    box-shadow: 0 16px 40px rgba(70, 45, 25, 0.16);
    overflow: hidden;
}

.sheet-panel {
    margin-bottom: 0.7rem;
}

.editor-panel {
    margin-top: 0.7rem;
}

.pane-splitter {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: row-resize;
    touch-action: none;
}

.pane-splitter::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: rgba(85, 58, 31, 0.18);
    transform: translateY(-50%);
}

.pane-splitter-handle {
    position: relative;
    z-index: 1;
    width: 64px;
    height: 8px;
    border-radius: 999px;
    border: 1px solid rgba(84, 57, 31, 0.18);
    background: linear-gradient(180deg, rgba(255, 252, 245, 0.94), rgba(230, 216, 186, 0.92));
    box-shadow: 0 4px 12px rgba(70, 45, 25, 0.12);
}

.pane-splitter:hover .pane-splitter-handle,
.pane-splitter:focus-visible .pane-splitter-handle {
    background: linear-gradient(180deg, rgba(255, 252, 245, 0.98), rgba(220, 199, 154, 0.96));
}

body.is-resizing {
    cursor: row-resize;
    user-select: none;
}

.sheet-toolbar,
.editor-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 1.4rem;
    border-bottom: 1px solid rgba(76, 51, 27, 0.12);
    background: linear-gradient(180deg, rgba(255, 252, 246, 0.95), rgba(248, 239, 220, 0.9));
}

.sheet-type {
    margin: 0;
    color: var(--accent);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.badge-row {
    grid-auto-flow: row;
}

.sheet-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.4rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid rgba(88, 58, 31, 0.18);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 253, 248, 0.92);
    white-space: nowrap;
}

.score-scroll {
    flex: 1;
    overflow: auto;
    padding: 1.35rem;
}

.score-root {
    position: relative;
    min-height: 100%;
    padding: 1.4rem;
    max-width: 1220px;
    margin: 0 auto;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 251, 240, 0.94)),
        var(--paper);
    box-shadow: inset 0 0 0 1px rgba(81, 52, 24, 0.08);
    transform-origin: top left;
}

.score-meta-block {
    margin: 0 0 1rem;
    color: #2a1f18;
}

.score-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1.6fr 1fr;
    align-items: end;
    gap: 1rem;
    margin-bottom: 0.45rem;
}

.score-meta-item {
    min-height: 1.2em;
    color: #2a1f18;
}

.score-meta-title {
    line-height: 1.12;
}

.score-meta-rhythm,
.score-meta-composer {
    font-style: italic;
}

.score-tempo-mark {
    margin-left: 4.4rem;
    color: #2a1f18;
    font-family: "Times New Roman", serif;
    font-size: 14pt;
    font-weight: 700;
    line-height: 1.1;
}

.score-text-layer {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
}

.score-staff-text,
.score-footer-text {
    position: absolute;
    color: #2a1f18;
    font-family: "Baskerville Old Face", "Times New Roman", serif;
    line-height: 1.15;
    white-space: nowrap;
}

.score-staff-text {
    font-size: 0.9rem;
    margin: 0;
}

.score-inline-block {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    margin: 0 0 0.22rem;
}

.score-inline-text {
    color: #2a1f18;
    line-height: 1.15;
    white-space: normal;
}

.score-footer-text {
    left: 18px;
    right: 18px;
    bottom: 12px;
    font-size: 0.88rem;
}

.align-l {
    text-align: left;
}

.align-c {
    text-align: center;
}

.align-r {
    text-align: right;
}

.playback-cursor-dot {
    position: absolute;
    z-index: 40;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2f7df6;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 2px 10px rgba(47, 125, 246, 0.35);
    pointer-events: none;
    transition: left 0.06s linear;
}

.score-empty {
    padding: 3rem 1rem;
    color: var(--muted);
    text-align: center;
}

.score-system {
    margin-bottom: 1.6rem;
}

.abc-score {
    display: grid;
    gap: 0.9rem;
}

.abc-score .abcjs-container {
    display: block;
    width: 100%;
}

.abc-score svg {
    display: block;
    width: 100%;
    height: auto;
}

.abc-score .abcjs-note_selected,
.abc-score .abcjs-note.abcjs-note_selected,
.abc-score .abcjs-note_selected path,
.abc-score .abcjs-note_selected ellipse,
.abc-score .abcjs-note.abcjs-highlight,
.abc-score .abcjs-note.abcjs-highlight path,
.abc-score .abcjs-note.abcjs-highlight ellipse,
.abc-score .abcjs-bar.abcjs-highlight path {
    fill: var(--ink) !important;
    stroke: var(--ink) !important;
}

.abc-score .abcjs-note.abcjs-loop-selected,
.abc-score .abcjs-note.abcjs-loop-selected path,
.abc-score .abcjs-note.abcjs-loop-selected ellipse {
    fill: #c32020 !important;
    stroke: #c32020 !important;
}

.system-header {
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-weight: 700;
}

.notation-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.09rem;
    min-height: calc(var(--token-height) + (var(--row-pad-y) * 2) + 6px);
    padding: var(--row-pad-y) 0.14rem;
    margin-bottom: 0.18rem;
    border-radius: 16px;
    overflow: hidden;
}

.notation-svg-row {
    display: block;
    min-height: auto;
    padding: 0;
    overflow: visible;
}

.notation-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.notation-svg .notation-glyph.active {
    fill: var(--accent-strong);
}

.notation-svg .notation-melody-glyph {
    color: #17120e;
}

.notation-svg .notation-melody-glyph.active {
    color: var(--accent-strong);
}

.notation-svg .notation-bar-glyph.active line,
.notation-svg .notation-bar-glyph.active circle {
    stroke: var(--accent-strong);
    fill: var(--accent-strong);
}

.notation-token,
.notation-gap {
    position: relative;
    z-index: 1;
}

.notation-prefix,
.notation-measures,
.notation-measure,
.measure-body,
.measure-group {
    position: relative;
    z-index: 1;
}

.notation-prefix {
    display: flex;
    align-items: flex-start;
    gap: 0;
    flex: 0 0 auto;
    min-width: 3.05rem;
    padding-left: 0;
}

.notation-measures {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.notation-measure {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    min-width: 0;
    padding: 0 0.06rem 0 0.03rem;
    flex: 1 1 0;
}

.notation-measure.pickup {
    flex: 0 0 auto;
    min-width: 0.72rem;
}

.measure-body {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.12rem;
    flex: 1 1 auto;
    min-width: 0;
}

.measure-group {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.03rem;
    min-width: 0;
    flex: 1 1 0;
}

.notation-measure.pickup .measure-group {
    flex: 0 0 auto;
}

.staff-lines {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--row-pad-y) + 20px);
    height: var(--staff-height);
    display: grid;
    grid-template-rows: repeat(5, 1fr);
    pointer-events: none;
    z-index: 0;
}

.staff-line {
    display: block;
    border-top: 1px solid rgba(54, 37, 22, 0.52);
}

.notation-token {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0.56em;
    height: var(--token-height);
    font-size: var(--note-size);
    color: #17120e;
    line-height: 1;
    text-rendering: geometricPrecision;
    vertical-align: middle;
}

.notation-token.unknown {
    min-width: auto;
    padding: 0 0.3rem;
    font-size: 0.85rem;
    border-radius: 8px;
    color: var(--warning);
    background: rgba(255, 228, 213, 0.9);
}

.notation-token.active {
    color: var(--accent-strong);
    text-shadow: 0 0 10px rgba(169, 73, 37, 0.3);
    filter: drop-shadow(0 2px 3px rgba(169, 73, 37, 0.18));
}

.notation-token.token-clef {
    min-width: 0.98em;
    height: calc(var(--staff-height) + 18px);
    font-size: var(--clef-size);
    margin-right: -0.1rem;
    transform: translateY(8px);
}

.notation-token.token-accidental {
    min-width: 0.22em;
    font-size: var(--accidental-size);
    margin-right: -0.2rem;
    transform: translateY(-1px);
}

.notation-token.token-time {
    min-width: 0.3em;
    font-size: var(--time-size);
    margin-left: -0.04rem;
    margin-right: -0.04rem;
    transform: translateY(1px);
}

.notation-token.token-section {
    min-width: 0.38em;
    margin-left: 0.04rem;
    margin-right: 0.08rem;
}

.notation-token.token-ornament {
    min-width: 0.26em;
    font-size: var(--ornament-size);
    margin-right: -0.03rem;
    margin-left: 0;
    transform: translateY(-20px);
}

.notation-token.token-melody,
.notation-token.token-generic {
    font-size: var(--note-size);
    transform: translateY(-14px);
}

.notation-bar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.05rem;
    height: var(--staff-height);
    margin-left: 0;
    margin-right: 0;
    z-index: 1;
    transform: translateY(20px);
}

.notation-bar-lines {
    display: inline-flex;
    align-items: stretch;
    height: 100%;
    gap: 0.06rem;
}

.notation-bar-line {
    display: block;
    height: 100%;
    background: #17120e;
}

.notation-bar-line.thin {
    width: 1px;
}

.notation-bar-line.thick {
    width: 4px;
}

.notation-bar-dots {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: calc(var(--staff-gap) - 1px);
    height: 100%;
}

.notation-bar-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #17120e;
}

.notation-gap {
    display: inline-block;
    flex: 0 0 auto;
    height: 1px;
    max-width: 1.6rem;
}

.font-1 { font-family: "BMW1", serif; }
.font-2 { font-family: "BMW2", serif; }
.font-3 { font-family: "BMW3", serif; }
.font-4 { font-family: "BMW4", serif; }
.font-5 { font-family: "BMW5", serif; }
.font-6 { font-family: "BMW6", serif; }
.font-7 { font-family: "BMW7", serif; }
.font-8 { font-family: "BMW8", serif; }

.editor-panel textarea {
    flex: 1;
    min-height: 0;
    padding: 1rem 1.15rem;
    border: 0;
    border-radius: 0;
    background:
        linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(247, 239, 220, 0.92));
    color: #2a1f18;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 0.95rem;
    line-height: 1.45;
    resize: none;
}

.status-ok {
    color: var(--success);
}

.status-error {
    color: var(--danger);
}

.status-warning {
    color: var(--warning);
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .workspace {
        grid-template-rows: auto auto auto;
        overflow: visible;
    }

    .badge-row {
        grid-auto-flow: column;
    }

    .pane-splitter {
        display: none;
    }

    .sheet-panel,
    .editor-panel {
        margin: 0;
    }
}

@media (max-width: 720px) {
    .control-panel,
    .workspace {
        padding: 1rem;
    }

    .transport-row,
    .field-grid,
    .inline-controls {
        grid-template-columns: 1fr;
    }

    .sheet-toolbar,
    .editor-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .badge-row {
        grid-auto-flow: row;
        width: 100%;
    }

    .workspace {
        grid-template-rows: auto auto auto;
    }

    .pane-splitter {
        display: none;
    }

    .sheet-panel,
    .editor-panel {
        margin: 0;
    }
}

@media print {
    @page {
        margin: 0.5in;
    }

    body {
        background: #fff;
    }

    .app-shell {
        display: block;
        height: auto;
        overflow: visible;
    }

    .control-panel,
    .editor-panel,
    .pane-splitter {
        display: none;
    }

    .workspace {
        display: block;
        padding: 0;
    }

    .sheet-panel {
        box-shadow: none;
        border-radius: 0;
        background: #fff;
    }

    .sheet-toolbar,
    .playback-cursor-dot {
        display: none !important;
    }

    .score-scroll {
        overflow: visible;
        padding: 0;
    }

    .score-root {
        padding: 0;
        box-shadow: none;
        background: #fff;
        transform: none !important;
        width: auto !important;
    }

    .score-meta-block {
        margin-bottom: 0.75rem;
    }

    .score-text-layer {
        inset: 0;
    }

    .abc-score .abcjs-author,
    .abc-score .abcjs-origin,
    .abc-score .abcjs-part-order,
    .abc-score .abcjs-meta-bottom,
    .abc-score .abcjs-bottom-text {
        display: none !important;
    }
}
