:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #101114;
  color: #f4f7f8;
  --panel: #181b1f;
  --panel-2: #20242a;
  --line: #333a42;
  --muted: #a9b4bd;
  --accent: #28d7b2;
  --accent-2: #ffd166;
  --danger: #ff6b6b;
  --good: #7bd88f;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  line-height: 1.5;
  background:
    radial-gradient(circle at top left, rgba(40, 215, 178, 0.14), transparent 28rem),
    #101114;
}

button,
select,
input {
  font: inherit;
}

button,
.file-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 var(--space-2);
  background: var(--panel-2);
  color: #f4f7f8;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
}

.button-link {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 var(--space-2);
  background: var(--panel-2);
  color: #f4f7f8;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  border-color: var(--accent);
}

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

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: var(--space-3);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(3, auto) minmax(150px, 190px) minmax(180px, 260px) auto;
  gap: 10px;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #061411;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p,
.empty-state p {
  color: var(--muted);
  margin-top: 4px;
}

.file-button {
  display: inline-grid;
  place-items: center;
  white-space: nowrap;
  background: #f4f7f8;
  color: #101114;
  font-weight: 700;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.control {
  display: grid;
  gap: 4px;
}

.control span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel-2);
  color: #f4f7f8;
}

.speed-control strong {
  color: #f4f7f8;
}

.octave-controls {
  display: grid;
  grid-template-columns: auto minmax(72px, auto) auto;
  gap: 8px;
  align-items: center;
  justify-content: end;
}

.octave-controls strong {
  text-align: center;
  color: var(--accent-2);
  white-space: nowrap;
}

.status-strip {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.seo-intro {
  max-width: 820px;
  margin: 16px 0;
}

.seo-intro h2 {
  font-size: 18px;
  margin-bottom: 6px;
}

.seo-intro p {
  color: var(--muted);
  line-height: 1.5;
}

.project-showcase {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-3);
  background:
    linear-gradient(135deg, rgba(40, 215, 178, 0.12), transparent 34rem),
    var(--panel);
}

.project-showcase-header {
  display: grid;
  gap: 8px;
  max-width: 900px;
}

.project-showcase .eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-showcase h2 {
  max-width: 760px;
  font-size: 28px;
  line-height: 1.12;
}

.project-showcase p {
  color: var(--muted);
  line-height: 1.6;
}

.showcase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

.showcase-grid article {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-2);
  background: rgba(13, 15, 18, 0.62);
}

.showcase-grid h3 {
  margin: 0;
  font-size: 18px;
}

.status-pill {
  justify-self: start;
  border: 1px solid rgba(123, 216, 143, 0.45);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(123, 216, 143, 0.12);
  color: var(--good);
  font-size: 12px;
  font-weight: 900;
}

.status-pill.beta {
  border-color: rgba(255, 209, 102, 0.5);
  background: rgba(255, 209, 102, 0.12);
  color: var(--accent-2);
}

.status-pill.open {
  border-color: rgba(40, 215, 178, 0.45);
  background: rgba(40, 215, 178, 0.12);
  color: var(--accent);
}

.showcase-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.text-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.trainer-guide {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(420px, 1.4fr);
  gap: var(--space-3);
  align-items: start;
  margin: var(--space-3) 0 var(--space-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-3);
  background: rgba(24, 27, 31, 0.72);
}

.trainer-guide h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.trainer-guide p {
  color: var(--muted);
  line-height: 1.6;
}

.guide-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-steps li {
  display: grid;
  gap: 8px;
  min-width: 0;
  border-left: 3px solid var(--accent);
  padding-left: var(--space-2);
}

.guide-steps strong {
  color: #f4f7f8;
}

.guide-steps span {
  color: var(--muted);
  line-height: 1.55;
}

.feature-link {
  margin-top: 8px;
}

.feature-link a,
.simple-nav a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.feature-link a:hover,
.simple-nav a:hover {
  text-decoration: underline;
}

.site-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 16px 0 24px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.site-tabs a {
  flex: 0 0 auto;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  padding: 0 16px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.site-tabs a:hover {
  color: #f4f7f8;
}

.site-tabs a.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent);
}

.status-strip > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
}

.status-strip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.range-notice {
  margin: -4px 0 16px;
  border: 1px solid rgba(255, 209, 102, 0.55);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 209, 102, 0.12);
  color: #ffe6a0;
  line-height: 1.45;
}

.range-notice[hidden] {
  display: none;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  height: min(62vh, 680px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0f12;
}

#pianoRoll {
  display: block;
  width: 100%;
  height: 100%;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  max-width: 620px;
  margin: 0 auto;
  padding: var(--space-3);
  text-align: center;
  pointer-events: none;
}

.empty-state.hidden {
  display: none;
}

.empty-state h2 {
  font-size: 28px;
}

.empty-state p {
  max-width: 520px;
  line-height: 1.6;
}

.empty-state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-top: var(--space-2);
  pointer-events: auto;
}

.empty-state-actions .button-link {
  cursor: pointer;
}

.keyboard-panel {
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(var(--key-count, 29), minmax(38px, 1fr));
  min-width: 900px;
  height: 128px;
  padding: 0;
  gap: 0;
}

.key {
  position: relative;
  display: grid;
  align-content: end;
  justify-items: center;
  min-width: 0;
  border-radius: 0;
  padding: 8px 2px;
  color: #101114;
  background: #edf2f4;
  border: 1px solid #d2d8dd;
}

.key.black {
  height: 78px;
  z-index: 2;
  color: #f4f7f8;
  background: #17191d;
  border-color: #2e333a;
}

.key.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #061411;
}

.key.black.active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #121212;
}

.key small {
  color: inherit;
  opacity: 0.7;
}

.planning-page {
  max-width: 1100px;
}

.audio-topbar {
  display: flex;
  justify-content: flex-end;
  margin: -6px 0 18px;
}

.audio-topbar .language-control {
  min-width: 180px;
}

.simple-nav {
  margin-bottom: 24px;
}

.planning-hero {
  max-width: 860px;
  margin-bottom: var(--space-4);
}

.planning-hero .eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.planning-hero h1 {
  margin-bottom: 12px;
  font-size: 34px;
  line-height: 1.1;
}

.planning-hero p,
.planning-grid p,
.decision-panel p,
.decision-panel li {
  color: var(--muted);
  line-height: 1.6;
}

.planning-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.planning-grid article,
.decision-panel,
.audio-fit-panel,
.converter-panel,
.youtube-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-3);
  background: var(--panel);
}

.planning-grid h2,
.audio-fit-panel h2,
.decision-panel h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.decision-panel {
  margin-top: var(--space-2);
}

.audio-fit-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.audio-fit-panel ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.audio-fit-panel li + li {
  margin-top: 6px;
}

.converter-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  align-items: start;
}

.converter-copy h2,
.youtube-note h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.converter-copy p,
.youtube-note p {
  color: var(--muted);
  line-height: 1.6;
}

.converter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.quality-control {
  display: grid;
  gap: 6px;
  min-width: 192px;
  color: var(--muted);
  font-size: 12px;
}

.quality-control select {
  width: 100%;
}

.quality-control small {
  line-height: 1.5;
}

.selected-file-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-2);
  background: #111418;
}

.selected-file-card strong,
.selected-file-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-card small {
  color: var(--muted);
}

.benchmark-app {
  max-width: 1280px;
}

.benchmark-toolbar {
  grid-template-columns: minmax(260px, 1fr) auto auto;
}

.benchmark-intro {
  max-width: 980px;
}

.benchmark-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.benchmark-file-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.benchmark-file-card.required {
  border-color: rgba(40, 215, 178, 0.5);
}

.benchmark-file-card span {
  font-weight: 800;
}

.benchmark-file-card input {
  max-width: 100%;
}

.benchmark-file-card small {
  color: var(--muted);
  line-height: 1.35;
}

.benchmark-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.benchmark-settings input[type="number"] {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel-2);
  color: #f4f7f8;
}

.benchmark-status {
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
}

.benchmark-results {
  display: grid;
  gap: 16px;
}

.benchmark-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.benchmark-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.benchmark-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: var(--panel);
}

.benchmark-table th,
.benchmark-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: right;
  white-space: nowrap;
}

.benchmark-table th:first-child,
.benchmark-table td:first-child {
  text-align: left;
}

.benchmark-table thead th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.benchmark-table tr:last-child th,
.benchmark-table tr:last-child td {
  border-bottom: 0;
}

.reference-row {
  background: rgba(40, 215, 178, 0.08);
}

.good-score {
  color: var(--good);
  font-weight: 900;
}

.warn-score {
  color: var(--accent-2);
  font-weight: 900;
}

.bad-score {
  color: var(--danger);
  font-weight: 900;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.diagnostic-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.diagnostic-card h3 {
  margin: 0;
  font-size: 18px;
}

.diagnostic-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.metric-bars {
  display: grid;
  gap: 8px;
}

.metric-bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #111418;
}

.metric-bar span,
.metric-bar strong {
  position: relative;
  z-index: 1;
}

.metric-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(40, 215, 178, 0.16);
}

.backend-url-control {
  display: grid;
  gap: 6px;
}

.backend-url-control span {
  color: var(--muted);
  font-size: 12px;
}

.backend-url-control input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111418;
  color: #f4f7f8;
}

.audio-file-button {
  min-width: 180px;
}

.conversion-state {
  grid-column: 1 / -1;
}

.conversion-state progress {
  width: 100%;
  height: 14px;
  accent-color: var(--accent);
}

.conversion-state p {
  margin-top: var(--space-1);
  color: var(--muted);
}

.job-panel {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-2);
  background: #111418;
}

.job-panel[hidden] {
  display: none;
}

.job-panel-header,
.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.job-panel-header strong {
  margin-right: auto;
}

.job-status-badge {
  border: 1px solid rgba(40, 215, 178, 0.35);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(40, 215, 178, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.job-panel[data-status="failed"] .job-status-badge,
.job-panel[data-status="stopped"] .job-status-badge {
  border-color: rgba(255, 176, 77, 0.45);
  background: rgba(255, 176, 77, 0.12);
  color: #ffcf86;
}

.job-elapsed,
.job-meta,
.job-estimate,
.job-message {
  color: var(--muted);
}

.job-message {
  margin: 0;
}

.job-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.job-steps li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.job-steps li.complete,
.job-steps li.active {
  border-color: rgba(40, 215, 178, 0.35);
  color: #f4f7f8;
}

.job-steps li.complete {
  background: rgba(40, 215, 178, 0.08);
}

.job-steps li.active {
  background: rgba(40, 215, 178, 0.16);
}

.feedback-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  border: 1px solid rgba(40, 215, 178, 0.22);
  border-radius: 8px;
  padding: var(--space-3);
  background: rgba(40, 215, 178, 0.07);
}

.feedback-panel h2,
.feedback-panel p {
  margin: 0;
}

.feedback-panel h2 {
  margin-top: 4px;
  font-size: 22px;
}

.feedback-panel p:last-child {
  margin-top: 8px;
  color: var(--muted);
}

.conversion-result {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: var(--space-2);
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: var(--space-2);
}

.conversion-result[hidden] {
  display: none;
}

.conversion-result > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.conversion-result strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.youtube-note {
  margin-bottom: 14px;
}

.youtube-note input {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111418;
  color: var(--muted);
}

.decision-panel ol {
  margin: 0;
  padding-left: 20px;
}

@media (max-width: 1040px) {
  .toolbar {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .brand,
  .status-strip {
    grid-column: 1 / -1;
  }

  .status-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .octave-controls,
  .control {
    justify-content: stretch;
  }

  .planning-grid {
    grid-template-columns: 1fr;
  }

  .showcase-grid {
    grid-template-columns: 1fr;
  }

  .trainer-guide,
  .guide-steps {
    grid-template-columns: 1fr;
  }

  .converter-panel,
  .conversion-result,
  .feedback-panel,
  .audio-fit-panel {
    grid-template-columns: 1fr;
  }

  .audio-topbar {
    justify-content: stretch;
  }

  .converter-controls {
    justify-content: stretch;
  }

  .benchmark-toolbar,
  .benchmark-grid,
  .benchmark-settings,
  .benchmark-status,
  .diagnostic-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app {
    padding: var(--space-2);
  }

  .toolbar,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .stage-wrap {
    min-height: 360px;
  }

  .project-showcase {
    padding: var(--space-2);
  }

  .project-showcase h2 {
    font-size: 22px;
  }

  .empty-state {
    padding: var(--space-2);
  }

  .empty-state h2 {
    font-size: 22px;
  }

  .showcase-actions .button-link,
  .showcase-actions .text-link,
  .empty-state-actions .button-link,
  .empty-state-actions .text-link {
    width: 100%;
    justify-content: center;
  }

  .benchmark-result-actions {
    justify-content: stretch;
  }

  .benchmark-result-actions button {
    width: 100%;
  }

  .job-steps {
    grid-template-columns: 1fr 1fr;
  }

  .job-actions button {
    flex: 1 1 140px;
  }
}
