/* Planner — Todoist-style UI */
:root {
  --bg: #ffffff;
  --sidebar: #fcfaf8;
  --hover: #f2efed;
  --active: #ffefe5;
  --active-text: #c3392c;
  --surface: #ffffff;
  --surface-2: #faf8f6;
  --text: #202020;
  --text-2: #666666;
  --muted: #808080;
  --faint: #b3b3b3;
  --border: #ebebeb;
  --border-strong: #dcdcdc;
  --red: #dc4c3e;
  --red-hover: #c3392c;
  --red-soft: #fdf0ee;
  --p1: #d1453b;
  --p2: #eb8909;
  --p3: #246fe0;
  --p4: #b3b3b3;
  --d-overdue: #d1453b;
  --d-today: #058527;
  --d-tomorrow: #ad6200;
  --d-week: #692ec2;
  --d-later: #808080;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 2px 8px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 15px 50px rgba(0,0,0,.18), 0 3px 10px rgba(0,0,0,.06);
  --radius: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1e1e1e;
  --sidebar: #252525;
  --hover: #333333;
  --active: #3d2a26;
  --active-text: #ff8a7a;
  --surface: #282828;
  --surface-2: #2c2c2c;
  --text: #e8e8e8;
  --text-2: #b8b8b8;
  --muted: #8f8f8f;
  --faint: #5c5c5c;
  --border: #333333;
  --border-strong: #444444;
  --red: #e2574a;
  --red-hover: #ef6a5d;
  --red-soft: #3a2522;
  --p1: #ff7066;
  --p2: #ff9a14;
  --p3: #5297ff;
  --p4: #707070;
  --d-overdue: #ff7066;
  --d-today: #4cbb5e;
  --d-tomorrow: #f0a247;
  --d-week: #a970ff;
  --d-later: #9a9a9a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 2px 10px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.xs { width: 13px; height: 13px; stroke-width: 2; }
::selection { background: color-mix(in srgb, var(--red) 25%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- shell ---------- */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 280px; flex: none; background: var(--sidebar); display: flex; flex-direction: column;
  padding: 12px 12px 8px; overflow-y: auto; transition: margin-left .2s ease;
}
.app.collapsed .sidebar { margin-left: -280px; }
.sidebar > *, .side-section > * { flex-shrink: 0; }  /* a tall menu scrolls instead of squashing its rows */
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.brand-mark { width: 24px; height: 24px; border-radius: 7px; background: var(--red); display: grid; place-items: center; color: #fff; }
.brand-mark svg { width: 15px; height: 15px; stroke-width: 2.4; }
.icon-btn { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px; border-radius: 6px;
  color: var(--text); font-size: 14px; position: relative; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--active); color: var(--active-text); font-weight: 500; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.nav-item.active .count { color: var(--active-text); }
.nav-item .count.alert { color: var(--d-overdue); }
.nav-add { color: var(--red); font-weight: 600; margin-bottom: 2px; }
.nav-add .plus { width: 24px; height: 24px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; }
.nav-add .plus svg { width: 15px; height: 15px; stroke-width: 2.6; }
.nav-add:hover { background: var(--hover); }
.ic-inbox { color: #246fe0; } .ic-today { color: #058527; } .ic-upcoming { color: #692ec2; }
.ic-calendar { color: #dc4c3e; } .ic-timeline { color: #158fad; } .ic-labels { color: #eb8909; }
:root[data-theme="dark"] .ic-inbox { color: #5297ff; } :root[data-theme="dark"] .ic-today { color: #4cbb5e; }
:root[data-theme="dark"] .ic-upcoming { color: #a970ff; }
.today-ic { position: relative; display: grid; place-items: center; }
.today-ic span { position: absolute; font-size: 8.5px; font-weight: 700; top: 7px; }
.side-section { margin-top: 18px; }
.side-heading {
  display: flex; align-items: center; justify-content: space-between; padding: 0 8px 4px; height: 30px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.side-heading .icon-btn { width: 24px; height: 24px; opacity: 0; }
.side-section:hover .side-heading .icon-btn { opacity: 1; }
.hash { width: 24px; display: grid; place-items: center; font-weight: 600; font-size: 16px; }
.side-search { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px; border-radius: 6px; color: var(--text); }
.side-search:hover, .side-search:focus-within { background: var(--hover); }
.side-search input { border: 0; background: none; outline: none; width: 100%; font-size: 14px; }
.side-search input::placeholder { color: var(--text); opacity: .9; }
.side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 1px; }
.side-foot .nav-item { height: 30px; font-size: 13px; color: var(--text-2); }

.main { flex: 1; overflow-y: auto; position: relative; }
.topbar { position: sticky; top: 0; height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: var(--bg); z-index: 5; }
.topbar .crumb { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.topbar .tools { display: flex; gap: 2px; align-items: center; }
.tool { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 6px; color: var(--text-2); font-size: 13px; }
.tool:hover { background: var(--hover); color: var(--text); }
.tool.on { color: var(--text); background: var(--hover); }
.content { max-width: 860px; margin: 0 auto; padding: 8px 55px 120px; }
.content.wide { max-width: none; padding: 0 28px 28px; }
.page-head { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 22px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.page-head .sub { font-size: 13px; color: var(--muted); }
.page-head .hash { font-size: 22px; width: auto; margin-right: -2px; }

/* ---------- sections & tasks ---------- */
.group { margin-bottom: 26px; }
.group-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 0 8px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 700;
}
.group-head .n { font-weight: 400; color: var(--muted); font-size: 12px; }
.group-head .tag { font-weight: 400; color: var(--muted); }
.group-head .act { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--red); padding: 2px 6px; border-radius: 4px; }
.group-head .act:hover { background: var(--red-soft); }
.group-head .toggle { color: var(--muted); margin-left: -26px; width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center; }
.group-head .toggle:hover { background: var(--hover); }
.group.closed .tasks, .group.closed .add-row { display: none; }
.group.closed .toggle svg { transform: rotate(-90deg); }

.tasks { list-style: none; }
.task {
  display: flex; gap: 8px; padding: 9px 0 9px; border-bottom: 1px solid var(--border); position: relative;
  cursor: pointer; transition: opacity .25s, transform .25s;
}
.task:hover .task-actions { opacity: 1; }
.task.leaving { opacity: 0; transform: translateX(8px); }
.task .body { flex: 1; min-width: 0; }
.task .title { font-size: 14px; line-height: 20px; word-wrap: break-word; }
.task .desc { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.task .meta:empty { display: none; }
.task .meta span { display: inline-flex; align-items: center; gap: 4px; }
.task .proj { margin-left: auto; color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; align-self: flex-end; }
.task .proj i { font-style: normal; font-weight: 600; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task-actions { position: absolute; right: 0; top: 6px; display: flex; gap: 2px; opacity: 0; background: var(--bg); }
.children { list-style: none; margin-left: 28px; }
.children .task:last-child { border-bottom: 0; }
.task-wrap > .children { border-bottom: 1px solid var(--border); }
.task-wrap > .children:empty { display: none; }

.due { display: inline-flex; align-items: center; gap: 4px; }
.due.overdue { color: var(--d-overdue); } .due.today { color: var(--d-today); } .due.tomorrow { color: var(--d-tomorrow); }
.due.week { color: var(--d-week); } .due.later { color: var(--d-later); }
.chip-label { color: var(--muted); }
.chip-label:hover { text-decoration: underline; }

.check {
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--p4); flex: none; margin-top: 1px;
  display: grid; place-items: center; color: transparent; position: relative; transition: background .15s;
}
.check svg { width: 11px; height: 11px; stroke-width: 3; }
.check:hover { color: var(--p4); }
.check.p1 { border: 2px solid var(--p1); background: color-mix(in srgb, var(--p1) 10%, transparent); }
.check.p2 { border: 2px solid var(--p2); background: color-mix(in srgb, var(--p2) 10%, transparent); }
.check.p3 { border: 2px solid var(--p3); background: color-mix(in srgb, var(--p3) 10%, transparent); }
.check.p1:hover { color: var(--p1); } .check.p2:hover { color: var(--p2); } .check.p3:hover { color: var(--p3); }
.check.checked, .task.done .check { background: var(--p4); border-color: var(--p4); color: #fff; }
.check.checked.p1, .task.done .check.p1 { background: var(--p1); border-color: var(--p1); }
.check.checked.p2, .task.done .check.p2 { background: var(--p2); border-color: var(--p2); }
.check.checked.p3, .task.done .check.p3 { background: var(--p3); border-color: var(--p3); }
.check.checked { animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }

.add-row { display: flex; align-items: center; gap: 8px; height: 38px; color: var(--muted); width: 100%; font-size: 14px; }
.add-row .plus { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: var(--red); }
.add-row:hover { color: var(--red); }
.add-row:hover .plus { background: var(--red); color: #fff; }
.add-row .plus svg { width: 14px; height: 14px; stroke-width: 2.4; }

.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state .big { font-size: 15px; font-weight: 600; color: var(--text); margin: 14px 0 6px; }
.empty-state svg { width: 64px; height: 64px; stroke-width: 1.2; color: var(--faint); }
.note-box { margin-top: 30px; padding: 14px 16px; background: var(--surface-2); border-radius: var(--radius); }
.note-box .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.note-box .txt { font-size: 13px; white-space: pre-wrap; }

/* ---------- upcoming ---------- */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); margin-bottom: 18px; position: sticky; top: 52px; background: var(--bg); z-index: 4; }
.week-strip a { text-align: center; padding: 8px 0 10px; font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.week-strip a b { display: block; font-size: 15px; font-weight: 600; color: var(--text); margin-top: 1px; }
.week-strip a:hover { background: var(--hover); border-radius: 6px 6px 0 0; }
.week-strip a.is-today b { color: var(--red); }
.week-strip a .dot { display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--muted); margin: 4px auto 0; opacity: 0; }
.week-strip a.has .dot { opacity: 1; }
.up-nav { display: flex; align-items: center; gap: 6px; margin: -10px 0 14px; }
.up-nav .month { font-weight: 600; font-size: 14px; margin-right: auto; }
.btn-ghost { height: 36px; min-width: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-ghost.disabled { opacity: .35; pointer-events: none; }

/* ---------- board ---------- */
.board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding: 4px 28px 24px; min-height: calc(100vh - 140px); }
.column { width: 290px; flex: none; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 6px 4px 10px; font-weight: 700; font-size: 14px; }
.column-head .n { color: var(--muted); font-weight: 400; font-size: 13px; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 30px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px;
  display: flex; gap: 8px; cursor: pointer; box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.card .title { font-size: 14px; line-height: 20px; word-wrap: break-word; }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.card .meta:empty { display: none; }
.card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.card .desc { font-size: 12px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sortable-ghost { opacity: .35; }
.sortable-chosen .card, .card.sortable-chosen { box-shadow: var(--shadow-lg); }
.add-section { width: 290px; flex: none; }
.add-section button { width: 100%; height: 40px; border-radius: var(--radius); color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500; border: 1px dashed transparent; }
.add-section button:hover { color: var(--red); border-color: var(--border-strong); }

/* ---------- modal & forms ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 12vh 16px 16px; animation: fade .12s ease; }
.overlay.open { display: flex; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px) scale(.99); opacity: 0; } }
.qa { width: 560px; max-width: 100%; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: rise .16s ease; }
.qa-body { padding: 14px 16px 10px; }
.qa-title { width: 100%; border: 0; outline: none; background: none; font-size: 17px; font-weight: 600; padding: 2px 0; }
.qa-desc { width: 100%; border: 0; outline: none; background: none; font-size: 13px; resize: none; padding: 4px 0 2px; color: var(--text-2); min-height: 22px; }
.qa-title::placeholder, .qa-desc::placeholder { color: var(--faint); font-weight: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; border: 1px solid var(--border-strong);
  border-radius: 6px; font-size: 13px; color: var(--text-2); background: var(--surface); position: relative;
}
.chip:hover { background: var(--hover); }
.chip.set { color: var(--text); }
.chip.set.overdue { color: var(--d-overdue); } .chip.set.today { color: var(--d-today); } .chip.set.tomorrow { color: var(--d-tomorrow); } .chip.set.week { color: var(--d-week); }
.chip input[type=date], .chip input[type=time] { border: 0; background: none; outline: none; font-size: 13px; color: inherit; width: 118px; }
.chip input[type=time] { width: 78px; }
.chip select { border: 0; background: none; outline: none; font-size: 13px; color: inherit; cursor: pointer; appearance: none; padding-right: 2px; }
.chip .x { color: var(--muted); margin-left: 2px; display: grid; place-items: center; }
.chip .x:hover { color: var(--text); }
.qa-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border); gap: 8px; }
.qa-foot select.proj-select { border: 0; background: none; font-size: 13px; color: var(--text-2); outline: none; cursor: pointer; padding: 6px 4px; border-radius: 6px; max-width: 260px; }
.qa-foot select.proj-select:hover { background: var(--hover); }
.btn { height: 40px; padding: 0 18px; border-radius: 8px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: var(--hover); color: var(--text); }
.btn-secondary:hover { filter: brightness(.96); }
.btn-danger { color: var(--d-overdue); }
.btn-danger:hover { background: var(--red-soft); }
.quick-dates { display: flex; gap: 4px; margin-top: 8px; }
.quick-dates button { font-size: 12px; padding: 3px 8px; border-radius: 5px; color: var(--text-2); }
.quick-dates button:hover { background: var(--hover); color: var(--text); }

/* task detail */
.detail { width: 880px; max-width: 100%; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; animation: rise .16s ease; display: flex; flex-direction: column; max-height: 82vh; }
.detail-top { display: flex; align-items: center; gap: 6px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.detail-top .crumb { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.detail-top .crumb i { font-style: normal; font-weight: 600; }
.detail-main { display: flex; flex: 1; min-height: 0; }
.detail-left { flex: 1; padding: 18px 22px 24px; overflow-y: auto; }
.detail-right { width: 270px; flex: none; background: var(--surface-2); padding: 14px 16px; overflow-y: auto; border-left: 1px solid var(--border); }
.d-title-row { display: flex; gap: 10px; align-items: flex-start; }
.d-title-row .check { margin-top: 5px; }
.d-title { width: 100%; border: 0; outline: none; background: none; font-size: 20px; font-weight: 700; resize: none; line-height: 1.35; padding: 1px 4px; border-radius: 5px; overflow: hidden; }
.d-title:hover { background: var(--hover); }
.d-title:focus { background: none; box-shadow: inset 0 0 0 1px var(--border-strong); }
.d-desc { width: 100%; border: 0; outline: none; background: none; font-size: 14px; resize: none; color: var(--text-2); margin: 6px 0 0 28px; width: calc(100% - 28px); min-height: 26px; padding: 4px; border-radius: 5px; line-height: 1.5; }
.d-desc:hover { background: var(--hover); }
.d-desc:focus { background: none; box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--text); }
.d-block { margin: 22px 0 0 28px; }
.d-block-head { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.d-block-head .n { color: var(--muted); font-weight: 400; }
.d-sub { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; cursor: pointer; }
.d-sub .check { margin-top: 0; }
.d-sub.done .t { text-decoration: line-through; color: var(--muted); }
.d-sub .due { font-size: 12px; margin-left: auto; }
.inline-add { display: flex; gap: 8px; align-items: center; padding: 6px 0; }
.inline-add input { flex: 1; border: 0; outline: none; background: none; font-size: 14px; padding: 4px 0; }
.comment { display: flex; gap: 10px; padding: 10px 0; }
.avatar { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.comment .who { font-size: 13px; font-weight: 600; }
.comment .who span { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.comment .txt { font-size: 14px; white-space: pre-wrap; margin-top: 2px; word-wrap: break-word; }
.comment-box { display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.comment-box textarea { flex: 1; border: 0; outline: none; background: none; resize: none; font-size: 14px; min-height: 22px; }
.field { padding: 10px 0; border-bottom: 1px solid var(--border); }
.field:last-child { border-bottom: 0; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field select, .field input[type=date], .field input[type=time], .field input[type=number], .field input[type=text] {
  width: 100%; border: 1px solid transparent; background: none; border-radius: 6px; padding: 5px 6px; font-size: 13px; outline: none; color: var(--text);
}
.field select:hover, .field input:hover { background: var(--hover); }
.field select:focus, .field input:focus { border-color: var(--border-strong); background: var(--surface); }
.field .row { display: flex; gap: 6px; }
.prio-pick { display: flex; gap: 4px; }
.prio-pick button { flex: 1; height: 30px; border-radius: 6px; display: grid; place-items: center; border: 1px solid transparent; }
.prio-pick button:hover { background: var(--hover); }
.prio-pick button.on { border-color: var(--border-strong); background: var(--surface); }
.flag-p1 { color: var(--p1); } .flag-p2 { color: var(--p2); } .flag-p3 { color: var(--p3); } .flag-p4 { color: var(--muted); }
.label-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.lchip { font-size: 12px; background: var(--hover); border-radius: 4px; padding: 2px 4px 2px 8px; display: inline-flex; align-items: center; gap: 2px; }
.lchip button { color: var(--muted); display: grid; place-items: center; width: 16px; height: 16px; }
.lchip button:hover { color: var(--text); }
.detail-foot { font-size: 12px; color: var(--muted); padding: 10px 0 0; }

/* toast */
.toast { position: fixed; left: 24px; bottom: 24px; background: #282828; color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg); display: flex; gap: 16px; align-items: center; transform: translateY(120px); transition: transform .25s ease; z-index: 200; }
.toast.show { transform: none; }
.toast button { color: #ff9f94; font-weight: 600; }

/* tables / cards for activity & settings */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.panel p, .panel li { font-size: 13px; color: var(--text-2); }
.panel ol { padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.copy-row { display: flex; gap: 8px; margin: 4px 0 14px; }
.copy-row input { flex: 1; border: 1px solid var(--border-strong); border-radius: 6px; padding: 7px 10px; font-size: 13px; background: var(--surface-2); outline: none; font-family: ui-monospace, Menlo, monospace; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--hover); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; }
.row-item .t { font-size: 14px; }
.row-item .s { font-size: 12px; color: var(--muted); }
.feed { list-style: none; }
.feed li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.feed .what { font-size: 14px; }
.feed .what b { font-weight: 600; }
.feed .when { font-size: 12px; color: var(--muted); margin-top: 2px; }
.feed .chg { font-size: 12px; color: var(--muted); margin-top: 4px; }
.feed .chg s { color: var(--faint); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pill { height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--border-strong); font-size: 13px; display: inline-flex; align-items: center; color: var(--text-2); }
.pill:hover { background: var(--hover); }
.pill.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.label-row { display: flex; align-items: center; gap: 10px; height: 40px; border-bottom: 1px solid var(--border); padding: 0 4px; }
.label-row:hover { background: var(--hover); }
.label-row .n { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ---------- calendar ---------- */
.cal-wrap { display: flex; height: 100%; }
.cal-main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0 20px 16px 28px; }
.cal-head { display: flex; align-items: center; gap: 10px; padding: 2px 0 14px; flex-wrap: wrap; }
.cal-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-right: 6px; min-width: 230px; }
.cal-title::first-letter { text-transform: uppercase; }
.cal-title span { color: var(--muted); font-weight: 400; }
.round-btn { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); }
.round-btn:hover { background: var(--hover); color: var(--text); }
.seg { display: inline-flex; background: var(--hover); border-radius: 8px; padding: 3px; margin-left: auto; }
.seg button { height: 28px; padding: 0 12px; border-radius: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
#calendar { flex: 1; min-height: 0; }
.cal-side { width: 290px; flex: none; border-left: 1px solid var(--border); padding: 4px 16px 16px; overflow-y: auto; background: var(--sidebar); }
.cal-side h3 { font-size: 13px; font-weight: 700; margin: 14px 0 8px; display: flex; align-items: center; gap: 6px; }
.cal-side h3 .n { color: var(--muted); font-weight: 400; }
.cal-side .hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.drag-task { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; font-size: 13px; cursor: grab; box-shadow: var(--shadow-sm); border-left: 3px solid var(--c); }
.drag-task:hover { box-shadow: var(--shadow); }
.drag-task .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drag-task .p { font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend-item { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px; border-radius: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.legend-item:hover { background: var(--hover); }
.legend-item .sw { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--c); background: var(--c); flex: none; transition: background .15s; }
.legend-item.off .sw { background: transparent; }
.legend-item.off { color: var(--muted); }
.switch-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 6px 6px; }
.switch { width: 32px; height: 18px; border-radius: 9px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on { background: var(--red); }
.switch.on::after { left: 16px; }

/* FullCalendar theme */
.fc {
  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--bg);
  --fc-neutral-bg-color: var(--surface-2);
  --fc-today-bg-color: transparent;
  --fc-now-indicator-color: var(--red);
  --fc-highlight-color: color-mix(in srgb, var(--red) 10%, transparent);
  --fc-list-event-hover-bg-color: var(--hover);
  --fc-small-font-size: 12px;
  --fc-event-text-color: var(--text);
  font-size: 13px;
}
.fc .fc-scrollgrid { border: 0; }
.fc .fc-scrollgrid-section > td, .fc .fc-scrollgrid-section > th { border: 0; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--border); }
.fc .fc-col-header-cell { border: 0; border-bottom: 1px solid var(--border); }
.fc .fc-col-header-cell-cushion { padding: 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fc .fc-daygrid-day-top { flex-direction: row; padding: 6px 6px 2px; }
.fc .fc-daygrid-day-number { font-size: 13px; font-weight: 500; color: var(--text-2); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; padding: 0; }
.fc .fc-day-today .fc-daygrid-day-number { background: var(--red); color: #fff; font-weight: 700; }
.fc .fc-day-other .fc-daygrid-day-number { color: var(--faint); }
.fc .fc-day-sat, .fc .fc-day-sun { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.fc .fc-daygrid-day:hover { background: color-mix(in srgb, var(--hover) 45%, transparent); }
.fc-daygrid-event-harness { margin: 1px 4px 2px; }
.fc .fc-event { border: 0; border-radius: 6px; cursor: pointer; }
.fc .fc-h-event, .fc .fc-daygrid-dot-event, .fc .fc-v-event {
  background: color-mix(in srgb, var(--c, var(--p3)) 16%, var(--bg)) !important;
  box-shadow: inset 3px 0 0 var(--c, var(--p3));
  color: var(--text);
}
:root[data-theme="dark"] .fc .fc-h-event, :root[data-theme="dark"] .fc .fc-daygrid-dot-event, :root[data-theme="dark"] .fc .fc-v-event {
  background: color-mix(in srgb, var(--c, var(--p3)) 26%, var(--bg)) !important;
}
.fc .fc-event:hover { filter: brightness(.97); box-shadow: inset 3px 0 0 var(--c), 0 2px 6px rgba(0,0,0,.08); }
.fc .fc-daygrid-dot-event { padding: 0; }
.fc .fc-daygrid-dot-event:hover { background: color-mix(in srgb, var(--c) 22%, var(--bg)) !important; }
.fc .fc-event.is-done { opacity: .5; }
.fc .fc-event.is-done .ev-title { text-decoration: line-through; }
.fc .fc-event.is-overdue { box-shadow: inset 3px 0 0 var(--d-overdue); }
.ev { display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 8px; min-width: 0; font-size: 12px; line-height: 16px; width: 100%; }
.ev-check { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--c); flex: none; display: grid; place-items: center; background: var(--bg); transition: background .15s; }
.ev-check svg { width: 8px; height: 8px; stroke-width: 3.5; color: transparent; }
.ev-check:hover svg { color: var(--c); }
.ev-check.p1 { border-color: var(--p1); } .ev-check.p2 { border-color: var(--p2); } .ev-check.p3 { border-color: var(--p3); }
.is-done .ev-check { background: var(--c); }
.is-done .ev-check svg { color: #fff; }
.ev-time { color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; font-weight: 500; }
.ev-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ev-icons { display: inline-flex; gap: 3px; color: var(--muted); flex: none; margin-left: auto; }
.fc-timegrid-event .ev { flex-wrap: wrap; align-items: flex-start; padding: 4px 6px 4px 8px; }
.fc-timegrid-event .ev-title { white-space: normal; flex-basis: calc(100% - 22px); }
.fc-timegrid-event .ev-time { flex-basis: 100%; order: 3; font-size: 11px; margin-left: 19px; }
.ev-proj { font-size: 11px; color: var(--muted); flex-basis: 100%; margin-left: 19px; order: 4; }
.fc .fc-daygrid-more-link { font-size: 12px; color: var(--text-2); font-weight: 600; margin-left: 6px; }
.fc .fc-popover { background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.fc .fc-popover-header { background: var(--surface-2); padding: 8px 10px; font-weight: 600; }
.fc .fc-timegrid-slot { height: 26px; }
.fc .fc-timegrid-slot-minor { border-top-style: none; }
.fc .fc-timegrid-slot-label-cushion { font-size: 11px; color: var(--muted); padding-right: 10px; font-variant-numeric: tabular-nums; }
.fc .fc-timegrid-axis-cushion { font-size: 11px; color: var(--muted); }
.fc .fc-timegrid-now-indicator-line { border-width: 2px 0 0; }
.fc .fc-timegrid-now-indicator-arrow { border: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--red); margin-top: -5px; left: auto; right: -5px; }
.fc .fc-timegrid-col.fc-day-today { background: color-mix(in srgb, var(--red) 3%, transparent); }
.fc .fc-col-header-cell.fc-day-today .fc-col-header-cell-cushion { color: var(--red); }
.fc .fc-list { border: 0; }
.fc .fc-list-day-cushion { background: var(--bg); padding: 14px 6px 6px; }
.fc .fc-list-day-text, .fc .fc-list-day-side-text { font-size: 14px; font-weight: 700; color: var(--text); display: inline-block; }
.fc .fc-list-day-text::first-letter { text-transform: uppercase; }
.fc .fc-list-day-side-text { font-weight: 400; color: var(--muted); }
.fc .fc-list-event td { border-color: var(--border); padding: 8px 6px; }
.fc .fc-list-event-dot { border-color: var(--c); }
.fc .fc-list-event-time { color: var(--muted); font-size: 12px; width: 90px; }
.fc .fc-list-empty { background: none; color: var(--muted); }
.fc-event-mirror { opacity: .85; }
.fc .fc-daygrid-body-natural .fc-daygrid-day-events { margin-bottom: 4px; }

/* timeline */
.tl-wrap { padding: 0 28px 28px; }
#timeline { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
#timeline .vis-timeline { border: 0; font-family: var(--font); font-size: 12px; }
#timeline .vis-panel.vis-left, #timeline .vis-panel.vis-center, #timeline .vis-panel.vis-top, #timeline .vis-panel.vis-bottom { border-color: var(--border); }
#timeline .vis-labelset .vis-label { color: var(--text); border-color: var(--border); font-weight: 600; font-size: 13px; }
#timeline .vis-labelset .vis-label .vis-inner { padding: 10px 14px; display: flex; align-items: center; gap: 8px; }
#timeline .vis-foreground .vis-group { border-color: var(--border); }
#timeline .vis-time-axis .vis-grid.vis-minor { border-color: color-mix(in srgb, var(--border) 60%, transparent); }
#timeline .vis-time-axis .vis-grid.vis-major { border-color: var(--border-strong); }
#timeline .vis-time-axis .vis-text { color: var(--muted); text-transform: capitalize; }
#timeline .vis-time-axis .vis-text.vis-major { color: var(--text); font-weight: 600; }
#timeline .vis-current-time { background: var(--red); width: 2px; }
#timeline .vis-item { border-radius: 6px; border: 0; color: var(--text); font-size: 12px; font-weight: 500; cursor: pointer;
  background: color-mix(in srgb, var(--c, var(--p3)) 22%, var(--surface)); box-shadow: inset 3px 0 0 var(--c, var(--p3)); }
#timeline .vis-item.vis-range .vis-item-content { padding: 5px 10px; }
#timeline .vis-item.vis-selected { box-shadow: inset 3px 0 0 var(--c), 0 0 0 2px var(--c); }
#timeline .vis-item.vis-background { background: color-mix(in srgb, var(--c, var(--p3)) 7%, transparent); box-shadow: none; border-radius: 0; cursor: default; }
#timeline .vis-item.vis-point { background: none; box-shadow: none; }
#timeline .vis-item.vis-point .vis-item-content { padding-left: 4px; }
#timeline .vis-item.vis-dot { border: 0; width: 12px; height: 12px; transform: rotate(45deg); border-radius: 2px; background: var(--c, var(--p2)); margin-top: -1px; }
#timeline .vis-item.is-done { opacity: .45; }
#timeline .vis-item.is-overdue { box-shadow: inset 3px 0 0 var(--d-overdue); }
.sw-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

/* bare pages (oauth) */
.bare { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; background: var(--sidebar); padding: 20px 16px; }
.bare-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 28px; }
.bare-card h1 { font-size: 20px; margin: 14px 0 8px; }
.bare-card p { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }

/* responsive */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 80; top: 0; left: 0; height: 100vh; height: 100dvh; box-shadow: var(--shadow-lg); }
  .app:not(.collapsed) .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 75; animation: fade .15s ease; }
  .content { padding: 8px 18px 100px; }
  .cal-side { display: none; }
  .cal-main { padding: 0 10px 10px; }
  .detail-main { flex-direction: column; overflow-y: auto; }
  .detail-right { width: auto; border-left: 0; border-top: 1px solid var(--border); }
  .detail-left { overflow: visible; }
}
.app:not(.collapsed) .sb-open { display: none; }
@media (max-width: 900px) { .app.collapsed .sidebar { margin-left: -280px; } }

/* calendar polish */
.fc .fc-event-main, .fc .fc-event-main-frame, .fc a.fc-event { color: var(--text); }
.fc-dayGridMonth-view .ev-icons { display: none; }
.fc-timegrid-event .ev { overflow: hidden; height: 100%; align-content: flex-start; }
.fc .fc-timegrid-axis-cushion { font-size: 10px; line-height: 1.2; }
.fc .fc-daygrid-day-frame { min-height: 0; }
.page-head h1 .hash { display: inline; font-size: inherit; width: auto; margin-right: 2px; }
.cal-head .sb-open { margin-left: -6px; }
.cal-side { transition: margin-right .2s ease; }
.cal-wrap.side-closed .cal-side { margin-right: -290px; }

.ic-focus { color: #db4035; }
.focus-pill { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--red) !important; display: inline-flex; align-items: center; gap: 4px; }
.focus-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.6s ease-in-out infinite; }
.focus-pill.paused { color: var(--muted) !important; }
.focus-pill.paused::before { animation: none; }
@keyframes blink { 50% { opacity: .2; } }
.btn-focus { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; font-size: 13px; font-weight: 600; color: var(--red); background: var(--red-soft); margin-right: 4px; }
.btn-focus:hover { filter: brightness(.97); }
.btn-focus svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }

.ic-habits { color: #058527; }
:root[data-theme="dark"] .ic-habits { color: #4cbb5e; }
.ic-food { color: #eb8909; }

/* ---------- installed app / mobile ---------- */
.fab { display: none; position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
       width: 56px; height: 56px; border-radius: 50%; background: var(--red); color: #fff; place-items: center; z-index: 60;
       box-shadow: 0 6px 18px rgba(0,0,0,.22); }
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
.fab:active { transform: scale(.94); }
@media (max-width: 900px) {
  .fab { display: grid; }
  .sidebar { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .main { padding-top: env(safe-area-inset-top); }
  .content, .ninner { padding-bottom: 96px; }
  .overlay { padding-top: max(16px, env(safe-area-inset-top)); align-items: flex-start; }
  .detail { max-height: calc(100vh - 32px - env(safe-area-inset-top)); }
  .nav-item { height: 40px; }
  .task { padding: 11px 0; }
}
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; -webkit-user-select: none; user-select: none; }
  input, textarea, [contenteditable], .task .title, .desc, .comment .txt { -webkit-user-select: text; user-select: text; }
}
.app.collapsed .sidebar { box-shadow: none; }
@media (max-width: 900px) { .group-head .toggle { margin-left: -6px; } }
@media (hover: none) { .keys { display: none !important; } .task-actions { display: none; } }
.no-fab .fab { display: none !important; }
.ic-fitness { color: #884dff; }
:root[data-theme="dark"] .ic-fitness { color: #a970ff; }
.ic-panel { color: #246fe0; }
:root[data-theme="dark"] .ic-panel { color: #5297ff; }
.ic-money { color: #158fad; }
:root[data-theme="dark"] .ic-money { color: #3bb5d3; }
.ic-journal { color: #e05194; }
:root[data-theme="dark"] .ic-journal { color: #f06aa9; }
.ic-sleep { color: #692ec2; }
:root[data-theme="dark"] .ic-sleep { color: #a970ff; }
.ic-watch { color: #0f9d8a; }
.ic-health { color: #e0435e; }
:root[data-theme="dark"] .ic-health { color: #f26b83; }
:root[data-theme="dark"] .ic-watch { color: #3cc4b0; }

/* ---------- charts (static/planner/charts.js): validated categorical pair, recessive chrome ---------- */
:root { --viz-1: #2a78d6; --viz-2: #eb6834; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --viz-1: #3987e5; --viz-2: #d95926; } }
:root[data-theme="dark"] { --viz-1: #3987e5; --viz-2: #d95926; }
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-size: 10.5px; fill: var(--muted); font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; outline: none; }
.chart .wash { fill: var(--hover); }
.ftip { position: fixed; z-index: 300; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; min-width: 150px; opacity: 0; transition: opacity .08s; }
.ftip.on { opacity: 1; }
.ftip .tt { color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.ftip .tr { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.ftip .tr i { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.ftip .tr b { font-variant-numeric: tabular-nums; }
.ftip .tr span { color: var(--muted); }
.tview { margin-top: 8px; font-size: 12px; }
.tscroll { max-height: 220px; overflow-y: auto; }
.tview summary { cursor: pointer; color: var(--muted); width: max-content; }
.tview table { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tview th, .tview td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.tview th:first-child, .tview td:first-child { text-align: left; }
.tview th { color: var(--muted); font-weight: 600; }

/* ---------- project filter (Hoy, Próximo, Calendario, Cronología) ---------- */
.pf-btn.on { color: var(--active-text); background: var(--active); border-color: transparent; }
button.legend-item { width: 100%; text-align: left; color: inherit; }
.legend-item:focus-visible, .pf-only:focus-visible { outline: 2px solid var(--p3); outline-offset: -2px; }
.pf-pop { position: fixed; z-index: 120; width: 300px; max-height: min(520px, calc(100vh - 80px)); display: flex; flex-direction: column;
          background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: rise .14s ease; }
.pf-head { padding: 12px 14px 8px; display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.pf-head span { font-size: 12px; color: var(--muted); }
.pf-list { overflow-y: auto; padding: 0 6px 6px; }
.pf-row { display: flex; align-items: center; border-radius: 6px; }
.pf-row:hover { background: var(--hover); }
.pf-row .legend-item { flex: 1; min-width: 0; }
.pf-row .legend-item:hover { background: none; }
.pf-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-only { font-size: 12px; color: var(--muted); padding: 3px 8px; border-radius: 4px; margin-right: 4px; opacity: 0; }
.pf-row:hover .pf-only, .pf-only:focus-visible { opacity: 1; }
.pf-only:hover { color: var(--text); background: var(--surface); }
.pf-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.pf-foot button { font-weight: 600; font-size: 13px; color: var(--red); padding: 3px 6px; border-radius: 4px; }
.pf-foot button:hover { background: var(--red-soft); }
@media (hover: none) { .pf-only { opacity: 1; } }
@media (max-width: 600px) {
  .pf-pop { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 70vh; border-radius: 14px 14px 0 0;
            padding-bottom: env(safe-area-inset-bottom); animation: sheet .18s ease; }
  .pf-row .legend-item { height: 42px; font-size: 14px; }
  .pf-btn .pf-label { display: none; }
  .pf-btn.on .pf-label { display: inline; }
}
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } }
.hidden-note { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: -10px 0 18px; padding: 7px 10px; border-radius: 8px;
               background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.hidden-note > svg { color: var(--muted); flex: none; }
.hidden-note > span { flex: 1; min-width: 180px; }
.hidden-note b { font-weight: 600; white-space: nowrap; }
.hidden-note b i { font-style: normal; margin-right: 1px; }
.hidden-note button { font-weight: 600; color: var(--red); padding: 2px 6px; border-radius: 4px; }
.hidden-note button:hover { background: var(--red-soft); }
.nav-hidden { color: var(--faint); display: inline-grid; place-items: center; flex: none; margin-left: auto; }
.nav-item .nav-hidden:not([hidden]) + .count { margin-left: 6px; }
.nav-item:has(.nav-hidden:not([hidden])) .hash { opacity: .5; }

/* ---------- health pages (Sueño, Withings): shared layout and the sleep-stage ramp ---------- */
:root { --st-deep: #1c5cab; --st-light: #5598e7; --st-rem: #86b6ef; --st-awake: var(--viz-2); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --st-deep: #184f95; --st-light: #3987e5; --st-rem: #86b6ef; } }
:root[data-theme="dark"] { --st-deep: #184f95; --st-light: #3987e5; --st-rem: #86b6ef; }
.hpage .main { overflow: hidden; }
.hpage .topbar { display: none; }
.hw { height: 100%; overflow-y: auto; }
.hinner { max-width: 1120px; margin: 0 auto; padding: 22px 28px 90px; }
.hhead { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.hhead h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-right: auto; }
/* page tabs (Nutrición, Ejercicio, Diario, Finanzas, Sueño, Withings, Salud): one size everywhere, easy to tap */
.tabs, .htabs { display: inline-flex; background: var(--hover); border-radius: 11px; padding: 4px; flex-wrap: wrap; gap: 2px; }
.tabs a, .htabs a { height: 38px; padding: 0 18px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; }
.tabs a:hover, .htabs a:hover { color: var(--text); }
.tabs a.on, .htabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
@media (max-width: 600px) {  /* one row across the screen: big targets, scroll sideways if they don't fit */
  .tabs, .htabs { display: flex; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs a, .htabs a { flex: 1 0 auto; justify-content: center; padding: 0 12px; }
}
.hdaynav { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.hdaynav .lbl { font-size: 15px; font-weight: 700; padding: 0 6px; min-width: 0; }
@media (max-width: 600px) { .hdaynav .lbl { flex: 1; text-align: center; font-size: 14px; } }
.hgrid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.hbox { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.hbox h2 { font-size: 13px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hbox h2 span, .hbox h2 a.more { font-size: 12px; font-weight: 400; color: var(--muted); }
.hbox h2 a.more:hover { color: var(--text); text-decoration: underline; }
.hkpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.hkpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; min-width: 0; }
.hkpi .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hkpi .v small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px; letter-spacing: 0; }
.hkpi .l { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.htwo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hmuted { color: var(--muted); }
.hgood { color: var(--d-today); font-weight: 600; }
.hbad { color: var(--d-overdue); font-weight: 600; }
.hli { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.hli:last-child { border-bottom: 0; }
.hli .t { flex: 1; min-width: 0; }
.hli .t small { display: block; font-size: 12px; color: var(--muted); }
.hli .r { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; text-align: right; }
.hlegend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.hlegend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.htip { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 12px; color: var(--text-2); line-height: 1.55; }
.htip b { color: var(--text); }
.hempty { text-align: center; padding: 40px 16px; color: var(--muted); font-size: 13px; }
.hempty .big { font-size: 15px; font-weight: 600; color: var(--text); margin: 10px 0 4px; }
.hbar { height: 8px; border-radius: 4px; background: var(--hover); overflow: hidden; }
.hbar i { display: block; height: 100%; border-radius: 4px; background: var(--viz-1); }
.hstages { display: flex; height: 26px; gap: 2px; border-radius: 7px; overflow: hidden; margin: 6px 0 8px; }
.hstages i { display: block; min-width: 2px; }
.hstages i:first-child { border-radius: 7px 0 0 7px; } .hstages i:last-child { border-radius: 0 7px 7px 0; }
.hcmp { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 14px; font-size: 13px; align-items: baseline; }
.hcmp .h { font-size: 11px; color: var(--muted); font-weight: 600; text-align: right; }
.hcmp .n { text-align: right; font-variant-numeric: tabular-nums; }
.hfactor { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.hfactor:last-child { border-bottom: 0; }
.hfactor .top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.hfactor .top small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.hfactor .eff { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 5px; font-size: 12px; color: var(--text-2); }
.hpill { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 9px; background: var(--hover); color: var(--text-2); }
.hform { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hform label { font-size: 12px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 5px; }
.hform input, .hform select { width: 100%; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 14px; background: var(--surface); outline: none; color: var(--text); }
.hcode { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; color: var(--text); }
@media (max-width: 1000px) { .hgrid, .htwo { grid-template-columns: 1fr; } .hkpis { grid-template-columns: repeat(2, 1fr); } .hinner { padding: 18px 16px 90px; } .hform { grid-template-columns: 1fr 1fr; } }

/* ---- balance: eaten against burned as ranges (balance.js; Salud and Nutrición) ---- */
/* the two "who measured it" series of the sources chart: categorical slots 7 and 3 (validated as a pair) */
:root { --src-app: #6250d6; --src-watch: #1baf7a; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --src-app: #9085e9; --src-watch: #199e70; } }
:root[data-theme="dark"] { --src-app: #9085e9; --src-watch: #199e70; }
.rbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.bal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 24px; align-items: center; margin-bottom: 16px; }
.bal .tx b { display: block; font-size: 15px; line-height: 1.45; }
.bal .tx p { font-size: 13px; color: var(--text-2); line-height: 1.5; margin-top: 4px; }
.strip { position: relative; height: 34px; margin: 0 6px; }
.strip .ax { position: absolute; left: 0; right: 0; top: 16px; height: 1px; background: var(--border-strong); }
.strip .rg { position: absolute; top: 9px; height: 15px; border-radius: 4px; background: color-mix(in srgb, var(--text-2) 28%, transparent); box-shadow: inset 0 0 0 1px var(--text-2); }
.strip .md { position: absolute; top: 6px; height: 21px; width: 0; border-left: 2px solid var(--text-2); }
.strip .zero { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--text); }
.strip .sc { position: absolute; top: 10px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.strip .se { position: absolute; top: 16px; height: 1px; background: var(--text); }
.strip-l { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
.strip-k { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin: 6px 6px 0; }
.strip-k i { display: inline-block; vertical-align: -2px; margin-right: 5px; }
.ovl { background: linear-gradient(135deg, color-mix(in srgb, var(--viz-1) 45%, transparent) 50%, color-mix(in srgb, var(--viz-2) 45%, transparent) 50%); }
.src-tx p { font-size: 13px; line-height: 1.5; color: var(--text-2); margin-top: 8px; }
.strip-k .k-rg { width: 16px; height: 9px; border-radius: 3px; background: color-mix(in srgb, var(--text-2) 28%, transparent); box-shadow: inset 0 0 0 1px var(--text-2); }
.strip-k .k-sc { width: 9px; height: 9px; border-radius: 50%; background: var(--text); }
.bl-chart, .bl-src, .bl-sc { height: auto !important; }
.bl-main h2 .seg { margin-left: auto; }
@media (max-width: 700px) { .bal { grid-template-columns: 1fr; } }

/* ---------- phones: bottom tab bar, sheets, touch-sized controls ---------- */
.sb-backdrop, .tabbar { display: none; }
@media (max-width: 900px) {
  :root { --tabbar-h: calc(58px + env(safe-area-inset-bottom)); }
  .app { height: calc(100vh - var(--tabbar-h)); height: calc(100dvh - var(--tabbar-h)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
            height: var(--tabbar-h); padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
            background: color-mix(in srgb, var(--sidebar) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
            border-top: 1px solid var(--border); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
                              font-size: 11px; font-weight: 500; color: var(--muted); -webkit-tap-highlight-color: transparent; }
  .tabbar svg.i { width: 23px; height: 23px; }
  .tabbar .on { color: var(--red); }
  .tabbar .on svg.i { stroke-width: 2.1; }
  .tabbar b { position: absolute; top: 5px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
              background: var(--hover); color: var(--text-2); font-size: 10px; font-weight: 700; display: grid; place-items: center; }
  .tabbar b.alert { background: var(--red); color: #fff; }
  .fab { bottom: calc(var(--tabbar-h) + 14px); width: 52px; height: 52px; }
  .toast { left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 12px); justify-content: space-between; }
  /* the sidebar is the «Más» menu: bigger rows, always-visible actions */
  .sidebar { width: min(300px, 86vw); }
  .app.collapsed .sidebar { margin-left: max(-300px, -86vw); }
  .nav-item { height: 44px; font-size: 15px; }
  .side-search { height: 44px; }
  .side-heading .icon-btn { opacity: 1; width: 34px; height: 34px; }
  .side-foot .nav-item { height: 40px; font-size: 14px; }
  .topbar { height: 48px; padding: 0 8px; }
  .icon-btn { width: 40px; height: 40px; }
  /* dialogs become sheets that rise from the bottom, above the keyboard-safe area */
  .overlay { align-items: flex-end; padding: max(12px, env(safe-area-inset-top)) 0 0; }
  .qa, .mform, .detail { width: 100%; max-width: none; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: sheet .2s ease; }
  .detail { max-height: calc(100dvh - 24px - env(safe-area-inset-top)); }
  .detail-left { padding: 16px 16px 20px; }
  .d-desc, .d-block { margin-left: 0; width: 100%; }
  .qa-foot { flex-wrap: wrap; }
  .qa-foot select.proj-select { max-width: 100%; flex: 1 1 100%; }
  .qa-foot > div { flex: 1; justify-content: flex-end; }
  .chip { height: 34px; }
  .quick-dates button { padding: 6px 10px; font-size: 13px; }
  .btn { height: 44px; }
  .btn-ghost { height: 40px; min-width: 40px; }
  .seg button { height: 34px; }
  /* iOS zooms into any field under 16px: keep them at 16 */
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px !important; }
  /* shared page parts */
  .hinner { padding: 14px 14px 32px; }
  .hhead, .nhead { gap: 10px; margin-bottom: 14px; }
  .hhead h1, .nhead h1, .page-head h1 { font-size: 23px; }
  .hkpi .v { font-size: 19px; }
  .hbox { padding: 14px; border-radius: 12px; }
  .ftip { max-width: calc(100vw - 16px); }
}
@media (max-width: 600px) {
  .content { padding: 4px 14px 96px; }
  .content.wide, .tl-wrap { padding-left: 10px; padding-right: 10px; }
  .page-head { margin: 4px 0 16px; flex-wrap: wrap; }
  .hkpis { gap: 8px; }
  .hkpi { padding: 11px 12px; }
  .panel { padding: 14px; }
  .pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .pill { flex: none; height: 34px; }
}
@media (max-width: 900px) { .sb-open { display: none !important; } }  /* «Más» in the tab bar opens it */
