:root {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --border:         rgba(11,11,11,0.10);
  --day-fill:       #2a78d6;
  --day-track:      #cde2fb;
  --year-fill:      #008300;
  --year-track:     #cfe8cd;
  --life-fill:      #4a3aa7;
  --life-track:     #ddd8f2;
  --pomo-danger:    #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page:           #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --border:         rgba(255,255,255,0.10);
    --day-fill:       #3987e5;
    --day-track:      #0d366b;
    --year-fill:      #008300;
    --year-track:     #0e330f;
    --life-fill:      #9085e9;
    --life-track:     #2a2568;
  }
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  gap: 24px;
}
header { text-align: center; }
header h1 { font-size: 20px; font-weight: 600; }
header .now {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 960px;
}
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  flex: 1 1 280px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}
.card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}
.ring-wrap { position: relative; width: 220px; height: 220px; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke-width: 14; }
.ring-fill  { fill: none; stroke-width: 14; stroke-linecap: round; }
#dayRing  .ring-track { stroke: var(--day-track); }
#dayRing  .ring-fill  { stroke: var(--day-fill); }
#yearRing .ring-track { stroke: var(--year-track); }
#yearRing .ring-fill  { stroke: var(--year-fill); }
#lifeRing .ring-track { stroke: var(--life-track); }
#lifeRing .ring-fill  { stroke: var(--life-fill); }
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.ring-center .pct {
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ring-center .pct-label { font-size: 12px; color: var(--text-muted); }
.times { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.time-main {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.time-main .unit { font-size: 15px; font-weight: 500; color: var(--text-secondary); margin: 0 2px 0 1px; }
.time-sub {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.time-sub .unit { font-size: 15px; font-weight: 500; color: var(--text-secondary); margin: 0 2px 0 1px; }
.time-sub .sub-label { font-size: 12px; color: var(--text-muted); margin-right: 6px; }
.ratio-sep { color: var(--text-muted); font-weight: 400; margin: 0 6px; }
.denom { color: var(--text-muted); }
.denom .unit { color: var(--text-muted); }
footer { font-size: 12px; color: var(--text-muted); }

/* Bottom settings row (age / lifespan / confirm) */
.settings {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 24px;
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.setting-item { display: flex; align-items: center; gap: 8px; }
.setting-item label { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.settings input {
  width: 72px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.setting-unit { font-size: 14px; color: var(--text-secondary); }
#confirmBtn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 9px 22px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  color: #ffffff;
  background: var(--life-fill);
}
#confirmBtn.saved { background: var(--year-fill); }

/* Today's tasks — list (top) */
.tasklist-wrap {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tasklist-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-align: center; }
.tasklist { display: flex; flex-direction: column; gap: 8px; }
.task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s;
}
.task-name { flex: 1; font-weight: 600; font-size: 15px; word-break: break-word; }
.task-warn { display: none; color: var(--pomo-danger); font-size: 15px; }
.task-time { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.task-del {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 6px;
}
.task-del:hover { color: var(--text-primary); }
.task.overdue { border-color: var(--pomo-danger); background: rgba(208,59,59,0.14); }
.task.overdue .task-name { color: var(--text-primary); }
.task.overdue .task-time { color: var(--pomo-danger); font-weight: 600; }
.task.overdue .task-warn { display: inline; }

/* Today's tasks — registration form (bottom) */
.taskform {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 24px;
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: center;
}
.task-name-input {
  flex: 1 1 220px;
  min-width: 140px;
  font-family: inherit;
  font-size: 16px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
}
.taskform input[type="time"] {
  font-family: inherit;
  font-size: 16px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
#taskAddBtn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 9px 22px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  color: #ffffff;
  background: var(--day-fill);
}

/* Pomodoro timer */
.pomodoro {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s;
}
.pomo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.pomo-row label { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
#pomoInput {
  width: 84px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#pomoInput:disabled { opacity: 0.45; }
.pomo-unit { font-size: 15px; color: var(--text-secondary); }
#pomoBtn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  color: #ffffff;
  background: var(--day-fill);
  transition: background 0.2s;
}
#pomoBtn.finish { background: var(--pomo-danger); }
.pomo-bar {
  width: 100%;
  max-width: 420px;
  height: 8px;
  border-radius: 4px;
  background: var(--day-track);
  overflow: hidden;
}
.pomo-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--day-fill);
  border-radius: 4px;
}
.pomo-display {
  font-size: 46px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  line-height: 1;
}
.pomodoro.alarming { border-color: var(--pomo-danger); }
.pomodoro.alarming .pomo-display { color: var(--pomo-danger); animation: pomo-pulse 0.8s ease-in-out infinite; }
.pomodoro.alarming .pomo-bar-fill { background: var(--pomo-danger); }
@keyframes pomo-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.pomo-hidden { display: none !important; }

/* Top user bar */
.userbar {
  width: 100%;
  max-width: 960px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.userbar .user-email { font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#logoutBtn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  cursor: pointer;
}
#logoutBtn:hover { color: var(--text-primary); }

/* Auth screen */
.auth-screen {
  width: 100%;
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}
.auth-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-card h1 { font-size: 22px; font-weight: 600; text-align: center; }
.auth-sub { font-size: 13px; color: var(--text-secondary); text-align: center; margin-top: -8px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.auth-field input {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
}
.auth-btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  color: #ffffff;
  background: var(--day-fill);
}
.auth-btn:disabled { opacity: 0.6; cursor: default; }
.auth-error { color: var(--pomo-danger); font-size: 13px; font-weight: 600; text-align: center; min-height: 1em; }
.auth-toggle { font-size: 13px; color: var(--text-secondary); text-align: center; }
.auth-toggle a { color: var(--day-fill); font-weight: 600; cursor: pointer; text-decoration: none; }
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 11px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  cursor: pointer; text-decoration: none;
}
.google-btn svg { width: 18px; height: 18px; }

/* Compact layout so all 3 rings fit one iPhone screen */
@media (max-width: 640px) {
  body { padding: 10px 8px; gap: 10px; }
  .pomodoro { padding: 10px 14px; gap: 8px; border-radius: 12px; }
  .pomo-display { font-size: 34px; }
  header { margin: 0; }
  header h1 { font-size: 15px; }
  header .now { margin-top: 2px; font-size: 17px; }
  .cards { gap: 10px; flex-direction: column; }
  .card {
    flex: 1 1 auto;
    max-width: 100%;
    width: 100%;
    padding: 12px 16px;
    gap: 6px;
    border-radius: 12px;
  }
  .card h2 { font-size: 13px; }
  .card-body { flex-direction: row; gap: 16px; justify-content: flex-start; }
  .ring-wrap { width: 150px; height: 150px; flex-shrink: 0; }
  .ring-center .pct { font-size: 25px; }
  .ring-center .pct-label { display: block; font-size: 10px; }
  .times { align-items: flex-start; text-align: left; gap: 2px; flex: 1; min-width: 0; }
  .time-main { font-size: 19px; }
  .time-sub { font-size: 15px; }
  .time-main .unit, .time-sub .unit { font-size: 11px; margin: 0 1px; }
  .ratio-sep { margin: 0 3px; }
  .settings { padding: 12px 14px; gap: 12px; border-radius: 12px; }
  .settings input { width: 60px; font-size: 16px; padding: 6px 7px; }
  .setting-item label { font-size: 13px; }
  footer { display: none; }
  .userbar { font-size: 12px; }
}
