/* ===== DESIGN SYSTEM ===== */
:root {
  /* Color palette */
  --bg-primary: #0b0f1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-border: rgba(99, 131, 255, 0.12);
  --bg-input: rgba(30, 41, 59, 0.7);

  --accent: #818cf8;
  --accent-bright: #a5b4fc;
  --accent-dim: #6366f1;
  --accent-glow: rgba(129, 140, 248, 0.25);

  --success: #34d399;
  --success-dim: rgba(52, 211, 153, 0.15);
  --danger: #f87171;
  --warning: #fbbf24;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 80px rgba(99, 102, 241, 0.06);
  --shadow-btn: 0 4px 14px rgba(99, 102, 241, 0.3);
  --shadow-glow: 0 0 40px rgba(129, 140, 248, 0.15);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 0.35s;

  /* Timer ring */
  --ring-circumference: 753.98;
  --ring-offset: 0;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== ANIMATED BACKGROUND ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 30%, rgba(99, 102, 241, 0.08), transparent),
    radial-gradient(ellipse 500px 350px at 80% 70%, rgba(129, 140, 248, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, rgba(148, 163, 184, 0.2), transparent),
    radial-gradient(1px 1px at 30% 65%, rgba(148, 163, 184, 0.15), transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, rgba(148, 163, 184, 0.18), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(148, 163, 184, 0.12), transparent),
    radial-gradient(1.2px 1.2px at 90% 40%, rgba(148, 163, 184, 0.16), transparent);
  background-size: 100% 100%;
  animation: subtlePulse 8s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes subtlePulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* ===== APP WRAPPER ===== */
.app-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: -0.02em;
  user-select: none;
}

.logo span {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sound-toggle {
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  letter-spacing: 0.02em;
}

.sound-toggle:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent-dim);
  color: var(--accent-bright);
}

.sound-toggle.off {
  opacity: 0.5;
}

/* ===== MAIN CARD ===== */
.pomodoro-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 32px 28px 28px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  transition: box-shadow var(--duration) var(--ease-out);
}

/* ===== MODE TABS ===== */
.mode-tabs {
  display: flex;
  gap: 6px;
  background: rgba(30, 41, 59, 0.5);
  padding: 4px;
  border-radius: var(--radius-full);
  width: 100%;
}

.mode-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.mode-tab:hover {
  color: var(--text-secondary);
  background: rgba(99, 102, 241, 0.08);
}

.mode-tab.active {
  background: var(--accent-dim);
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

/* ===== TIMER RING ===== */
.timer-ring-wrapper {
  position: relative;
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: rgba(51, 65, 85, 0.35);
  stroke-width: 6;
}

.timer-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: var(--ring-circumference);
  stroke-dashoffset: var(--ring-offset);
  transition: stroke-dashoffset 1s linear, stroke 0.5s var(--ease-out);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.timer-display {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  gap: 2px;
  user-select: none;
}

.timer-minutes,
.timer-seconds {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: center;
}

.timer-separator {
  font-size: 3.2rem;
  font-weight: 300;
  color: var(--text-muted);
  animation: blink 1.4s step-end infinite;
  margin: 0 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.timer-separator.paused {
  animation: blink 0.8s step-end infinite;
}

.timer-separator.running {
  animation: none;
  opacity: 1;
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 100%);
  pointer-events: none;
}

.btn-primary {
  background: var(--accent-dim);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.running {
  background: rgba(239, 68, 68, 0.8);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-primary.running:hover {
  background: rgba(239, 68, 68, 0.95);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--bg-card-border);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.6);
  border-color: rgba(99, 131, 255, 0.25);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* ===== SESSION COUNTER ===== */
.session-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.session-dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(51, 65, 85, 0.5);
  border: 1.5px solid rgba(99, 131, 255, 0.15);
  transition: all var(--duration) var(--ease-out);
}

.dot.completed {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.dot.current {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.session-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ===== TASKS SECTION ===== */
.tasks-section {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-card);
}

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

.tasks-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.clear-done-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--duration) var(--ease-out);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.clear-done-btn:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.08);
}

/* Task form */
.task-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.task-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: all var(--duration) var(--ease-out);
}

.task-input::placeholder {
  color: var(--text-muted);
}

.task-input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.btn-add {
  width: 46px;
  min-width: 46px;
  flex: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 400;
  background: var(--accent-dim);
  color: #fff;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
}

.btn-add:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

/* Task list */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.2) transparent;
}

.task-list::-webkit-scrollbar {
  width: 4px;
}

.task-list::-webkit-scrollbar-track {
  background: transparent;
}

.task-list::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-full);
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid transparent;
  transition: all var(--duration) var(--ease-out);
  animation: slideIn 0.3s var(--ease-out);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.task-item:hover {
  background: rgba(30, 41, 59, 0.5);
  border-color: var(--bg-card-border);
}

.task-checkbox {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--text-muted);
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.task-checkbox:hover {
  border-color: var(--accent);
}

.task-checkbox.checked {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

.task-checkbox.checked::after {
  content: '✓';
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}

.task-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
  transition: all var(--duration) var(--ease-out);
}

.task-item.done .task-label {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.6;
}

.task-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: all var(--duration) var(--ease-out);
  font-family: inherit;
  font-weight: 600;
}

.task-item:hover .task-delete {
  opacity: 1;
}

.task-delete:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
}

.tasks-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 20px 0;
  font-weight: 500;
}

.tasks-empty.hidden {
  display: none;
}

/* ===== SHORTCUTS BAR ===== */
.shortcuts-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.shortcuts-bar span {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(99, 131, 255, 0.12);
  border-radius: 4px;
  line-height: 1.4;
}

/* ===== MODE COLORS ===== */
body.mode-focus {
  --accent: #818cf8;
  --accent-bright: #a5b4fc;
  --accent-dim: #6366f1;
  --accent-glow: rgba(129, 140, 248, 0.25);
}

body.mode-short {
  --accent: #34d399;
  --accent-bright: #6ee7b7;
  --accent-dim: #059669;
  --accent-glow: rgba(52, 211, 153, 0.25);
}

body.mode-long {
  --accent: #60a5fa;
  --accent-bright: #93c5fd;
  --accent-dim: #2563eb;
  --accent-glow: rgba(96, 165, 250, 0.25);
}

/* ===== TIMER COMPLETE PULSE ===== */
.timer-ring-wrapper.pulse .timer-ring-progress {
  animation: ringPulse 0.6s ease-in-out 3;
}

@keyframes ringPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.timer-display.flash .timer-minutes,
.timer-display.flash .timer-seconds {
  animation: textFlash 0.6s ease-in-out 3;
}

@keyframes textFlash {
  0%, 100% { color: var(--text-primary); }
  50% { color: var(--accent-bright); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  .app-wrapper {
    padding: 16px 12px 32px;
    gap: 16px;
  }

  .pomodoro-card {
    padding: 24px 20px 24px;
    gap: 22px;
  }

  .timer-ring-wrapper {
    width: 200px;
    height: 200px;
  }

  .timer-minutes,
  .timer-seconds {
    font-size: 3.2rem;
  }

  .timer-separator {
    font-size: 2.6rem;
  }

  .mode-tab {
    font-size: 0.72rem;
    padding: 9px 6px;
  }

  .btn {
    padding: 13px 16px;
    font-size: 0.85rem;
  }

  .shortcuts-bar {
    display: none;
  }
}

@media (max-width: 360px) {
  .timer-ring-wrapper {
    width: 180px;
    height: 180px;
  }

  .timer-minutes,
  .timer-seconds {
    font-size: 2.8rem;
  }

  .timer-separator {
    font-size: 2.2rem;
  }

  .pomodoro-card {
    padding: 20px 16px;
  }

  .tasks-section {
    padding: 18px 14px;
  }
}

/* ===== FOCUS / HOVER UTILITIES ===== */
@media (hover: none) {
  .task-delete {
    opacity: 0.6;
  }
}

/* Smooth page-load fade-in */
.app-wrapper {
  animation: fadeInUp 0.6s var(--ease-out);
}

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