:root {
  /* Common Variables */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  
  /* Fallback Theme Variables (Overridden by distinct themes) */
  --bg-color: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --primary-color: #3b82f6;
  --accent-color: #8b5cf6;
  --danger-color: #ef4444;
}

body.theme-city {
  --bg-color: #000000;
  --bg-image: linear-gradient(to right bottom, #1e1b4b, #020617);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --primary-color: #8b5cf6;
  --accent-color: #ec4899;
  --glass-bg: rgba(30, 27, 75, 0.4);
  --glass-border: rgba(139, 92, 246, 0.2);
}

body.theme-rain {
  --bg-color: #0f172a;
  --bg-image: linear-gradient(to right bottom, #1e293b, #0f172a);
  --text-primary: #e2e8f0;
  --text-secondary: #cbd5e1;
  --primary-color: #0ea5e9;
  --accent-color: #06b6d4;
  --glass-bg: rgba(15, 23, 42, 0.6);
  --glass-border: rgba(14, 165, 233, 0.2);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  background-image: var(--bg-image);
  color: var(--text-primary);
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

/* Glassmorphism Panel */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.workspace-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

/* Header & Quotes */
.header-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 100;
}

.logo {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quote-container {
  text-align: center;
  flex: 1;
  margin: 0 24px;
  opacity: 0.9;
  transition: opacity 0.5s;
}

#quote-text {
  font-style: italic;
  font-size: 0.95rem;
}

#quote-author {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-left: 8px;
}

.controls-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
}

.theme-selector {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 20px;
  padding: 4px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.icon-btn.active {
  color: var(--primary-color);
  background: rgba(255, 255, 255, 0.05);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  outline: none;
  margin: 0 8px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
}

/* Main Grid Layout */
.main-grid {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 24px;
  flex: 1;
}

/* Utilities */
h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.btn.primary {
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
  color: white;
}

.btn.primary:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Timer Left Column */
.timer-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.timer-display {
  position: relative;
  width: 240px;
  height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  transform: rotate(-90deg);
}

.progress-ring__circle {
  transition: stroke-dashoffset 0.1s linear;
  stroke-dasharray: 691; /* 2 * pi * 110 */
  stroke-dashoffset: 0;
}

.timer-text {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 800;
  z-index: 10;
  letter-spacing: -2px;
}

.timer-status {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  z-index: 10;
  margin-top: -8px;
}

.timer-controls {
  display: flex;
  gap: 12px;
  width: 100%;
}

.timer-controls .btn {
  flex: 1;
}

.timer-presets {
  width: 100%;
  margin-top: 10px;
}

.timer-presets h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.preset-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.preset-chip:hover, .preset-chip.active {
  background: var(--primary-color);
  background: rgba(var(--primary-rgb), 0.2);
  border-color: var(--primary-color);
}

.add-preset {
  display: flex;
  gap: 8px;
}

.add-preset input {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  outline: none;
}
.add-preset input#preset-name { flex: 1; }
.add-preset input#preset-mins { width: 60px; }

/* History Panel */
.history-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 4px 0;
}
.history-panel h3 { margin-bottom: 0; }

.history-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 16px;
}
.history-content.collapsed { max-height: 0; margin-top: 0; }

.history-item {
  padding: 12px;
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.history-item .timestamp { color: var(--text-secondary); font-size: 0.75rem; margin-bottom: 4px; }
.history-item .summary { color: var(--text-primary); }

/* Center Column (YouTube Player) */
.player-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.player-header h3 { margin-bottom: 0; }

.station-selector {
  display: flex;
  gap: 8px;
}

.station-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.station-btn.active, .station-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.youtube-container {
  flex: 1;
  background: black;
  border-radius: 12px;
  overflow: hidden;
  min-height: 300px;
  position: relative;
}

.youtube-container iframe {
  width: 100%;
  height: 100%;
  pointer-events: none; /* Make it simple and elegant, avoid yt branding noise */
}

.player-controls {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
}

.play-btn {
  color: var(--primary-color);
  transform: scale(1.5);
}
.play-btn:hover { color: var(--accent-color); transform: scale(1.6); }

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

/* Right Column (Tasks) */
.task-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: 12px;
}

.add-task-container {
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  padding: 8px 16px;
  margin-bottom: 16px;
}

.add-task-container input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  outline: none;
  font-family: var(--font-body);
}

.filter-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 12px;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
}
.filter-btn.active { color: var(--text-primary); }
.filter-btn.active::after {
  content: '';
  position: absolute;
  bottom: -13px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary-color);
}

.task-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  margin-bottom: 16px;
}

.task-list::-webkit-scrollbar { width: 6px; }
.task-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: var(--transition);
  cursor: grab;
}

.task-item:active { cursor: grabbing; }
.task-item:hover { background: rgba(255,255,255,0.08); }

.task-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: var(--transition);
}

.task-item.completed .task-checkbox {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}
.task-item.completed .task-text {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.task-text {
  flex: 1;
  font-size: 0.95rem;
  transition: var(--transition);
}

.drag-handle {
  color: var(--text-secondary);
  cursor: grab;
  opacity: 0.5;
}

.delete-btn {
  opacity: 0;
  transition: var(--transition);
}
.task-item:hover .delete-btn { opacity: 1; color: var(--danger-color); }

.text-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}
.text-btn:hover { color: var(--danger-color); }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: var(--transition);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 400px;
  max-width: 90%;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.shortcuts-list {
  list-style: none;
}
.shortcuts-list li {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--glass-border);
}

kbd {
  background: rgba(255,255,255,0.1);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: monospace;
  border: 1px solid rgba(255,255,255,0.2);
  border-bottom-width: 2px;
}

/* Responsiveness */
@media (max-width: 1024px) {
  .main-grid {
    grid-template-columns: 1fr 1fr;
  }
  .center-col {
    grid-column: span 2;
    order: -1;
  }
}

@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .center-col { grid-column: 1; }
  .header-section {
    flex-direction: column;
    gap: 16px;
    border-radius: 20px;
    padding: 16px;
  }
  .quote-container { margin: 0; }
  .controls-toolbar { width: 100%; justify-content: space-between; }
}

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

/* Phase 2: Gamification & Mixing */

.score-badge {
  display: flex;
  align-items: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 6px 16px;
  border-radius: 20px;
  gap: 12px;
  backdrop-filter: blur(10px);
}
.level-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-color);
  letter-spacing: 1px;
}
.score-points {
  font-family: var(--font-heading);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: white;
}
.streak-icon {
  color: #fb923c;
  width: 16px;
  height: 16px;
}

.ambient-mixer-container {
  position: relative;
}
.mixer-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 12px;
  width: 200px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 50;
}
.ambient-mixer-container.active .mixer-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.mixer-dropdown h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
}
.mixer-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mixer-row span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-primary);
}
.styled-select {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: var(--font-body);
  outline: none;
  cursor: pointer;
}
.styled-select option {
  background: #1e1e1e;
  color: white;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 300px;
  animation: slideInUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.toast-error {
  border-left: 4px solid var(--danger-color);
}
.toast.toast-success {
  border-left: 4px solid #10b981;
}
.toast-icon {
  margin-top: 2px;
}
.toast-error .toast-icon { color: var(--danger-color); }
.toast-success .toast-icon { color: #10b981; }

.toast-content h4 {
  margin: 0 0 4px 0;
  font-family: var(--font-heading);
  font-size: 1rem;
}
.toast-content p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.toast.fade-out {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(50px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateX(50px); }
}

/* Score Pulse Animation */
@keyframes scorePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  50% { transform: scale(1.1); box-shadow: 0 0 20px rgba(239, 68, 68, 0.8); border-color: var(--danger-color); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
}
.score-badge.pulse-error {
  animation: scorePulse 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
@keyframes scorePulseSuccess {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(16, 185, 129, 0); }
  50% { transform: scale(1.1); box-shadow: 0 0 20px rgba(16, 185, 129, 0.8); border-color: #10b981; }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(16, 185, 129, 0); }
}
.score-badge.pulse-success {
  animation: scorePulseSuccess 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
