/* My Brain — fintech-style system: two-mode canvas (white / true black), pill buttons,
   20px cards, no drop shadows, one cobalt-violet accent, saturated colours only inside icons. */
:root {
  --canvas: #ffffff;
  --surface: #f4f4f4;          /* cards and inset groups on white */
  --surface-2: #e9e9ec;        /* pressed / tracks */
  --text: #191c1f;
  --muted: #505a63;
  --faint: #8d969e;
  --line: #e2e2e7;
  --primary: #494fdf;
  --primary-deep: #3a40c4;
  --on-primary: #ffffff;
  --pill-bg: #191c1f;          /* main CTA on light: dark pill */
  --pill-text: #ffffff;
  --good: #00a87e;
  --good-soft: rgba(0, 168, 126, 0.14);
  --warn: #b07600;
  --warn-soft: rgba(236, 126, 0, 0.14);
  --hot-soft: rgba(73, 79, 223, 0.12);
  --danger: #e23b4a;
  --radius: 20px;
  --c-tasks: #376cd5; --c-notes: #b09000; --c-reels: #e61e49; --c-deals: #00a87e;
  --c-habits: #494fdf; --c-goals: #ec7e00; --c-food: #428619; --c-workouts: #e23b4a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #000000; --surface: #16181a; --surface-2: #24272a; --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.72); --faint: rgba(255, 255, 255, 0.5); --line: rgba(255, 255, 255, 0.12);
    --primary: #4f55f1; --pill-bg: #ffffff; --pill-text: #000000;
    --good: #2ecc9a; --good-soft: rgba(46, 204, 154, 0.16); --warn: #f5a524; --warn-soft: rgba(245, 165, 36, 0.16);
    --hot-soft: rgba(79, 85, 241, 0.22); --danger: #ff5a67;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--canvas); color: var(--text);
  font: 16px/1.5 Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 640px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
}
h1 { font-size: 32px; line-height: 1.15; margin: 8px 0 4px; letter-spacing: -0.02em; font-weight: 600; }
h2 { font-size: 20px; letter-spacing: -0.01em; margin: 28px 0 10px; font-weight: 600; text-transform: capitalize; }
p { margin: 0; }
.muted { color: var(--muted); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }

/* top bar */
.bar { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.bar .spacer { flex: 1; }
.back {
  text-decoration: none; width: 40px; height: 40px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-size: 22px; line-height: 1; margin-left: 0;
}
.back span { transform: translateY(-1px); }
.iconbtn {
  border: 0; background: var(--pill-bg); color: var(--pill-text); border-radius: 999px;
  height: 40px; padding: 0 18px; cursor: pointer; font-weight: 600; font-size: 15px;
  text-decoration: none; display: inline-flex; align-items: center;
}

/* home: balance hero */
.hero { text-align: center; padding: 28px 0 8px; }
.hero .eyebrow { color: var(--muted); font-size: 15px; }
.hero .balance { font-size: 52px; line-height: 1.05; font-weight: 600; letter-spacing: -0.035em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.hero .balance small { font-size: 0.55em; letter-spacing: -0.02em; }
.hero .sub { color: var(--muted); font-size: 15px; }
.hero .pill-link {
  display: inline-flex; margin-top: 14px; padding: 8px 16px; border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.actions-row { display: flex; justify-content: space-around; gap: 8px; margin: 24px 0 8px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; font-size: 13px; color: var(--text); min-width: 64px; }
.action .ico {
  width: 52px; height: 52px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 22px; font-weight: 500;
  color: var(--text);
}

/* summary cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; text-decoration: none; display: block; }
.card .big { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.card .label { font-size: 14px; color: var(--muted); margin-top: 2px; }
.card .ico { margin-bottom: 12px; }

/* app grid */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 8px; background: var(--surface); border-radius: var(--radius); padding: 20px 8px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; font-size: 13px; color: var(--text); }
.ico {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 19px; color: #fff; position: relative;
}
.tile .ico { width: 52px; height: 52px; font-size: 22px; }
.badge {
  position: absolute; top: -4px; right: -6px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px;
  border: 2px solid var(--surface);
}

/* lists */
.toolbar { display: flex; gap: 8px; margin: 14px 0 10px; flex-wrap: wrap; }
.search { flex: 1; min-width: 160px; }
input[type="search"] { background: var(--surface); border-color: transparent; border-radius: 999px; padding-left: 18px; }
input[type="search"], input[type="text"], input[type="number"], input[type="date"], input[type="password"], select, textarea {
  width: 100%; background: var(--canvas); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-height: 56px;
}
input[type="search"] { background: var(--surface); border-color: transparent; border-radius: 999px; min-height: 48px; }
textarea { min-height: 120px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 0; background: var(--surface); border-radius: 999px; padding: 0 16px; height: 36px; font-size: 14px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--pill-bg); color: var(--pill-text); }
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; padding: 4px 0; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; min-height: 68px; }
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row .main { flex: 1; min-width: 0; text-decoration: none; display: block; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row.done .title { color: var(--faint); text-decoration: line-through; }
.row.done .ico { opacity: 0.45; }
.check {
  appearance: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--faint); margin: 0; cursor: pointer; flex: none;
  display: grid; place-items: center; background: transparent;
}
.check:checked { background: var(--good); border-color: var(--good); }
.check:checked::after { content: "✓"; color: #fff; font-size: 14px; font-weight: 700; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-transform: capitalize; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.hot { background: var(--hot-soft); color: var(--primary); }
.late { color: var(--danger); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* habits */
.dots { display: flex; gap: 4px; margin-top: 6px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--surface-2); }
.dot.on { background: var(--c-habits); }
.donebtn { border: 0; background: var(--canvas); color: var(--text); border-radius: 999px; padding: 0 16px; height: 36px; font-weight: 600; cursor: pointer; font-size: 14px; }
.donebtn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* goals */
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--c-goals); border-radius: 3px; }

/* day header (food/workouts) */
.daynav { display: flex; align-items: center; justify-content: space-between; margin: 14px 0; }
.daynav button { border: 0; background: var(--surface); width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 20px; }
.daynav button:disabled { opacity: 0.35; cursor: default; }
.daynav .d { font-weight: 600; font-size: 18px; }
.macros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 4px; }
.macros .card { padding: 14px 8px; text-align: center; }
.macros .big { font-size: 22px; }
.macros .card:first-child { background: var(--primary); color: var(--on-primary); }
.macros .card:first-child .label { color: rgba(255, 255, 255, 0.8); }
.stat-line { display: flex; gap: 10px; margin: 14px 0 4px; }
.stat-line .card { flex: 1; }
.stat-line .card:first-child { background: var(--primary); color: var(--on-primary); }
.stat-line .card:first-child .label { color: rgba(255, 255, 255, 0.8); }

/* forms */
form .field { margin-bottom: 16px; }
form label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 12px; font-weight: 600; min-height: 48px; color: var(--text) !important; font-size: 16px !important; }
.toggle input { width: 22px; height: 22px; accent-color: var(--primary); }
.actions { display: flex; gap: 10px; margin-top: 24px; }
.btn { border: 0; border-radius: 999px; padding: 0 28px; font-weight: 600; cursor: pointer; height: 52px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-size: 16px; }
.btn.primary { background: var(--pill-bg); color: var(--pill-text); flex: 1; }
.btn.primary:active { opacity: 0.8; }
.btn.ghost { background: var(--surface); }
.btn.danger { background: transparent; color: var(--danger); width: 100%; }
.error { color: var(--danger); margin-top: 8px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.note-line { color: var(--muted); margin-top: 4px; }

/* login */
.login { max-width: 380px; margin: 16vh auto 0; text-align: center; }
.login .logo { width: 72px; height: 72px; margin: 0 auto 20px; display: block; border-radius: 50%; }
.login h1 { font-size: 40px; letter-spacing: -0.03em; }
.login form { text-align: left; margin-top: 32px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--pill-bg); color: var(--pill-text); padding: 12px 20px; border-radius: 999px; font-size: 15px; font-weight: 600; max-width: calc(100% - 32px);
}
.footer { margin-top: 32px; display: flex; justify-content: center; }
.linkbtn { border: 0; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600; padding: 0 18px; height: 40px; border-radius: 999px; }

@media (max-width: 380px) {
  .tiles { gap: 16px 4px; }
  .tile .ico, .action .ico { width: 48px; height: 48px; }
  .hero .balance { font-size: 44px; }
}
@media (prefers-reduced-motion: no-preference) { .progress > span { transition: width 0.3s; } }
