/* ═══════════════════════════════════════════════════════════════
   Design Tokens
═══════════════════════════════════════════════════════════════ */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --text: #1a1d21;
  --text-2: #5c6168;
  --muted: #9ca3af;
  --border: #e4e7eb;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --accent-light: #eff6ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.14);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: 0.18s ease;
}

/* ═══════════════════════════════════════════════════════════════
   Base Reset
═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════
   Scrollbar
═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ═══════════════════════════════════════════════════════════════
   App Shell
═══════════════════════════════════════════════════════════════ */
.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

/* ═══════════════════════════════════════════════════════════════
   Topbar
═══════════════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar-left h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
  margin-bottom: 5px;
}

.topbar-left p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  max-width: 520px;
}

body.alerting .topbar-left h1 { color: var(--warning); }

/* ═══════════════════════════════════════════════════════════════
   Buttons
═══════════════════════════════════════════════════════════════ */
button, .import-label {
  font-family: inherit;
  min-height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

button:hover, .import-label:hover {
  background: var(--accent-2);
}

button:active, .import-label:active {
  transform: scale(.97);
}

button.secondary, .import-label {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

button.secondary:hover, .import-label:hover {
  background: var(--surface-2);
  border-color: #cdd2d9;
}

button.ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-2);
}

button.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
}

button.danger { background: var(--danger); }
button.danger:hover { background: #dc2626; }

/* ═══════════════════════════════════════════════════════════════
   Top Actions
═══════════════════════════════════════════════════════════════ */
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   Workspace
═══════════════════════════════════════════════════════════════ */
.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

/* ═══════════════════════════════════════════════════════════════
   Cards
═══════════════════════════════════════════════════════════════ */
.editor-panel,
.list-panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.editor-panel { padding: 22px 20px; }
.list-panel { padding: 18px 18px; }

/* ═══════════════════════════════════════════════════════════════
   Form Elements
═══════════════════════════════════════════════════════════════ */
label {
  display: block;
  margin-bottom: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: .3px;
}

input[type="text"],
input[type="datetime-local"],
input[type="time"],
select,
.pomo-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
select:focus,
.pomo-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  background: #fff;
}

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

/* Number input spinner hide */
.pomo-input {
  -moz-appearance: textfield;
}
.pomo-input::-webkit-inner-spin-button,
.pomo-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

/* ═══════════════════════════════════════════════════════════════
   Type Selector (Radio Pills)
═══════════════════════════════════════════════════════════════ */
.type-field {
  border: none;
  padding: 0;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.type-field legend {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 8px;
  letter-spacing: .3px;
}

.type-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.type-option:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.type-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-2);
  font-weight: 700;
}

.type-option input { display: none; }

/* ═══════════════════════════════════════════════════════════════
   Form Actions
═══════════════════════════════════════════════════════════════ */
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.form-actions button[type="submit"] {
  flex: 1;
}

.form-actions button.ghost {
  flex: .6;
}

/* ═══════════════════════════════════════════════════════════════
   Filter Row
═══════════════════════════════════════════════════════════════ */
.filter-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.filter {
  height: 36px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text-2);
  min-height: auto;
  padding: 0 10px;
}

.filter:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   Backup Row
═══════════════════════════════════════════════════════════════ */
.backup-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   Todo List
═══════════════════════════════════════════════════════════════ */
.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.todo-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: all var(--transition);
}

.todo-item:hover {
  border-color: #cdd2d9;
  box-shadow: var(--shadow-sm);
}

.todo-item.completed {
  opacity: .6;
}

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

.todo-check {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.todo-main { min-width: 0; }

.todo-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--accent-light);
  color: var(--accent-2);
  margin-right: 6px;
  vertical-align: middle;
}

.todo-badge.badge-weekly { background: #f3e8ff; color: #7c3aed; }
.todo-badge.badge-once { background: #f0f9ff; color: #0284c7; }

.todo-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.4;
  word-break: break-word;
}

.todo-meta {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}

.todo-actions {
  display: flex;
  gap: 6px;
}

.todo-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: var(--radius-xs);
  min-height: auto;
}

.todo-actions .delete {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.todo-actions .delete:hover {
  background: var(--danger);
  color: #fff;
}

.empty-state {
  margin: 60px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════
   Pomodoro Panel
═══════════════════════════════════════════════════════════════ */
.pomodoro-panel {
  margin-top: 20px;
  padding: 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
}

.pomodoro-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-2);
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.pomodoro-body {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pomodoro-clock {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 0 0 4px rgba(59,130,246,.12);
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
  letter-spacing: 3px;
  position: relative;
  overflow: hidden;
}

.pomodoro-clock.running {
  animation: clockPulse 2s ease-in-out infinite;
}

@keyframes clockPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(59,130,246,.12); }
  50% { box-shadow: 0 0 0 7px rgba(59,130,246,.2); }
}

#pomoMinutes { color: var(--accent-2); }
#pomoSeconds { color: var(--accent-2); }

.pomodoro-colon {
  animation: blink 1s step-start infinite;
  color: var(--accent);
}

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

.pomodoro-set {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pomodoro-set .pomo-input {
  width: 58px;
  height: 38px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  border-radius: var(--radius-xs);
}

.pomo-set-label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 600;
}

.pomodoro-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pomo-preset {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-2);
  min-height: auto;
}

.pomo-preset:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.pomo-preset.history {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-2);
}

.pomodoro-controls {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.pomo-btn {
  min-height: 36px;
  padding: 0 16px;
  font-size: 13.5px;
  border-radius: 99px;
}

.pomo-btn.secondary {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════
   Reminder Dialog
═══════════════════════════════════════════════════════════════ */
.reminder-dialog {
  width: min(460px, calc(100vw - 32px));
  border: none;
  border-radius: 20px;
  padding: 0;
  box-shadow: var(--shadow-lg);
  animation: dialogIn .25s ease;
}

.reminder-dialog::backdrop {
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
}

.reminder-dialog form { padding: 24px; }

.dialog-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
}

.reminder-dialog h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  word-break: break-word;
}

.reminder-dialog p { color: var(--text-2); font-size: 14px; }

.dialog-note {
  margin-top: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text) !important;
}

.snooze-row {
  display: flex;
  gap: 8px;
  margin: 18px 0 14px;
  flex-wrap: wrap;
}

.snooze-row button {
  flex: 1;
  min-height: 36px;
  border-radius: 99px;
  font-size: 13px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text);
  min-height: auto;
  padding: 0 12px;
}

.snooze-row button:hover {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}

.dialog-actions {
  display: flex;
  gap: 8px;
}

.dialog-actions button:first-child { flex: 1; }

@keyframes dialogIn {
  from { opacity: 0; transform: scale(.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   Toast Notifications
═══════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  padding: 12px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  pointer-events: auto;
  animation: toastIn .28s cubic-bezier(.34,1.56,.64,1);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast.out {
  animation: toastOut .22s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(.95); }
}

/* ═══════════════════════════════════════════════════════════════
   Responsive — Tablet / Mobile
═══════════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
  .app-shell { padding: 20px 14px 32px; }

  .topbar {
    flex-direction: column;
    gap: 14px;
  }

  .top-actions { gap: 6px; }
  .top-actions button { min-height: 34px; font-size: 12.5px; padding: 0 12px; }

  .workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .editor-panel, .list-panel {
    border-radius: 14px;
  }

  .filter-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .pomodoro-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .pomodoro-controls { margin-left: 0; }

  .todo-item {
    grid-template-columns: auto 1fr;
  }

  .todo-actions {
    grid-column: 2;
    flex-direction: row;
  }
}

@media (max-width: 480px) {
  .app-shell { padding: 14px 10px 24px; }
  .topbar-left h1 { font-size: 22px; }
  .filter-row { grid-template-columns: repeat(2, 1fr); }
  .pomodoro-clock { min-width: 110px; font-size: 26px; }
  #toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { min-width: unset; }
}