/* PhoneDemo Drummer — dark home-studio UI. No external assets. */

:root {
  --bg: #141210;
  --bg-glow: #241a10;
  --panel: #1d1a16;
  --panel-2: #232019;
  --panel-3: #2a251d;
  --border: #332d25;
  --border-strong: #4a4034;
  --text: #f3ede4;
  --text-dim: #b6ac9e;
  --muted: #8c8375;
  --accent: #f59f36;
  --accent-2: #ffc46b;
  --accent-ink: #2b1c06;
  --ok: #6fd394;
  --warn: #f0b64a;
  --bad: #ef6060;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 0 0 40px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 460px at 50% -180px, var(--bg-glow) 0%, rgba(36, 26, 16, 0) 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 22px 18px;
}

.brand-title {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-accent { color: var(--accent); }

.brand-subtitle {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13.5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.pill--pending { color: var(--text-dim); }
.pill--ok { color: var(--ok); border-color: rgba(111, 211, 148, 0.4); }
.pill--ok::before { background: var(--ok); box-shadow: 0 0 8px rgba(111, 211, 148, 0.7); }
.pill--warn { color: var(--warn); border-color: rgba(240, 182, 74, 0.4); }
.pill--warn::before { background: var(--warn); box-shadow: 0 0 8px rgba(240, 182, 74, 0.6); }
.pill--bad { color: var(--bad); border-color: rgba(239, 96, 96, 0.45); }
.pill--bad::before { background: var(--bad); box-shadow: 0 0 8px rgba(239, 96, 96, 0.6); }

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

.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel,
.card {
  background: linear-gradient(180deg, var(--panel) 0%, #1a1713 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card { padding: 18px 20px; }

.panel-head,
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-head { margin-bottom: 14px; }

.panel-title,
.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title { font-size: 13.5px; color: var(--text-dim); }

.panel-title .step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 7px;
  background: rgba(245, 159, 54, 0.15);
  border: 1px solid rgba(245, 159, 54, 0.45);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.panel-hint,
.card-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* --------------------------------------------------------------- dropzone */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 178px;
  padding: 26px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.012);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.dropzone:hover { border-color: #5d5142; background: rgba(245, 159, 54, 0.035); }

.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(245, 159, 54, 0.09);
  transform: scale(1.004);
}

.dropzone.has-file { border-style: solid; border-color: rgba(245, 159, 54, 0.55); }

.dropzone-icon {
  font-size: 30px;
  line-height: 1;
  color: var(--accent);
  opacity: 0.85;
}

.dropzone-title {
  margin: 4px 0 0;
  font-size: 15.5px;
  font-weight: 600;
}

.dropzone-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.file-meta {
  margin: 10px 0 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent-2);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.inline-error {
  margin: 12px 0 0;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 96, 96, 0.45);
  background: rgba(239, 96, 96, 0.1);
  color: #ffb3b3;
  font-size: 13px;
}

/* --------------------------------------------------------------- settings */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: 16px;
  align-items: start;
}

.field-group {
  margin: 0;
  padding: 15px 15px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.014);
  min-width: 0;
}

.field-group legend {
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}

.field { margin-bottom: 15px; }

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.field-head .field-label { margin-bottom: 6px; }

.field-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-2);
  white-space: nowrap;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.select,
.number-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
}

.select:focus-visible,
.number-input:focus-visible,
.range:focus-visible,
.check input:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(245, 159, 54, 0.55), rgba(245, 159, 54, 0.16));
  border: 1px solid var(--border-strong);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1a1713;
  box-shadow: 0 0 0 1px rgba(245, 159, 54, 0.5), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.range::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(245, 159, 54, 0.3);
  border: 1px solid var(--border-strong);
}

.range::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1a1713;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  margin: 0 -8px 6px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
}

.check:hover { background: rgba(255, 255, 255, 0.03); }

.check input {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}

.check-text { color: var(--text-dim); }
.check input:checked + .check-text { color: var(--text); }

.link-button {
  border: 0;
  background: none;
  padding: 4px 2px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

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

/* ----------------------------------------------------------------- action */

.action-panel { padding: 18px 20px; }

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.1s ease, filter 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.primary-button {
  padding: 13px 24px;
  min-width: 250px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 22px rgba(245, 159, 54, 0.22);
}

.primary-button:hover:not(:disabled) { filter: brightness(1.06); }
.primary-button:active:not(:disabled) { transform: translateY(1px); }

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.25);
  box-shadow: none;
}

.secondary-button {
  padding: 12px 20px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
}

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

.spinner {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(43, 28, 6, 0.35);
  border-top-color: var(--accent-ink);
  animation: spin 0.7s linear infinite;
  flex: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-wrap { margin-top: 16px; }

.progress-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.progress-bar {
  position: absolute;
  top: 0; bottom: 0;
  width: 34%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(245, 159, 54, 0), var(--accent), rgba(245, 159, 54, 0));
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { left: -36%; }
  100% { left: 102%; }
}

.status-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.elapsed {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  flex: none;
}

/* ------------------------------------------------------------ error card */

.error-card {
  border-color: rgba(239, 96, 96, 0.45);
  background: linear-gradient(180deg, rgba(239, 96, 96, 0.09), rgba(239, 96, 96, 0.02));
}

.error-card .card-title { color: #ffa8a8; }

.error-message {
  margin: 0 0 14px;
  font-size: 14px;
  color: #ffd9d9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card-actions { display: flex; gap: 10px; }

/* --------------------------------------------------------------- results */

.results {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.stat {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  min-width: 0;
}

.stat-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.stat-value small {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.warnings {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.warnings-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warn);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chip-list li {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(240, 182, 74, 0.4);
  background: rgba(240, 182, 74, 0.1);
  color: #ffd88b;
  overflow-wrap: anywhere;
}

.chip-list--plain li {
  border-color: var(--border-strong);
  background: var(--panel-2);
  color: var(--text-dim);
}

/* -------------------------------------------------------- sections strip */

.sections-strip {
  display: flex;
  width: 100%;
  min-height: 58px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.section-seg {
  position: relative;
  min-width: 2px;
  padding: 9px 9px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  border-right: 1px solid rgba(0, 0, 0, 0.42);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.section-seg:last-child { border-right: 0; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-bars {
  font-family: var(--mono);
  font-size: 10.5px;
  opacity: 0.86;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sections-empty {
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
}

/* ------------------------------------------------------------ piano roll */

.canvas-wrap {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #120f0c;
  overflow: hidden;
}

#piano-roll {
  display: block;
  width: 100%;
  height: 330px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
}

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

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex: none;
}

/* --------------------------------------------------------------- preview */

.preview-audio {
  width: 100%;
  margin-top: 6px;
  filter: invert(0.92) hue-rotate(180deg) saturate(0.85);
  border-radius: 999px;
}

/* ------------------------------------------------------------- downloads */

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.download-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

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

.download-button--primary {
  background: rgba(245, 159, 54, 0.14);
  border-color: rgba(245, 159, 54, 0.55);
  color: var(--accent-2);
}

.download-button--primary:hover { background: rgba(245, 159, 54, 0.22); }

/* --------------------------------------------------------- pattern tablet */

.pattern {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  padding: 4px 2px;
}

.pattern-section { margin-bottom: 14px; }
.pattern-section:last-child { margin-bottom: 0; }

.pattern-title {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 5px;
}

.pattern-title .pattern-bars {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.pattern-line { white-space: pre; }

.pat-label { display: inline-block; }

.pat-steps { color: var(--text); }

.pattern-empty { color: var(--muted); font-size: 12px; }

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

.app-footer {
  max-width: 1080px;
  margin: 26px auto 0;
  padding: 0 22px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.app-footer p { margin: 0; }

.noscript {
  max-width: 1080px;
  margin: 16px auto;
  padding: 0 22px;
  color: var(--bad);
}

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

@media (max-width: 620px) {
  .app-header { padding: 20px 16px 14px; }
  .app-main { padding: 0 16px; }
  .panel, .card { padding: 16px; }
  .primary-button { width: 100%; min-width: 0; }
  #piano-roll { height: 260px; }
  .stat-value { font-size: 15.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar { animation-duration: 3s; }
  .spinner { animation-duration: 1.4s; }
  .dropzone { transition: none; }
}

/* ------------------------------------------------------------------ *
 * Preview mix controls (drums / with-demo toggle + balance)
 * ------------------------------------------------------------------ */

.preview-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
  margin: 14px 0 12px;
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.field--inline {
  margin-bottom: 0;
  flex: 1 1 190px;
  min-width: 170px;
}

.preview-controls .select {
  width: 100%;
}

.range-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field--inline.is-disabled {
  opacity: 0.45;
}

.field--inline.is-disabled .range {
  cursor: not-allowed;
}

/* Groove picker: an inline "next" action in the field header. */
.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

/* Fields that do not apply to the current mode. */
.field.is-disabled { opacity: 0.45; }
.field.is-disabled .select { cursor: not-allowed; }

/* The pattern readout card was removed; keep the class harmless if cached CSS
   or older HTML still references it. */
.pattern { display: none; }
