/* ---------- Theme tokens ---------- */
:root {
  --bg: #fff8fb; --card: #ffffff; --ink: #2b2233; --muted: #7a6f86; --line: #f0e3ec;
  --accent: #c2417a; --accent2: #7c5cff; --soft: #fde7f1; --soft2: #efeaff;
  --ok: #1f9d6b; --warn: #d98b0b; --bad: #d64545;
  --r: 18px; --shadow: 0 6px 24px rgba(60, 20, 50, .08);
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
[data-theme="ocean"]    { --accent: #1677c9; --accent2: #12a59a; --soft: #e2f1fd; --soft2: #def7f4; --bg: #f6fbff; --line: #e1edf7; }
[data-theme="sunny"]    { --accent: #e0661b; --accent2: #e8a400; --soft: #fff0e3; --soft2: #fff7d6; --bg: #fffaf3; --line: #f6e8d8; }
[data-theme="mint"]     { --accent: #1c8f62; --accent2: #3aa0c8; --soft: #e0f6ec; --soft2: #e3f3fa; --bg: #f6fdf9; --line: #dcefe5; }
[data-theme="lavender"] { --accent: #7a4fd6; --accent2: #d0559a; --soft: #efe7ff; --soft2: #fde8f3; --bg: #faf7ff; --line: #e9e1f8; }
[data-theme="calm"]     { --accent: #4a5568; --accent2: #8a7a6a; --soft: #eceff3; --soft2: #f3efea; --bg: #f8f8f6; --line: #e6e6e2; }

[data-dark="true"] {
  --bg: #17141c; --card: #221e29; --ink: #f3eef7; --muted: #a99db6; --line: #322c3b;
  --soft: color-mix(in srgb, var(--accent) 22%, #221e29);
  --soft2: color-mix(in srgb, var(--accent2) 20%, #221e29);
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 500 16px/1.45 var(--font); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -.01em; }
h1 { font-size: clamp(24px, 4vw, 32px); }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--card); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 20px; padding: 0 8px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; color: var(--ink); text-decoration: none; font-weight: 700; }
.nav a i { font-style: normal; width: 24px; text-align: center; }
.nav a:hover { background: var(--soft); }
.nav a.on { background: var(--accent); color: #fff; }

.content { min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 28px; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.top .mob { display: none; padding: 0; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }
main { padding: 6px 28px 60px; max-width: 1100px; outline: none; }

/* ---------- Building blocks ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-weight: 800; font-size: 14px; }
.pill:hover { border-color: var(--accent); }
.pts { background: var(--soft); border-color: transparent; }
.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-cal { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 12px; }
.hello { margin: 8px 0 18px; }
.hello p { margin: 4px 0 0; color: var(--muted); font-weight: 700; }
.sec-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }

.btn { border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800; background: var(--accent); color: #fff; }
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid currentColor; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.icon { border: 0; background: transparent; font-size: 18px; padding: 6px; border-radius: 10px; line-height: 1; }
.icon:hover { background: var(--soft); }

input[type=text], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 110px; }
label.f { display: block; font-weight: 800; font-size: 13px; color: var(--muted); margin: 10px 0 5px; }
.add { display: flex; gap: 8px; }
.add input { flex: 1; }

.seg { display: inline-flex; background: var(--soft); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 10px; font-weight: 800; font-size: 14px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); color: var(--accent); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--soft2); color: var(--ink); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.chip.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); }
.chip.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); }

.bar { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width .4s; }

.empty { text-align: center; color: var(--muted); padding: 18px 8px; font-weight: 700; }

/* ---------- Energy ---------- */
.energy { background: linear-gradient(135deg, var(--soft), var(--soft2)); border: 0; }
.energy .opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.energy .opts button { border: 2px solid transparent; background: var(--card); border-radius: 16px; padding: 12px 6px; font-weight: 800; }
.energy .opts button b { display: block; font-size: 26px; }
.energy .opts button.on { border-color: var(--accent); }
.energy .tip { margin: 12px 0 0; font-weight: 700; }

/* ---------- Tasks ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px dashed var(--line); }
.task:last-child { border-bottom: 0; }
.check { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--accent); background: transparent; color: #fff; font-weight: 900; display: grid; place-items: center; padding: 0; }
.task.done .check, .check.on { background: var(--accent); }
.tmain { flex: 1; min-width: 0; cursor: pointer; }
.ttitle { font-weight: 800; overflow-wrap: anywhere; }
.task.done .ttitle { text-decoration: line-through; color: var(--muted); }
.tmeta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 3px; }
.star { color: var(--warn); margin-right: 4px; }
details.later { margin-top: 8px; }
details.later summary { cursor: pointer; font-weight: 800; color: var(--muted); padding: 6px 0; }

.ring { --p: 0; width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--soft) 0); }
.ring span { width: 66px; height: 66px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 900; font-size: 18px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 58px 1fr; gap: 10px; padding: 7px 0; }
.timeline .tm { font-weight: 900; color: var(--accent); font-size: 14px; }
.timeline .blk { background: var(--soft); border-left: 4px solid var(--accent); border-radius: 10px; padding: 6px 10px; font-weight: 800; }
.timeline .blk.done { opacity: .5; text-decoration: line-through; }

/* ---------- Brain dump ---------- */
.dump-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.dump-item span { flex: 1; font-weight: 700; overflow-wrap: anywhere; }

/* ---------- Habits ---------- */
.habit { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.habit:last-child { border-bottom: 0; }
.habit .name { font-weight: 800; }
.dots { display: flex; gap: 6px; }
.dot { width: 34px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); font-size: 10px; font-weight: 800; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; }
.dot.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dot.today { outline: 2px solid var(--accent2); outline-offset: 1px; }
.habit-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.hchip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 12px; font-weight: 800; }
.hchip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { text-align: center; font-size: 12px; font-weight: 900; color: var(--muted); }
.cal .day { min-height: 70px; border-radius: 12px; background: var(--bg); border: 1.5px solid var(--line); padding: 5px; text-align: left; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal .day.out { opacity: .4; }
.cal .day.today { border-color: var(--accent2); }
.cal .day.sel { background: var(--soft); border-color: var(--accent); }
.cal .num { font-weight: 900; font-size: 13px; }
.cal .mini { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--card); border-radius: 6px; padding: 1px 4px; }
.cal .mini.done { text-decoration: line-through; opacity: .6; }
.cal .cnt { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.week .wd { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.week .wd h3 { font-size: 14px; color: var(--muted); }
.week .wd.today h3 { color: var(--accent); }

/* ---------- Goals / money ---------- */
.goal h3 { display: flex; gap: 8px; align-items: center; }
.ms { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.ms span { flex: 1; font-weight: 700; }
.ms.done span { text-decoration: line-through; color: var(--muted); }
.ms .check { width: 22px; height: 22px; font-size: 12px; border-width: 2px; }
.money-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.money-row:last-child { border-bottom: 0; }
.money-row .nm { flex: 1; min-width: 120px; font-weight: 800; }
.stat { font-size: 26px; font-weight: 900; }
.mini-form { display: flex; gap: 6px; }
.mini-form input { width: 100px; padding: 6px 9px; }

/* ---------- Themes ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.sw { border: 2px solid var(--line); border-radius: 14px; padding: 10px 8px; background: var(--card); font-weight: 800; font-size: 13px; }
.sw i { display: block; height: 28px; border-radius: 9px; margin-bottom: 6px; }
.sw.on { border-color: var(--ink); }

/* ---------- Modal / focus / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 10, 30, .45); display: grid; place-items: center; padding: 16px; }
.sheet { background: var(--card); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; border-radius: 22px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.sheet .x { float: right; }
.tour { text-align: center; }
.tour .big { font-size: 56px; }
.tour .dots-n { display: flex; gap: 6px; justify-content: center; margin: 14px 0; }
.tour .dots-n i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.tour .dots-n i.on { background: var(--accent); }

.focus { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; overflow: auto; }
.focus h1 { max-width: 700px; overflow-wrap: anywhere; }
.focus .now { margin: 10px 0 0; font-weight: 800; color: var(--accent); }
.timer { position: relative; width: 240px; height: 240px; margin: 22px 0; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer .t { position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; font-weight: 900; font-variant-numeric: tabular-nums; }
.focus .steps { text-align: left; width: min(420px, 100%); margin-top: 14px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 150%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 800; z-index: 70; transition: transform .25s, opacity .25s; max-width: calc(100vw - 32px); opacity: 0; visibility: hidden; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; width: 100%; height: 100%; }

/* ---------- Login ---------- */
.auth { position: fixed; inset: 0; z-index: 60; background: linear-gradient(135deg, var(--soft), var(--soft2)); display: grid; place-items: center; padding: 16px; overflow: auto; }
.auth-card { background: var(--card); width: min(420px, 100%); border-radius: 24px; padding: 26px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 24px; text-align: center; }
.auth-card > p { text-align: center; }
.auth-card .seg { display: flex; }
.auth-card .seg button { flex: 1; }
.auth-card input[type=email], .auth-card input[type=password] { width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; outline: none; }
.auth-card input:focus { border-color: var(--accent); }
.auth-msg { color: var(--bad); font-weight: 800; min-height: 1.2em; margin: 10px 0; font-size: 14px; }
.sheet input[type=password] { width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; }
body.locked { overflow: hidden; }
#sync { text-decoration: none; }

/* ---------- Phones & tablets ---------- */
@media (max-width: 900px) {
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .side .brand { display: none; }
  .nav { flex-direction: row; justify-content: space-around; gap: 0; }
  .nav a { flex-direction: column; gap: 1px; padding: 5px 2px; font-size: 10.5px; border-radius: 12px; flex: 1; min-width: 0; }
  .nav a i { font-size: 19px; }
  .top { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .top .mob { display: flex; font-size: 17px; }
  .top .mob img { width: 28px; height: 28px; }
  .hide-s { display: none; }
  main { padding: 4px 16px 110px; }
  .g2, .g3, .g-cal { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stats .card { padding: 11px; }
  .stats .stat { font-size: 18px; }
  .cal .dow { font-size: 10px; }
  .card { padding: 15px; }
  .cal { gap: 3px; }
  .cal .day { min-height: 46px; padding: 3px; border-radius: 9px; }
  .cal .mini { display: none; }
  .cal .cnt { display: block; }
  .dot { width: 30px; height: 36px; }
  .habit { grid-template-columns: 1fr; }
  .timer { width: 200px; height: 200px; }
  .toast { bottom: 90px; }
}
