:root {
  --bg: #101218;
  --panel: #1a1e28;
  --text: #f2efe8;
  --muted: #9aa3b2;
  --accent: #e8c56a;
  --danger: #e86a6a;
  --paper: #f3eee3;
  --ink: #1c1820;
  --border: #2c3340;
  --playhead: #ff4d6d;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
}

.cal-app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.cal-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-family: Georgia, "Iowan Old Style", serif;
}

.hint {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.hint kbd {
  background: #2a3140;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.78rem;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

.cal-main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr min(340px, 38vw);
}

.score-pane {
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  -webkit-overflow-scrolling: touch;
}

.paper {
  padding: 0.5rem 0.35rem 2rem;
}

.paper svg {
  max-width: 100%;
  display: block;
}

.paper svg .abcjs-cursor {
  stroke: var(--playhead);
  stroke-width: 2.5;
}

/* Suppress playback note-head paint in the editor — mark bars are the cue */
.paper svg .note-active {
  fill: inherit !important;
  stroke: inherit !important;
  opacity: 1 !important;
}

.paper svg .abcjs-note {
  cursor: pointer;
}

.paper svg .cal-selected {
  fill: #2a6fd6 !important;
  stroke: #2a6fd6 !important;
  filter: drop-shadow(0 0 3px rgba(42, 111, 214, 0.8));
}

.paper svg .cal-mark-bar,
.paper svg .cal-mark-hit {
  pointer-events: stroke;
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--panel);
}

.transport {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.row.times {
  display: grid;
  grid-template-columns: 2.4rem 1fr 2.4rem;
}

.row.times span {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

#scrubber {
  width: 100%;
  accent-color: var(--accent);
}

.row.buttons {
  justify-content: center;
}

.row.mark {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.mark-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
}

.row.nudge {
  flex-wrap: wrap;
  gap: 0.35rem;
}

.nudge-label {
  width: 100%;
  font-size: 0.72rem;
  color: var(--muted);
}

.selected {
  font-size: 0.85rem;
  color: var(--accent);
  min-height: 1.2em;
}

button {
  appearance: none;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #242a36;
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.play {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1200;
  border: none;
  font-size: 1rem;
}

button.primary {
  background: var(--accent);
  color: #1a1200;
  border-color: var(--accent);
}

button.ghost {
  background: transparent;
}

button.danger {
  color: var(--danger);
  border-color: rgba(232, 106, 106, 0.4);
  background: transparent;
}

.status {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.list-head {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.anchor-list {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
  padding: 0.35rem;
}

.anchor-row {
  display: grid;
  grid-template-columns: 4.8rem 1fr auto auto;
  gap: 0.35rem 0.45rem;
  align-items: center;
  padding: 0.45rem 0.4rem;
  border-radius: 8px;
  margin-bottom: 0.3rem;
  background: #12151c;
  cursor: pointer;
}

.anchor-row.active {
  outline: 1px solid var(--accent);
  background: #1c2230;
}

.anchor-row .stamp {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--accent);
}

.anchor-row .score-pos {
  font-size: 0.8rem;
}

.anchor-row .dim {
  color: var(--muted);
  font-weight: 400;
}

.anchor-row .row-nudge {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.anchor-row .row-nudge input {
  width: 4.2rem;
  background: #242a36;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.25rem 0.3rem;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.anchor-row button.tiny {
  padding: 0.2rem 0.4rem;
  min-width: 1.6rem;
  font-size: 0.75rem;
}

.anchor-row .del {
  padding: 0.3rem 0.45rem;
  font-size: 0.75rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

.actions .primary {
  grid-column: 1 / -1;
}

.foot {
  margin: 0;
  padding: 0 0.75rem 0.75rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.foot code {
  font-size: 0.68rem;
  color: var(--accent);
}

@media (max-width: 800px) {
  .cal-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .side {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 45vh;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .cal-header { padding: 0.35rem 0.75rem; }
  .cal-header .hint { display: none; }
}
