:root {
  --bg-primary: #000000; /* pure black = transparent on additive display, lets real world show through */
  --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);
  --success: #00ff88;
  --warning: #ffaa00;
  --info: #00b4d8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

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: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 {
  font-size: 22px;
  font-weight: 600;
  flex: 1;
}
.header-icon { font-size: 24px; }
.header-meta {
  font-size: 13px;
  color: var(--text-secondary);
}
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}

/* --- Content Area --- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-top: 4px;
}

.hint {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px;
}

/* --- Focus States (critical for EMG/D-pad) --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* --- Cards / List Items --- */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  gap: 12px;
  flex-shrink: 0;
}
.list-item:focus { background: var(--bg-card); }
.list-item-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}
.list-item-content { flex: 1; min-width: 0; }
.list-item-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Player --- */
.player-header { gap: 16px; }
.player-title-block { flex: 1; min-width: 0; }
.player-song {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-artist {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 24px;
  position: relative;
  overflow: hidden;
}

.lyrics-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.lyric-line {
  width: 100%;
  line-height: 1.3;
  overflow: hidden;
}
.lyric-line.prev {
  font-size: 18px;
  color: var(--text-muted);
  min-height: 24px;
}
.lyric-line.current {
  position: relative;
  font-size: 30px;
  font-weight: 700;
  color: var(--text-secondary);
  min-height: 78px;
}
.lyric-line.next {
  font-size: 20px;
  color: var(--text-secondary);
  min-height: 26px;
}
.lyric-line.next2 {
  font-size: 18px;
  color: var(--text-muted);
  min-height: 24px;
}

/* Karaoke wipe: bright copy clipped left-to-right over the dim base copy */
.line-base { display: block; }
.line-fill {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: var(--accent-primary);
  text-shadow: 0 0 18px var(--focus-glow);
  clip-path: inset(0 100% 0 0);
  pointer-events: none;
}

.countdown {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-warm);
  background: var(--bg-secondary);
  padding: 8px 20px;
  border-radius: var(--radius-lg);
}

.player-footer {
  flex-shrink: 0;
  padding: 12px 20px 16px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.player-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.control-hint {
  font-size: 13px;
  color: var(--text-secondary);
}
.control-hint.accent { color: var(--accent-primary); font-weight: 600; }

/* --- Loading States --- */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  flex: 1;
}
.loading-spinner {
  width: 48px;
  height: 48px;
  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: 16px;
  color: var(--text-secondary);
}

/* --- Error States --- */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  text-align: center;
}
.error-icon { font-size: 48px; }
.error-message {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 400px;
}

/* --- Toast Notifications --- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  border: 1px solid var(--accent-primary);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

/* --- Progress Bar --- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-primary);
  border-radius: 3px;
}

/* --- D-pad Keyboard --- */
.search-content { gap: 14px; }

.query-display {
  min-height: 56px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 20px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
}
.query-text { color: var(--text-primary); }
.query-placeholder { color: var(--text-muted); }
.query-caret {
  display: inline-block;
  width: 2px;
  height: 24px;
  margin-left: 2px;
  background: var(--accent-primary);
  flex-shrink: 0;
}

.kbd {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.kbd-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}
.kbd-key {
  flex: 1;
  max-width: 52px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}
.kbd-key.kbd-wide { max-width: 118px; flex: 2; font-size: 16px; }
.kbd-key.kbd-space { max-width: 200px; flex: 4; font-size: 15px; color: var(--text-secondary); }
.kbd-key.targeted {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
  background: var(--bg-card);
  color: var(--accent-primary);
}

.search-results { flex: 1; }

/* --- Text Input --- */
.text-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  flex-shrink: 0;
}
.text-input:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
  outline: none;
}
.text-input::placeholder { color: var(--text-muted); }

/* --- Utility --- */
.hidden { display: none !important; }
