/* ============================================
   Micro-Cluster Synth — UI matching screenshot
   ============================================ */

:root {
  --bg: #15151c;
  --bg-panel: #1c1c26;
  --bg-input: #0f0f14;
  --bg-btn: #252532;
  --bg-btn-active: #2a2a3a;
  --border: #2a2a3a;
  --border-active: #5b6ef5;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --text-label: #666680;
  --accent-blue: #6b8cff;
  --accent-green: #6dd58a;
  --accent-green-hover: #5cc47a;
  --slider-track: #2a2a3a;
  --slider-thumb: #ffffff;
  --radius: 14px;
  --radius-pill: 999px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* Install banners */
.install-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 1000;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.install-banner[hidden] { display: none; }
.install-banner button {
  background: none; border: none; color: var(--text-dim);
  font-size: 1.3rem; cursor: pointer; padding: 2px 6px;
  border-radius: 4px; line-height: 1;
}
.install-banner button:hover { color: var(--text); }
.btn-install {
  background: var(--accent-blue) !important;
  color: #fff !important;
  font-size: 0.8rem !important;
  font-weight: 600;
  padding: 5px 14px !important;
  border-radius: 6px !important;
}

/* App container */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent-green);
  display: inline-block;
  transition: background 0.3s;
}
.status-dot.idle { background: #444; }
.status-dot.playing { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.app-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

/* Visualizer */
.viz-panel {
  position: relative;
  background: var(--bg-input);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  aspect-ratio: 16 / 7;
  margin-bottom: 20px;
}
#visualizer {
  width: 100%; height: 100%;
  display: block;
}
.viz-label {
  position: absolute;
  bottom: 8px; right: 12px;
  font-size: 0.7rem;
  color: var(--text-label);
  font-family: 'SF Mono', Monaco, monospace;
  pointer-events: none;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.control-row.row-three > .control-block { flex: 1 1 30%; min-width: 180px; }
.control-row.row-two > .control-block { flex: 1 1 45%; min-width: 200px; }
.control-block.flex-grow { flex: 2 1 40%; }

.control-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-label);
  margin-bottom: 8px;
}
.value-blue {
  color: var(--accent-blue);
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-weight: 600;
  font-size: 0.9em;
}
.unit {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 0.85em;
  margin-left: 2px;
}

/* Number input */
.number-input-wrap {
  position: relative;
}
.number-input-wrap input[type="number"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 10px 14px;
  padding-right: 32px;
  outline: none;
  -moz-appearance: textfield;
  transition: border-color 0.2s;
}
.number-input-wrap input[type="number"]::-webkit-outer-spin-button,
.number-input-wrap input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: inner-spin-button;
  opacity: 0.6;
  margin-right: 4px;
}
.number-input-wrap input[type="number"]:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px rgba(91, 110, 245, 0.2);
}

/* Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--slider-track);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  margin-top: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  background: var(--slider-thumb);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--accent-blue);
  box-shadow: 0 0 10px rgba(107, 140, 255, 0.4), 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 14px rgba(107, 140, 255, 0.6), 0 2px 6px rgba(0,0,0,0.3);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  background: var(--slider-thumb);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--accent-blue);
  box-shadow: 0 0 10px rgba(107, 140, 255, 0.4);
}
.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-label);
  margin-top: 4px;
  font-family: 'SF Mono', Monaco, monospace;
}

/* Button groups */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pill-btn {
  background: var(--bg-btn);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  outline: none;
}
.pill-btn:hover {
  background: var(--bg-btn-active);
  color: var(--text);
}
.pill-btn.active {
  background: var(--bg-btn-active);
  color: var(--text);
  border-color: var(--border-active);
  box-shadow: 0 0 0 1px var(--border-active), 0 2px 8px rgba(91, 110, 245, 0.2);
}
.pill-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(91, 110, 245, 0.4);
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* Play button */
.play-wrap {
  margin-top: 8px;
}
.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-green);
  color: #0a1f0f;
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 36px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(109, 213, 138, 0.25);
}
.play-btn:hover {
  background: var(--accent-green-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(109, 213, 138, 0.35);
}
.play-btn:active {
  transform: translateY(0);
}
.play-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(109, 213, 138, 0.4);
}
.play-icon {
  font-size: 0.85em;
}

/* Status bar */
.status-bar {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-family: 'SF Mono', Monaco, monospace;
  margin-top: 4px;
}
.status-bar strong {
  color: var(--text);
  font-weight: 600;
}
.status-bar .sep {
  color: var(--border);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 380px;
  pointer-events: none;
}
.toast {
  background: var(--bg-panel);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid #ff4757; }
.toast.warning { border-left: 3px solid #ffa502; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-16px); } }

/* Responsive */
@media (max-width: 640px) {
  .app { padding: 16px 12px 32px; }
  .app-header h1 { font-size: 1.15rem; }
  .control-row { gap: 14px; }
  .control-row.row-three > .control-block,
  .control-row.row-two > .control-block { flex: 1 1 100%; min-width: unset; }
  .status-bar { font-size: 0.75rem; gap: 10px; padding: 10px 12px; }
  .play-btn { width: 100%; justify-content: center; padding: 14px; }
  .btn-group { gap: 5px; }
  .pill-btn { padding: 6px 11px; font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
