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

:root {
  --bg-primary: #0c0c0f;
  --bg-secondary: #141417;
  --bg-card: #1c1c21;
  --text-primary: #e4e4e7;
  --text-secondary: #71717a;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --success: #34d399;
  --warning: #fbbf24;
  --border: #27272a;
  --shadow: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --accent: #e94560;
  --accent-hover: #d63851;
  --success: #16a34a;
  --warning: #d97706;
  --border: #d4d4d8;
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* ── Modal (shared) ── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.modal h2 {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* ── Toggle Switch (shared) ── */

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.25s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.25s ease, background 0.25s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* ── Settings Modal ── */

.settings-modal {
  max-width: 440px;
}

.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.settings-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.settings-tab:hover {
  color: var(--text-primary);
}

.settings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.settings-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.keybind-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.keybind-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  background: var(--bg-primary);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.keybind-label {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.keybind-key {
  min-width: 44px;
  padding: 0.3rem 0.7rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.keybind-key:hover {
  border-color: var(--accent);
}

.keybind-key.listening {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
  animation: pulse-key 0.8s ease-in-out infinite;
  color: var(--accent);
}

@keyframes pulse-key {
  0%, 100% { box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2); }
  50% { box-shadow: 0 0 0 5px rgba(233, 69, 96, 0.1); }
}

.reaction-edit-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.reaction-edit-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.reaction-input {
  flex: 1;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}

.reaction-remove {
  padding: 0.3rem 0.6rem;
  font-size: 1.1rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.reaction-remove:hover {
  color: var(--accent);
}

.reaction-add {
  margin-top: 0.3rem;
  justify-content: center;
  font-size: 0.8rem;
}

.settings-reset-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ── Settings Button (gear icon) ── */

.settings-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.settings-btn svg {
  width: 20px;
  height: 20px;
}

/* ── Reaction Wheel ── */

.reaction-wheel-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  cursor: default;
}

.reaction-wheel {
  position: absolute;
  pointer-events: none;
}

.reaction-wheel-item {
  position: absolute;
  padding: 0.35rem 0.7rem;
  background: rgba(0, 0, 0, 0.85);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  transform: translate(-50%, -50%);
}

.reaction-wheel-item:hover,
.reaction-wheel-item.highlighted {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translate(-50%, -50%) scale(1.15);
}

.reaction-wheel-center {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.5;
}
