/* ============================================================
   6oal Studio — dark neon studio theme
   Shared component library used by every module.
   ============================================================ */

:root {
  --bg: #0b0e14;
  --panel: #151a24;
  --raised: #1d2432;
  --line: #2a3346;
  --line-bright: #3b4763;
  --text: #e8ecf4;
  --dim: #8a94a8;
  --accent: #00e5ff;
  --accent2: #ff3d81;
  --good: #3dff8a;
  --warn: #ffb020;
  --danger: #ff4757;
  --glow: 0 0 12px;
  --accent-soft: rgba(0, 229, 255, 0.14);
  --accent2-soft: rgba(255, 61, 129, 0.14);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(0, 229, 255, 0.07), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(255, 61, 129, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

::selection { background: rgba(0, 229, 255, 0.3); }

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 6px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--line-bright); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- Focus ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Base form controls (theme-wide) ---------- */
button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  touch-action: manipulation;
}
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #0d1118;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 40px;
  touch-action: manipulation;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.18);
}
input::placeholder { color: var(--dim); }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
  cursor: pointer;
}
input[type="number"] { font-family: var(--mono); }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="file"] { min-height: 0; padding: 6px; }

/* ============================================================
   Topbar
   ============================================================ */
#topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 8px 14px;
  background: rgba(15, 19, 28, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}
#topbar::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent));
  opacity: 0.8;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  margin-right: 4px;
  border-radius: 11px;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.brand:hover, .brand:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.22);
  outline: none;
}
.brand:hover .brand-mark, .brand:focus-visible .brand-mark {
  filter: drop-shadow(0 0 16px rgba(0, 229, 255, 0.85));
  transform: rotate(-12deg);
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 0 9px rgba(0, 229, 255, 0.45));
  transition: filter 0.16s ease, transform 0.16s ease;
}
.brand-mark svg { display: block; }
.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--accent), #9be8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}
.brand-name em {
  font-style: normal;
  font-weight: 300;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: var(--dim);
}

.tb-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tb-group + .tb-group { padding-left: 12px; border-left: 1px solid var(--line); }
.tb-actions { margin-left: auto; }

#project-name {
  width: 170px;
  min-height: 40px;
  font-weight: 600;
  background: transparent;
  border-color: transparent;
}
#project-name:hover { border-color: var(--line); background: #0d1118; }
#project-name:focus { border-color: var(--accent); background: #0d1118; }

#position-display {
  min-width: 74px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.tb-bpm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tb-bpm-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--dim);
}
#bpm-input {
  width: 64px;
  text-align: center;
  min-height: 40px;
  color: var(--accent);
  font-weight: 600;
}

#master-meter {
  width: 64px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #05070b;
  box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.8);
  flex: none;
}

/* transport button states */
.tb-rec.active {
  color: var(--danger) !important;
  border-color: var(--danger) !important;
  background: radial-gradient(circle at 50% 40%, rgba(255, 71, 87, 0.3), rgba(255, 71, 87, 0.06)) !important;
  box-shadow: var(--glow) rgba(255, 71, 87, 0.8);
  animation: recPulse 1.1s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 71, 87, 0.5); }
  50% { box-shadow: 0 0 16px rgba(255, 71, 87, 0.95); }
}
.tb-play.active {
  color: var(--good) !important;
  border-color: var(--good) !important;
  background: radial-gradient(circle at 50% 40%, rgba(61, 255, 138, 0.22), rgba(61, 255, 138, 0.05)) !important;
  box-shadow: var(--glow) rgba(61, 255, 138, 0.6);
}
#btn-export .caret { font-size: 11px; opacity: 0.8; margin-left: 2px; }

/* ============================================================
   Tabs & panels
   ============================================================ */
#tabs {
  position: sticky;
  top: 0;
  z-index: 400;
  display: flex;
  gap: 2px;
  padding: 0 10px;
  background: rgba(11, 14, 20, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  min-height: 48px;
  padding: 0 18px;
  color: var(--dim);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: linear-gradient(180deg, transparent 40%, rgba(0, 229, 255, 0.1));
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.55);
}

main {
  padding: 14px;
  max-width: 1500px;
  margin: 0 auto;
}
.panel { display: none; }
.panel.active { display: block; animation: panelIn 0.2s ease; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--raised), var(--panel));
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: border-color 0.12s, box-shadow 0.12s, color 0.12s, transform 0.06s, background 0.12s;
}
.btn:hover { border-color: var(--line-bright); color: #fff; }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn.primary {
  border-color: rgba(0, 229, 255, 0.6);
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.22), rgba(0, 229, 255, 0.07)), linear-gradient(180deg, var(--raised), var(--panel));
  color: var(--accent);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}
.btn.primary:hover { box-shadow: var(--glow) rgba(0, 229, 255, 0.4); color: #bff5ff; }

.btn.danger {
  border-color: rgba(255, 71, 87, 0.6);
  background: linear-gradient(180deg, rgba(255, 71, 87, 0.2), rgba(255, 71, 87, 0.05)), linear-gradient(180deg, var(--raised), var(--panel));
  color: var(--danger);
}
.btn.danger:hover { box-shadow: var(--glow) rgba(255, 71, 87, 0.45); color: #ffb3ba; }

.btn.small {
  min-height: 36px;
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 7px;
}

.btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), rgba(0, 229, 255, 0.04)), linear-gradient(180deg, var(--raised), var(--panel));
  box-shadow: var(--glow) rgba(0, 229, 255, 0.5), inset 0 0 10px rgba(0, 229, 255, 0.12);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--raised), var(--panel));
  color: var(--dim);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, box-shadow 0.12s, color 0.12s, transform 0.06s, background 0.12s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-bright); }
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { display: block; pointer-events: none; }
.icon-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: radial-gradient(circle at 50% 35%, var(--accent-soft), rgba(0, 229, 255, 0.03));
  box-shadow: var(--glow) rgba(0, 229, 255, 0.55);
}

/* ============================================================
   Knobs
   ============================================================ */
.knob-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 56px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  user-select: none;
  -webkit-user-select: none;
  text-align: center;
}
.knob {
  --rot: 0deg;
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line-bright);
  background:
    radial-gradient(circle at 34% 28%, #313c52, #1a2130 62%, #10141e);
  box-shadow:
    0 5px 12px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -3px 8px rgba(0, 0, 0, 0.5);
  cursor: ns-resize;
  touch-action: none;
  transform: rotate(var(--rot));
  transition: box-shadow 0.15s;
}
.knob::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}
.knob::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  width: 4px;
  height: 14px;
  margin-left: -2px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: var(--glow) var(--accent);
  pointer-events: none;
}
.knob:hover { box-shadow: 0 5px 12px rgba(0, 0, 0, 0.55), var(--glow) rgba(0, 229, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08); }

/* ============================================================
   Faders (range inputs)
   ============================================================ */
.fader {
  -webkit-appearance: none;
  appearance: none;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 44px;
  height: 132px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 10px, rgba(138, 148, 168, 0.18) 10px 11px) no-repeat center / 22px calc(100% - 16px),
    linear-gradient(to top, rgba(0, 229, 255, 0.35), rgba(42, 51, 70, 0.9)) no-repeat center / 6px calc(100% - 8px);
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
}
.fader:focus { box-shadow: none; border: none; }
.fader::-webkit-slider-runnable-track { background: transparent; border: none; }
.fader::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 38px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--line-bright);
  background:
    linear-gradient(to bottom, transparent 8px, var(--accent) 8px, var(--accent) 11px, transparent 11px),
    linear-gradient(180deg, #39445c, #212939 55%, #171d29);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), var(--glow) rgba(0, 229, 255, 0.3);
  cursor: grab;
}
.fader::-moz-range-track { background: transparent; border: none; }
.fader::-moz-range-thumb {
  width: 38px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--line-bright);
  background:
    linear-gradient(to bottom, transparent 8px, var(--accent) 8px, var(--accent) 11px, transparent 11px),
    linear-gradient(180deg, #39445c, #212939 55%, #171d29);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), var(--glow) rgba(0, 229, 255, 0.3);
  cursor: grab;
}
.fader:active::-webkit-slider-thumb { cursor: grabbing; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), var(--glow) rgba(0, 229, 255, 0.65); }
.fader:active::-moz-range-thumb { cursor: grabbing; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), var(--glow) rgba(0, 229, 255, 0.65); }

.hfader {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 90px;
  height: 44px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background:
    linear-gradient(to right, rgba(0, 229, 255, 0.35), rgba(42, 51, 70, 0.9)) no-repeat center / calc(100% - 8px) 6px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
}
.hfader:focus { box-shadow: none; border: none; }
.hfader::-webkit-slider-runnable-track { background: transparent; border: none; }
.hfader::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 34px;
  margin-top: 5px;
  border-radius: 5px;
  border: 1px solid var(--line-bright);
  background:
    linear-gradient(to right, transparent 8px, var(--accent) 8px, var(--accent) 11px, transparent 11px),
    linear-gradient(90deg, #39445c, #212939 55%, #171d29);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), var(--glow) rgba(0, 229, 255, 0.3);
  cursor: grab;
}
.hfader::-moz-range-track { background: transparent; border: none; }
.hfader::-moz-range-thumb {
  width: 20px;
  height: 34px;
  border-radius: 5px;
  border: 1px solid var(--line-bright);
  background:
    linear-gradient(to right, transparent 8px, var(--accent) 8px, var(--accent) 11px, transparent 11px),
    linear-gradient(90deg, #39445c, #212939 55%, #171d29);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), var(--glow) rgba(0, 229, 255, 0.3);
  cursor: grab;
}

/* ============================================================
   Pads
   ============================================================ */
.pad-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 10px;
  max-width: 440px;
}
.pad {
  position: relative;
  min-width: 56px;
  min-height: 56px;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.05), transparent 55%),
    linear-gradient(180deg, var(--raised), var(--panel));
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: var(--dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: box-shadow 0.1s, border-color 0.1s, color 0.1s, transform 0.05s;
}
.pad:hover { border-color: var(--line-bright); color: var(--text); }
.pad:active { transform: scale(0.96); }
.pad.lit {
  border-color: var(--accent);
  color: var(--accent);
  background:
    radial-gradient(circle at 50% 30%, rgba(0, 229, 255, 0.35), rgba(0, 229, 255, 0.05) 75%),
    linear-gradient(180deg, var(--raised), var(--panel));
  box-shadow: var(--glow) rgba(0, 229, 255, 0.8), inset 0 0 20px rgba(0, 229, 255, 0.3);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.8);
}

/* ============================================================
   Step sequencer cells
   ============================================================ */
.step {
  width: 44px;
  height: 44px;
  min-width: 34px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #171d29, #121722);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.08s, box-shadow 0.08s, border-color 0.08s;
}
.step:hover { border-color: var(--line-bright); }
.step.accent-beat {
  border-color: var(--line-bright);
  background: linear-gradient(180deg, #1c2434, #151b28);
}
.step.on {
  border-color: var(--accent);
  background: linear-gradient(180deg, #35f0ff, #00a8c4);
  box-shadow: var(--glow) rgba(0, 229, 255, 0.6), inset 0 1px 3px rgba(255, 255, 255, 0.45);
}
.step.playhead {
  border-color: var(--accent2);
  box-shadow: var(--glow) rgba(255, 61, 129, 0.75), inset 0 0 8px rgba(255, 61, 129, 0.35);
}
.step.on.playhead {
  background: linear-gradient(180deg, #a8f8ff, #35d4ec);
  box-shadow: var(--glow) rgba(255, 255, 255, 0.7), inset 0 1px 3px rgba(255, 255, 255, 0.6);
}

/* ============================================================
   Screens & LEDs
   ============================================================ */
.screen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #04060a, #0a1019);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 7px rgba(0, 229, 255, 0.65);
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.85),
    inset 0 0 24px rgba(0, 229, 255, 0.05);
  user-select: none;
  white-space: nowrap;
}

.led {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #232c3d;
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
  flex: none;
  transition: background 0.1s, box-shadow 0.1s;
}
.led.on {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--glow) var(--accent), inset 0 0 3px rgba(255, 255, 255, 0.8);
}

/* ============================================================
   Cards & chips
   ============================================================ */
.card {
  background: linear-gradient(180deg, var(--raised), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.card:hover {
  border-color: var(--line-bright);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 14px rgba(0, 229, 255, 0.06);
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--raised), var(--panel));
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  touch-action: manipulation;
  transition: border-color 0.12s, color 0.12s, box-shadow 0.12s, background 0.12s;
}
.chip:hover { color: var(--text); border-color: var(--line-bright); }
.chip.active {
  color: var(--accent);
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), rgba(0, 229, 255, 0.03));
  box-shadow: var(--glow) rgba(0, 229, 255, 0.35);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

/* ============================================================
   Layout helpers
   ============================================================ */
.row { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.hidden { display: none !important; }

/* ============================================================
   Tooltips
   ============================================================ */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-3px);
  background: #0a0e16;
  border: 1px solid var(--line-bright);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  letter-spacing: 0.02em;
  text-transform: none;
  text-shadow: none;
  line-height: 1.3;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55), 0 0 10px rgba(0, 229, 255, 0.07);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease 0.25s, transform 0.15s ease 0.25s, visibility 0s linear 0.4s;
  z-index: 900;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: opacity 0.15s ease 0.35s, transform 0.15s ease 0.35s, visibility 0s linear 0.35s;
}

/* ============================================================
   Toasts
   ============================================================ */
#toast-root {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  background: linear-gradient(180deg, #202a3d, #171e2c);
  border: 1px solid var(--line-bright);
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 16px rgba(0, 229, 255, 0.1);
  max-width: 100%;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast.hide { opacity: 0; transform: translateY(6px); }

/* ============================================================
   Export menu (app.js)
   ============================================================ */
.app-menu {
  position: fixed;
  z-index: 1500;
  min-width: 210px;
  padding: 6px;
  background: linear-gradient(180deg, #1c2434, #141a26);
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65), 0 0 18px rgba(0, 229, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: panelIn 0.14s ease;
}
.app-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.app-menu-item:hover, .app-menu-item:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}
.app-menu-item .app-menu-sub {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--dim);
}

/* ============================================================
   First-run help overlay (app.js)
   ============================================================ */
.app-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: panelIn 0.2s ease;
  overflow-y: auto;
}
.app-help-card {
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: linear-gradient(180deg, #1a2130, #12161f);
  border: 1px solid var(--line-bright);
  border-radius: 16px;
  padding: 26px 26px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 229, 255, 0.08);
}
.app-help-card h2 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.app-help-card > p { margin: 0 0 18px; color: var(--dim); font-size: 14px; }
.app-help-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.app-help-step {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
}
.app-help-step .app-help-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #041014;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}
.app-help-step h3 { margin: 0 0 3px; font-size: 14px; color: var(--text); }
.app-help-step p { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--dim); }
.app-help-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.app-help-motto {
  margin-right: auto;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ============================================================
   Legal & rights overlay + site footer
   ============================================================ */
.legal-card { max-width: 680px; }
.legal-sec { margin-bottom: 14px; }
.legal-sec h3 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.legal-sec p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--dim); }
.legal-stamp {
  margin: 18px 0 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--dim);
  opacity: 0.8;
}

/* Kids / Learn app links in the top bar */
.tb-apps { display: flex; gap: 6px; }
.applink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-bright);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015));
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}
.applink:hover, .applink:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.28);
  transform: translateY(-1px);
  outline: none;
}
.applink-emoji { font-size: 15px; line-height: 1; }
/* Keep the words as long as they fit — an emoji alone reads as decoration,
   and these are the doorways to the kids and learning apps. */
@media (max-width: 560px) { .applink-txt { display: none; } .applink { padding: 0 9px; } }

.foot-apps a { font-weight: 600; }

/* Master volume in the transport bar */
.tb-vol {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
}
.tb-vol .hfader { width: 66px; }
.tb-vol:hover { color: var(--accent); }
/* On small screens the device's own volume keys cover this. */
@media (max-width: 700px) { .tb-vol { display: none; } }

/* "Save app to phone" — home-screen install bar */
#install-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2400;
  width: min(460px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-bright);
  border-radius: 16px;
  background: linear-gradient(180deg, #1a2130, #10151e);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 229, 255, 0.12);
  animation: installIn 0.32s cubic-bezier(.2,.9,.3,1.2);
}
#install-bar[hidden] { display: none; }
@keyframes installIn {
  from { opacity: 0; transform: translate(-50%, 26px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.ib-icon {
  border-radius: 10px;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.35);
}
.ib-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ib-text strong { font-size: 14px; }
.ib-sub { font-size: 11.5px; color: var(--dim); line-height: 1.35; }
.ib-close {
  appearance: none;
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--dim);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
.ib-close:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.ib-ios {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--dim);
  line-height: 1.45;
}
.ib-ios[hidden] { display: none; }
.ib-ios svg { color: var(--accent); flex: none; }
.ib-ios strong { color: var(--text); }
@media (max-width: 420px) {
  .ib-sub { display: none; }
}

/* "Tap to turn on sound" — shown whenever the browser has audio blocked */
#sound-nag {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2500;
}
#sound-nag[hidden] { display: none; }
#sound-nag button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  min-height: 48px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.22), rgba(0, 229, 255, 0.08));
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55), 0 0 26px rgba(0, 229, 255, 0.4);
  animation: nagPulse 2s ease-in-out infinite;
  touch-action: manipulation;
}
#sound-nag button:hover { background: linear-gradient(180deg, rgba(0,229,255,0.32), rgba(0,229,255,0.12)); }
@keyframes nagPulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(0,0,0,0.55), 0 0 20px rgba(0,229,255,0.32); }
  50%      { box-shadow: 0 8px 30px rgba(0,0,0,0.55), 0 0 34px rgba(0,229,255,0.62); }
}

#sitefoot a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 229, 255, 0.35);
}
#sitefoot a:hover, #sitefoot a:focus-visible {
  color: #9be8ff;
  border-bottom-color: #9be8ff;
  outline: none;
}
.foot-built { font-weight: 600; }

#sitefoot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: #080b11;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--dim);
  text-align: center;
}
#sitefoot em { font-style: normal; color: #a9b4c8; }
.foot-sep { opacity: 0.4; }
.foot-motto {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.foot-link {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 2px 4px;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  border-radius: 5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.foot-link:hover, .foot-link:focus-visible {
  color: #9be8ff;
  outline: none;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}
@media (max-width: 720px) {
  #sitefoot { font-size: 11px; }
  .foot-sep { display: none; }
  .foot-copy, .foot-tm, .foot-motto { flex-basis: 100%; }
}

/* ============================================================
   The 6 Elements — Create hub (app.js)
   ============================================================ */
.hub-card {
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 26px 22px 20px;
  border-radius: 18px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(0, 229, 255, 0.10), transparent 62%),
    radial-gradient(110% 80% at 50% 100%, rgba(255, 61, 129, 0.09), transparent 60%),
    linear-gradient(180deg, #161c28, #0f131c);
  border: 1px solid var(--line-bright);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75), 0 0 60px rgba(0, 229, 255, 0.07);
  text-align: center;
}

/* Ring layout: the 6 sits in the middle, six elements orbit it. */
.hub-ring {
  position: relative;
  width: min(560px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: repeat(3, auto);
  gap: 10px 16px;
  align-items: center;
}
.hub-center {
  grid-column: 2;
  grid-row: 2;
  width: 108px;
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: hubPulse 3.2s ease-in-out infinite;
}
.hub-center svg { display: block; }
@keyframes hubPulse {
  0%, 100% { filter: drop-shadow(0 0 16px rgba(0,229,255,0.45)) drop-shadow(0 0 30px rgba(255,61,129,0.20)); }
  50%      { filter: drop-shadow(0 0 26px rgba(0,229,255,0.75)) drop-shadow(0 0 46px rgba(255,61,129,0.34)); }
}
.hub-el {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 62px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012));
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  touch-action: manipulation;
}
/* left column = 1,2,3 ; right column = 4,5,6 */
.hub-el:nth-of-type(1) { grid-column: 1; grid-row: 1; }
.hub-el:nth-of-type(2) { grid-column: 1; grid-row: 2; }
.hub-el:nth-of-type(3) { grid-column: 1; grid-row: 3; }
.hub-el:nth-of-type(4) { grid-column: 3; grid-row: 1; }
.hub-el:nth-of-type(5) { grid-column: 3; grid-row: 2; }
.hub-el:nth-of-type(6) { grid-column: 3; grid-row: 3; }
.hub-el:hover, .hub-el:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(0,229,255,0.14), rgba(0,229,255,0.04));
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.28);
  outline: none;
}
.hub-el:active { transform: translateY(0); }
.hub-el-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.hub-el-tag { font-size: 12px; color: var(--dim); line-height: 1.35; }
.hub-el:hover .hub-el-tag, .hub-el:focus-visible .hub-el-tag { color: var(--text); }

.hub-tagline {
  margin: 20px 0 16px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* "New here?" — Kids / Learn doorways inside the first-run hub */
.hub-who {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}
.hub-who-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-right: 2px;
}
.hub-who-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 260px;
  max-width: 340px;
  min-height: 62px;
  padding: 11px 16px;
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-decoration: none;   /* these are buttons, not body links */
  text-align: left;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.hub-who-link::after {
  content: '→';
  margin-left: auto;
  font-size: 17px;
  color: var(--accent);
  opacity: 0.75;
  transition: transform 0.14s ease, opacity 0.14s ease;
}
.hub-who-link:hover, .hub-who-link:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.14), rgba(0, 229, 255, 0.04));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 24px rgba(0, 229, 255, 0.32);
  outline: none;
}
.hub-who-link:hover::after, .hub-who-link:focus-visible::after {
  transform: translateX(3px);
  opacity: 1;
}
.hub-who-link:active { transform: translateY(0); }
.hub-who-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 22px;
  line-height: 1;
}
.hub-who-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hub-who-txt strong { font-size: 14.5px; font-weight: 700; line-height: 1.2; }
.hub-who-sub { font-size: 11.5px; line-height: 1.3; color: var(--dim); }
@media (max-width: 620px) {
  .hub-who { flex-direction: column; align-items: stretch; gap: 8px; }
  .hub-who-label { text-align: center; margin: 0 0 2px; }
}

.hub-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.hub-pref {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: auto;
  font-size: 12.5px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}
.hub-pref input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.hub-fine {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--dim);
  opacity: 0.75;
  letter-spacing: 0.02em;
}

@media (max-width: 620px) {
  .hub-ring {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 9px;
  }
  .hub-center {
    grid-column: 1;
    grid-row: 1;
    width: 74px;
    height: 74px;
    font-size: 40px;
    margin: 0 auto 6px;
  }
  .hub-el:nth-of-type(1), .hub-el:nth-of-type(2), .hub-el:nth-of-type(3),
  .hub-el:nth-of-type(4), .hub-el:nth-of-type(5), .hub-el:nth-of-type(6) {
    grid-column: 1;
    grid-row: auto;
  }
  .hub-card { padding: 20px 14px 16px; }
  .hub-pref { margin-right: 0; width: 100%; justify-content: center; }
  .hub-foot > .btn { flex: 1; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  #project-name { width: 120px; }
  .brand-name em { display: none; }
}

@media (max-width: 720px) {
  #topbar { padding: 6px 8px; gap: 6px 8px; }
  .tb-group + .tb-group { padding-left: 8px; }
  .tb-group.tb-history { border-left: none; padding-left: 0; }
  .brand-name { display: none; }
  #project-name { width: 100px; font-size: 13px; }
  .tab { padding: 0 13px; font-size: 13px; }
  main { padding: 10px; }
  #position-display { min-width: 60px; font-size: 14px; }
  .step { width: 38px; height: 38px; }
}

@media (max-width: 480px) {
  .tb-bpm-label { display: none; }
  #master-meter { display: none; }
  #btn-help { display: none; }
  .tb-actions .btn.small { padding: 5px 9px; }
  #project-name { width: 84px; }
  .step { width: 34px; height: 34px; border-radius: 6px; }
  .pad-grid { gap: 8px; }
  [data-tip]::after { display: none; }
}

@media (pointer: coarse) {
  [data-tip]::after { display: none; }
}

.legal-more { margin: 4px 0 0; font-size: 13px; color: var(--dim); }
.legal-more a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(0,229,255,.35); }
.legal-more a:hover { color: #9be8ff; }
.foot-legal a { font-weight: 600; }
