:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --panel-2: #fbfaf8;
  --ink: #1d1f24;
  --ink-2: #555a66;
  --ink-3: #8b909b;
  --line: #e7e4de;
  --accent: #1f9e7a;
  --danger: #c8412f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .05);
  --area: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a; --panel: #1d1f24; --panel-2: #22252b; --ink: #eceef2; --ink-2: #b1b6c0;
    --ink-3: #7c828e; --line: #2e3139; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 248px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-name { font-weight: 700; font-size: 16px; }
.child-switch { display: flex; gap: 6px; padding: 0 4px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.child-switch select { flex: 1; min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2);
  text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.active { background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--ink); }
.nav a .ic { color: var(--c); }
.nav a .label { flex: 1; }
.nav a .pct { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.sidebar-foot { display: flex; gap: 12px; padding: 10px 8px 0; border-top: 1px solid var(--line); }

.icon-btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; width: 34px; height: 34px;
  cursor: pointer; display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--line); }
.link-btn { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 12px; padding: 0; }
.link-btn:hover { color: var(--ink); }

/* Main */
.main { flex: 1; min-width: 0; }
.topbar { display: none; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.crumb { font-weight: 600; }
.content { max-width: 1200px; margin: 0 auto; padding: 28px 32px 60px; }
.scrim { display: none; }

.page-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.page-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--area) 15%, transparent); color: var(--area); flex: none; }
.page-icon .ic { width: 24px; height: 24px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.page-head .sub { color: var(--ink-2); margin: 4px 0 0; max-width: 720px; }
.head-stats { margin-left: auto; display: flex; gap: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink-2); cursor: pointer;
}
.chip.on { background: var(--area); border-color: var(--area); color: #fff; }
.chip.add { border-style: dashed; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a {
  padding: 9px 14px; text-decoration: none; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.tabs a.active { color: var(--ink); border-color: var(--area); }
.tabs a .n { font-size: 11px; color: var(--ink-3); margin-left: 4px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat { padding: 10px 14px; min-width: 96px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--area); border-color: var(--area); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.muted { color: var(--ink-3); }
.empty { color: var(--ink-3); text-align: center; padding: 28px 12px; font-size: 13px; }

/* Board */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 180px; }
.col.drop { outline: 2px dashed var(--area); outline-offset: -4px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; font-weight: 600; font-size: 13px; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.col-head .count { color: var(--ink-3); font-weight: 500; }
.col-head .add { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 18px; line-height: 1; }
.task {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; margin-bottom: 8px;
  cursor: grab; box-shadow: var(--shadow);
}
.task:hover { border-color: color-mix(in srgb, var(--area) 50%, var(--line)); }
.task.dragging { opacity: .4; }
.task .t { font-weight: 500; }
.task.done .t { text-decoration: line-through; color: var(--ink-3); }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; font-size: 11px; color: var(--ink-3); align-items: center; }
.tag { padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--area) 12%, transparent); color: var(--ink-2); }
.prio { display: inline-flex; align-items: center; gap: 4px; }
.prio::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--p); }
.due.late { color: var(--danger); font-weight: 600; }

.ideas { margin-top: 22px; padding: 14px 16px; }
.ideas h3 { margin: 0 0 10px; font-size: 13px; }

/* Habits */
.habit-grid { overflow-x: auto; }
.habit-grid table { width: 100%; border-collapse: collapse; min-width: 620px; }
.habit-grid th, .habit-grid td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.habit-grid th { font-size: 11px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.habit-grid th.today { color: var(--area); }
.habit-grid td.name { text-align: left; font-weight: 500; }
.habit-grid td.name small { display: block; color: var(--ink-3); font-weight: 400; }
.habit-grid tr:last-child td { border-bottom: 0; }
.cell {
  width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--panel); cursor: pointer;
  display: inline-grid; place-items: center; color: #fff; font-size: 14px;
}
.cell.on { background: var(--area); border-color: var(--area); }
.cell.future { opacity: .35; cursor: default; }
.streak { font-variant-numeric: tabular-nums; font-weight: 600; }
.row-del { opacity: 0; border: 0; background: none; cursor: pointer; color: var(--ink-3); }
tr:hover .row-del { opacity: 1; }

/* Milestones */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 500; }
.item.done .title { color: var(--ink-3); text-decoration: line-through; }
.item .sm { font-size: 12px; color: var(--ink-3); }
.check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: none; cursor: pointer; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 12px;
}
.check.on { background: var(--area); border-color: var(--area); }
.item .actions { display: flex; gap: 4px; opacity: 0; }
.item:hover .actions { opacity: 1; }

/* Journal */
.entry { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.entry-head .mood { font-size: 16px; }
.entry-head .actions { margin-left: auto; opacity: 0; display: flex; gap: 4px; }
.entry:hover .actions { opacity: 1; }
.entry p { margin: 0; white-space: pre-wrap; }

/* Dashboard */
.dash-top { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.area-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.area-card { padding: 14px; text-decoration: none; color: inherit; display: block; transition: transform .1s; }
.area-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--area) 40%, var(--line)); }
.area-card .top { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 2px; }
.area-card .top .ic { color: var(--area); }
.area-card .full { font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--area); border-radius: 99px; }
.area-card .nums { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.side-panel { padding: 16px; margin-bottom: 16px; }
.side-panel h3 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.side-panel h3 .muted { font-weight: 400; margin-left: auto; font-size: 12px; }
.mini { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.mini .check { width: 20px; height: 20px; }
.mini .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--area); flex: none; }
.mini .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prayers { display: flex; gap: 8px; }
.prayer { flex: 1; text-align: center; font-size: 11px; color: var(--ink-3); }
.prayer .check { width: 34px; height: 34px; margin: 0 auto 4px; font-size: 15px; }
h2.section { font-size: 15px; margin: 0 0 12px; }

/* Modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 16, 20, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-wrap[hidden] { display: none; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal form { padding: 20px; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--area) 50%, transparent); border-color: var(--area); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.moods { display: flex; gap: 6px; }
.moods label { cursor: pointer; font-size: 22px; padding: 2px 6px; border-radius: 8px; border: 1px solid transparent; margin: 0; }
.moods input { display: none; }
.moods input:checked + span { outline: 2px solid var(--area); border-radius: 6px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions .grow { flex: 1; }

/* Responsive */
@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-top { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 20; }
  .topbar { display: flex; }
  .content { padding: 18px 16px 50px; }
  .page-head { flex-wrap: wrap; }
  .head-stats { margin-left: 0; width: 100%; }
  .board { grid-template-columns: repeat(4, 78vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .item .actions, .entry-head .actions, .row-del { opacity: 1; }
}
