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

body {
  font-family: 'Courier New', monospace;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 16px;
}

.app {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

h1 {
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  color: #7f9cf5;
  text-transform: uppercase;
}

.card {
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card h2 {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7f9cf5;
  margin-bottom: 4px;
}

/* Input grid */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
}

.field input[type="number"] {
  background: #0f3460;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 1rem;
  padding: 6px 10px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.field input[type="number"]:focus {
  border-color: #7f9cf5;
}

/* Checkboxes */
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
}

.check-item input[type="checkbox"] {
  accent-color: #7f9cf5;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Sliders */
.slider-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider-row {
  display: grid;
  grid-template-columns: 100px 1fr 36px 28px 24px;
  align-items: center;
  gap: 10px;
}

.sample-file {
  display: none;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2a2a4a;
  color: #4b5563;
  border: 1px solid #374151;
  border-radius: 3px;
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
  user-select: none;
}

.upload-btn:hover {
  border-color: #7f9cf5;
  color: #7f9cf5;
}

.upload-btn.sample-loaded {
  border-color: #22c55e;
  color: #22c55e;
}

.slider-row label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #0f3460;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #7f9cf5;
  cursor: pointer;
}

.slider-val {
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: right;
  width: 36px;
}

/* Buttons */
.buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, transform 0.07s;
}

button:active {
  transform: scale(0.97);
}

#btn-generate {
  background: #7f9cf5;
  color: #1a1a2e;
  font-weight: bold;
}

#btn-generate:hover {
  background: #a0b4f8;
}

#btn-play {
  background: #22c55e;
  color: #1a1a2e;
  font-weight: bold;
  min-width: 90px;
}

#btn-play:hover {
  background: #4ade80;
}

#btn-play.playing {
  background: #ef4444;
}

#btn-play.playing:hover {
  background: #f87171;
}

#btn-midi {
  background: #2a2a4a;
  color: #e0e0e0;
  border: 1px solid #7f9cf5;
}

#btn-midi:hover {
  background: #3a3a5a;
}

#btn-midi:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#btn-rec {
  background: #2a2a4a;
  color: #ff7b7b;
  border: 1px solid #ff7b7b;
  font-weight: bold;
}

#btn-rec:hover:not(:disabled) {
  background: #3a1a1a;
}

#btn-rec:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#btn-rec.recording {
  background: #ef4444;
  color: #fff;
  animation: pulse-rec 1.2s ease-in-out infinite;
}

@keyframes pulse-rec {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.65;
  }
}

#btn-rec-clear {
  background: #2a2a4a;
  color: #e0e0e0;
  border: 1px solid #4b5563;
}

#btn-rec-clear:hover:not(:disabled) {
  background: #3a3a5a;
}

#btn-rec-clear:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mute-btn {
  background: #2a2a4a;
  color: #9ca3af;
  border: 1px solid #4b5563;
  border-radius: 3px;
  padding: 0;
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
  font-family: inherit;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  line-height: 1;
}

.mute-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.mute-btn.muted {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

.shift-btn {
  background: #2a2a4a;
  color: #e0e0e0;
  border: 1px solid #4b5563;
  padding: 6px 14px;
  font-size: 0.8rem;
}

.shift-btn:hover {
  background: #3a3a5a;
  border-color: #7f9cf5;
}

.shift-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Pattern display */
#pattern-display {
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  line-height: 1.8;
  word-break: break-all;
  min-height: 48px;
  padding: 12px;
  background: #0f1b35;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  color: #e0e0e0;
}

#pattern-display .beat-O {
  color: #f59e0b;
  font-weight: bold;
}

#pattern-display .beat-X {
  color: #7f9cf5;
  font-weight: bold;
}

#pattern-display .beat-x {
  color: #a78bfa;
}

#pattern-display .beat-o {
  color: #4b5563;
}

.status {
  font-size: 0.72rem;
  color: #9ca3af;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Step visualizer */
#step-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 28px;
  align-items: center;
}

.step-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
}

.step-cell {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #2a2a4a;
  transition: background 0.05s;
}

.step-cell.beat-step {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.step-cell.on-O {
  background: #f59e0b;
}

.step-cell.on-X {
  background: #7f9cf5;
}

.step-cell.on-x {
  background: #a78bfa;
}

.step-cell.on-o {
  background: #4b5563;
}

.step-cell.beat-step.on-o {
  background: #6b7280;
}

.step-cell.active {
  outline: 2px solid #fbbf24;
  outline-offset: 1px;
}

/* Footer */
.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.5rem 1rem;
  border-top: 1px solid #2a2a4a;
  font-size: 0.8rem;
  color: #9ca3af;
}

.site-footer a {
  color: #7f9cf5;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}