:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-raised: #151a22;
  --bg-sunken: #0a0d12;
  --bg-code: #10141b;
  --border: #262d38;
  --border-strong: #38414f;
  --text: #e6ebf2;
  --text-dim: #9aa6b6;
  --text-faint: #6b7787;
  --accent: #7dd3a0;
  --accent-dim: #2f6b4c;
  --warn: #e6b455;
  --error: #f0776c;
  --info: #74b6f0;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code,
kbd,
pre,
textarea {
  font-family: var(--mono);
}

/* ------------------------------------------------------------------ header */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #121822, var(--bg));
}

.identity {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.mark {
  font-size: 30px;
  line-height: 1;
  color: var(--accent);
  margin-top: 2px;
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--text-dim);
  max-width: 74ch;
  font-size: 13px;
}

.topbar code {
  font-size: 12px;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  background: var(--bg-raised);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}

.badge.ok::before {
  background: var(--accent);
}
.badge.no::before {
  background: var(--error);
}
.badge.warn::before {
  background: var(--warn);
}

/* ------------------------------------------------------------------ layout */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(340px, 42fr) minmax(360px, 58fr);
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: #12161d;
  min-height: 44px;
}

.panel-head h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-faint);
}

select {
  background: var(--bg-sunken);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12.5px;
  font-family: var(--sans);
  max-width: 22ch;
}

/* ----------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.formats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.formats label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

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

.buttons {
  display: flex;
  gap: 8px;
}

button {
  font: inherit;
  font-size: 12.5px;
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-sunken);
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent-dim);
  background: #1a212b;
}

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

button.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #eafff2;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

button.primary:hover:not(:disabled) {
  background: #3a805c;
}

button kbd {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  opacity: 0.75;
}

/* ------------------------------------------------------------------ editor */

textarea {
  flex: 1;
  min-height: 220px;
  resize: none;
  border: 0;
  outline: none;
  background: var(--bg-code);
  color: var(--text);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
}

.statusbar {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  background: #12161d;
}

.status {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

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

.progress {
  height: 3px;
  border-radius: 2px;
  background: var(--bg-sunken);
  overflow: hidden;
  margin-bottom: 7px;
}

.progress .bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s linear;
}

.progress.indeterminate .bar {
  width: 35%;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(320%);
  }
}

/* ------------------------------------------------------------------ output */

.tabs {
  display: flex;
  gap: 2px;
}

.tabs button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.tabs button:hover:not(:disabled) {
  background: #1a212b;
  border: 0;
}

.tabs button.active {
  background: var(--bg-sunken);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.timing {
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.panes {
  flex: 1;
  position: relative;
  min-height: 0;
}

.pane {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: none;
}

.pane.active {
  display: block;
}

.pane[data-pane="result"] {
  background: #eef1f5;
  padding: 14px;
}

.pane[data-pane="log"],
.pane[data-pane="files"],
.pane[data-pane="diag"] {
  background: var(--bg-code);
  padding: 14px;
}

.empty {
  color: #4a5568;
  max-width: 60ch;
  margin: 6vh auto;
  text-align: center;
}

.empty .hint {
  font-size: 12px;
  color: #6b7787;
  line-height: 1.6;
}

.empty code {
  font-size: 11.5px;
  background: #dfe4ea;
  border-radius: 3px;
  padding: 0 3px;
}

/* rendered pages */

.page {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), 0 8px 24px rgba(0, 0, 0, 0.1);
  margin: 0 auto 16px;
  padding: 10px;
  max-width: 100%;
}

.page img,
.page embed,
.page iframe {
  display: block;
  width: 100%;
  border: 0;
  background: #fff;
}

.page.pdf embed,
.page.pdf iframe {
  height: 78vh;
}

.page .caption {
  font-family: var(--mono);
  font-size: 11px;
  color: #7a8698;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 6px;
}

.page .caption a {
  color: #2f6b4c;
  text-decoration: none;
  font-weight: 600;
}

.page .caption a:hover {
  text-decoration: underline;
}

/* midi player */

.player {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 2px;
}

.player-summary {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #5c6879;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

button.small {
  font-size: 12px;
  padding: 5px 10px;
}

button.primary.small {
  padding: 5px 12px;
}

/* the play control is the point of the audio card, so make it unmissable */
button.play {
  font-size: 13.5px;
  font-weight: 650;
  padding: 9px 20px;
  letter-spacing: 0.01em;
}

.page.audio {
  box-shadow: 0 0 0 2px var(--accent-dim), 0 1px 3px rgba(0, 0, 0, 0.18), 0 8px 24px rgba(0, 0, 0, 0.1);
}

.scrub {
  flex: 1;
  min-width: 140px;
  accent-color: var(--accent-dim);
}

.player-time {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #5c6879;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* keyboard */

.keyboard {
  position: relative;
  height: 78px;
  margin-top: 2px;
  border-radius: 8px;
  overflow: hidden;
  background: #0b0e13;
  box-shadow: inset 0 0 0 1px var(--border);
}

.keyboard-whites {
  display: flex;
  height: 100%;
}

.key {
  position: relative;
}

.key.white {
  flex: 1;
  background: linear-gradient(180deg, #fdfefe, #dde3ea);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.16), inset 0 -3px 0 rgba(0, 0, 0, 0.1);
  transition: background 0.05s linear;
}

.key.white.on {
  background: linear-gradient(180deg, #d8efe1, #7dd3a0);
}

.key.black {
  position: absolute;
  top: 0;
  height: 62%;
  background: linear-gradient(180deg, #313945, #0a0d11);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 2;
  transition: background 0.05s linear;
}

.key.black.on {
  background: linear-gradient(180deg, #57996f, #2f6b4c);
}

.key-label {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 8.5px;
  color: #8b95a4;
  pointer-events: none;
}

.caption-note {
  font-family: var(--mono);
  font-size: 11px;
  color: #7a8698;
}

.player-detail {
  font-size: 12px;
  color: #5c6879;
}

.player-detail summary {
  cursor: pointer;
  color: #2f6b4c;
  font-weight: 600;
}

.player-detail p {
  margin: 6px 0 0;
  line-height: 1.6;
}

.note button {
  margin-top: 8px;
}

/* log */

.log {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
}

.log .stdout {
  color: var(--text-dim);
}
.log .stderr {
  color: var(--warn);
}
.log .error {
  color: var(--error);
}
.log .meta {
  color: var(--text-faint);
}

/* files */

.files table,
.diag table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.files th,
.files td,
.diag th,
.diag td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.files th,
.diag th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.files td.num,
.diag td.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  white-space: nowrap;
}

.files a {
  color: var(--accent);
  text-decoration: none;
}

.files a:hover {
  text-decoration: underline;
}

.diag h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin: 18px 0 6px;
}

.diag h3:first-child {
  margin-top: 0;
}

.diag pre {
  margin: 0;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 12px;
  overflow-x: auto;
  color: var(--text-dim);
}

.note {
  border-left: 2px solid var(--info);
  background: rgba(116, 182, 240, 0.07);
  padding: 9px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 12px 0 0;
}

.note.error {
  border-color: var(--error);
  background: rgba(240, 119, 108, 0.08);
  color: #f3b7b1;
}

.note.warn {
  border-color: var(--warn);
  background: rgba(230, 180, 85, 0.08);
}

.note code {
  font-size: 12px;
  color: var(--text);
}

/* ------------------------------------------------------------------ footer */

.footer {
  border-top: 1px solid var(--border);
  padding: 11px 22px 18px;
  color: var(--text-faint);
  font-size: 12px;
}

.footer p {
  margin: 0;
  max-width: 120ch;
}

.footer code {
  color: var(--text-dim);
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(380px, 1fr) minmax(380px, 1fr);
  }

  .topbar {
    padding: 14px 16px;
  }

  .layout {
    padding: 10px;
  }
}
