/* ============ Colours (light mode, then dark mode) ============ */
:root {
  --bg: #F5F3EF;
  --card: #FFFFFF;
  --text: #1E1D1B;
  --muted: #8A857E;
  --line: rgba(0, 0, 0, 0.07);
  --accent: #4FA3A5;          /* changed from Settings */
  --on-accent: #FFFFFF;
  --danger: #D2564A;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 18px rgba(60, 50, 30, 0.05);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --card: #1E1E1F;
    --text: #F2F1EF;
    --muted: #8F8C88;
    --line: rgba(255, 255, 255, 0.08);
    --shadow: none;
    --danger: #E8776B;
  }
}

/* ============ Basics ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100dvh; overscroll-behavior-y: none; }
body.sheet-open { overflow: hidden; }

button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
button:disabled { cursor: default; }
input, textarea { font: inherit; font-size: 17px; color: inherit; } /* 17px stops iPhone zooming in */
[hidden] { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(var(--safe-top) + 10px)
    calc(var(--safe-right) + 16px)
    calc(var(--safe-bottom) + 160px)
    calc(var(--safe-left) + 16px);
}

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ============ Top bar ============ */
.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 30px; line-height: 1; color: var(--accent);
  display: grid; place-items: center; padding-bottom: 3px;
}
.icon-btn:disabled { opacity: 0.25; }
.icon-btn:active:not(:disabled) { background: var(--line); }
.topbar-title { text-align: center; min-height: 44px; }
.topbar-title h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.link { color: var(--accent); font-weight: 600; }

/* ============ Daily summary ============ */
.summary { display: flex; align-items: center; gap: 16px; padding: 16px 18px; }
.ring { width: 56px; height: 56px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 6; }
.ring-track { stroke: var(--line); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.4s ease; }
.summary-count { font-size: 20px; font-weight: 650; }
.summary-msg { color: var(--muted); font-size: 15px; margin-top: 2px; }

/* ============ Habit groups and rows ============ */
.group-title {
  margin: 24px 6px 8px;
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}

.habit-row {
  --tint: color-mix(in srgb, var(--habit) 16%, var(--card));
  display: flex; align-items: center; gap: 8px;
  min-height: 72px;
  margin-bottom: 10px;
  padding: 0 12px 0 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* The tinted part shows progress for number habits */
  background: linear-gradient(to right, var(--tint) var(--p), var(--card) var(--p));
}
.habit-row.done { background: var(--tint); }
.habit-row.skipped { opacity: 0.6; }

.habit-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0 12px 12px;
  text-align: left; min-height: 72px;
}
.emoji-badge {
  flex: none;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 24px;
  background: color-mix(in srgb, var(--habit, var(--accent)) 20%, transparent);
}
.emoji-badge.big { width: 72px; height: 72px; font-size: 38px; }
.habit-text { display: flex; flex-direction: column; min-width: 0; }
.habit-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-done-name { text-decoration: line-through; }
.habit-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* Round tick button */
.check {
  flex: none;
  width: 48px; height: 48px; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--habit) 55%, transparent);
  display: grid; place-items: center;
  color: transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.check svg { width: 26px; height: 26px; }
.check.done { background: var(--habit); border-color: var(--habit); color: #fff; }
.check:active { transform: scale(0.9); }
.check.pop { animation: pop 0.35s ease; }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* + / − buttons */
.stepper { display: flex; gap: 8px; flex: none; }
.step-btn {
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 24px; font-weight: 500; line-height: 1;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--habit, var(--accent)) 18%, transparent);
  color: color-mix(in srgb, var(--habit, var(--accent)) 80%, var(--text));
  transition: transform 0.12s;
}
.step-btn:active:not(:disabled) { transform: scale(0.9); }
.step-btn:disabled { opacity: 0.35; }
.step-btn.big { width: 56px; height: 56px; font-size: 30px; }

.quiet-note { text-align: center; color: var(--muted); margin: 28px 0; }

/* ============ Empty state ============ */
.empty { text-align: center; padding: 36px 24px; margin-top: 12px; }
.empty-emoji { font-size: 48px; }
.empty h2 { margin: 10px 0 6px; font-size: 20px; }
.empty p { margin: 0; color: var(--muted); }

/* ============ Floating "New habit" button ============ */
.fab {
  position: fixed;
  right: calc(var(--safe-right) + 20px);
  bottom: calc(var(--safe-bottom) + 70px);
  height: 54px; padding: 0 22px;
  border-radius: 27px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 600;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  display: flex; align-items: center; gap: 6px;
  transition: transform 0.15s;
  z-index: 5;
}
.fab span { font-size: 26px; font-weight: 400; line-height: 1; margin-top: -2px; }
.fab:active { transform: scale(0.95); }

/* ============ Slide-up sheets ============ */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
}
.sheet-overlay.open { background: rgba(0, 0, 0, 0.35); }

.sheet {
  width: 100%; max-width: 560px;
  max-height: calc(100dvh - var(--safe-top) - 12px);
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding-bottom: var(--safe-bottom);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.85, 0.25, 1);
}
.sheet.tall { height: calc(100dvh - var(--safe-top) - 12px); }
.sheet-overlay.open .sheet { transform: none; }

.sheet-header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.sheet-header h2 { margin: 0; font-size: 17px; font-weight: 650; }
.sheet-header > :first-child { justify-self: start; }
.sheet-header > :last-child { justify-self: end; }
.text-btn { color: var(--accent); min-height: 44px; padding: 0 4px; }
.text-btn.strong { font-weight: 650; }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px calc(var(--safe-right) + 16px) 28px calc(var(--safe-left) + 16px);
}

/* ============ Form pieces ============ */
.field { display: block; margin-bottom: 22px; }
.field-label {
  display: block; margin: 0 4px 8px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted);
}
.input {
  width: 100%; min-height: 50px;
  padding: 12px 14px;
  border: 1px solid transparent; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow);
  outline: none; -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.input.small { margin-top: 10px; min-height: 44px; font-size: 17px; }
.input.tiny { width: 80px; min-height: 40px; padding: 8px 10px; display: inline-block; margin-left: 8px; }
textarea.input { resize: none; line-height: 1.4; }
.input-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }
.inline-label { display: flex; align-items: center; margin-top: 12px; color: var(--muted); font-size: 15px; }

.form-preview { display: flex; justify-content: center; margin: 4px 0 18px; }
.form-error {
  margin: 0 0 16px; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger);
  font-weight: 500;
}

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-opt {
  aspect-ratio: 1; border-radius: 12px; font-size: 24px;
  display: grid; place-items: center;
}
.emoji-opt.selected { background: color-mix(in srgb, var(--accent) 22%, transparent); }

.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; padding: 0 4px; }
.swatch {
  width: 100%; max-width: 40px; aspect-ratio: 1; border-radius: 50%; justify-self: center;
  background: var(--c);
  box-shadow: 0 0 0 0 var(--bg), 0 0 0 0 var(--c);
  transition: box-shadow 0.15s;
}
.swatch.selected { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5.5px var(--c); }

.segmented {
  display: flex; gap: 3px; padding: 3px;
  border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
}
.segmented button {
  flex: 1; min-height: 42px; padding: 0 4px;
  border-radius: 11px; font-size: 15px; font-weight: 500;
  white-space: nowrap;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.day-chips { display: flex; justify-content: space-between; gap: 6px; margin-top: 12px; }
.day-chip {
  flex: 1; max-width: 46px; aspect-ratio: 1; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow);
  font-weight: 600; color: var(--muted);
}
.day-chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.times-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding: 8px; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow);
  font-weight: 600;
}

.secondary-btn {
  width: 100%; min-height: 50px; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow);
  color: var(--accent); font-weight: 600;
}
.secondary-btn.danger { color: var(--danger); }
.secondary-btn:active { opacity: 0.7; }
.danger-zone { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.danger-zone .secondary-btn + .hint { margin: 8px 4px 18px; }
.hint { color: var(--muted); font-size: 14px; }

/* ============ Day details sheet ============ */
.day-hero { text-align: center; margin: 4px 0 20px; }
.day-hero .emoji-badge { margin: 0 auto 10px; }
.day-hero-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }

.big-check {
  width: 100%; min-height: 58px; margin-bottom: 14px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 650; font-size: 18px;
  background: color-mix(in srgb, var(--habit) 18%, var(--card));
  color: color-mix(in srgb, var(--habit) 75%, var(--text));
  transition: background 0.2s, transform 0.12s;
}
.big-check svg { width: 24px; height: 24px; }
.big-check.done { background: var(--habit); color: #fff; }
.big-check:active { transform: scale(0.98); }

.number-log {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; margin-bottom: 14px;
}
.number-value { text-align: center; flex: 1; }
.number-value input {
  width: 100%; max-width: 160px;
  border: 0; background: none; text-align: center;
  font-size: 40px; font-weight: 700; outline: none;
  -moz-appearance: textfield;
}
.number-value input::-webkit-inner-spin-button,
.number-value input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.number-value span { display: block; font-size: 15px; }

.switch-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; margin-bottom: 22px; text-align: left;
}
.switch-text { display: flex; flex-direction: column; }
.switch-text small { color: var(--muted); font-size: 14px; margin-top: 2px; }
.switch {
  flex: none; position: relative;
  width: 51px; height: 31px; border-radius: 16px;
  background: color-mix(in srgb, var(--text) 15%, transparent);
  transition: background 0.2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.switch-row[aria-checked="true"] .switch { background: var(--accent); }
.switch-row[aria-checked="true"] .switch::after { transform: translateX(20px); }

/* ============ Full-screen pages (Habit detail) ============ */
body.page-open { overflow: hidden; }
.page {
  position: fixed; inset: 0; z-index: 15;
  display: flex; flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.85, 0.25, 1);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
}
.page.open { transform: none; }
.page-header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(var(--safe-top) + 4px) calc(var(--safe-right) + 12px) 4px calc(var(--safe-left) + 8px);
}
.page-header > :last-child { justify-self: end; }
.page-header > :first-child { justify-self: start; }
.text-btn.back { font-size: 17px; }
.page-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 4px calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 32px) calc(var(--safe-left) + 16px);
}
.page-body > * { max-width: 560px; margin-left: auto; margin-right: auto; }

.pill {
  display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 10px;
  background: var(--line); color: var(--muted); font-size: 13px; font-weight: 600;
}

/* Streak tiles */
.stat-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { padding: 14px 16px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.stat-sub { color: var(--muted); font-size: 14px; }

/* Cards with a title */
.section { padding: 14px 16px 16px; margin-bottom: 12px; }
.section-title { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.center { text-align: center; }
.section .hint { margin: 10px 0 0; font-size: 13px; }

/* Completion rates */
.rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.rate-value { font-size: 24px; font-weight: 700; }
.rate-label { font-size: 13px; font-weight: 600; margin-top: 2px; }
.rate-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* Month switcher */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px 8px; }
.month-nav .section-title { margin: 0; }
.icon-btn.small { width: 40px; height: 40px; font-size: 26px; }

/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-head { margin-bottom: 6px; }
.cal-head span { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-day {
  position: relative;
  aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.cal-day.partial {
  background: color-mix(in srgb, var(--habit) calc(15% + var(--f) * 45%), var(--card));
}
.cal-day.done { background: var(--habit); color: #fff; font-weight: 650; }
.cal-day.skip {
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--habit) 22%, transparent) 0 3px, transparent 3px 6px);
  color: var(--muted);
}
.cal-day.off { background: transparent; color: var(--muted); }
.cal-day.future { background: transparent; color: var(--muted); opacity: 0.45; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--text); }
.cal-day.done.today { box-shadow: inset 0 0 0 2px var(--text), inset 0 0 0 4px var(--habit); }
.cal-day.has-note::after {
  content: ""; position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; opacity: 0.6;
}
.cal-day:active:not(:disabled) { transform: scale(0.92); }

.cal-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.cal-legend span { display: flex; align-items: center; gap: 5px; }
.key { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.key.done { background: var(--habit); }
.key.partial { background: color-mix(in srgb, var(--habit) 40%, var(--card)); }
.key.skip { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--habit) 45%, transparent) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--habit) 40%, transparent); }
.key.off { box-shadow: inset 0 0 0 1px var(--muted); opacity: 0.6; }

/* Daily amounts chart */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 10px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .baseline { stroke: var(--line); stroke-width: 1; }
.chart .target { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.chart .target-label { font-size: 10px; }
.chart .bar path { fill: color-mix(in srgb, var(--habit) 55%, var(--card)); }
.chart .bar.met path { fill: var(--habit); }
.chart .bar.picked path { fill: var(--text); }
.chart-caption { margin: 8px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.chart-caption strong { color: var(--text); font-weight: 600; }

/* Notes list */
.note-row {
  width: 100%; display: flex; gap: 12px; text-align: left;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.note-row:first-of-type { border-top: 0; padding-top: 0; }
.note-date { flex: none; width: 82px; color: var(--muted); font-size: 14px; }
.note-text { font-size: 15px; white-space: pre-wrap; word-break: break-word; }

.secondary-btn + .secondary-btn { margin-top: 10px; }

/* ============ Tab bar ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center;
  padding: 6px calc(var(--safe-right) + 8px) calc(var(--safe-bottom) + 4px) calc(var(--safe-left) + 8px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 160px; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); }

/* ============ Overview ============ */
.screen-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin: 6px 4px 14px;
}
.screen-header h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.screen-header p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.week-pct {
  flex: none; width: 64px; height: 56px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: var(--accent);
}
.reorder-hint { margin: 14px 0 0; }

.ov-list { margin-top: 14px; }
.ov-card {
  display: flex; align-items: stretch;
  margin-bottom: 10px;
  position: relative;
  transition: box-shadow 0.2s;
}
.ov-main { flex: 1; min-width: 0; padding: 12px 14px 14px; text-align: left; }
.ov-top { display: flex; align-items: center; gap: 12px; }
.ov-top .habit-text { flex: 1; }
.ov-streak { flex: none; display: flex; align-items: baseline; gap: 3px; font-size: 15px; }
.ov-streak strong { font-size: 20px; }
.ov-streak small { color: var(--muted); font-size: 13px; }

.week-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.dot {
  height: 30px; border-radius: 15px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.dot.done { background: var(--habit); color: #fff; }
.dot.partial { background: color-mix(in srgb, var(--habit) calc(15% + var(--f) * 45%), var(--card)); color: var(--text); }
.dot.skip {
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--habit) 25%, transparent) 0 3px, transparent 3px 6px);
}
.dot.off, .dot.future { background: transparent; }
.dot.future { opacity: 0.5; }
.dot.missed { background: color-mix(in srgb, var(--text) 9%, transparent); }
.dot.today { box-shadow: inset 0 0 0 2px var(--text); }

.drag-handle { display: none; }
.reordering .drag-handle {
  display: grid; place-items: center;
  width: 52px; flex: none;
  font-size: 26px; color: var(--muted);
  touch-action: none; cursor: grab;
  border-left: 1px solid var(--line);
}
.reordering .week-dots { display: none; }
.ov-card.dragging {
  z-index: 2;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  transition: none;
}

.archived { margin-top: 26px; }
.archived-toggle {
  width: 100%; text-align: left; padding: 10px 6px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.archived-card { opacity: 0.75; align-items: center; }
.restore-btn {
  flex: none; margin-right: 12px; padding: 0 14px; min-height: 38px; border-radius: 19px;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; font-size: 15px;
}

/* ============ Settings ============ */
.settings-text { margin: 0 0 12px; font-size: 15px; line-height: 1.45; }
.primary-btn {
  width: 100%; min-height: 50px; border-radius: 14px;
  background: var(--accent); color: var(--on-accent); font-weight: 650;
}
.primary-btn:active { opacity: 0.85; }
.section .primary-btn + .hint, .section .secondary-btn + .hint { margin: 8px 4px 0; text-align: left; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.settings-msg { margin: 12px 0 0; font-size: 15px; font-weight: 500; }
.settings-msg.error { color: var(--danger); }
.section .swatches { padding: 4px 0; }
.about .settings-text { margin: 0; }

/* ============ Groups (Fitness, Diet…) ============ */
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 20px;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 15px; font-weight: 500; color: var(--text);
  transition: background 0.2s, color 0.2s;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.ov-group .group-title { margin-top: 20px; }
.ov-group .ov-list { margin-top: 0; }

.group-toggle { margin-top: 12px; }
.group-toggle button { min-height: 36px; font-size: 14px; }

/* ============ Undo bar ============ */
.toast {
  position: fixed; z-index: 30;
  left: 50%; bottom: calc(var(--safe-bottom) + 134px);
  width: min(calc(100% - 32px), 420px);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 18px; min-height: 52px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--bg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  font-size: 15px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.25s, transform 0.3s cubic-bezier(0.2, 0.85, 0.25, 1);
}
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast-text { flex: 1; }
.toast-undo {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px;
  font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--bg) 12%, transparent);
}

/* ============ Confetti (falls down the whole screen) ============ */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i {
  position: absolute; top: -24px; border-radius: 2px;
  opacity: 0;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.35, 0.1, 0.6, 1);
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
  25% { transform: translate3d(calc(var(--sway) * -0.6), 25vh, 0) rotate(calc(var(--r) * 0.25)); }
  50% { transform: translate3d(var(--sway), 52vh, 0) rotate(calc(var(--r) * 0.5)); }
  75% { transform: translate3d(calc(var(--sway) * -0.4), 80vh, 0) rotate(calc(var(--r) * 0.75)); }
  90% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(calc(var(--sway) * 0.5), 105vh, 0) rotate(var(--r)); }
}

/* ============ Sliding between days ============ */
.screen.slide-from-right { animation: slide-from-right 0.28s ease-out; }
.screen.slide-from-left { animation: slide-from-left 0.28s ease-out; }
@keyframes slide-from-right { from { opacity: 0.3; transform: translateX(36px); } to { opacity: 1; transform: none; } }
@keyframes slide-from-left { from { opacity: 0.3; transform: translateX(-36px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .screen.slide-from-right, .screen.slide-from-left { animation: none; }
}

/* ============ "Do less" limit habits ============ */
.over-text { color: var(--danger); font-weight: 600; }
.habit-row.over { box-shadow: var(--shadow), inset 3px 0 0 var(--danger); }
.limit-status { text-align: center; margin: -4px 0 16px; font-size: 15px; color: var(--muted); }
.type-hint { margin: 8px 4px 0; }
.cal-day.over, .dot.over {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--danger) 55%, transparent);
}
.cal-day.over.today { box-shadow: inset 0 0 0 2px var(--text); }
.key.over { background: color-mix(in srgb, var(--danger) 25%, transparent); box-shadow: inset 0 0 0 1px var(--danger); }
.chart .bar.over path { fill: var(--danger); }

.summary-limits { font-size: 14px; color: var(--muted); margin-top: 3px; }
