*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-dim: #4b5563;
  --text-muted: #9ca3af;
  --primary: #9B1B22; 
  --primary-glow: rgba(155, 27, 34, 0.15);
  --primary-soft: #fdf2f2; 
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --accent-warm: #f59e0b;
  --accent-warm-glow: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 100px;
}
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
  animation: fadeUp .5s ease;
  background: #fafafa;
}
.login-logo {
  width: 72px;
  height: 72px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 20px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.login-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 32px;
}
.login-input {
  width: 100%;
  max-width: 320px;
  padding: 16px 20px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border .2s, box-shadow .2s;
}
.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.login-input::placeholder { color: var(--text-muted); }
.login-btn {
  width: 100%;
  max-width: 320px;
  margin-top: 16px;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: transform .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.login-btn:active { transform: scale(.97); }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 8px 0;
}
.header-left h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.header-left p {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 2px;
}
.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.header-avatar:active { transform: scale(.92); }
.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num {
  font-size: 26px;
  font-weight: 700;
}
.stat-num.pending { color: var(--text); }
.stat-num.done    { color: var(--success); }
.stat-num.total   { color: var(--primary); }
.stat-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 500;
  text-transform: capitalize;
}
.section { margin-bottom: 20px; }
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.section-dot.recurring { background: var(--primary); }
.section-dot.onetime   { background: var(--text-muted); }
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}
.section-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
  font-weight: 500;
}
.task-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: transform .15s, opacity .3s, background .2s;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}
.task-card:active { transform: scale(.985); }
.task-card.done { opacity: .6; background: #f9fafb; border-color: #f3f4f6; }
.task-card.done .task-name {
  text-decoration: line-through;
  color: var(--text-muted);
}
.task-card.completing { animation: completePulse .4s ease; }
.task-name {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
  color: var(--text);
}
.task-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.task-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
  background: #f3f4f6;
  color: var(--text-dim);
}
.task-badge.daily    { background: var(--primary-soft); color: var(--primary); }
.task-badge.weekly   { background: #f3f4f6; color: var(--text-dim); }
.task-badge.one-time { background: #fef3c7; color: #d97706; }
.task-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.mark-done-btn {
  width: 100%;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
  background: var(--primary-soft);
  color: var(--primary);
}
.mark-done-btn:active { background: #fce8e8; transform: scale(.98); }
.mark-done-btn.completed {
  background: transparent;
  color: var(--success);
  border: 1px solid var(--success-glow);
  pointer-events: none;
}
.skeleton {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.skel-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skel-line.w70  { width: 70%; }
.skel-line.w40  { width: 40%; margin-top: 12px; }
.skel-line.w100 { width: 100%; height: 40px; margin-top: 16px; }
.sync-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  z-index: 10;
  backdrop-filter: blur(8px);
  font-weight: 500;
}
.sync-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
  vertical-align: middle;
}
.sync-dot.syncing {
  background: var(--primary);
  animation: pulse 1s infinite;
}
.sync-retry {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 2px;
  -webkit-tap-highlight-color: transparent;
}
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-dim);
}
.empty-state .emoji { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; line-height: 1.5; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s ease, visibility .25s ease;
}
.modal-overlay.show {
  visibility: visible;
  opacity: 1;
}
.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 24px 32px;
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
}
.modal-overlay.show .modal {
  transform: none;
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.modal p  { font-size: 14px; color: var(--text-dim); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions button {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.modal-cancel { background: #f3f4f6; color: var(--text); }
.modal-logout { background: var(--danger); color: #fff; }
.refresh-btn {
  position: fixed;
  bottom: 56px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(155, 27, 34, 0.3);
  z-index: 10;
  transition: transform .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
  display: none;
}
.refresh-btn:active { transform: scale(.92); box-shadow: 0 2px 8px rgba(155, 27, 34, 0.4); }
.refresh-btn.spin svg { animation: spin .6s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}
@keyframes completePulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(.96); }
  100% { transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .5; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}