:root {
  /* Instrument theme */
  color-scheme: dark;

  --bg: #17191d;
  --panel: #20242a;
  --panel-2: #292f36;
  --border: #414b54;

  /* Typography */
  --text: #e9edf0;
  --muted: #aab5bd;
  --heading-muted: #3dbbf0;

  /* Serendipity orange */
  --accent: #f47b20;
  --accent-bright: #ff9a4d;

  /* Playback states */
  --active: #176b8f;
  --pulse: #f47b20;
  --step-bg: #343b43;
  --step-border: #49545d;

  /* Validation */
  --error-bg: #39291f;

  /* Layout */
  --radius: 4px;
  --control-height: 40px;
}

/* Reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 3px;
}

button,
select,
input {
  min-height: var(--control-height);
}

button {
  padding: 0 15px;
  cursor: pointer;
  font-size: 14px;
}

button:hover {
  border-color: var(--accent);
  background: #343941;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

input,
select {
  padding: 0 10px;
}

input[type="number"] {
  width: 82px;
}

select {
  min-width: 105px;
}

/* Validation */

input:invalid,
input.invalid {
  border-color: var(--accent);
  background: var(--error-bg);
  color: #fff;
  box-shadow: none;
}

input:invalid:focus,
input.invalid:focus {
  outline-color: var(--accent-bright);
  border-color: var(--accent-bright);
}

/* Shared layout */

.app {
  width: min(1200px, 100%);
  margin-inline: auto;
}

.panel {
  margin-top: 2px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

/* Header */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  /* gap: 24px; */
  background: linear-gradient(135deg, #073b5c 0%, #0b506f 65%, #03A 100%);
  border-radius: 10px 10px 0 0;
}

.app-header-text {
  flex: 1 1 auto;
  min-width: 0;
}

.app-header h1 {
  margin: 0;
  font-size: 28px;
  overflow-wrap: break-word;
}

.app-header a {
  margin: 0;
  color: var(--accent);
  text-decoration: none;
}

.app-header a:hover {
  color: var(--accent-bright);
}

.app-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.app-logo {
  display: block;
  flex: 0 0 auto;
  width: auto;
  max-width: 30%;
  height: 80px;
  object-fit: contain;
  opacity: 0.8;
}

/* Transport controls */

.transport-spacer {
  flex: 1;
}

.transport-panel > .status {
  margin-top: 12px;
}

.slider-row output {
  display: inline-block;
  width: 45px;
  overflow: visible;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
}

/* Labels and controls */

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  /* text-transform: uppercase; */
}

.mode-buttons {
  display: flex;
  gap: 6px;
}

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

.controls > button {
  align-self: end;
}

.checkbox-control input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 8px 8px 8px 2px;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Button states */

button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

button.active:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}

/* Status */

.status {
  color: var(--muted);
  font-size: 13px;
}

/* Sequencers */

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

.sequencer {
  min-width: 0;
}

.sequencer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.sequencer-header h2 {
  margin: 0;
  color: var(--accent);
  font-size: 18px;
}

.section {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}

.section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.section h3 {
  margin: 0 0 13px;
  color: var(--heading-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Step sequencer grid */

.pattern {
  margin-top: 15px;
  overflow: hidden;
}

.steps {
  display: grid;
  grid-template-columns: repeat(16, 18px);
  grid-auto-rows: 18px;
  gap: 4px;
  overflow: hidden;
  padding-bottom: 2px;
}

.step {
  width: 18px;
  height: 18px;
  background: var(--step-bg);
  border: 1px solid var(--step-border);
  border-radius: 2px;
}

.step.active {
  background: var(--active);
  border-color: #2383aa;
}

.step.current {
  background: var(--pulse);
  border-color: var(--accent-bright);
}

.step.active.current {
  background: #ffb36f;
  border-color: var(--accent);
}

/* Responsive layout */

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

@media (max-width: 560px) {
  body {
    padding: 12px;
  }

  .panel {
    padding: 14px;
  }

  .app-header {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 2px;
  }

  .app-header-text {
    width: 100%;
  }

  .app-header h1 {
    font-size: 24px;
  }

  .app-logo {
    height: 52px;
    max-width: 45%;
  }

  .transport {
    align-items: stretch;
  }

  .transport-spacer {
    display: none;
  }

  .controls > label {
    flex: 1 1 110px;
  }

  .steps {
    grid-template-columns: repeat(16, 18px);
  }
}

/* Reduced motion and visual effects */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}