:root {
  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-2: #efedf4;
  --text: #17141f;
  --muted: #6e6a7c;
  --line: #e3e0ea;
  --accent: #6d28d9;
  --accent-ink: #ffffff;
  --success: #19a974;
  --danger: #e0454a;
  --empty-cell: #e7e4ee;
  --s1: #0a0a0c; --s2: #2e1065; --s3: #4c1d95; --s4: #6d28d9; --s5: #a23fb0;
  --s6: #d6517c; --s7: #ee6a52; --s8: #f98c2c; --s9: #fbbf24; --s10: #f2d683;
  --shadow: 0 1px 2px rgba(20, 10, 40, .05), 0 6px 20px rgba(20, 10, 40, .06);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0c14;
    --surface: #18151f;
    --surface-2: #221e2b;
    --text: #f2f0f7;
    --muted: #9a95aa;
    --line: #2c2836;
    --accent: #8b5cf6;
    --empty-cell: #24202d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
/* No double-tap zoom: quick repeated taps (like 11 on the keypad) stay taps. */
html, body, button, a, input, textarea, select, label { touch-action: manipulation; }
.key { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
body.sheet-open { overflow: hidden; position: fixed; left: 0; right: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .1em; }
.mt { margin-top: 16px; }
.hidden { display: none !important; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-s { gap: 10px; }
.warn { color: var(--danger); }

/* Privacy cover for the app switcher: hide the journal, show just the name */
body.privacy #app { visibility: hidden; }
body.privacy::after {
  content: 'Supplemental';
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  font-size: 40px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--s6);
  background: linear-gradient(90deg, var(--s3), var(--s6), var(--s9)) center / 8.5em 1.3em no-repeat, #fff;
  -webkit-background-clip: text, border-box; background-clip: text, border-box;
  -webkit-text-fill-color: transparent;
}

/* ---------- Lock screen ---------- */
.lock {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
  gap: 28px;
}
.lock-head { text-align: center; }
.logo { width: 64px; height: 64px; display: block; margin: 0 auto 14px; }
.lock h1 { font-size: 26px; font-weight: 650; }
.lock-msg { margin: 6px 0 0; min-height: 22px; }
.link-btn { background: none; border: 0; padding: 6px 4px; color: var(--accent); font-size: 15px; }
.link-btn.strong { font-weight: 600; }

.pin-pad { width: 100%; max-width: 300px; margin: 0 auto; touch-action: manipulation; }
.pin-pad.busy .key { opacity: .5; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin-bottom: 28px; }
.pin-dot { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--muted); transition: all .12s; }
.pin-dot.on { background: var(--text); border-color: var(--text); transform: scale(1.1); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 22px; justify-items: center; }
.key {
  width: 74px; height: 74px; border-radius: 50%; border: 0;
  background: var(--surface-2); font-size: 28px; font-weight: 400;
  display: grid; place-items: center; transition: background .1s, transform .1s;
}
.key:active, .key.down { background: var(--line); transform: scale(.95); }
.key-icon { background: transparent; font-size: 24px; }
.key-slot { width: 74px; height: 74px; }
.faceid { color: var(--accent); }

/* ---------- Shell ---------- */
.shell { min-height: 100dvh; }
.view {
  padding: 14px 16px calc(var(--safe-bottom) + 100px);
  max-width: 640px; margin: 0 auto;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.app-head { display: flex; align-items: center; justify-content: center; gap: 10px; height: 52px; padding: 24px 16px 0; }
.app-tagline { font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line); line-height: 14px; }
.wordmark {
  font-size: 21px; font-weight: 800; letter-spacing: -0.02em; text-decoration: none;
  background: linear-gradient(90deg, var(--s3), var(--s6), var(--s9));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--s6);
}
.demo-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, var(--s3), var(--s6));
  color: #fff; font-size: 13px; font-weight: 500;
}
.chip-btn { border: 0; border-radius: 999px; padding: 6px 12px; background: rgba(255, 255, 255, .95); color: #111; font-weight: 600; font-size: 13px; white-space: nowrap; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 500; color: var(--muted); padding: 4px 0; }
.tab svg { width: 24px; height: 24px; padding: 3px 16px; box-sizing: content-box; border-radius: 999px; transition: background .2s; }
.tab.active { color: var(--accent); font-weight: 700; }
.tab.active svg { background: color-mix(in srgb, var(--accent) 22%, transparent); stroke-width: 2.4; }
.tab-new { justify-self: center; }
.tab-new .plus {
  width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center;
  font-size: 30px; font-weight: 300; line-height: 1; color: #fff;
  background: linear-gradient(135deg, var(--s3), var(--s7));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--s6) 40%, transparent);
}
.tab-new.active .plus { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--s6); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.page-head h1 { font-size: 30px; font-weight: 700; }
.page-head p { margin: 2px 0 0; font-size: 14px; }
.round-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 24px; line-height: 1; display: grid; place-items: center;
}
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--surface-2); font-size: 20px; line-height: 1; display: grid; place-items: center; }
.icon-btn:disabled { opacity: .35; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.section-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; }
.hint { color: var(--muted); font-size: 12.5px; text-align: center; margin: 10px 4px; }
.hint.left { text-align: left; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; border: 1.5px dashed var(--line); border-radius: var(--radius); }
.empty.small { padding: 16px 8px; font-size: 13px; }

/* ---------- Home ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.stat-num { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--muted); }
.today-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; margin-bottom: 14px; border-radius: var(--radius);
  background: linear-gradient(120deg, color-mix(in srgb, var(--s4) 14%, transparent), color-mix(in srgb, var(--s8) 16%, transparent));
  border: 1px solid color-mix(in srgb, var(--s6) 30%, transparent);
}
.today-plus { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(135deg, var(--s3), var(--s7)); }
.heat-card { padding: 14px 12px 12px; }
.heat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.heat-title { font-weight: 600; font-size: 15px; }
.heat-grid { display: grid; grid-template-columns: 18px repeat(12, 1fr); gap: 3px; }
.hm-corner, .hm-month, .hm-day { font-size: 10px; color: var(--muted); display: grid; place-items: center; }
.hm-month { padding-bottom: 2px; font-weight: 600; }
.hm-day { justify-items: end; padding-right: 3px; }
.hm-cell { height: 15px; border: 0; padding: 0; border-radius: 4px; background: var(--empty-cell); transition: transform .1s; }
.hm-cell.none { background: transparent; }
.hm-cell.future { opacity: .35; background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.hm-cell.today { box-shadow: 0 0 0 1.5px var(--text); }

.hm-cell.filled:active { transform: scale(1.3); }
.legend { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.legend-swatches { display: flex; gap: 2px; }
.legend-swatches i { width: 14px; height: 10px; border-radius: 3px; display: block; }
.home-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-card { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); border-top: 3px solid #ef5a5a; min-width: 0; }
.mini-card.goal { border-top-color: #34c39a; }
.mini-kicker { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini-title { font-weight: 600; margin: 4px 0; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field-row { display: flex; align-items: center; justify-content: space-between; }
.field-row .field-label { margin: 0; }
input[type=text], input[type=date], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
input[type=date] { min-height: 46px; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.score-display { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.score-tile {
  width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center;
  font-size: 26px; font-weight: 750; background: var(--surface-2); color: var(--muted); transition: background .15s;
}
.score-tile.set { background: var(--c); color: #fff; }
.score-word { font-size: 18px; font-weight: 600; }
.score-picker { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.score-sq {
  aspect-ratio: 1; border: 0; border-radius: 9px; background: var(--c); color: rgba(255, 255, 255, .92);
  font-size: 13px; font-weight: 700; opacity: .55; transition: transform .12s, opacity .12s, box-shadow .12s;
}
.ink-dark { color: rgba(30, 22, 0, .78) !important; }
.score-sq.on { opacity: 1; transform: scale(1.12); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c); }
.score-ends { display: flex; justify-content: space-between; margin-top: 6px; }
.form-actions { padding-top: 6px; }

.btn {
  border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 600; font-size: 16px;
  background: var(--surface-2); text-align: center; transition: transform .1s, opacity .1s;
}
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.success { background: var(--success); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.ghost { background: transparent; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; border-radius: 9px; padding: 7px 12px; font-size: 14px; font-weight: 500; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented.wide { display: flex; width: 100%; margin-bottom: 16px; }
.segmented.wide button { flex: 1; padding: 8px 6px; font-size: 13px; }

/* ---------- Snapshots (issues/goals on a day) ---------- */
.snap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.snap { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 12px; padding: 9px 12px; }
.snap-rank { font-weight: 700; font-size: 14px; min-width: 30px; color: #ef5a5a; }
.snap.goal .snap-rank { color: #34c39a; }
.snap-rank small { color: var(--muted); font-weight: 500; font-size: 11px; }
.snap-title { flex: 1; font-size: 14.5px; line-height: 1.3; }
.snap-meta { white-space: nowrap; font-size: 15px; }
.snap-meta small { color: var(--muted); font-size: 12px; }

/* ---------- Day detail ---------- */
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.day-nav .sheet-title { font-size: 18px; margin: 0; text-align: center; flex: 1; }
.day-score { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.day-score-sq { width: 64px; height: 64px; border-radius: 18px; background: var(--c); display: grid; place-items: center; color: #fff; font-size: 30px; font-weight: 750; }

.day-score-word { font-size: 22px; font-weight: 700; }
.day-note { white-space: normal; font-size: 16px; line-height: 1.55; margin: 0 0 14px; }
.thankful { background: color-mix(in srgb, #34c39a 12%, transparent); border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.thankful span { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #1f9c78; margin-bottom: 2px; }

/* ---------- Issues & goals ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.item-list { display: flex; flex-direction: column; gap: 10px; position: relative; }
.item-card {
  position: relative; display: flex; align-items: stretch; gap: 4px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  border-left: 4px solid var(--accent); padding: 12px 12px 12px 6px;
  transition: transform .2s ease, opacity .3s, box-shadow .2s;
  touch-action: pan-y;
}
.is-dragging .item-card { transition: transform .18s ease; }
.item-card.dragging { transition: none; z-index: 5; box-shadow: 0 14px 34px rgba(20, 10, 40, .25); }
.item-card.done { opacity: .7; }
.item-card.completing { animation: complete .65s ease forwards; }
@keyframes complete {
  0% { transform: scale(1); }
  30% { transform: scale(1.04); box-shadow: 0 0 0 3px var(--success); }
  100% { transform: translateX(110%) scale(.9); opacity: 0; }
}
.drag-handle {
  flex: none; width: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  touch-action: none; cursor: grab; color: var(--muted);
}
.drag-handle span { width: 14px; height: 2px; border-radius: 2px; background: currentColor; opacity: .6; }
.item-main { flex: 1; min-width: 0; padding-left: 6px; }
.item-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.item-rank { font-weight: 750; font-size: 13px; color: var(--text); }
.tag { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.status-pill { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.s-noticed, .s-planned { background: rgba(124, 156, 191, .18); color: #557797; }
.s-working, .s-doing { background: rgba(242, 163, 58, .18); color: #b56d0d; }
.s-resolved, .s-done { background: rgba(25, 169, 116, .16); color: #138a5e; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.s-noticed, .status-dot.s-planned { background: #7c9cbf; }
.status-dot.s-working, .status-dot.s-doing { background: #f2a33a; }
.status-dot.s-resolved, .status-dot.s-done { background: #19a974; }
.item-title { font-weight: 600; font-size: 16px; line-height: 1.3; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 13px; }
.item-meta .age { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin-left: auto; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.item-meta .age.aging { color: #d98a1c; font-weight: 600; }
.item-meta .age.old { color: var(--danger); font-weight: 600; }
.check-btn {
  flex: none; align-self: center; width: 30px; height: 30px; margin-left: 6px; border-radius: 50%;
  border: 2px solid var(--line); background: transparent; position: relative;
}
.check-btn::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; color: var(--success); opacity: 0; transition: opacity .1s; }
.check-btn:active { border-color: var(--success); }
.check-btn:active::after { opacity: 1; }
.done-mark { align-self: center; color: var(--success); font-weight: 700; padding: 0 6px; }
.advance-btn { margin-top: 10px; border: 0; background: var(--surface-2); border-radius: 9px; padding: 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: 82%; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 6px;
  scrollbar-width: none;
}
.board::-webkit-scrollbar { display: none; }
/* iPad and wider: every column fits on screen, no sideways swipe. */
@media (min-width: 700px) {
  .board { grid-auto-columns: minmax(0, 1fr); overflow-x: visible; margin: 0; padding: 0 0 6px; }
  .swipe-hint { display: none; }
  .view:has(.board) { max-width: 1100px; }
}
.board-col { scroll-snap-align: start; background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.board-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; margin: 2px 4px 10px; }
.board-head .count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.board-cards { display: flex; flex-direction: column; gap: 8px; }
.board .item-card { padding-left: 10px; }

/* ---------- Editor ---------- */
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.title-input { font-size: 20px !important; font-weight: 650; border: 0 !important; padding: 4px 0 12px !important; background: transparent !important; box-shadow: none !important; resize: none; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.rank-row { display: flex; align-items: center; gap: 10px; }
.rank-row select { width: 80px; text-align: center; font-weight: 700; }
.intensity-val { float: right; color: var(--text); }
.reflect { background: var(--surface-2); border-radius: var(--radius); padding: 4px 14px; margin-top: 6px; }
.reflect summary { list-style: none; padding: 12px 0; font-weight: 650; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.reflect summary::-webkit-details-marker { display: none; }
.reflect[open] summary { margin-bottom: 4px; }
.reflect textarea { background: var(--surface); }

/* ---------- Settings ---------- */
.callout { background: linear-gradient(120deg, color-mix(in srgb, var(--s4) 12%, var(--surface)), color-mix(in srgb, var(--s8) 14%, var(--surface))); }
.callout p { margin-top: 0; }
.list-card { padding: 0; overflow: hidden; }
.row-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 0; background: transparent; text-align: left; font-size: 16px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.list-card > :last-child { border-bottom: 0; }
.row-btn:disabled, .row-btn.disabled { opacity: .45; pointer-events: none; }
.chev { color: var(--muted); font-size: 22px; line-height: 1; }
.switch { position: relative; flex: none; width: 51px; height: 31px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; }
.switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch input:checked + i { background: var(--success); }
.switch input:checked + i::after { transform: translateX(20px); }
.attempts { list-style: none; padding: 0; margin: 8px 0; }
.attempts li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.attempts li:last-child { border-bottom: 0; }
.attempts time { margin-left: auto; font-size: 12.5px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--success); }
.dot.bad { background: var(--danger); }
.collapse { border-bottom: 1px solid var(--line); }
.collapse summary { list-style: none; padding: 14px 16px; font-size: 16px; display: flex; justify-content: space-between; cursor: pointer; }
.collapse summary::-webkit-details-marker { display: none; }
.collapse summary::after { content: "›"; color: var(--muted); font-size: 22px; line-height: 1; transition: transform .2s; }
.collapse[open] summary::after { transform: rotate(90deg); }
.collapse > :not(summary) { padding: 0 16px 14px; margin: 0; }
.steps { padding-left: 36px !important; }
.steps li { margin-bottom: 8px; }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 12px; padding-left: 18px; }
.prose li { margin-bottom: 6px; }

/* ---------- Sheet ---------- */
/* The wrap tracks the visual viewport, so the on-screen keyboard never pushes the
   top of a sheet out of reach. Only the body scrolls; the grabber and X stay put. */
.sheet-wrap { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--vv-h, 100dvh); z-index: 100; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 5, 20, .45); opacity: 0; transition: opacity .25s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: calc(var(--vv-h, 100dvh) * .9);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); border-radius: 22px 22px 0 0;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .9, .3, 1);
  max-width: 640px; margin: 0 auto;
}
.sheet .sheet-grabber { flex: none; margin-top: 8px; }
.sheet-body {
  flex: 0 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 0 18px calc(var(--safe-bottom) + 20px);
}
.sheet.tall { height: calc(var(--vv-h, 100dvh) * .92); max-height: calc(var(--vv-h, 100dvh) * .92); }
.sheet.tall .sheet-body { flex: 1 1 auto; }
.sheet-wrap.show .sheet { transform: translateY(0); }
.sheet-wrap.show .sheet-backdrop { opacity: 1; }
.sheet-grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.sheet .pin-pad { margin: 22px auto; }

/* ---------- Toast & celebration ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); z-index: 200;
  transform: translate(-50%, 20px); opacity: 0; transition: all .25s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 300; }
.celebrate-badge {
  position: fixed; left: 50%; top: 42%; z-index: 301; pointer-events: none;
  transform: translate(-50%, -50%) scale(.6); opacity: 0; transition: all .35s cubic-bezier(.2, 1.4, .4, 1);
  background: var(--surface); color: var(--text); border-radius: 22px; padding: 20px 26px; text-align: center;
  font-weight: 700; font-size: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.celebrate-badge.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.celebrate-check { width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; font-size: 28px; color: #fff; background: linear-gradient(135deg, #19a974, #34c39a); }

@media (prefers-reduced-motion: reduce) {
  *:not(.gold), *:not(.gold)::before, *:not(.gold)::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }

}

/* ---------- Round two: score ends, sheet close, keypad ok, themes ---------- */
.gold {
  /* Gold leaf: a metallic gradient with a fine grain, plus two twinkling sparkles. */
  position: relative; overflow: hidden;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.93 0 0 0 0 0.7 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='60' height='60' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(120% 90% at 25% 15%, #fff4c9 0%, rgba(255, 244, 201, 0) 45%),
    linear-gradient(135deg, #e7c05c 0%, #f6dc8c 30%, #d6a943 60%, #f1d07a 80%, #c99a35 100%) !important;
  background-size: 60px 60px, 100% 100%, 100% 100% !important;
  box-shadow: 0 0 5px rgba(242, 214, 131, .45);
}
.gold::before, .gold::after {
  content: ""; position: absolute; height: 60%; max-height: 12px; aspect-ratio: 1; pointer-events: none;
  background: #fff;
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
  filter: drop-shadow(0 0 2px #fff);
  opacity: 0;
  animation: sparkle 2.3s ease-in-out infinite;
}
/* Different lengths so the two sparkles drift in and out of step. */
.gold::before { top: 8%; left: 18%; animation-delay: var(--d, 0s); }
.gold::after { bottom: 10%; right: 16%; animation-duration: 3.1s; animation-delay: calc(var(--d, 0s) + 1.1s); }
@keyframes sparkle {
  0%, 45%, 100% { opacity: 0; transform: scale(.2) rotate(0deg); }
  62% { opacity: 1; transform: scale(1) rotate(45deg); }
  82% { opacity: 0; transform: scale(.3) rotate(90deg); }
}
/* Big tiles (a day's score) also get a pulsing glow. */
.gold.big { animation: gold-glow 3s ease-in-out infinite; }
.gold.big::before, .gold.big::after { max-height: 18px; height: 28%; }
@keyframes gold-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(242, 214, 131, .45); }
  50% { box-shadow: 0 0 18px 2px rgba(255, 224, 140, .9); }
}
:root[data-scheme="dark"] .black { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
.stat-sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 7px; vertical-align: 1px; }

.sheet-x {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--surface-2); color: var(--muted); display: grid; place-items: center;
}
.sheet-x:active { transform: scale(.92); }
.sheet-body { padding-top: 22px; }
.sheet-body > .sheet-title:first-child, .day-nav, .editor-head { padding-right: 40px; }
.sheet-body > .sheet-title.center:first-child { padding: 0 40px; }

.key-ok { background: transparent; color: var(--muted); font-size: 26px; opacity: .35; transition: opacity .15s, background .15s, color .15s; }
.key-ok.ready { opacity: 1; background: var(--accent); color: var(--accent-ink); }
.pin-dots { min-height: 15px; }
.lock-links { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.link-btn.faceid { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.link-btn.faceid svg { width: 22px; height: 22px; }
.muted-link { color: var(--muted); font-size: 14px; }

.theme-grid { display: grid; gap: 10px; }
.theme-opt {
  text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.theme-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.theme-opt-head { display: flex; align-items: center; justify-content: space-between; font-weight: 650; }
.theme-strip { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.theme-strip i { height: 16px; border-radius: 4px; display: block; }
.theme-check { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; display: grid; place-items: center; }

.celebrate-pop {
  position: fixed; z-index: 301; pointer-events: none; transform: translate(-50%, -50%) scale(.7); opacity: 0;
  background: var(--success); color: #fff; font-weight: 700; font-size: 14px; padding: 6px 12px; border-radius: 999px;
  transition: transform .3s cubic-bezier(.2, 1.4, .4, 1), opacity .3s; white-space: nowrap;
}
.celebrate-pop.show { transform: translate(-50%, -160%) scale(1); opacity: 1; }

/* Board drag and drop */
.drag-ghost { position: fixed; z-index: 250; pointer-events: none; margin: 0; transform: rotate(2deg) scale(1.03); box-shadow: 0 18px 40px rgba(20, 10, 40, .3); opacity: .96; }
.drag-source { opacity: .25; }
.drop-slot { height: 6px; border-radius: 3px; background: var(--accent); margin: -2px 4px; }
.board-col.drop-target { box-shadow: inset 0 0 0 2px var(--accent); }
/* On the board the handle sits on the right, away from iOS's swipe-back edge. */
.board .drag-handle { order: 2; margin-right: -4px; width: 34px; align-self: stretch; }
.board .item-main { padding-left: 0; }

/* Install tip */
.install-tip { display: flex; gap: 14px; align-items: flex-start; border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--s4) 10%, var(--surface)), color-mix(in srgb, var(--s8) 10%, var(--surface))); }
.install-icon { width: 64px; height: 64px; border-radius: 15px; flex: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.install-body { flex: 1; min-width: 0; }
.install-body p { margin: 4px 0 8px; }
.install-steps { margin: 0 0 12px; padding-left: 18px; }
.install-steps li { margin-bottom: 4px; }
.kbd { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 7px; background: var(--surface-2); font-weight: 600; white-space: nowrap; }

/* Weekly review */
.weekly.card { border: 1.5px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.wk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wk-title { font-size: 20px; font-weight: 700; margin-top: 2px; }
.weekly .wk-x { position: static; flex: none; }
.wk-score { margin: 8px 0 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wk-sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.weekly .section-label { margin: 16px 2px 8px; }
.wk-item { background: var(--surface-2); border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.weekly:not(.card) .wk-item { background: var(--surface); }
.wk-item-head { display: flex; gap: 10px; align-items: flex-start; }
.wk-rank { font-weight: 750; color: #ef5a5a; min-width: 24px; }
.wk-rank.goal { color: #34c39a; }
.wk-item-title { font-weight: 600; line-height: 1.3; flex: 1; min-width: 0; }
.wk-item-title .small { font-weight: 400; margin-top: 2px; }
.trend { display: flex; align-items: center; gap: 6px; margin: 10px 0 8px; flex-wrap: wrap; }
.trend-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; }
.trend-btn.on.t-better { background: var(--success); border-color: var(--success); color: #fff; }
.trend-btn.on.t-same { background: #7c9cbf; border-color: #7c9cbf; color: #fff; }
.trend-btn.on.t-worse { background: var(--danger); border-color: var(--danger); color: #fff; }
.trend-btn.on.t-none { background: #7c9cbf; border-color: #7c9cbf; color: #fff; }
.trend-btn.on.t-some { background: color-mix(in srgb, var(--success) 70%, #fff); border-color: transparent; color: #fff; }
.trend-btn.on.t-big { background: var(--success); border-color: var(--success); color: #fff; }
.wk-reflect { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; text-align: left;
  border: 0; background: transparent; padding: 4px 0 0; font-size: 13.5px; line-height: 1.35; }
.wk-reflect .wk-meter { grid-column: 1 / -1; height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; }
.wk-meter i { display: block; height: 100%; background: #ef5a5a; border-radius: 3px; }
.wk-meter.goal i { background: #34c39a; }

/* Monthly backup reminder */
.backup-nag { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.backup-nag-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
}
.backup-nag-text { flex: 1; min-width: 0; }
.backup-nag-btns { display: flex; gap: 8px; margin-top: 10px; }

/* Reminders */
.reminders { padding: 0; }
.rem-block { padding: 14px 16px; }
.rem-block + .rem-block { border-top: 1px solid var(--line); }
.rem-block p { margin: 2px 0 10px; }
.rem-block .segmented.wide { margin-bottom: 4px; }
.rem-daily { display: flex; gap: 8px; }
.rem-daily select { flex: 1; min-width: 0; }
.rem-daily .btn { flex: none; text-decoration: none; display: inline-flex; align-items: center; }
.list-card.flush { margin: 8px -16px -14px; border-top: 1px solid var(--line); }

/* Settings tabs */
.set-tabs { margin-bottom: 18px; }
.set-pane > .section-label:first-child { margin-top: 0; }
.privacy-note { display: flex; gap: 14px; align-items: flex-start; }
.privacy-note p { margin: 4px 0 0; }
.privacy-note-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success);
}

/* Type-to-confirm for destructive actions */
.type-confirm { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.type-confirm input { width: 100%; }
.btn:disabled { opacity: .4; }

/* Storage meter */
.storage p { margin: 8px 0 0; }
.storage p + p { margin-top: 2px; }
.storage-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.storage-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--s3), var(--s7)); }

/* First-run walkthrough */
.tour { position: fixed; inset: 0; z-index: 90; }
.tour-hole { position: fixed; border-radius: 16px; box-shadow: 0 0 0 200vmax rgba(10, 8, 20, .62); transition: all .25s ease; pointer-events: none; }
.tour-tip { position: fixed; background: var(--surface); color: var(--text); border-radius: 16px; padding: 14px 16px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.3); animation: tour-in .2s ease; }
.tour-tip strong { display: block; font-size: 17px; margin-bottom: 4px; }
.tour-tip p { margin: 0 0 12px; font-size: 15px; line-height: 1.4; color: var(--muted); }
.tour-tip::after { content: ""; position: absolute; left: calc(var(--arrow-x) - 9px); border: 9px solid transparent; }
.tour-tip.above::after { top: 100%; border-top-color: var(--surface); }
.tour-tip.below::after { bottom: 100%; border-bottom-color: var(--surface); }
.tour-tip.floating::after { display: none; }
.tour-tip.floating[style*="top: 12px"] { margin-top: env(safe-area-inset-top); }
.tour-btns { display: flex; align-items: center; justify-content: space-between; }
.tour-right { display: flex; gap: 8px; }
@keyframes tour-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Month in review ---------- */
.rv-hero { min-height: calc(100dvh - 200px); display: flex; flex-direction: column; justify-content: center; text-align: center; position: relative; padding-bottom: 40px; }
.rv-nav { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; }
.rv-kicker { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; color: var(--accent); margin: 0 0 6px; }
.rv-title { font-size: clamp(48px, 15vw, 88px); font-weight: 800; letter-spacing: -0.04em; line-height: 1; margin: 0 0 12px;
  background: linear-gradient(90deg, var(--s4), var(--s6), var(--s8)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rv-scroll-cue { position: absolute; bottom: 0; left: 0; right: 0; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rv-scroll-cue span { animation: rv-bob 1.6s ease-in-out infinite; font-size: 18px; }
@keyframes rv-bob { 50% { transform: translateY(6px); } }

.rv-bloom { margin: 0 -14px; padding: 4vh 0 0; display: flex; flex-direction: column; align-items: center; }
.rv-flower-wrap { position: relative; width: min(100%, 72dvh, 640px); aspect-ratio: 1; }
.rv-flower { width: 100%; height: 100%; overflow: visible; display: block; }
.rv-petal { transform-box: view-box; transform-origin: 0 0; cursor: pointer;
  transform: rotate(0deg) scale(.15); opacity: 0;
  transition: transform 1.1s cubic-bezier(.2, 1.25, .35, 1), opacity .35s ease, filter .3s;
  transition-delay: calc(var(--i) * 22ms); }
.bloomed .rv-petal { transform: rotate(var(--a)) scale(1); opacity: 1; }
.rv-petal path { stroke: var(--bg); stroke-width: 1.5; }
.rv-petal.empty path { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }
.rv-ptext { font-size: 11px; font-weight: 600; fill: #fff; pointer-events: none; opacity: 0; transition: opacity .6s ease calc(900ms + var(--i) * 22ms); letter-spacing: .01em; }
.rv-ptext.dark { fill: #241a2e; }
.bloomed .rv-ptext { opacity: 1; }
.bloomed .rv-petal.on { transform: rotate(var(--a)) translateY(-10px) scale(1.06); filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3)); transition-delay: 0s; }
.rv-core { fill: var(--surface); stroke: var(--line); }
.rv-core-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.rv-core-text strong { font-size: clamp(18px, 5.5vw, 28px); font-weight: 800; line-height: 1; }
.rv-core-text span { font-size: 10px; color: var(--muted); }
.rv-caption { min-height: 96px; max-width: 440px; width: 100%; text-align: center; padding: 14px 18px 0; }
.rv-caption p { margin: 0; font-size: 14px; }
.rv-day { display: flex; flex-direction: column; gap: 6px; animation: rv-fade .35s ease both; }
@keyframes rv-fade { from { opacity: 0; transform: translateY(8px); } }
.rv-cap-date { font-size: 13px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.rv-cap-date i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.rv-cap-thanks { font-size: 19px; line-height: 1.35; }
.rv-cap-note { font-size: 15px; line-height: 1.4; color: var(--muted); font-style: italic; }

.rv-section { padding: 14vh 0 2vh; }
.rv-h2 { font-size: clamp(28px, 8vw, 40px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 0 0 22px; }
.rv-cards { display: grid; gap: 14px; }
@media (min-width: 700px) { .rv-cards { grid-template-columns: 1fr 1fr; } }
.rv-card { position: relative; background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border-left: 4px solid var(--success); }
.rv-card.goals { border-left-color: var(--s9); }
.rv-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; padding-right: 34px; }
.rv-card-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; line-height: 1.3; }
.rv-stamp { position: absolute; top: -10px; right: -6px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--success); color: #fff; font-weight: 800; font-size: 18px; box-shadow: 0 6px 16px rgba(0, 0, 0, .2);
  transform: scale(0) rotate(-40deg); }
.rv-card.goals .rv-stamp { background: linear-gradient(135deg, var(--s8), var(--s10)); color: #241a2e; }
.rv-card.in { animation: rv-pop .75s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i, 0) * 120ms); }
.rv-card.in .rv-stamp { animation: rv-stamp .5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(350ms + var(--i, 0) * 120ms); }
@keyframes rv-pop { 0% { opacity: 0; transform: translateY(40px) scale(.9); } 60% { opacity: 1; transform: translateY(-6px) scale(1.03); } 100% { opacity: 1; transform: none; } }
@keyframes rv-stamp { to { transform: scale(1) rotate(0); } }
.rv-card:not(.in) { opacity: 0; }
.rv-h2, .rv-empty, .rv-end { opacity: 0; transform: translateY(28px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .8, .2, 1); }
.rv-h2.in, .rv-empty.in, .rv-end.in { opacity: 1; transform: none; }
.rv-end { text-align: center; padding: 14vh 0 6vh; }
.rv-end-mark { font-size: 44px; background: linear-gradient(135deg, var(--s5), var(--s9)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rv-end p { font-size: 18px; margin: 8px 0 18px; }

/* Home entry point */
.review-link { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.review-link svg { width: 52px; height: 52px; flex: none; }
.review-link .rv-petal { transition: none; }
.review-link strong { display: block; font-size: 16px; }
.review-link .chev { margin-left: auto; color: var(--muted); font-size: 22px; }

@media (prefers-reduced-motion: reduce) {
  .rv-petal, .rv-ptext { transition: none; }
  .rv-card, .rv-card .rv-stamp { animation: none !important; opacity: 1; }
  .rv-card .rv-stamp { transform: none; }
  .rv-h2, .rv-empty, .rv-end { opacity: 1; transform: none; transition: none; }
  .rv-scroll-cue span { animation: none; }
}
