@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;400;500;600;700&family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');

  :root {
    --bg: #050508;
    --surface: #0d0d14;
    --surface2: #13131f;
    --border: #1e1e30;
    --accent: #00f5d4;
    --accent2: #f72585;
    --accent3: #7209b7;
    --text: #e8e8f0;
    --muted: #5a5a7a;
    --mono: 'Share Tech Mono', monospace;
    --display: 'Orbitron', monospace;
    --body: 'Rajdhani', sans-serif;
    --tab-h: 56px;
    --header-h: 52px;
  }

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

  html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    height: 100%;
    overflow: hidden;
    background-image:
      radial-gradient(ellipse at 20% 20%, rgba(114,9,183,0.07) 0%, transparent 50%),
      radial-gradient(ellipse at 80% 80%, rgba(0,245,212,0.04) 0%, transparent 50%);
  }

  /* ── HEADER ── */
  #app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px;
    background: rgba(5,5,8,0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }
  .logo {
    font-family: var(--display); font-size: 1rem; font-weight: 900;
    letter-spacing: 0.12em;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  }
  .midi-badge {
    display: flex; align-items: center; gap: 7px;
    font-family: var(--mono); font-size: 0.6rem; color: var(--muted);
  }
  .status-dot { width: 7px; height: 7px; border-radius: 50%; background: #333; transition: all .3s; }
  .status-dot.connected { background: var(--accent); box-shadow: 0 0 7px var(--accent); }
  .status-dot.error     { background: var(--accent2); box-shadow: 0 0 7px var(--accent2); }
  @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

  /* ── TAB BAR ── */
  #tab-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
    height: var(--tab-h);
    display: flex;
    background: rgba(5,5,8,0.97);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }
  .tab-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px;
    border: none; background: transparent; color: var(--muted);
    font-family: var(--display); font-size: 0.45rem; letter-spacing: 0.12em;
    cursor: pointer; transition: color .2s; padding: 8px 0;
    position: relative;
  }
  .tab-btn .tab-icon { font-size: 1.1rem; line-height: 1; }
  .tab-btn.active { color: var(--accent); }
  .tab-btn.active::after {
    content: ''; position: absolute; top: 0; left: 20%; right: 20%;
    height: 2px; background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
  }
  .tab-btn.seq-active { color: var(--accent2); }
  .tab-btn.seq-active::after { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }

  /* ── PAGES ── */
  #pages {
    position: fixed;
    top: var(--header-h); bottom: var(--tab-h); left: 0; right: 0;
    overflow: hidden;
  }
  .page {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    overflow-y: auto; overflow-x: hidden;
    padding: 14px 12px 20px;
    opacity: 0; pointer-events: none;
    transform: translateY(8px);
    transition: opacity .22s ease, transform .22s ease;
    -webkit-overflow-scrolling: touch;
  }
  .page.active {
    opacity: 1; pointer-events: all; transform: translateY(0);
  }

  /* ── SECTION LABELS ── */
  .sec-label {
    font-family: var(--display); font-size: 0.58rem; letter-spacing: 0.18em;
    color: var(--accent); text-transform: uppercase; margin-bottom: 10px;
  }
  .sec-divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

  /* ── CARD ── */
  .card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 12px; margin-bottom: 12px;
    position: relative; overflow: hidden;
  }
  .card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
  }

  /* ── COLOR WHEEL ── */
  #colorWheelCanvas {
    display: block; width: 100%; margin: 0 auto;
    cursor: grab; touch-action: none;
  }
  .wheel-sliders {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; margin-top: 10px;
  }
  .ws-item {
    display: flex; align-items: center; gap: 6px;
    font-family: var(--mono); font-size: 0.56rem; color: var(--muted);
  }
  .ws-item input[type=range] { flex: 1; }

  /* ── COLOR INFO BAR ── */
  .color-info-bar {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 5px; padding: 10px; margin-top: 10px;
  }
  .big-swatch {
    width: 44px; height: 44px; border-radius: 5px;
    border: 1px solid var(--border); flex-shrink: 0;
  }
  .color-data {
    font-family: var(--mono); font-size: 0.6rem; line-height: 1.9; color: var(--muted); flex: 1;
  }
  .color-data span { color: var(--text); }

  /* ── HARMONY PILLS ── */
  .harmony-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
  .pill {
    font-family: var(--mono); font-size: 0.55rem; padding: 4px 9px;
    border: 1px solid var(--border); border-radius: 20px;
    cursor: pointer; color: var(--muted); transition: all .2s; background: transparent;
  }
  .pill.active { border-color: var(--accent); color: var(--accent); background: rgba(0,245,212,.1); }

  .harmony-swatches { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-top: 10px; }
  .color-swatch {
    height: 42px; border-radius: 4px; border: 1px solid var(--border);
    position: relative; overflow: hidden; cursor: pointer;
  }
  .color-swatch-label {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.6); font-family: var(--mono); font-size: 0.5rem;
    text-align: center; padding: 2px; color: #fff;
  }

  /* ── CHORD CANVAS ── */
  #chordCanvas { display: block; width: 100%; cursor: pointer; }

  /* ── CHORD INFO ── */
  .chord-bar {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 5px; padding: 10px; margin-top: 10px;
  }
  .chord-name-big {
    font-family: var(--display); font-size: 1.8rem; font-weight: 700;
    color: var(--accent); min-width: 60px; text-align: center;
  }
  .chord-meta { font-family: var(--mono); font-size: 0.6rem; line-height: 1.9; color: var(--muted); flex: 1; }
  .chord-meta span { color: var(--text); }
  .chord-btns { display: flex; flex-direction: column; gap: 5px; }

  /* ── PIANO ── */
  #piano-container { overflow-x: auto; margin-top: 10px; -webkit-overflow-scrolling: touch; }
  #piano { display: flex; height: 80px; width: max-content; margin: 0 auto; }
  .piano-key { position: relative; flex-shrink: 0; }
  .piano-key.white {
    width: 28px; height: 80px; background: #e8e8e0;
    border: 1px solid #999; border-top: none; border-radius: 0 0 3px 3px; z-index: 1;
  }
  .piano-key.white.active { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
  .piano-key.black {
    position: absolute; width: 18px; height: 50px;
    background: #1a1a1a; border-radius: 0 0 3px 3px; z-index: 2; top: 0;
  }
  .piano-key.black.active { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }

  /* ── SLIDERS ── */
  .slider-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
  .slider-row label {
    display: flex; justify-content: space-between;
    font-family: var(--mono); font-size: 0.6rem; color: var(--muted);
  }
  .slider-row label .val { color: var(--accent); min-width: 36px; text-align: right; }
  input[type=range] {
    -webkit-appearance: none; width: 100%; height: 3px;
    background: var(--border); border-radius: 2px; outline: none;
  }
  input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    background: var(--accent); border-radius: 50%; cursor: pointer;
    box-shadow: 0 0 5px var(--accent);
  }
  input[type=range].pink::-webkit-slider-thumb  { background: var(--accent2); box-shadow: 0 0 5px var(--accent2); }
  input[type=range].purple::-webkit-slider-thumb { background: #9b5de5; box-shadow: 0 0 5px #9b5de5; }

  /* ── SELECTS ── */
  select {
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); font-family: var(--mono); font-size: 0.65rem;
    padding: 8px 10px; border-radius: 3px; width: 100%; outline: none;
  }

  /* ── BUTTONS ── */
  .btn {
    font-family: var(--display); font-size: 0.62rem; letter-spacing: 0.1em;
    padding: 10px 14px; border: 1px solid; border-radius: 3px;
    cursor: pointer; transition: all .2s; background: transparent;
  }
  .btn-primary { border-color: var(--accent); color: var(--accent); }
  .btn-primary:hover, .btn-primary:active { background: var(--accent); color: var(--bg); box-shadow: 0 0 14px rgba(0,245,212,.4); }
  .btn-danger  { border-color: var(--accent2); color: var(--accent2); }
  .btn-danger:hover, .btn-danger:active { background: var(--accent2); color: #fff; }
  .btn-sm { padding: 7px 11px; font-size: 0.56rem; }
  .btn-full { width: 100%; display: block; text-align: center; }
  .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
  .btn.active { background: var(--accent); color: var(--bg); }
  @keyframes playing-glow { 0%,100%{box-shadow:0 0 10px rgba(0,245,212,.4)} 50%{box-shadow:0 0 24px rgba(0,245,212,.8)} }
  .btn-primary.active { animation: playing-glow 1.2s infinite; }

  /* ── SEQUENCE ── */
  .seq-display {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px; padding: 10px; min-height: 60px;
    font-family: var(--mono); font-size: 0.62rem; margin-bottom: 10px;
  }
  .seq-title { color: var(--muted); font-size: 0.56rem; letter-spacing: .1em; margin-bottom: 7px; text-transform: uppercase; }
  .seq-steps { display: flex; gap: 5px; flex-wrap: wrap; }
  .seq-step { display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .seq-step-color { width: 26px; height: 26px; border-radius: 3px; border: 1px solid var(--border); transition: all .15s; }
  .seq-step.active .seq-step-color { border-color: var(--accent); box-shadow: 0 0 7px var(--accent); transform: scale(1.1); }
  .seq-step-chord { font-size: 0.48rem; color: var(--muted); max-width: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .seq-step.active .seq-step-chord { color: var(--accent); }

  /* ── HARMONY CHIPS ── */
  .harmony-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 8px; }
  .harmony-chip {
    padding: 6px 7px; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 3px; font-family: var(--mono); font-size: 0.58rem;
    cursor: pointer; transition: all .2s; text-align: center;
  }
  .harmony-chip:hover, .harmony-chip:active { border-color: var(--accent); color: var(--accent); }
  .harmony-chip .type { display: block; color: var(--muted); font-size: 0.5rem; margin-bottom: 1px; }

  /* ── MIDI LOG ── */
  #midi-log {
    font-family: var(--mono); font-size: 0.58rem; color: var(--muted);
    height: 100px; overflow-y: auto; background: var(--bg);
    border: 1px solid var(--border); border-radius: 3px; padding: 7px; line-height: 1.8;
  }
  #midi-log::-webkit-scrollbar { width: 3px; }
  #midi-log::-webkit-scrollbar-thumb { background: var(--border); }
  .log-entry .ts { color: #333; }
  .log-entry .note-on  { color: var(--accent); }
  .log-entry .note-off { color: var(--accent2); }
  .log-entry .info     { color: #9b5de5; }

  /* ── CONTROL LABEL ── */
  .control-label {
    font-family: var(--mono); font-size: 0.58rem; color: var(--accent);
    letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; display: block;
  }

  /* ── BADGE ── */
  .badge {
    display: inline-block; background: var(--accent3); color: #fff;
    font-family: var(--mono); font-size: 0.52rem; padding: 2px 6px;
    border-radius: 8px; vertical-align: middle; margin-left: 5px;
  }

  /* ── TIP ── */
  .tip { font-family: var(--mono); font-size: 0.54rem; color: var(--muted); margin-top: 6px; }

  /* ── CONNECT BTN ── */
  #connectBtn {
    font-family: var(--display); font-size: 0.56rem; letter-spacing: .1em;
    padding: 6px 12px; border: 1px solid var(--accent); color: var(--accent);
    background: transparent; border-radius: 3px; cursor: pointer;
  }
/* ── CHROMAMIDI PLUGIN WRAPPER ── */
.chromamidi-wrapper {
  all: initial;
  display: block;
  font-size: 16px;
}
.chromamidi-wrapper *, .chromamidi-wrapper *::before, .chromamidi-wrapper *::after {
  box-sizing: border-box;
}

/* Eyedropper / Color Picker overlay */
#cm-eyedropper-overlay {
  position: fixed; inset: 0; z-index: 99999;
  cursor: crosshair;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center; justify-content: center;
}
#cm-eyedropper-overlay.active { display: flex; }
#cm-eyedropper-hint {
  background: rgba(5,5,8,0.92);
  border: 1px solid #00f5d4;
  border-radius: 6px;
  padding: 12px 20px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  color: #00f5d4;
  pointer-events: none;
}
#cm-eyedropper-preview {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #00f5d4;
  margin-bottom: 10px;
}
#cm-picker-btn {
  font-family: var(--display);
  font-size: 0.58rem; letter-spacing: .1em;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  color: var(--accent); background: transparent;
  border-radius: 3px; cursor: pointer;
  margin-left: 8px;
}

/* Admin notice */
.cm-admin-bar {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 8px 12px;
  font-family: var(--mono); font-size: 0.58rem;
  color: var(--muted); margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.cm-admin-bar a { color: var(--accent); }
