:root {
  --primary: #ff6b6b;
  --primary-dark: #ee5253;
  --secondary: #48dbfb;
  --success: #1dd1a1;
  --warning: #feca57;
  --bg: #f7f9fc;
  --card-bg: #ffffff;
  --text: #2f3542;
  --text-muted: #747d8c;
  --border: #e8e8e8;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
}

header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  font-size: 1.75rem;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* Timer Section */
.timer-section {
  text-align: center;
}

.mode-tabs {
  display: inline-flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  font-weight: 600;
}

.current-task-display {
  margin-bottom: 12px;
}

.current-task-display .label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.current-task-display .name {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  word-break: break-word;
}

.timer {
  font-size: 5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin: 16px 0 24px;
  font-variant-numeric: tabular-nums;
}

.timer-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #0abde3;
}

.btn-ghost {
  background: var(--bg);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--border);
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 0.85rem;
}

.btn-text:hover:not(:disabled) {
  color: var(--primary);
  background: rgba(255, 107, 107, 0.08);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg);
}

.progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 1s linear;
}

/* Stats Section */
.stats-section {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Task Section */
.task-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.task-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.task-input-row input:focus {
  border-color: var(--primary);
}

.task-list,
.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: all 0.2s ease;
  cursor: pointer;
}

.task-item:hover {
  background: #eef2f7;
}

.task-item.active {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.25);
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
  cursor: pointer;
  flex-shrink: 0;
}

.task-title {
  flex: 1;
  font-size: 0.95rem;
  word-break: break-word;
}

.task-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  flex-shrink: 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  gap: 12px;
}

.history-main {
  flex: 1;
  min-width: 0;
}

.history-task {
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-word;
}

.history-task.none-task {
  color: var(--text-muted);
}

.history-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 24px 0;
}

.hidden {
  display: none !important;
}

footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 480px) {
  .app {
    padding: 16px 12px;
  }

  .card {
    padding: 16px;
  }

  .timer {
    font-size: 3.5rem;
  }

  .timer-controls {
    flex-wrap: wrap;
  }

  .btn {
    padding: 10px 16px;
    flex: 1;
  }

  .task-input-row {
    flex-wrap: wrap;
  }

  .task-input-row input {
    width: 100%;
  }

  .task-input-row .btn {
    width: 100%;
  }

  .history-item {
    flex-direction: column;
    gap: 6px;
  }

  .history-time {
    align-self: flex-end;
  }
}
