/* Sheet2Midi – no external fonts, light + dark. */
:root {
  --bg: #f6f5fb; --card: #ffffff; --ink: #1f2233; --muted: #646a82; --line: #e2e2ee;
  --brand: #4f46e5; --brand-ink: #ffffff; --brand-soft: #eeedfd;
  --good: #15803d; --ok: #b45309; --bad: #b91c1c;
  --good-soft: #dcfce7; --ok-soft: #fef3c7; --bad-soft: #fee2e2; --info-soft: #e0ecff; --info: #1d4ed8;
  --log-bg: #171a2b; --log-ink: #dfe3f4; --log-muted: #8f96b5;
  --radius: 14px; --shadow: 0 1px 2px rgba(25,25,70,.06), 0 6px 20px rgba(25,25,70,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131c; --card: #1c1e2c; --ink: #eceef8; --muted: #a0a6c0; --line: #30334a;
    --brand: #8b85f7; --brand-ink: #14142a; --brand-soft: #2a2a4a;
    --good: #4ade80; --ok: #fbbf24; --bad: #f87171;
    --good-soft: #143524; --ok-soft: #3d2f10; --bad-soft: #421c1f; --info-soft: #1b2b4d; --info: #93c5fd;
    --log-bg: #0d0e16; --shadow: none;
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
}
a { color: var(--brand); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .98rem; }
code { font-size: .9em; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 20px; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* header */
.site-header { padding: 26px 0 8px; }
.site-header h1 { font-size: 1.7rem; letter-spacing: -.01em; }
.logo { color: var(--brand); }
.lead { margin: 8px 0 4px; max-width: 72ch; }
.hint { margin: 0; color: var(--muted); font-size: .88rem; max-width: 72ch; }
.site-footer { padding-top: 12px; padding-bottom: 28px; }

/* cards + top */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.top-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; margin: 16px 0; align-items: start; }
.top-grid h2 { margin-bottom: 6px; }
.top-grid p { margin: 0 0 10px; }
.field-label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; padding: 0; }
select, input[type=password], input[type=text] {
  width: 100%; min-height: 44px; padding: 8px 12px; font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.example-info { margin-top: 8px; color: var(--muted); min-height: 1.3em; overflow-wrap: anywhere; }

/* upload */
.dropzone { border: 2px dashed var(--line); border-radius: 12px; transition: border-color .15s, background .15s; }
.dropzone.is-drag, .dropzone:hover { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--brand); }
.dropzone:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.dropzone-label { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px; text-align: center; cursor: pointer; }
.drop-icon { font-size: 1.5rem; }
.file-chosen { font-weight: 600; overflow-wrap: anywhere; }
fieldset.engines { border: 0; margin: 0; padding: 0; }
.engine-list { display: flex; flex-wrap: wrap; gap: 8px; }
.engine-option {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.engine-option input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.engine-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.engine-option.is-disabled { opacity: .6; cursor: not-allowed; }
#pin-note { margin: 4px 0 0; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

/* buttons, tags, badges */
.btn {
  display: inline-flex; align-items: center; gap: 4px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); padding: 10px 16px; min-height: 44px;
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-small { padding: 5px 11px; min-height: 36px; font-size: .85rem; font-weight: 500; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .75rem; font-weight: 600; }
.tag-muted { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; background: var(--line); color: var(--ink); }
.badge-queued { background: var(--info-soft); color: var(--info); }
.badge-running { background: var(--ok-soft); color: var(--ok); }
.badge-done { background: var(--good-soft); color: var(--good); }
.badge-failed { background: var(--bad-soft); color: var(--bad); }
.alert { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; font-size: .92rem; overflow-wrap: anywhere; }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--info-soft); color: var(--info); }

/* job */
.job { margin-bottom: 20px; outline: 0; }
.job-title-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.job-title-row h2 { font-size: 1.3rem; overflow-wrap: anywhere; min-width: 0; }
.job-meta { margin-top: 4px; overflow-wrap: anywhere; }
.log-details { margin-top: 10px; }
.log-details summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: 4px 0; }
.log {
  margin-top: 6px; height: 220px; overflow: auto; padding: 8px 10px; border-radius: 10px;
  background: var(--log-bg); color: var(--log-ink);
  font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
.log-line { display: flex; gap: 8px; align-items: baseline; }
.log-t { color: var(--log-muted); flex: 0 0 auto; min-width: 4.2em; text-align: right; font-variant-numeric: tabular-nums; }
.log-eng { flex: 0 0 auto; padding: 0 6px; border-radius: 5px; font-size: .9em; background: hsl(var(--h, 240) 55% 30%); color: hsl(var(--h, 240) 90% 90%); }
.log-eng-general { background: transparent; color: var(--log-muted); }
.log-msg { min-width: 0; overflow-wrap: anywhere; flex: 1; }
.log-empty { color: var(--log-muted); }

.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; margin-top: 16px; align-items: start; }
.split.compare { grid-template-columns: minmax(0, 3fr) minmax(0, 8fr); }
.source { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.source h2 { margin-bottom: 10px; }
.pdf-actions { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.pages { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 8px; }
.page { display: block; text-decoration: none; text-align: center; }
.page-img { position: relative; display: block; }
.follow-layer { position: absolute; inset: 0; pointer-events: none; }
/* a thin line, multiplied onto the page so the notes under it stay black and readable */
.follow-marker { position: absolute; display: none; width: 3px; margin-left: -1px; border-radius: 2px;
  background: rgba(225, 50, 60, .75); mix-blend-mode: multiply; box-shadow: 0 0 0 3px rgba(255, 196, 0, .25); }
.page img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* results */
.tempo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.tempo-row label { font-weight: 600; font-size: .92rem; }
.tempo-row input { width: 72px; padding: 6px 8px; font: inherit; text-align: center; border: 1px solid var(--line); border-radius: 8px; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; min-height: 28px; }
.compare-toggle { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; cursor: pointer; }
.results-empty { margin: 0; }
.compare-card { margin-bottom: 12px; }
.compare-card p { margin: 4px 0 8px; }
.table-scroll { overflow-x: auto; }
table.cmp { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
table.cmp th, table.cmp td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
table.cmp thead th { color: var(--muted); font-weight: 600; font-size: .82rem; }
table.cmp td.best { background: var(--good-soft); font-weight: 600; }
table.cmp tr.avg-row th, table.cmp tr.avg-row td { border-bottom: 0; font-weight: 700; }
.acc-p { font-weight: inherit; }
.reference { margin-top: 12px; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 10px; min-height: 44px;
}
.tab[aria-selected=true] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot-done { background: #22c55e; } .dot-failed { background: #ef4444; } .dot-running { background: #f59e0b; }
#results.compare .tabs { display: none; }
#results.compare .panels.multi { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.panels > .engine-panel + .engine-panel { margin-top: 0; }

.engine-title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.score-title { margin: 4px 0 0; font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { padding: 2px 9px; font-size: .8rem; border: 1px solid var(--line); border-radius: 999px; }
.chip-acc { background: var(--brand-soft); border-color: transparent; }
.working { display: flex; align-items: center; gap: 10px; margin: 12px 0 2px; }
.spinner { width: 18px; height: 18px; flex: 0 0 auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.full-score { margin-top: 12px; padding: 12px; background: var(--brand-soft); border-radius: 10px; }
.full-score h4 { margin-bottom: 6px; }
.parts { display: grid; gap: 10px; margin-top: 12px; }
.part { border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.part-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.part-name { font-size: 1.02rem; }
.part-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.part-acc { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px 16px; margin-top: 6px; }
.meter { display: grid; grid-template-columns: 50px 1fr 38px; gap: 6px; align-items: center; font-size: .8rem; }
.meter-label { color: var(--muted); }
.meter-bar { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; display: block; }
.meter-fill { display: block; height: 100%; background: var(--muted); border-radius: 99px; }
.meter.good .meter-fill { background: var(--good); }
.meter.ok .meter-fill { background: var(--ok); }
.meter.bad .meter-fill { background: var(--bad); }
.meter-val { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }
.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 12px; margin-top: 8px; }
.player-wrap { min-width: 0; }
.player-label { display: block; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.player-slot { min-height: 54px; }
midi-player { display: block; width: 100%; min-height: 48px; }
midi-player::part(control-panel) { background: var(--brand-soft); border-radius: 10px; }
midi-player::part(play-button) { background: var(--brand); color: var(--brand-ink); border: 0; }
.dl-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* layout breakpoints */
@media (max-width: 900px) {
  .top-grid, .split, .split.compare { grid-template-columns: minmax(0, 1fr); }
  /* phones and tablets: the score stays on screen at the top while you scroll to the players, so it can follow along */
  .source { position: sticky; top: 0; z-index: 5; max-height: 45vh; overflow: auto; box-shadow: 0 6px 16px rgba(0, 0, 0, .12); }
  .compare-toggle { display: none; }
  #results.compare .tabs { display: flex; }
  #results.compare .panels.multi { display: block; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 12px; }
  .card { padding: 14px; }
  .site-header { padding-top: 16px; }
  .site-header h1 { font-size: 1.45rem; }
  .players { grid-template-columns: minmax(0, 1fr); }
  .log { height: 180px; }
  .log-line { flex-wrap: wrap; column-gap: 6px; }
  .log-msg { flex-basis: 100%; }
}
