/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  -webkit-tap-highlight-color: transparent;
}

/* === App Container === */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  padding: 10px;
}

h1 {
  font-size: 1.2rem;
  text-align: center;
  padding: 8px 0;
  letter-spacing: 0.05em;
  color: #ff6b6b;
  flex-shrink: 0;
}

/* === Controls === */
#controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
  flex-shrink: 0;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: opacity 0.15s, transform 0.1s;
  min-height: 48px;
  min-width: 80px;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-record {
  background: #ff4757;
  color: #fff;
}

.btn-pause {
  background: #ffa502;
  color: #fff;
}

.btn-reset {
  background: #67b1b1;
  color: #fff;
}

/* === Status === */
#status {
  text-align: center;
  font-size: 0.85rem;
  padding: 4px 0 8px;
  color: #aaa;
  flex-shrink: 0;
  min-height: 1.5em;
  transition: color 0.3s;
}

#status.calibrated {
  color: #2ed573;
}

#status.recording {
  color: #ff6b6b;
}

/* === Labels Row === */
#labels-row {
  display: flex;
  flex-shrink: 0;
  position: relative;
  height: 68px;
  font-size: 0.7rem;
  overflow: hidden;
  border-bottom: 1px solid #444;
  margin-bottom: 2px;
}

.label-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  border-right: 1px solid #333;
  text-align: center;
  line-height: 1;
  padding: 2px 1px 0;
}

.label-cell:last-child {
  border-right: none;
}

.label-note {
  height: 16px;
}

.label-freq {
  writing-mode: vertical-rl;
  color: #aaa;
  white-space: nowrap;
}

/* === Piano Roll Wrapper (scrollable) === */
#piano-roll-wrapper {
  flex: 1;
  overflow-y: scroll;
  overflow-x: hidden;
  border: 1px solid #444;
  border-radius: 4px;
  position: relative;
  background: #1e1e32;
  -webkit-overflow-scrolling: touch;
}

#piano-roll-inner {
  position: relative;
}

/* === Piano Keys (behind canvas) === */
#piano-keys {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
}

.piano-key {
  flex: 1;
  min-width: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.piano-key:last-child {
  border-right: none;
}

.piano-key.white {
  background: rgba(255,255,255,0.08);
}

.piano-key.black {
  background: rgba(0,0,0,0.3);
}

/* Octave boundary - subtle marker */
.piano-key.octave-start {
  border-left: 1px solid rgba(255,255,255,0.15);
}

/* === Pitch Canvas (overlay) === */
#pitch-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* === Scrollback Control === */
#scrollback-control {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  flex-shrink: 0;
}

#scrollback-control.visible {
  display: flex;
}

#scrollback-control label {
  font-size: 0.75rem;
  color: #888;
  white-space: nowrap;
}

#scrollback-slider {
  flex: 1;
  height: 6px;
  accent-color: #ff6b6b;
}

.btn-small {
  padding: 6px 12px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #333;
  color: #ccc;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}
