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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  min-height: 100dvh;
}

#app { max-width: 480px; margin: 0 auto; padding: 16px; }

/* Auth */
.auth-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 80dvh; gap: 24px; }
.auth-screen h1 { font-size: 24px; color: #4f46e5; }
.auth-form { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
.auth-form input { padding: 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 16px; }
.auth-form button { padding: 12px; background: #4f46e5; color: white; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; }
.auth-form button:last-child { background: none; color: #4f46e5; font-weight: 500; }
.auth-error { color: #dc2626; font-size: 14px; text-align: center; }

/* Header */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.header h1 { font-size: 20px; }
.header button { background: none; border: none; color: #6b7280; font-size: 14px; cursor: pointer; }
.date-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; }
.date-header.other-day { background: #eef2ff; border-radius: 12px; padding: 8px 12px; margin-left: -12px; margin-right: -12px; }
.progress-bar { height: 6px; background: #e5e7eb; border-radius: 3px; margin-bottom: 20px; overflow: hidden; }
.progress-fill { height: 100%; background: #4f46e5; border-radius: 3px; transition: width .3s; }
.progress-text { font-size: 13px; color: #6b7280; margin-bottom: 16px; }

/* Cards */
.task-card { background: white; border-radius: 12px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; }
.task-card-header { display: flex; align-items: center; gap: 12px; padding: 16px; cursor: pointer; }
.task-card-header .status { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #d1d5db; flex-shrink: 0; }
.task-card-header .status.done { background: #4f46e5; border-color: #4f46e5; }
.task-card-header .title { flex: 1; font-weight: 600; }
.sub-count { font-weight: 400; font-size: 12px; color: #9ca3af; margin-left: 4px; }
.task-card-header .time-badge { font-size: 11px; color: #6b7280; background: #f3f4f6; padding: 2px 8px; border-radius: 10px; }
.task-card-header .arrow { transition: transform .2s; color: #9ca3af; }
.task-card-header .arrow.open { transform: rotate(180deg); }
.task-card-body { max-height: 0; overflow: hidden; transition: max-height .2s; }
.task-card-body.open { max-height: 500px; }
.card-actions { display: none; gap: 12px; padding: 10px 16px 12px 48px; }
.task-card-body.open .card-actions { display: flex; }
.card-actions button { background: none; border: none; cursor: pointer; font-size: 14px; }
.card-actions .edit-btn { color: #9ca3af; }
.card-actions .del-btn { color: #dc2626; }
.task-desc { padding: 4px 16px 8px 48px; font-size: 13px; color: #6b7280; }
.subtask { display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 48px; font-size: 14px; color: #4b5563; }
.subtask .check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #d1d5db; flex-shrink: 0; cursor: pointer; }
.subtask .check.done { background: #4f46e5; border-color: #4f46e5; }
.subtask .del-btn, .task-card-header .del-btn, .task-card-header .edit-btn { opacity: 0; transition: opacity .15s; }
.task-card:hover .del-btn, .subtask:hover .del-btn, .task-card:hover .edit-btn { opacity: 1; }

/* New task form */
.new-task-form { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.new-task-form input, .new-task-form select { padding: 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; }
.new-task-form button { padding: 12px; background: #4f46e5; color: white; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.new-task-form .cancel { background: none; color: #6b7280; }
.type-toggle { display: flex; gap: 0; border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; }
.type-toggle button { flex: 1; padding: 10px; background: white; color: #6b7280; border: none; font-size: 14px; font-weight: 500; cursor: pointer; transition: none; border-radius: 0; }
.type-toggle button.active { background: #4f46e5; color: white; }

/* Bottom nav */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: white; display: flex; border-top: 1px solid #e5e7eb; }
.bottom-nav button { flex: 1; padding: 12px; background: none; border: none; font-size: 13px; color: #9ca3af; cursor: pointer; }
.bottom-nav button.active { color: #4f46e5; font-weight: 600; }

/* Bottom padding for fixed nav */
#app { padding-bottom: 60px; }

/* Calendar */
.cal-day { transition: background .15s; }
.cal-day:hover { background: #e5e7eb; }
.cal-day.today { background: #eef2ff; font-weight: 700; color: #4f46e5; }
.cal-day.selected { background: #4f46e5; color: white; }

/* Empty state */
.empty { text-align: center; padding: 40px 0; color: #9ca3af; }
.empty p { margin-top: 8px; font-size: 14px; }

/* Cycle cards */
.cycle-card { border-left: 3px solid #4f46e5; }
.cycle-mini { transition: background .15s; }
.cycle-mini:hover { background: #f9fafb; }

/* Stats */
.stats-card {
  background: white;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stats-number {
  font-size: 24px;
  font-weight: 700;
}
.stats-label {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}
.stats-bar {
  flex: 1;
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.stats-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width .3s;
}

.day-toggle {
  flex:1; padding:8px 4px; border:1px solid #d1d5db; border-radius:6px;
  background:#fff; cursor:pointer; font-size:13px; text-align:center;
  color:#374151; transition:all 0.15s;
}
.day-toggle.active { background:#3b82f6; color:#fff; border-color:#3b82f6; }

/* Task cards */
.task-card.type-todo { border-left: 3px solid #f97316; }
.task-card.type-routine { border-left: 3px solid #3b82f6; }
.task-card.overdue { border-left-color: #dc2626; background: #fef2f2; }
.task-card.overdue .title { color: #dc2626; }
.type-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600; margin-left: auto; }
.type-badge.todo { background: #fff7ed; color: #f97316; }
.type-badge.routine { background: #eff6ff; color: #3b82f6; }
.tag-pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: #374151; margin: 2px 4px 2px 0; }
.tags { padding: 4px 16px 8px 48px; }
.subitems { padding: 4px 16px 8px 48px; }
.subitem { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 14px; color: #4b5563; }
.subitem .check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #d1d5db; flex-shrink: 0; cursor: pointer; }
.subitem .check.done { background: #4f46e5; border-color: #4f46e5; }
.group-label { font-size: 13px; font-weight: 600; color: #6b7280; padding: 12px 0 8px; display:flex;align-items:center;justify-content:space-between }
.group-label:hover { color: #4b5563; }

.settings-page { padding: 16px; max-width: 600px; margin: 0 auto; }
.settings-page h2 { font-size: 20px; margin-bottom: 16px; }
.settings-card { padding: 16px; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.source-toggle input { width: auto; margin: 0; }

.gcal-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: #4285f4; color: white; font-size: 11px; font-weight: bold;
  margin-right: 6px; flex-shrink: 0;
}
