/* style.css */
* { box-sizing: border-box; }
:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --card-2: #232733;
  --ink: #f1f3f8;
  --muted: #9aa3b5;
  --brand: #7c5cff;
  --brand-dark: #6442f0;
  --good: #2dd471;
  --bad: #f87171;
  --line: #2c3140;
  --radius: 16px;
}

/* Light theme (explicit) + Auto (follows the device). Dark is the :root default. */
html[data-theme="light"] {
  --bg:#f3f4f7; --card:#ffffff; --card-2:#eceef4; --ink:#1b1e28; --muted:#586075; --line:#d7dbe4;
}
html[data-theme="light"] .pill.good { color:#0f7a3d; }
html[data-theme="light"] .pill.mid  { color:#8a6a00; }
html[data-theme="light"] .pill.bad  { color:#b22b2b; }
html[data-theme="light"] .pill.info { color:#5a3fd6; }
html[data-theme="light"] .notice.ok    { color:#0f7a3d; }
html[data-theme="light"] .notice.error { color:#b22b2b; }
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --bg:#f3f4f7; --card:#ffffff; --card-2:#eceef4; --ink:#1b1e28; --muted:#586075; --line:#d7dbe4;
  }
  html[data-theme="auto"] .pill.good { color:#0f7a3d; }
  html[data-theme="auto"] .pill.mid  { color:#8a6a00; }
  html[data-theme="auto"] .pill.bad  { color:#b22b2b; }
  html[data-theme="auto"] .pill.info { color:#5a3fd6; }
  html[data-theme="auto"] .notice.ok    { color:#0f7a3d; }
  html[data-theme="auto"] .notice.error { color:#b22b2b; }
}

/* Text size — scales all rem-based sizing */
html.ts-large  { font-size: 112.5%; }
html.ts-larger { font-size: 125%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--brand); }

header.topbar {
  background: linear-gradient(90deg, #6442f0, #9b5cff);
  color: #fff;
  padding: 16px 22px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
header.topbar h1, header.topbar .logo { font-size: 1.2rem; font-weight: 700; margin: 0; }
header.topbar nav a { color: #fff; margin-left: 16px; text-decoration: none; opacity: .92; font-weight: 600; }
header.topbar nav a:hover { opacity: 1; text-decoration: underline; }

.wrap { max-width: 760px; margin: 26px auto; padding: 0 16px; }
.narrow { max-width: 440px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 1.2rem; }

label { display: block; font-weight: 600; margin: 12px 0 5px; font-size: .9rem; }
input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 1rem; font-family: inherit;
  background: var(--card-2); color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }

.btn {
  display: inline-block; background: var(--brand); color: #fff;
  border: none; padding: 12px 20px; border-radius: 10px;
  font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--card-2); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 7px 13px; font-size: .82rem; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }

/* Big tappable task rows — easy targets, clear done-state */
.task-check {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 18px; margin-bottom: 12px;
  background: var(--card-2); border: 2px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: transform .08s, border-color .15s, background .15s;
  user-select: none;
}
.task-check:active { transform: scale(.99); }
.task-check.done { border-color: var(--good); background: rgba(45,212,113,.12); }
.task-check input { width: 26px; height: 26px; flex: none; cursor: pointer; accent-color: var(--good); }
.task-check .label { font-size: 1.12rem; font-weight: 600; }
.task-check.done .label { text-decoration: line-through; color: var(--muted); }
.task-check .cat { font-size: .72rem; color: var(--muted); display:block; font-weight:600; text-transform:uppercase; letter-spacing:.04em; }

.progress-wrap { margin: 8px 0 20px; }
.bar { background: var(--card-2); border-radius: 999px; height: 24px; overflow: hidden; border:1px solid var(--line); }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg,#2dd471,#7c5cff); transition: width .35s; }
.big-pct { font-size: 1.6rem; font-weight: 800; }

ul.clean { list-style: none; padding: 0; margin: 0; }
ul.clean li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
ul.clean li:last-child { border-bottom: none; }

.pill { display:inline-block; padding: 2px 10px; border-radius:999px; font-size:.78rem; font-weight:700; }
.pill.good { background: rgba(45,212,113,.18); color:#6ee7a3; }
.pill.mid  { background: rgba(250,204,21,.18); color:#fde047; }
.pill.bad  { background: rgba(248,113,113,.18); color:#fca5a5; }

.notice { padding: 12px 15px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; }
.notice.error { background: rgba(248,113,113,.15); color:#fca5a5; }
.notice.ok    { background: rgba(45,212,113,.15); color:#6ee7a3; }

.muted { color: var(--muted); font-size: .9rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing:.04em; color: var(--muted); }

.report-day { border:1px solid var(--line); border-radius:14px; padding:18px; margin-bottom:16px; background: var(--card-2); }
.report-day h3 { margin:0 0 8px; }
.note-box { background: var(--card); border-left:4px solid var(--brand); padding:12px 15px; border-radius:8px; margin-top:12px; }

/* Hype toast */
.hype-toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 40px);
  background: linear-gradient(90deg,#6442f0,#9b5cff);
  color: #fff; font-weight: 800; font-size: 1.15rem;
  padding: 16px 26px; border-radius: 999px;
  box-shadow: 0 12px 40px rgba(124,92,255,.5);
  opacity: 0; pointer-events: none; transition: all .3s cubic-bezier(.2,.8,.2,1);
  z-index: 1000; max-width: 90vw; text-align: center;
}
.hype-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Visually hidden but available to screen readers (for ARIA live announcements).
   Must not use display:none/visibility:hidden, which remove it from the a11y tree. */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toggle-row { display:flex; align-items:center; gap:10px; }
.toggle-row input { width:auto; }

.pill.info { background: rgba(124,92,255,.18); color:#c4b5fd; }

/* Quick "brain dump" capture — accented so it reads as the fast-capture spot */
.quick-add-card { border-color: var(--brand); }

/* Task row = checkbox label + a "Not today" skip button beside it */
.task-row { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.task-row .task-check { flex:1; margin-bottom:0; }
.skip-form { flex:none; margin:0; }

/* Day-of-week picker (add form + per-task schedule editor) */
.day-picker { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-top:4px; }
.day-opt {
  display:inline-flex; align-items:center; gap:6px; margin:0; padding:8px 12px;
  background:var(--card-2); border:1px solid var(--line); border-radius:10px;
  cursor:pointer; font-weight:600; font-size:.9rem;
}
.day-opt input { width:auto; margin:0; accent-color:var(--brand); }
.day-opt span { user-select:none; }
.presets { display:flex; gap:6px; margin-left:auto; }
.preset {
  background:transparent; color:var(--muted); border:1px solid var(--line);
  border-radius:999px; padding:6px 12px; font-size:.8rem; font-weight:600; cursor:pointer;
}
.preset:hover { color:var(--ink); border-color:var(--brand); }

/* Manage list: drag handle, reorder buttons, inline schedule editor */
ul.task-manage li { gap:12px; align-items:flex-start; }
.task-manage .task-info { flex:1; min-width:0; }
.task-manage .task-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.reorder-btns { display:flex; gap:4px; }
.drag-handle {
  flex:none; align-self:center; background:transparent; border:none; color:var(--muted);
  cursor:grab; font-size:1.3rem; line-height:1; padding:4px 6px; touch-action:none;
}
.drag-handle:active { cursor:grabbing; }
li.dragging { opacity:.6; background:var(--card); border-radius:10px; }
.sched-edit { margin-top:6px; }
.sched-edit summary {
  cursor:pointer; color:var(--brand); font-size:.82rem; font-weight:600;
  list-style:none; display:inline-block;
}
.sched-edit summary::-webkit-details-marker { display:none; }
.sched-edit[open] summary { margin-bottom:4px; }

/* Per-task action cluster (Focus + Not today) beside the checkbox */
.task-row { flex-wrap: wrap; }
.task-row .task-check { flex: 1 1 240px; }
.task-side { display:flex; gap:8px; align-items:center; margin-left:auto; flex:none; }
.task-side .skip-form { margin:0; }

/* Confetti layer for the 100% moment */
.confetti-canvas { position:fixed; inset:0; width:100%; height:100%; pointer-events:none; z-index:2000; }

/* Focus / body-doubling sprint overlay */
body.focus-open { overflow:hidden; }
.focus-overlay {
  position:fixed; inset:0; z-index:1500; display:none;
  align-items:center; justify-content:center; padding:20px;
  background:radial-gradient(circle at 50% 38%, #1a1d27, #0b0d12);
}
.focus-overlay.show { display:flex; }
.focus-card { text-align:center; max-width:480px; width:100%; }
.focus-msg { color:var(--muted); font-size:1rem; margin:0 0 10px; }
.focus-title { font-size:1.5rem; margin:0 0 16px; line-height:1.3; }
.focus-time { font-size:4.5rem; font-weight:800; font-variant-numeric:tabular-nums; margin:6px 0 18px; color:#fff; }
.focus-durations { display:flex; gap:8px; justify-content:center; margin-bottom:20px; }
.focus-durations button {
  background:var(--card-2); color:var(--ink); border:1px solid var(--line);
  border-radius:999px; padding:8px 16px; font-weight:600; cursor:pointer;
}
.focus-durations button.active { background:var(--brand); border-color:var(--brand); color:#fff; }
.focus-actions { display:flex; gap:10px; justify-content:center; margin-bottom:16px; flex-wrap:wrap; }
.focus-close { background:transparent; border:none; color:var(--muted); cursor:pointer; font-size:.95rem; text-decoration:underline; }

/* Insights bars */
.insight-bars { display:flex; flex-direction:column; gap:8px; }
.ib-row { display:flex; align-items:center; gap:10px; }
.ib-label { flex:0 0 92px; font-size:.9rem; color:var(--muted); }
.ib-track { flex:1; background:var(--card-2); border:1px solid var(--line); border-radius:999px; height:18px; overflow:hidden; }
.ib-fill { display:block; height:100%; background:linear-gradient(90deg,#2dd471,#7c5cff); }
.ib-val { flex:0 0 auto; font-weight:700; font-variant-numeric:tabular-nums; min-width:28px; text-align:right; }

/* Custom hype line editor */
.hype-pool { margin-bottom:14px; }
.hype-pool h3 { font-size:.95rem; margin:0 0 4px; }
.hype-pool ul.clean li { padding:8px 0; gap:10px; }

/* "What's new" banner + announcement page */
.whatsnew-banner {
  display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
  border-color:var(--brand);
  background:linear-gradient(90deg, rgba(124,92,255,.16), rgba(155,92,255,.05));
}
.whatsnew-banner .wn-actions { display:flex; gap:8px; flex:none; }
.wn-list { display:flex; flex-direction:column; }
.wn-item { display:flex; gap:14px; padding:14px 0; border-bottom:1px solid var(--line); }
.wn-item:last-child { border-bottom:none; }
.wn-emoji { font-size:1.6rem; flex:none; line-height:1.3; }
.wn-item h3 { margin:0 0 3px; font-size:1.02rem; }
.wn-item p { margin:0; color:var(--muted); font-size:.92rem; }
.wn-item a.tryit { color:var(--brand); font-weight:600; white-space:nowrap; }

/* Add-task "When?" type toggle (repeats vs one-off) */
.type-toggle { display:flex; gap:16px; flex-wrap:wrap; margin:4px 0 12px; }
.type-opt { display:inline-flex; align-items:center; gap:8px; margin:0; font-weight:600; cursor:pointer; }
.type-opt input { width:auto; margin:0; accent-color:var(--brand); }

/* Completed-tasks section on the Today screen */
.completed-heading {
  font-size:1rem; margin:22px 0 10px; color:var(--muted);
  border-top:1px solid var(--line); padding-top:16px;
}
.all-done-msg { font-size:1.05rem; }
/* Completed rows are done — no need for Focus / Not-today there */
#tasksDone .task-side { display:none; }

/* Insights activity heatmap (GitHub-style) */
.heatmap { display:grid; grid-template-rows:repeat(7,12px); grid-auto-flow:column; grid-auto-columns:12px; gap:3px; overflow-x:auto; padding-bottom:4px; }
.heatmap .cell { width:12px; height:12px; border-radius:3px; background:var(--card-2); border:1px solid var(--line); }
.heatmap .lvl1 { background:rgba(45,212,113,.35); border-color:transparent; }
.heatmap .lvl2 { background:rgba(45,212,113,.60); border-color:transparent; }
.heatmap .lvl3 { background:rgba(45,212,113,.82); border-color:transparent; }
.heatmap .lvl4 { background:#2dd471; border-color:transparent; }

/* In-app reminder toast */
.reminder-toast {
  position:fixed; left:50%; bottom:30px; transform:translate(-50%,40px);
  background:var(--card); border:2px solid var(--brand); color:var(--ink);
  font-weight:700; font-size:1.05rem; padding:14px 22px; border-radius:14px;
  box-shadow:0 12px 40px rgba(0,0,0,.45); opacity:0; pointer-events:none;
  transition:all .3s cubic-bezier(.2,.8,.2,1); z-index:1600; max-width:90vw; text-align:center; cursor:pointer;
}
.reminder-toast.show { opacity:1; transform:translate(-50%,0); pointer-events:auto; }

/* Time-of-day sections on the Today screen */
.slot-heading {
  font-size:.78rem; text-transform:uppercase; letter-spacing:.05em;
  color:var(--muted); font-weight:700; margin:16px 0 8px;
}
.slot-section:first-child .slot-heading { margin-top:4px; }
/* When only one slot is in use, suppress the (redundant) headings */
#tasksTodo:not(.show-slots) .slot-heading { display:none; }

/* Points economy */
.points-badge { margin-left:8px; font-weight:800; color:var(--brand); text-decoration:none; white-space:nowrap; }
.points-badge:hover { text-decoration:underline; }
.points-balance { font-size:2.4rem; font-weight:800; color:var(--brand); }

/* Break-it-down step groups (Today) */
.task-group { display:block; background:var(--card-2); border:2px solid var(--line); border-radius:14px; padding:14px 16px; margin-bottom:12px; }
.task-group.done { border-color:var(--good); background:rgba(45,212,113,.10); }
.task-group-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.task-group-info { min-width:0; }
.task-group .cat { font-size:.72rem; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; font-weight:600; display:block; }
.task-group-info .label { font-size:1.12rem; font-weight:700; }
.task-group.done .task-group-info .label { color:var(--muted); }
.group-progress { font-size:.82rem; color:var(--muted); font-weight:600; white-space:nowrap; }
.subtasks { margin-top:10px; display:flex; flex-direction:column; gap:8px; }
.subtasks .task-check { flex:none; padding:10px 14px; margin-bottom:0; border-width:1px; }
.subtasks .task-check .label { font-size:1rem; font-weight:600; }
#tasksDone .task-group .skip-form { display:none; }

/* Steps editor (My Tasks) */
.subtask-edit { margin-top:6px; }
.subtask-edit summary { cursor:pointer; color:var(--brand); font-size:.82rem; font-weight:600; list-style:none; display:inline-block; }
.subtask-edit summary::-webkit-details-marker { display:none; }
.step-list li { padding:6px 0; gap:10px; }

/* Snooze control */
.snooze-edit summary { cursor:pointer; color:var(--brand); font-size:.82rem; font-weight:600; list-style:none; display:inline-block; }
.snooze-edit summary::-webkit-details-marker { display:none; }
.snooze-edit .snooze-form { margin-top:6px; }

/* Site footer (privacy link) */
.site-footer { text-align:center; padding:24px 16px 36px; }
.site-footer a { color:var(--muted); font-size:.85rem; text-decoration:none; }
.site-footer a:hover { color:var(--brand); text-decoration:underline; }

@media print {
  header.topbar, .no-print { display: none !important; }
  body { background:#fff; color:#000; }
  .card, .report-day { border-color:#ccc; background:#fff; }
}

/* ── Calm mode: fewer moving parts, quieter celebration ─────────────── */
html.calm *, html.calm *::before, html.calm *::after {
  animation-duration: 0.01s !important;
  transition-duration: 0.01s !important;
}
html.calm .hype-toast {
  background: var(--card, #2a2a33);
  color: var(--text, #eee);
  border: 1px solid var(--border, #444);
  box-shadow: none;
  font-weight: 500;
}
html.calm .confetti-canvas { display: none !important; }

/* Pick for me: the chosen task gets a visible ring until the next pick. */
.task-row.picked {
  outline: 3px solid var(--accent, #7c5cff);
  outline-offset: 3px;
  border-radius: 10px;
}

/* ── Accessibility (2026-11-23 audit) ──────────────────────────────── */

/* Skip link: first tab stop, visible only while focused. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--card, #1a1d26);
  color: var(--ink, #fff);
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
  border: 2px solid #7c5cff;
}
.skip-link:focus {
  left: 0;
}

/* #main takes focus from the skip link; no ring needed on the page itself. */
main:focus { outline: none; }

/* A clear, consistent keyboard focus ring everywhere. */
:focus-visible {
  outline: 3px solid #7c5cff;
  outline-offset: 2px;
  border-radius: 4px;
}
html[data-theme="light"] :focus-visible { outline-color: #4c2fd6; }

/* Respect reduced-motion for everything, not just confetti. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important;
    scroll-behavior: auto !important;
  }
  .confetti-canvas { display: none !important; }
}
