:root {
  --bg-primary: #000000;       /* transparent on additive display */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #00d4ff;
  --accent-secondary: #00ff88;
  --accent-warm: #ff9f43;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --loop-color: #ff9f43;
  --loop-glow: rgba(255, 159, 67, 0.45);
  --success: #00ff88;
  --warning: #ffaa00;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* ============ SCREENS ============ */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0; left: 0;
}
.screen.hidden { display: none; }

/* ============ HEADER ============ */
.header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
  min-height: 64px;
}
.header h1 {
  font-size: 26px;
  font-weight: 600;
  flex: 1;
  letter-spacing: 0.3px;
}
.header-meta {
  font-size: 15px;
  color: var(--text-secondary);
}
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 28px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  line-height: 1;
  min-width: 52px;
  min-height: 52px;
}

/* ============ CONTENT ============ */
.content {
  flex: 1;
  padding: 14px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============ FOCUS ============ */
.focusable {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 52px;
  outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ============ NAV BAR ============ */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 16px 18px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  border: 2px solid transparent;
  cursor: pointer;
}
.nav-item:focus {
  background: var(--bg-card);
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
  outline: none;
}
.nav-item.primary {
  background: rgba(0, 212, 255, 0.18);
  color: var(--accent-primary);
  font-weight: 600;
}
.nav-item.primary:focus {
  background: rgba(0, 212, 255, 0.28);
  border-color: var(--accent-primary);
  box-shadow: 0 0 18px var(--focus-glow);
}
.nav-item.danger { background: rgba(255, 68, 102, 0.2); color: var(--danger); }
.nav-item.danger:focus { background: rgba(255, 68, 102, 0.3); border-color: var(--danger); box-shadow: 0 0 18px rgba(255, 68, 102, 0.4); }

/* ============ CARDS / LIST ============ */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-item {
  display: flex;
  align-items: center;
  padding: 18px 18px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 18px;
  text-align: left;
  gap: 14px;
  border: 2px solid transparent;
  cursor: pointer;
}
.list-item:focus {
  background: var(--bg-card);
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
  outline: none;
}
.list-item-icon {
  font-size: 26px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
  color: var(--accent-primary);
}
.list-item-content { flex: 1; min-width: 0; }
.list-item-title {
  font-weight: 500;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-meta {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 3px;
}
.list-item-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  background: rgba(0, 212, 255, 0.15);
  color: var(--accent-primary);
}

/* ============ SPLASH ============ */
.splash-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.splash-logo {
  font-size: 86px;
  color: var(--accent-primary);
  line-height: 1;
  text-shadow: 0 0 24px var(--focus-glow);
}
.splash-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 2px;
}
.loading-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--text-secondary); }

/* ============ ERROR / EMPTY ============ */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px;
  text-align: center;
}
.error-icon { font-size: 44px; color: var(--accent-warm); }
.error-message { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.error-message code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ============ PLAYER ============ */
.player-header { padding: 12px 18px; min-height: 60px; }
.player-title { flex: 1; min-width: 0; }
.player-track {
  font-size: 19px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-artist {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.player-stage {
  position: relative;
  flex: 1;
  background: var(--bg-secondary);
  overflow: hidden;
  min-height: 0;
}
.alphatab-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: transparent;
  scroll-behavior: smooth;
}
.alphatab-surface {
  background: transparent !important;
}
.alphatab-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-secondary);
  z-index: 5;
}
.alphatab-loading.hidden { display: none; }

.lock-indicator {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 68, 102, 0.18);
  color: var(--danger);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  border: 1.5px solid var(--danger);
  box-shadow: 0 0 16px rgba(255, 68, 102, 0.35);
  z-index: 12;
  pointer-events: none;
  user-select: none;
}
.lock-indicator.hidden { display: none; }

/* AlphaTab svg renders dark by default; force readable colors */
.alphatab-surface svg text,
.alphatab-surface svg tspan {
  fill: var(--text-primary) !important;
}
.alphatab-surface svg path,
.alphatab-surface svg line,
.alphatab-surface svg rect {
  stroke: var(--text-primary);
}
.alphatab-surface .at-cursor-bar {
  background: rgba(0, 212, 255, 0.18) !important;
  border-left: 2px solid rgba(0, 212, 255, 0.5) !important;
  border-right: 2px solid rgba(0, 212, 255, 0.5) !important;
}
.alphatab-surface .at-cursor-beat {
  background: #ff9f43 !important;
  width: 5px !important;
  box-shadow:
    0 0 8px rgba(255, 159, 67, 0.95),
    0 0 18px rgba(255, 159, 67, 0.6) !important;
  border-radius: 2px !important;
  opacity: 1 !important;
}
.alphatab-surface .at-selection div {
  background: rgba(255, 159, 67, 0.18) !important;
}

/* HUD */
.player-hud {
  display: flex;
  gap: 18px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
  border-top: 1px solid var(--bg-tertiary);
  flex-wrap: wrap;
}
.hud-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 16px;
}
.hud-label {
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1px;
}
.hud-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 17px;
}
.hud-value.muted { color: var(--text-secondary); font-weight: 400; }
.hud-divider { color: var(--text-muted); }
.hud-loop .hud-value { color: var(--text-secondary); }
.hud-loop.active .hud-value { color: var(--loop-color); }

/* Progress */
.player-progress {
  padding: 8px 18px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-primary);
  border-radius: 2px;
  transition: width 0.1s linear;
}
.progress-loop {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--loop-color);
  opacity: 0.35;
  pointer-events: none;
  display: none;
}
.progress-loop.visible { display: block; }

/* Keymap footer */
.player-keymap {
  display: flex;
  justify-content: space-between;
  padding: 10px 18px 12px;
  background: var(--bg-secondary);
  flex-shrink: 0;
  border-top: 1px solid var(--bg-tertiary);
  font-size: 13px;
  color: var(--text-secondary);
  gap: 8px;
}
.player-keymap .key {
  display: flex;
  align-items: center;
  gap: 6px;
}
.player-keymap kbd {
  font-family: inherit;
  font-size: 13px;
  padding: 3px 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-primary);
  border: 1px solid var(--bg-card);
}

/* ============ SETTINGS ============ */
.setting-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
}
.setting-row.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
  outline: none;
}
.setting-label {
  flex: 1;
  font-size: 17px;
  font-weight: 500;
}
.setting-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-primary);
  min-width: 70px;
  text-align: right;
}
.setting-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 8px;
}
.setting-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.step-btn {
  width: 48px;
  height: 48px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
}
.step-btn:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 14px var(--focus-glow);
  outline: none;
}

/* Catalog block */
.setting-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 8px 4px 0;
}
.setting-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}
.setting-stack .setting-label { flex: none; }
.setting-url {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent-primary);
  background: var(--bg-tertiary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  word-break: break-all;
  min-height: 32px;
}
.setting-url.muted { color: var(--text-muted); }
.text-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
}
.text-input:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
  outline: none;
}
.text-input::placeholder { color: var(--text-muted); }
.setting-row-actions {
  display: flex;
  gap: 8px;
}
.step-btn.wide {
  width: auto;
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 8px;
  height: auto;
}
.step-btn.danger {
  color: var(--danger);
  background: rgba(255, 68, 102, 0.12);
}
.step-btn.danger:focus { border-color: var(--danger); box-shadow: 0 0 14px rgba(255, 68, 102, 0.4); }
.setting-hint-block {
  margin-left: 0;
  line-height: 1.5;
  font-size: 12px;
}
.setting-hint-block code {
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 10px 22px;
  border-radius: var(--radius-md);
  font-size: 13px;
  border: 1px solid var(--accent-primary);
  transition: transform 0.25s ease;
  z-index: 100;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
.toast.loop { border-color: var(--loop-color); }

/* ============ UTILS ============ */
.hidden { display: none !important; }
.text-muted { color: var(--text-secondary); }
