@font-face {
  font-family: Bravura;
  src: url("./assets/bravura.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #132435;
  --muted: #4a5d6e;
  --line: #d7e1e9;
  --surface: #fff;
  --ground: #f1f5f8;
  --accent: #ffba68;
  --strong-accent: #9c3d12;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ground);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 290px; }
button, select, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid #377297;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }

.wrap { width: min(1200px, calc(100% - 64px)); margin-inline: auto; }
.masthead { color: #fff; background: #102336; border-bottom: 1px solid #294052; padding-top: env(safe-area-inset-top); }
.mast-inner { display: flex; justify-content: space-between; align-items: center; min-height: 65px; gap: 12px; }
.brand { display: inline-flex; gap: 11px; align-items: center; color: #fff; text-decoration: none; font-size: 1.26rem; font-weight: 720; letter-spacing: -.025em; }
.brand-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 9px; color: #231c13; background: var(--accent); font-size: 1.33rem; }
.account { display: inline-flex; align-items: center; gap: 14px; }
.local { color: #d6e4ee; font-size: .875rem; display: inline-flex; align-items: center; gap: 7px; }
.local span { width: 7px; height: 7px; border-radius: 50%; background: #9dddb9; }
.logout { min-height: 36px; padding-inline: 10px; border: 1px solid #3b5468; border-radius: 8px; background: transparent; color: #d6e4ee; font-size: .875rem; font-weight: 600; }
.logout:hover { background: #1b344a; }

.intro { padding-block: 36px 29px; }
.intro h1 { font-size: clamp(1.95rem, 3.9vw, 3rem); line-height: 1.1; letter-spacing: -.042em; font-weight: 770; }
.intro p { margin-top: 10px; color: var(--muted); line-height: 1.55; }
.layout { display: grid; grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); align-items: start; gap: 21px; }
.controls { display: grid; gap: 17px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 2px 6px #19344a07; overflow: hidden; }
.input-panel, .clef-panel { padding: 18px; }
h2 { font-size: 1.075rem; line-height: 1.35; letter-spacing: -.015em; }
.muted { font-size: .875rem; color: var(--muted); line-height: 1.45; }
.drop-area { position: relative; display: grid; gap: 7px; justify-items: center; text-align: center; border: 1px dashed #8ca2b4; border-radius: 12px; background: #f7fafc; padding: 18px 10px 14px; margin-block: 14px 11px; }
.drop-area:hover, .drop-area.dragging { background: #eaf3fa; border-color: #487491; }
.drop-area:focus-within { outline: 3px solid #377297; outline-offset: 2px; }
.file-icon { display: inline-block; width: 20px; height: 24px; border: 1.5px solid #55738a; border-radius: 4px; background: linear-gradient(#829bae,#829bae) center 9px / 8px 1.5px no-repeat, linear-gradient(#829bae,#829bae) center 14px / 8px 1.5px no-repeat; }
.file-label { font-weight: 700; }
#file { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
#file:disabled { cursor: default; }
.drop-note { font-size: .78rem; }
.selected-file { font-size: .875rem; font-weight: 600; overflow-wrap: anywhere; margin-block: 12px 4px; }
.sample, .page-button { min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding-inline: 9px; font-size: .875rem; font-weight: 670; }
.sample:hover:enabled, .page-button:hover:enabled { background: #edf4fa; }
.pages { display: flex; min-height: 42px; gap: 12px; align-items: center; justify-content: space-between; font-size: .875rem; margin-bottom: 8px; }
.page-button { font-size: 1.35rem; min-width: 44px; }
button:disabled { opacity: .48; }
.primary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 47px; font-weight: 740; background: var(--accent); border: 1px solid #eba960; border-radius: 10px; color: #301f12; }
.primary:hover:enabled { background: #ffae4d; }
.status, .error { font-size: .875rem; line-height: 1.4; overflow-wrap: anywhere; }
.status { color: #36536b; font-weight: 630; }
.error { margin-top: 10px; color: #a32622; }
.progress { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #f2f7fb; border: 1px solid var(--line); }
.progress .muted { margin-top: 2px; font-size: .8rem; }
.spinner { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 2.5px solid #c8d7e3; border-top-color: var(--strong-accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.field { display: grid; gap: 5px; margin-top: 12px; }
.field label { font-size: .875rem; font-weight: 630; }
.field select, .field input { width: 100%; min-height: 42px; padding: 7px 10px; color: var(--ink); border: 1px solid #b1c2d0; border-radius: 8px; background: #f8fafc; font-size: 1rem; }
.field select { padding-right: 34px; appearance: none; background: linear-gradient(45deg, transparent 50%, #496579 50%) right 16px center / 5px 5px no-repeat, linear-gradient(135deg, #496579 50%, transparent 50%) right 11px center / 5px 5px no-repeat, #f8fafc; }
.clef-panel p { margin-top: 13px; }

.login-panel { max-width: 420px; padding: 22px; margin-bottom: 21px; }
.login-panel .muted { margin-top: 6px; }
.login-panel .primary { margin-top: 18px; }

.workspace-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 21px; background: #fff; }
.workspace-header .muted { margin-top: 3px; }
.view-switch { display: inline-flex; flex: none; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #eef4f7; }
.view-switch button { border: 0; background: transparent; padding: 7px 10px; min-height: 36px; border-radius: 7px; font-size: .875rem; font-weight: 680; }
.view-switch button[aria-pressed="true"] { background: #fff; box-shadow: 0 1px 3px #19344a22; }
.empty { min-height: 400px; display: grid; place-content: center; justify-items: center; text-align: center; padding: 25px; border-block: 1px solid var(--line); background: #f8fbfd; }
.empty p:first-of-type { margin: 10px 0 6px; font-weight: 700; }
.empty-staff { position: relative; width: 200px; height: 78px; color: #6a869d; background: repeating-linear-gradient(to bottom, #b4c6d4 0 1px, transparent 1px 11px) left center / 100% 45px no-repeat; }
.empty-staff span { position: absolute; font: 45px Bravura; }
.empty-staff span:nth-child(1) { left: 16px; top: 28px; }
.empty-staff span:nth-child(2) { left: 67px; top: 29px; }
.empty-staff span:nth-child(3) { left: 112px; top: 18px; }
.empty-staff span:nth-child(4) { left: 154px; top: 12px; color: #9d501e; }
.source-panel { position: relative; line-height: 0; border-block: 1px solid var(--line); }
#source-canvas { display: block; width: 100%; height: auto; }
.result-panel { padding: 15px 20px; border-block: 1px solid var(--line); }
details { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
summary { cursor: pointer; font-size: .875rem; }
.workspace-footer { color: #4d6172; font-size: .875rem; padding: 13px 20px; line-height: 1.5; }
.footer { padding: 18px 0 22px; color: var(--muted); font-size: .875rem; line-height: 1.5; padding-bottom: max(22px, env(safe-area-inset-bottom)); }

@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }
  .layout { grid-template-columns: 1fr; gap: 15px; }
  .intro { padding-block: 26px 19px; }
  .mast-inner { min-height: 57px; }
  .local { display: none; }
  .controls { gap: 12px; }
  .empty { min-height: 235px; }
  .workspace-header { padding: 13px; }
  .workspace-footer, .result-panel { padding-inline: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .spinner { animation-duration: 3s; }
}

.cancel { margin-top: 8px; width: 100%; }
#score img { display: block; width: 100%; height: auto; margin: 0 0 8px; }
.output-actions { display: flex; flex-wrap: wrap; gap: 7px; padding-block: 8px; }
#rhythms { display: flex; flex-wrap: wrap; gap: 6px 26px; padding-left: 19px; font-size: .875rem; line-height: 1.5; }
#engraving-status { margin-top: 12px; }

@media print {
  html, body, :root { background: white; }
  .masthead, .intro, .controls, .workspace-header, .workspace-footer, .footer, .login-panel,
  .output-actions, #rhythm-list, #engraving-status { display: none !important; }
  .wrap { width: 100%; margin: 0; }
  .layout, .workspace, .result-panel { display: block; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  #score img { display: block; width: 100%; max-height: 270mm; object-fit: contain; break-inside: avoid; }
  #score img:not(:last-child) { break-after: page; }
}

.contrast-option { display: flex; align-items: center; gap: .45rem; min-height: 36px; margin-bottom: 5px; font-size: .875rem; }
.contrast-option input { width: 1.1rem; height: 1.1rem; accent-color: #9c3d12; }
