/* Layout: one column. Upload and controls on top, then the playable score on a sheet of
   paper (kept light in dark mode, like real manuscript), then the photo and ABC side by side. */
:root {
  --bg: #f3efe7;
  --paper: #fffdf8;
  --sheet: #fffdf8;
  --sheet-ink: #1d1a16;
  --ink: #1d1a16;
  --muted: #6b6358;
  --rule: #ddd5c8;
  --accent: #8a3b2e;
  --accent-ink: #ffffff;
  --play: #c2410c;
  --warn: #9a6b00;
  --error: #b42318;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f; --paper: #1f1c17; --ink: #ece6dc; --muted: #a39a8c; --rule: #363129;
    --sheet: #f4efe4; --accent: #e08a74; --accent-ink: #1a0f0b; --warn: #e0b04a; --error: #ff7a6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15130f; --paper: #1f1c17; --ink: #ece6dc; --muted: #a39a8c; --rule: #363129;
  --sheet: #f4efe4; --accent: #e08a74; --accent-ink: #1a0f0b; --warn: #e0b04a; --error: #ff7a6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--font-body);
  padding-block: 24px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main { max-width: 980px; margin: 0 auto; display: grid; gap: 20px; }
header { display: grid; gap: 2px; }
h1 { margin: 0; font-size: 1.7rem; letter-spacing: -0.01em; }
.sub { margin: 0; color: var(--muted); }
h2 { margin: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.drop {
  display: grid; gap: 4px; justify-items: center; text-align: center;
  padding: 28px 16px; border: 2px dashed var(--rule); border-radius: 10px;
  background: var(--paper); cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop.has-file { border-style: solid; padding: 16px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-main { overflow-wrap: anywhere; }
.drop-sub { color: var(--muted); font-size: 0.9rem; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
button, select, input, textarea {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 6px; padding: 8px 14px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#read { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.busy #read { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .busy #read { animation: none; } }
.field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.92rem; }
.spacer { flex: 1; }

.status { margin: -8px 0 0; color: var(--muted); font-size: 0.95rem; }
.status.error { color: var(--error); font-weight: 700; }
progress { width: 100%; height: 6px; margin-top: -12px; accent-color: var(--accent); }
progress[hidden] { display: none; }
#readClaude { font-weight: 700; }
footer { font-size: 0.85rem; }
footer a, .note a { color: inherit; }
.note { color: var(--muted); margin: 0; font-size: 0.92rem; }

.card { background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 20px; display: grid; gap: 12px; min-width: 0; }
.card .head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.player-card { padding: 0; overflow: hidden; gap: 0; }
.player .abcjs-inline-audio { border-radius: 0; height: 40px; }
.player .abcjs-inline-audio .abcjs-btn { height: 40px; }
.player input { width: 3.4em; padding: 2px 4px; border-radius: 3px; font-size: 0.8rem; color: #1d1a16; background: #fff; }
.score { background: var(--sheet); color: var(--sheet-ink); padding: 16px; min-height: 180px; }
.score .note { color: #6b6358; }
.score svg { display: block; }
.score .playing { fill: var(--play); stroke: var(--play); }
.remark { margin: 0; padding: 10px 16px; border-top: 1px solid var(--rule); font-size: 0.92rem; }
.remark[data-confidence="medium"], .remark[data-confidence="low"] { color: var(--warn); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.preview img { display: block; max-width: 100%; max-height: 520px; margin: 0 auto; border-radius: 4px; }
textarea {
  width: 100%; min-height: 320px; resize: vertical;
  font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.5; white-space: pre; overflow-x: auto;
}

details.settings { color: var(--muted); }
details.settings summary { cursor: pointer; }
.settings .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.settings input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 0.85rem; }
