* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --birch: #F5E6C8;
  --amber: #C4913B;
  --walnut: #3E2723;
  --charcoal: #2D2D2D;
  --bg: #141F14;
  --bg-felt: #1A2F1A;
  --string-silver: #B8B8B8;
  --glow-amber: rgba(196, 145, 59, 0.4);
  --port-dark: #1a1008;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--birch);
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ===== HEADER ===== */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(0,0,0,0.35);
  border-bottom: 1px solid rgba(196,145,59,0.15);
  flex-shrink: 0;
  z-index: 10;
  min-height: 44px;
}

.header-inner {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hedgehog-icon {
  font-size: 18px;
  flex-shrink: 0;
}

h1 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--birch);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  font-size: 11px;
  color: rgba(245,230,200,0.45);
  font-style: italic;
  font-family: 'Crimson Pro', Georgia, serif;
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(196,145,59,0.3);
  background: rgba(62,39,35,0.6);
  color: var(--birch);
  font-family: 'Crimson Pro', serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.icon-btn:hover, .icon-btn:active {
  background: rgba(196,145,59,0.2);
  border-color: var(--amber);
}

.record-btn { position: relative; }
.record-btn.active {
  border-color: #e53935;
  animation: rec-pulse 1s ease infinite;
}

.rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e53935;
  display: block;
}

@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229,57,53,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(229,57,53,0); }
}

/* ===== RECORDING BAR ===== */
.recording-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(229,57,53,0.1);
  border-bottom: 1px solid rgba(229,57,53,0.2);
  flex-shrink: 0;
  z-index: 10;
}

.recording-bar.hidden { display: none; }

#waveform-canvas {
  height: 28px;
  flex: 1;
  max-width: 250px;
  min-width: 80px;
}

#rec-timer {
  font-family: 'IBM Plex Sans', monospace;
  font-size: 13px;
  color: #e53935;
  min-width: 32px;
}

.small-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(245,230,200,0.2);
  background: rgba(62,39,35,0.6);
  color: var(--birch);
  font-size: 12px;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  min-height: 28px;
}

.small-btn:hover { background: rgba(196,145,59,0.2); }
.small-btn.hidden { display: none; }

/* ===== CANVAS ===== */
#canvas {
  flex: 1;
  width: 100%;
  display: block;
  cursor: pointer;
  touch-action: none;
  min-height: 0;
}

/* ===== CONTROLS ===== */
#controls {
  flex-shrink: 0;
  background: rgba(0,0,0,0.45);
  border-top: 1px solid rgba(196,145,59,0.12);
  z-index: 10;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(196,145,59,0.2) transparent;
}

#controls::-webkit-scrollbar {
  height: 3px;
}
#controls::-webkit-scrollbar-thumb {
  background: rgba(196,145,59,0.3);
  border-radius: 2px;
}

.controls-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 8px 12px;
  min-width: max-content;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 70px;
  flex-shrink: 0;
}

.slider-group {
  min-width: 90px;
}

.control-group label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(245,230,200,0.5);
  font-weight: 500;
  white-space: nowrap;
}

select {
  background: rgba(62,39,35,0.8);
  border: 1px solid rgba(196,145,59,0.25);
  color: var(--birch);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'IBM Plex Sans', sans-serif;
  outline: none;
  min-height: 30px;
  max-width: 100px;
}

select:focus {
  border-color: var(--amber);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(245,230,200,0.15);
  border-radius: 2px;
  outline: none;
  margin-top: 4px;
  width: 100%;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--walnut);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--walnut);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: rgba(245,230,200,0.3);
  line-height: 1;
}

.temp-group {
  min-width: 60px;
  align-items: center;
}

#temp-display {
  font-size: 11px;
  color: var(--amber);
  font-weight: 500;
  text-align: center;
}

#ctrl-temp {
  width: 60px;
}

/* ===== FOOTER ===== */
#footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px;
  background: rgba(0,0,0,0.3);
  font-size: 10px;
  flex-shrink: 0;
  z-index: 10;
  min-height: 24px;
}

#footer span {
  color: rgba(245,230,200,0.3);
}

#footer a {
  color: rgba(196,145,59,0.5);
  text-decoration: none;
  transition: color 0.2s;
}

#footer a:hover {
  color: var(--amber);
}

/* ===== TUTORIAL OVERLAY ===== */
#tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
  padding: 16px;
}

#tutorial-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tutorial-content {
  background: rgba(30,20,15,0.95);
  border: 1px solid rgba(196,145,59,0.3);
  border-radius: 12px;
  padding: 24px;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.tutorial-content h2 {
  font-family: 'Crimson Pro', serif;
  font-size: 22px;
  color: var(--amber);
  margin-bottom: 14px;
}

.tutorial-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.tutorial-item {
  padding: 10px;
  background: rgba(245,230,200,0.04);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.tutorial-item .t-icon {
  font-size: 18px;
  display: block;
  margin-bottom: 3px;
}

.tutorial-item strong {
  color: var(--amber);
}

.tutorial-keys {
  font-size: 11px;
  color: rgba(245,230,200,0.4);
  margin-bottom: 14px;
}

.tutorial-keys kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid rgba(245,230,200,0.2);
  border-radius: 3px;
  font-family: 'IBM Plex Sans', monospace;
  font-size: 10px;
  background: rgba(245,230,200,0.05);
}

.dismiss-btn {
  width: 100%;
  padding: 10px;
  background: var(--amber);
  color: var(--walnut);
  border: none;
  border-radius: 6px;
  font-family: 'Crimson Pro', serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 44px;
}

.dismiss-btn:hover {
  background: #d9a644;
}

/* ===== MOBILE ===== */
@media (max-width: 600px) {
  h1 { font-size: 13px; }
  .subtitle { font-size: 9px; }
  
  #header { padding: 5px 10px; min-height: 40px; }
  
  .controls-inner {
    gap: 10px;
    padding: 7px 10px;
  }
  
  .control-group { min-width: 62px; }
  .slider-group { min-width: 80px; }
  
  .control-group label { font-size: 8px; }
  select { font-size: 11px; max-width: 80px; }
  
  .tutorial-items { grid-template-columns: 1fr; }
  .tutorial-content { padding: 18px; }
  .tutorial-content h2 { font-size: 20px; }
  .tutorial-keys { display: none; }
  
  #footer { padding: 3px 10px; font-size: 9px; }
}

@media (max-width: 380px) {
  h1 { font-size: 12px; }
  .subtitle { display: none; }
}