/* ==========================================================================
   lifeOS

   Design intent: a notebook you want to open, not a control panel.

   1. Warm paper and ink. Surfaces are tinted, never pure black or white, so
      the screen reads as a place rather than a terminal.
   2. A serif for the human parts — greetings, titles, big figures — and a
      sans for the working parts. The pairing is what stops it looking like
      every other dark SaaS dashboard.
   3. One warm accent (persimmon) for focus and the primary action. Semantic
      colours are kept distinct from it so red still means something.
   4. Small rewards. Completing things should feel good: the check pops, the
      row settles away, a toast offers an undo.
   ========================================================================== */

:root {
  --bg:        #f4f1ea;
  --surface:   #fbf9f4;
  --raised:    #ffffff;
  --hover:     #efebe2;
  --selected:  #e9e3d6;

  --rule:        #e6e0d3;
  --rule-strong: #d5ccba;

  --text:    #221d17;
  --text-2:  #6d6458;
  --text-3:  #9d9486;

  --accent:      #dc5a2b;
  --accent-ink:  #b9461c;
  --accent-dim:  rgba(220, 90, 43, 0.12);
  --on-accent:   #fffaf5;

  --red:    #c63b52;
  --amber:  #b98314;
  --green:  #4c8a3b;
  --red-dim:   rgba(198, 59, 82, 0.11);
  --amber-dim: rgba(185, 131, 20, 0.13);
  --green-dim: rgba(76, 138, 59, 0.12);

  --shadow-sm: 0 1px 2px rgba(60, 40, 20, 0.05);
  --shadow:    0 1px 2px rgba(60, 40, 20, 0.04), 0 6px 20px -8px rgba(60, 40, 20, 0.12);
  --shadow-lg: 0 2px 6px rgba(40, 25, 10, 0.06), 0 24px 60px -12px rgba(40, 25, 10, 0.28);

  --r-lg: 14px;
  --r:    10px;
  --r-sm: 7px;

  --row:     36px;
  --sidebar: 216px;
  --gutter:  28px;

  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
           "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino,
           "Book Antiqua", Georgia, ui-serif, serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

:root[data-theme="dark"] {
  --bg:        #161412;
  --surface:   #1d1a17;
  --raised:    #25211d;
  --hover:     #272320;
  --selected:  #2f2a25;

  --rule:        #2c2723;
  --rule-strong: #3b352f;

  --text:    #efe9de;
  --text-2:  #aaa092;
  --text-3:  #7b7266;

  --accent:      #f0784a;
  --accent-ink:  #f59266;
  --accent-dim:  rgba(240, 120, 74, 0.15);
  --on-accent:   #1b120c;

  --red:    #e8667a;
  --amber:  #e2ad45;
  --green:  #86b56f;
  --red-dim:   rgba(232, 102, 122, 0.14);
  --amber-dim: rgba(226, 173, 69, 0.14);
  --green-dim: rgba(134, 181, 111, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px -10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.3), 0 28px 70px -12px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

.num, .mono, td.num, .money, .stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
/* Figures use tabular numerals, not a code face; only secrets and config
   (tokens, recovery codes) are set in monospace. */
.mono { font-weight: 550; }
.card.mono, pre, code { font-family: var(--mono); font-size: 0.92em; }

html { scrollbar-color: var(--rule-strong) transparent; }
* { scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 5px;
                            border: 2px solid transparent; background-clip: padding-box; }
.serif { font-family: var(--serif); }

.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap, .truncate { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; }
.pos, .value.pos { color: var(--green); }
.neg, .value.neg { color: var(--red); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font: 600 26px/1.2 var(--serif); letter-spacing: -0.015em; }
h2 { font: 600 20px/1.25 var(--serif); }
h3 { font: 600 16px/1.3 var(--serif); }

h4, .label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--text-2);
}

p { margin: 0; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-ink); }

::selection { background: var(--accent-dim); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
input, select, textarea, button { font: inherit; color: inherit; }

input, select, textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
select {
  appearance: none; cursor: pointer; padding-right: 28px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12"><path d="M3 4.5l3 3 3-3" fill="none" stroke="%239d9486" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  background-repeat: no-repeat; background-position: right 8px center;
  background-size: 12px;
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); margin: 0; }
input[type="range"] { padding: 0; border: 0; background: transparent;
                      accent-color: var(--accent); box-shadow: none; }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1); opacity: 0.5; }

.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 5px; font-size: 12.5px;
                 font-weight: 550; color: var(--text-2); }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline > label { margin: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { margin: 5px 0 0; font-size: 12px; color: var(--text-3); }
.error { min-height: 18px; margin: 10px 0 0; font-size: 13px; color: var(--red); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px;
  background: var(--raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  font-size: 13px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.btn:hover { background: var(--hover); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: transparent; color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(120, 40, 10, 0.25);
}
.btn.primary:hover { background: var(--accent-ink); }
:root[data-theme="dark"] .btn.primary:hover { background: #f58a60; }
.btn.danger { color: var(--red); background: transparent; border-color: transparent;
              box-shadow: none; }
.btn.danger:hover { background: var(--red-dim); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none;
             color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.block { width: 100%; height: 40px; justify-content: center; margin-top: 18px;
             font-size: 14px; }
.btn.tiny { height: 26px; padding: 0 9px; font-size: 12px; box-shadow: none; }
.btn kbd { margin-left: 2px; }
.btn.primary kbd { background: rgba(255, 255, 255, 0.18); border-color: transparent;
                   color: inherit; }

.link {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--text-2); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--rule-strong);
}
.link:hover { color: var(--accent-ink); text-decoration-color: currentColor; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

kbd {
  display: inline-block; min-width: 18px; padding: 0 5px;
  font: 500 11px/17px var(--sans);
  text-align: center; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 16px 12px 12px;
  background: var(--surface);
  border-right: 1px solid var(--rule);
}

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 16px; }
.brand-mark {
  position: relative; width: 20px; height: 20px; flex: none; border-radius: 50%;
  background: var(--accent);
  overflow: hidden;
}
/* A sun on the horizon: the day, and the life, as the unit of attention. */
.brand-mark::after {
  content: ""; position: absolute; left: -2px; right: -2px; bottom: 0; height: 42%;
  background: var(--surface);
  border-top: 2px solid var(--surface);
}
.brand-mark::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 42%; height: 2px;
  background: var(--accent-ink); opacity: 0.35;
}
.brand strong, .brand h1 {
  font: 600 19px/1 var(--serif); letter-spacing: -0.02em;
}
.brand strong em, .brand h1 em { font-style: italic; color: var(--accent-ink);
                                 font-weight: 500; }

.searchbar {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 34px; margin-bottom: 14px; padding: 0 10px;
  background: var(--raised); border: 1px solid var(--rule);
  border-radius: var(--r-sm); box-shadow: var(--shadow-sm);
  color: var(--text-3); font-size: 13px; text-align: left; cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.searchbar:hover { border-color: var(--rule-strong); color: var(--text-2); }
.searchbar kbd { margin-left: auto; }

#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 14px; font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
#nav a:hover { background: var(--hover); color: var(--text); }
#nav a.active { background: var(--raised); color: var(--text); font-weight: 600;
                box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--rule); }
#nav a.active .ico { color: var(--accent); opacity: 1; }
#nav a .key {
  margin-left: auto; font: 11px var(--mono); color: var(--text-3); opacity: 0;
  transition: opacity 0.12s;
}
#nav a:hover .key { opacity: 1; }
#nav .nav-sep { height: 1px; margin: 8px 10px; background: var(--rule); }

.sidebar-foot {
  margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--rule);
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-3);
}
.sidebar-foot .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent-ink);
  font: 600 12px/1 var(--serif);
}

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.topbar.scrolled { border-bottom-color: var(--rule); }
.topbar h2 { font: 600 21px/1 var(--serif); letter-spacing: -0.015em; }

.view {
  padding: 8px var(--gutter) 64px; width: 100%;
  animation: view-in 0.28s var(--ease-out);
}
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.view > .row:first-child { margin-bottom: 18px; }

/* --------------------------------------------------------------------------
   Cards and sections
   -------------------------------------------------------------------------- */
.section, .card, .panel {
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.section { padding: 4px 8px 6px; }
.section-head, .card-head, .panel > .panel-head {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 8px;
}
.section-head h4, .card-head h3, .card-head h4, .panel-head h4 {
  font: 600 16px/1.2 var(--serif); color: var(--text); letter-spacing: -0.01em;
}
.count, .section-head .count {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--hover); color: var(--text-2);
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}

.card { padding: 18px 20px; }
.card.stack { gap: 12px; }
.card.stack > .btn { align-self: flex-start; }
.card.stack > .field-row > .field, .card.stack .field:last-child { margin-bottom: 0; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card:has(> .card-head) { padding: 4px 8px 6px; }
.card.pad-0:has(> .card-head) { padding: 0; }
.card.pad-0 > .card-head { padding: 0 16px; border-bottom: 1px solid var(--rule); }
.card-body { padding: 0; }
.card.pad-0 > .card-body { padding: 14px 16px; }
.card.mono { padding: 12px 14px; background: var(--bg); box-shadow: none;
             word-break: break-all; }
pre.card { overflow-x: auto; white-space: pre-wrap; }
.card > h3 { margin-bottom: 2px; }

.panel-body { padding: 12px; }

.grid { display: grid; gap: 1px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid.c2 > div > .section:last-child, .grid.c2 > .stack > *:last-child { margin-bottom: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.stack > .section, .stack > .card { margin-bottom: 0; }
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar select, .row > select, .row > input[type="month"] { width: auto; }
.toolbar input[type="search"], .row > input[type="search"] { width: 220px; }

/* --------------------------------------------------------------------------
   Metrics — soft tiles with a serif figure
   -------------------------------------------------------------------------- */
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.metric, .stat {
  padding: 14px 16px 13px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.metric.clickable { cursor: pointer; transition: transform 0.15s var(--ease-out), box-shadow 0.15s; }
.metric.clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.metric .label, .stat .label { display: block; margin-bottom: 4px; }
.metric .stat-value, .stat .stat-value {
  font: 600 27px/1.15 var(--serif); letter-spacing: -0.02em;
  font-variant-numeric: lining-nums tabular-nums;
}
.metric .sub, .stat .sub { margin-top: 3px; font-size: 12.5px; color: var(--text-3); }

/* --------------------------------------------------------------------------
   Rows — the primary list idiom
   -------------------------------------------------------------------------- */
.rows, .list { display: flex; flex-direction: column; }

.r, .item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--row); padding: 6px 8px;
  border-radius: var(--r-sm);
  cursor: default; scroll-margin: 80px;
  transition: background 0.12s;
}
.r + .r, .item + .item { box-shadow: 0 -1px 0 var(--rule); }
.r:hover, .item:hover { background: var(--hover); box-shadow: none; }
.r:hover + .r, .item:hover + .item { box-shadow: none; }
.r.clickable, .item[onclick], .item.clickable { cursor: pointer; }
.list .item { cursor: pointer; }
.r.cursor { background: var(--hover); box-shadow: inset 3px 0 0 var(--accent) !important; }
.r.selected { background: var(--accent-dim); }
.r.selected.cursor { box-shadow: inset 3px 0 0 var(--accent) !important; }

.r .primary {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px;
}
.r.done .primary { color: var(--text-3); text-decoration: line-through;
                   text-decoration-color: var(--text-3); }
.r .secondary {
  flex: none; display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--text-3);
}
.r .trailing { flex: none; font-size: 13px; color: var(--text-2); }

.r.two { align-items: flex-start; padding: 8px; }
.r.two .body { flex: 1; min-width: 0; }
.r.two .sub {
  margin-top: 1px; font-size: 12.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.item { align-items: flex-start; padding: 10px 8px; }
.item > .dot { margin-top: 8px; }
.item > .check { margin-top: 2px; }
.item > strong, .item > .chip { margin-top: 1px; flex: none; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-main > .bar { margin-top: 4px; }
.item .title {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 550;
}
.item p.small { line-height: 1.5; }

.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
        font-size: 12.5px; color: var(--text-3); }

/* Round check, Things-style: completing should feel like a small reward. */
.check {
  position: relative;
  display: grid; place-items: center;
  width: 18px; height: 18px; flex: none; padding: 0;
  background: transparent; border: 1.5px solid var(--rule-strong);
  border-radius: 50%; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.check:hover { border-color: var(--accent); background: var(--accent-dim); }
.check:hover::after {
  content: ""; width: 7px; height: 3.5px;
  border: 1.6px solid var(--accent); border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px); opacity: 0.6;
}
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on::after, .check.on:hover::after {
  content: ""; width: 7px; height: 3.5px;
  border: 1.8px solid var(--on-accent); border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px); opacity: 1;
}
.check.pop { animation: pop 0.42s var(--ease-spring); }
.check.pop::before {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ring 0.55s var(--ease-out) forwards;
}
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(0.82); }
                 100% { transform: scale(1); } }
@keyframes ring { from { transform: scale(1); opacity: 0.7; }
                  to { transform: scale(2.4); opacity: 0; } }

.r.completing .primary {
  color: var(--text-3);
  text-decoration: line-through; text-decoration-color: var(--text-3);
}
.r.leaving {
  overflow: hidden;
  animation: leave 0.36s var(--ease-out) forwards;
}
@keyframes leave {
  to { opacity: 0; min-height: 0; height: 0; padding-top: 0; padding-bottom: 0;
       transform: translateX(10px); }
}

/* --------------------------------------------------------------------------
   Tags and status
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px;
  border-radius: 11px;
  background: var(--hover); color: var(--text-2);
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.chip.good { background: var(--green-dim); color: var(--green); }
.chip.warn { background: var(--amber-dim); color: var(--amber); }
.chip.bad  { background: var(--red-dim);   color: var(--red); }
.chip.accent { background: var(--accent-dim); color: var(--accent-ink); }
.chip.tag { background: transparent; box-shadow: inset 0 0 0 1px var(--rule-strong);
            color: var(--text-2); }
.chip.tag::before { content: "#"; opacity: 0.5; margin-right: -2px; }

.pri { width: 3px; height: 16px; flex: none; border-radius: 2px;
       background: transparent; }
.pri.urgent { background: var(--red); }
.pri.high   { background: var(--amber); }
.pri.medium { background: var(--rule-strong); }

.dot { width: 8px; height: 8px; flex: none; border-radius: 50%;
       background: var(--rule-strong); }
.dot.good { background: var(--green); }
.dot.warn { background: var(--amber); }
.dot.bad  { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 56px; z-index: 1;
  padding: 10px 12px; text-align: left;
  background: var(--surface);
  border-bottom: 1px solid var(--rule-strong);
  font-size: 12px; font-weight: 600; color: var(--text-2);
  white-space: nowrap;
}
tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--rule);
  font-size: 13.5px; vertical-align: middle;
}
tbody td .chip { margin-left: 6px; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Bars, rings, sparklines
   -------------------------------------------------------------------------- */
.bar { height: 6px; border-radius: 3px; background: var(--hover);
       overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px;
           background: var(--text-3);
           transition: width 0.6s var(--ease-out); }
.bar > i.good { background: var(--green); }
.bar > i.warn { background: var(--amber); }
.bar > i.bad  { background: var(--red); }
.bar > i.accent { background: var(--accent); }

.ring { position: relative; width: 64px; height: 64px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--hover); }
.ring .fill { stroke: var(--accent); stroke-linecap: round;
              transition: stroke-dashoffset 0.9s var(--ease-out); }
.ring .ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 600 17px/1 var(--serif); font-variant-numeric: lining-nums;
}

.spark { display: flex; align-items: flex-end; gap: 2px; height: 22px; }
.spark > i {
  flex: 1; min-width: 3px; background: var(--rule-strong); border-radius: 2px;
}
.spark > i.on { background: var(--text-3); }
.spark > i.good { background: var(--green); }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 10px);
        gap: 3px; }
.heat > i { width: 10px; height: 10px; border-radius: 3px;
            background: var(--hover); }
.heat > i.on { background: var(--green); }
.heat > i.future { opacity: 0.35; }

/* --------------------------------------------------------------------------
   Today
   -------------------------------------------------------------------------- */
.hero {
  display: flex; align-items: flex-end; gap: 24px;
  padding: 18px 0 22px;
}
.hero .eyebrow { font-size: 13px; color: var(--text-3); font-weight: 500;
                 margin-bottom: 6px; }
.hero h1 { font-size: 38px; line-height: 1.1; letter-spacing: -0.025em; }
.hero h1 em { font-style: italic; font-weight: 500; color: var(--accent-ink); }
.hero .summary {
  max-width: 640px; margin-top: 10px;
  font-size: 16px; line-height: 1.55; color: var(--text-2);
}
.hero .summary b { color: var(--text); font-weight: 600; }
.hero .summary b.bad { color: var(--red); }
.hero .summary b.good { color: var(--green); }
.hero .ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px;
                   font-size: 12px; color: var(--text-3); }

.heads-up { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 22px; }
.heads-up .note {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px 0 10px; border-radius: 15px;
  background: var(--surface); border: 1px solid var(--rule);
  font-size: 13px; color: var(--text-2);
}
.heads-up .note.clickable { cursor: pointer; }
.heads-up .note.clickable:hover { border-color: var(--rule-strong); color: var(--text); }

/* Capture: the one input that matters. */
.capture {
  position: relative;
  margin-bottom: 22px;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.capture:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim), var(--shadow);
}
.capture-row { display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.capture-row .ico { color: var(--accent); opacity: 1; width: 16px; height: 16px; }
.capture input {
  height: 52px; padding: 0; border: 0; background: transparent;
  font-size: 16px; box-shadow: none !important;
}
.capture input:hover { border: 0; }
.capture input:focus-visible { outline: none; }
.capture .preview {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 0 14px 12px 40px; min-height: 0;
  font-size: 12px; color: var(--text-3);
}
.capture .preview:empty { display: none; }
.capture.compact { margin-bottom: 14px; border-radius: var(--r); box-shadow: var(--shadow-sm); }
.capture.compact input { height: 42px; font-size: 14px; }
.capture.compact .preview { padding-left: 38px; padding-bottom: 10px; }
.capture.flash { animation: flash 0.5s var(--ease-out); }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--accent-dim); }
                   50% { box-shadow: 0 0 0 8px var(--accent-dim); } }

.habit-pills { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 8px 10px; }
.habit {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 8px; border-radius: 18px;
  background: var(--raised); border: 1px solid var(--rule-strong);
  font-size: 13.5px; font-weight: 550; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.habit:hover { border-color: var(--accent); }
.habit:active { transform: scale(0.97); }
.habit .check { pointer-events: none; }
.habit .streak { font-size: 12px; font-weight: 500; color: var(--text-3); }
.habit.on { background: var(--accent-dim); border-color: transparent; }
.habit.on .streak { color: var(--accent-ink); }
.habit.on:hover { border-color: transparent; }

/* --------------------------------------------------------------------------
   Focus mode
   -------------------------------------------------------------------------- */
.focus {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(800px 500px at 50% 0%, var(--accent-dim), transparent 70%),
    var(--bg);
  animation: fade 0.25s ease-out;
}
.focus-box { width: 100%; max-width: 620px; text-align: center;
             display: flex; flex-direction: column; align-items: center; gap: 14px; }
.focus-eyebrow { font-size: 13px; color: var(--text-3); }
.focus-title { font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; }
.focus-presets { display: flex; gap: 4px; padding: 3px; margin-top: 8px;
                 background: var(--hover); border-radius: var(--r); }
.focus-clock {
  font: 500 clamp(72px, 16vw, 128px)/1 var(--serif);
  font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.03em;
  margin: 6px 0 4px;
}
.focus-clock.over { color: var(--accent-ink); }
.focus-actions { justify-content: center; flex-wrap: wrap; }
.focus-main { min-width: 140px; justify-content: center; height: 40px; font-size: 14px; }
.focus-checklist { display: flex; flex-direction: column; gap: 6px; margin-top: 10px;
                   text-align: left; min-width: 280px; }
.focus-checklist:empty { display: none; }
.focus-item { display: flex; align-items: center; gap: 10px; font-size: 15px;
              padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface);
              border: 1px solid var(--rule); cursor: pointer; }
.focus-item:has(input:checked) span { color: var(--text-3); text-decoration: line-through; }
.focus-hint { margin-top: 18px; font-size: 12px; color: var(--text-3); }
.focus-hint kbd { margin: 0 2px; }

/* --------------------------------------------------------------------------
   Editors: checklist, inline groups
   -------------------------------------------------------------------------- */
.checklist { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.check-item input[type="text"] { border-color: transparent; background: transparent;
                                 padding: 5px 6px; }
.check-item input[type="text"]:hover { border-color: var(--rule); }
.check-item input[type="text"]:focus { border-color: var(--accent); background: var(--raised); }
.check-item.done input[type="text"] { color: var(--text-3); text-decoration: line-through; }
.check-item .icon-btn { opacity: 0; width: 24px; height: 24px; }
.check-item:hover .icon-btn { opacity: 1; }
.progress-text { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.fieldset { padding: 12px 14px 2px; margin-bottom: 14px; border: 1px solid var(--rule);
            border-radius: var(--r); background: var(--surface); }
.fieldset > .legend { font: 600 14px var(--serif); margin-bottom: 10px; display: flex;
                      align-items: center; gap: 8px; }

/* --------------------------------------------------------------------------
   Projects and charts
   -------------------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
         gap: 14px; }
.pcard {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 18px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s, border-color 0.15s;
}
.pcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--rule-strong); }
.pcard h3 { display: flex; align-items: center; gap: 8px; }
.pcard .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none;
                 background: var(--accent); }
.pcard .desc { font-size: 13px; color: var(--text-2); display: -webkit-box;
               -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard.new { align-items: center; justify-content: center; min-height: 120px;
             border-style: dashed; color: var(--text-3); box-shadow: none;
             background: transparent; font-weight: 550; }
.pcard.new:hover { color: var(--accent-ink); border-color: var(--accent); }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 64px; padding-top: 6px; }
.chart > i {
  position: relative; flex: 1; min-width: 4px; border-radius: 3px 3px 1px 1px;
  background: var(--accent); opacity: 0.85; transition: opacity 0.12s;
}
.chart > i.zero { background: var(--hover); opacity: 1; }
.chart > i.today { background: var(--accent-ink); opacity: 1; }
.chart > i:hover { opacity: 1; }
.chart-foot { display: flex; justify-content: space-between; margin-top: 6px;
              font-size: 11.5px; color: var(--text-3); }
.momentum { padding: 4px 8px 10px; }
.momentum .headline { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.momentum .headline strong { font: 600 24px var(--serif); }

.mood-strip { display: flex; gap: 3px; align-items: flex-end; height: 44px; }
.mood-strip > i { flex: 1; min-width: 5px; border-radius: 3px; background: var(--hover); }
.mood-strip > i.m1 { background: var(--red); }
.mood-strip > i.m2 { background: color-mix(in srgb, var(--red) 50%, var(--amber)); }
.mood-strip > i.m3 { background: var(--amber); }
.mood-strip > i.m4 { background: color-mix(in srgb, var(--green) 60%, var(--amber)); }
.mood-strip > i.m5 { background: var(--green); }

.fav { background: none; border: 0; cursor: pointer; font-size: 18px; line-height: 1;
       color: var(--text-3); padding: 2px 4px; border-radius: var(--r-sm); }
.fav:hover { color: var(--amber); background: var(--hover); }
.fav.on { color: var(--amber); }

/* --------------------------------------------------------------------------
   Board
   -------------------------------------------------------------------------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px;
         scroll-snap-type: x proximity; }
.col, .column {
  flex: 0 0 264px; scroll-snap-align: start;
  padding: 4px 6px 6px;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-lg);
}
.col-head, .column > h4 {
  display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 6px;
  font: 600 15px/1.2 var(--serif); color: var(--text);
}
.column > h4 > span { margin-left: auto; font: 500 12px var(--sans); color: var(--text-3);
                      font-variant-numeric: tabular-nums; }
.col .rows, .column .list { max-height: 66vh; overflow-y: auto; }
.column .item, .col .r { background: var(--raised); box-shadow: var(--shadow-sm) !important;
                         border: 1px solid var(--rule); margin-bottom: 6px; }
.column .item:hover, .col .r:hover { border-color: var(--rule-strong); }

/* --------------------------------------------------------------------------
   Empty and loading
   -------------------------------------------------------------------------- */
.empty { padding: 30px 16px; text-align: center; color: var(--text-3);
         font: italic 15px/1.5 var(--serif); }
.empty .btn { margin-top: 12px; font: 550 13px var(--sans); }
.empty.small { padding: 14px; font-size: 13px; }

.skel, .skeleton { display: flex; flex-direction: column; gap: 8px; }
.skel > i {
  display: block; height: 28px; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--hover) 0%, var(--surface) 50%,
                              var(--hover) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skel > i:nth-child(3n) { width: 72%; }
.skel > i:nth-child(3n+2) { width: 88%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --------------------------------------------------------------------------
   Overlays
   -------------------------------------------------------------------------- */
.modal, .drawer { position: fixed; inset: 0; z-index: 60; }
.backdrop { position: absolute; inset: 0; background: rgba(30, 20, 10, 0.32);
            backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
            animation: fade 0.18s ease-out; }
:root[data-theme="dark"] .backdrop { background: rgba(0, 0, 0, 0.55); }
@keyframes fade { from { opacity: 0; } }

.modal-box, .palette-box {
  position: relative; margin: 12vh auto 0;
  width: calc(100% - 32px); max-width: 520px;
  background: var(--raised); border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.22s var(--ease-out);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(0.98); } }
.modal-box { padding: 20px 22px; }
.palette-box { max-width: 620px; overflow: hidden; }

.palette-box > input {
  height: 56px; padding: 0 18px 0 46px;
  background: transparent no-repeat 18px center / 17px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%239d9486" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg>');
  border: 0; border-bottom: 1px solid var(--rule);
  border-radius: 0; font-size: 17px;
}
.palette-box > input:focus { box-shadow: none; }
.palette-results { max-height: 56vh; overflow-y: auto; padding: 6px; }
.palette-group {
  padding: 10px 12px 4px; font-size: 12px; font-weight: 600; color: var(--text-3);
}
.presult {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px; border-radius: var(--r-sm); cursor: pointer;
}
.presult.sel { background: var(--accent-dim); }
.presult.sel .ptitle { color: var(--text); }
.presult .pico { display: grid; place-items: center; width: 22px; height: 22px;
                 border-radius: 6px; background: var(--hover); color: var(--text-2);
                 font-size: 12px; flex: none; }
.presult.sel .pico { background: var(--accent); color: var(--on-accent); }
.presult .ptitle { flex: 1; min-width: 0; overflow: hidden;
                   text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.presult .psub { flex: none; display: flex; gap: 5px; font-size: 12px; color: var(--text-3);
                 max-width: 50%; overflow: hidden; text-overflow: ellipsis;
                 white-space: nowrap; }
.palette-foot {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px; border-top: 1px solid var(--rule);
  background: var(--surface);
  font-size: 12px; color: var(--text-3);
}
.palette-foot span + kbd { margin-left: 8px; }

.drawer-box {
  position: absolute; inset: 10px 10px 10px auto; width: min(500px, calc(100% - 20px));
  padding: 22px 24px; overflow-y: auto;
  background: var(--raised); border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: drawer-in 0.26s var(--ease-out);
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } }
.drawer-box > h3:first-child, .drawer-box > .row:first-child { margin-bottom: 18px; }
.drawer-box > h3:first-child { font-size: 21px; }
.drawer-head {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 14px; margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.drawer-head h3 { font-size: 21px; }
.form-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--rule);
}
.event-form + .connections { margin-top: 20px; }
.note-body, .prose { font: 16px/1.7 var(--serif); }
.note-body h1, .prose h1 { font-size: 24px; margin: 20px 0 8px; }
.note-body h2, .prose h2 { font-size: 19px; margin: 18px 0 6px; }
.note-body h3, .prose h3 { font-size: 16px; margin: 16px 0 4px; }
.note-body ul, .prose ul { margin: 6px 0; padding-left: 20px; }
.note-body li, .prose li { margin: 3px 0; }
.note-body code, .prose code { padding: 1px 5px; font: 13px var(--mono);
                               background: var(--hover); border-radius: 5px; }
.note-body blockquote, .prose blockquote {
  margin: 10px 0; padding-left: 14px;
  border-left: 3px solid var(--accent); color: var(--text-2); font-style: italic;
}
.note-body a, .prose a { color: var(--accent-ink); text-decoration: underline;
                         text-underline-offset: 3px; }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; padding: 3px;
        width: fit-content; max-width: 100%; overflow-x: auto;
        background: var(--hover); border-radius: var(--r); }
.tab {
  height: 30px; padding: 0 14px; flex: none;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13px; font-weight: 550; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--raised); color: var(--text);
              box-shadow: var(--shadow-sm), 0 0 0 1px var(--rule); }
.row > .tabs, .row.wrap > .tabs { margin-bottom: 0; }

.bulkbar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 50;
  display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 8px 0 16px;
  background: var(--text); color: var(--bg);
  border-radius: 23px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: rise 0.24s var(--ease-spring);
}
.bulkbar .n { font: 600 16px var(--serif); }
.bulkbar .sep { width: 1px; height: 18px; background: color-mix(in srgb, var(--bg) 25%, transparent); }
.bulkbar .btn { background: transparent; color: inherit; border-color: transparent; }
.bulkbar .btn:hover { background: color-mix(in srgb, var(--bg) 14%, transparent); }
.bulkbar select { width: auto; height: 28px; padding-top: 0; padding-bottom: 0;
                  background-color: transparent; color: inherit;
                  border-color: color-mix(in srgb, var(--bg) 30%, transparent); }

.keys-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
             gap: 22px 28px; }
.keys-grid dl { margin: 0; }
.keys-grid dt { margin-bottom: 8px; font: 600 15px var(--serif); color: var(--text); }
.keys-grid dd {
  display: flex; align-items: center; gap: 10px; margin: 0 0 6px;
  font-size: 13px; color: var(--text-2);
}
.keys-grid dd .k { flex: none; min-width: 64px; }

/* Toasts */
.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  min-height: 40px; padding: 0 8px 0 16px;
  background: var(--text); color: var(--bg);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 500;
  pointer-events: auto;
  animation: rise 0.26s var(--ease-spring);
  transition: opacity 0.2s, transform 0.2s;
}
.toast:not(:has(button)) { padding-right: 16px; }
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%;
                 background: var(--text-3); flex: none; }
.toast.good::before { background: var(--green); }
.toast.bad::before  { background: var(--red); }
.toast button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 14px; cursor: pointer;
  background: color-mix(in srgb, var(--bg) 16%, transparent); color: inherit;
  font-size: 13px; font-weight: 600;
}
.toast button:hover { background: color-mix(in srgb, var(--bg) 26%, transparent); }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.96); } }

/* --------------------------------------------------------------------------
   Auth
   -------------------------------------------------------------------------- */
.auth, .offline-page { min-height: 100dvh; display: grid; place-items: center;
                       padding: 24px; }
.auth {
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-dim), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px; padding: 32px 30px 26px;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 18px; box-shadow: var(--shadow-lg);
}
.auth-card .brand { padding: 0 0 22px; }
.auth-card .brand h1 { font-size: 22px; }
.auth-card .headline { font: 600 28px/1.15 var(--serif); letter-spacing: -0.02em;
                       margin: 0 0 6px; }
.auth-card .headline em { font-style: italic; font-weight: 500; color: var(--accent-ink); }
.auth-card label { display: block; margin: 14px 0 5px; font-size: 12.5px;
                   font-weight: 550; color: var(--text-2); }
.auth-card input { height: 40px; }
.auth-card .tagline { margin: 0 0 14px; font-size: 14px; color: var(--text-2); }
.switcher { margin-top: 18px; text-align: center; font-size: 13px; }

/* --------------------------------------------------------------------------
   Icons — CSS masks, so they inherit currentColor and need no network
   -------------------------------------------------------------------------- */
.ico {
  display: inline-block; width: 16px; height: 16px; flex: none;
  background: currentColor; opacity: 0.8;
  -webkit-mask: var(--i) no-repeat center / contain;
  mask: var(--i) no-repeat center / contain;
}
.ico[data-ico="home"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>'); }
.ico[data-ico="check"]  { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M8.5 12.5l2.5 2.5 4.5-5"/></svg>'); }
.ico[data-ico="people"] { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 00-4-4H6a4 4 0 00-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 00-3-3.87M16 3.13A4 4 0 0119 7"/></svg>'); }
.ico[data-ico="cal"]    { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><rect x="3.5" y="5" width="17" height="15.5" rx="2.5"/><path d="M3.5 10h17M8 3v4M16 3v4"/></svg>'); }
.ico[data-ico="money"]  { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><rect x="2.5" y="6" width="19" height="13" rx="2.5"/><path d="M2.5 10h19M6.5 15h3"/></svg>'); }
.ico[data-ico="note"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><path d="M14 2v6h6M9 13h6M9 17h4"/></svg>'); }
.ico[data-ico="book"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg>'); }
.ico[data-ico="target"] { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M4 21V4"/><path d="M4 4h11l-2 4 2 4H4"/></svg>'); }
.ico[data-ico="gear"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 01-2.83 2.83l-.06-.06a1.65 1.65 0 00-2.82 1.17V21a2 2 0 01-4 0v-.09A1.65 1.65 0 007 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83-2.83l.06-.06A1.65 1.65 0 003.6 14H3a2 2 0 010-4h.09A1.65 1.65 0 004.6 8.4L4.54 8.34a2 2 0 012.83-2.83l.06.06A1.65 1.65 0 0010 5.4V5a2 2 0 014 0v.09a1.65 1.65 0 002.82 1.17l.06-.06a2 2 0 012.83 2.83l-.06.06A1.65 1.65 0 0020.4 10H21a2 2 0 010 4h-.09a1.65 1.65 0 00-1.51 1z"/></svg>'); }
.ico[data-ico="deal"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M3 17l6-6 4 4 8-8"/><path d="M14 7h7v7"/></svg>'); }
.ico[data-ico="plus"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2.2" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>'); }
.ico[data-ico="menu"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round"><path d="M3 6h18M3 12h18M3 18h18"/></svg>'); }
.ico[data-ico="back"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M15 18l-6-6 6-6"/></svg>'); }
.ico[data-ico="moon"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.8A9 9 0 1111.2 3a7 7 0 009.8 9.8z"/></svg>'); }
.ico[data-ico="spark"]  { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v4M12 17v4M3 12h4M17 12h4M6 6l2.5 2.5M15.5 15.5L18 18M6 18l2.5-2.5M15.5 8.5L18 6"/></svg>'); }
.ico[data-ico="search"] { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg>'); }
.ico[data-ico="grid"]   { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.9" stroke-linejoin="round"><rect x="3.5" y="3.5" width="7" height="7" rx="2"/><rect x="13.5" y="3.5" width="7" height="7" rx="2"/><rect x="3.5" y="13.5" width="7" height="7" rx="2"/><rect x="13.5" y="13.5" width="7" height="7" rx="2"/></svg>'); }

/* --------------------------------------------------------------------------
   Touch — taps that feel like taps, swipeable rows, pull to refresh
   -------------------------------------------------------------------------- */
html { -webkit-tap-highlight-color: transparent; }
button, a, select, .r, .item, .nrow, .conn, .pick, .folder, .chip { touch-action: manipulation; }
.tabbar, .topbar, .btn, .seg, .folder, .tabs, #nav, .more-box {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.touch .r, .touch .item, .touch .nrow, .touch .conn, .touch .pick {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.tabbar, .ptr { display: none; }

@media (hover: none) {
  .conn-x { opacity: 1; }
  #nav a .key, .searchbar kbd, #quick-add kbd, .keys-hint, .palette-foot { display: none; }
  .btn:active, .icon-btn:active { transform: scale(0.96); }
  .r.clickable:active, .item:active, .nrow:active, .conn:active, .pick:active,
  .folder:active, .menu-item:active { background: var(--hover); }
}

.swipeable { overflow: hidden; }
.swipeable > * { transform: translateX(var(--sx, 0px)); transition: transform 0.26s var(--ease-out); }
.swipeable.swiping > * { transition: none; }
.swipeable::before {
  content: attr(data-swipe);
  position: absolute; top: 0; bottom: 0; width: var(--sxa, 0px);
  display: flex; align-items: center; overflow: hidden; white-space: nowrap;
  padding-inline: min(18px, calc(var(--sxa, 0px) / 3));
  font: 650 13px var(--sans); color: #fff; background: var(--text-3);
  border-radius: var(--r-sm); pointer-events: none;
  transition: width 0.26s var(--ease-out), background 0.15s;
}
.swipeable.swiping::before { transition: background 0.15s; }
.swipeable.swipe-right::before { left: 0; justify-content: flex-start; }
.swipeable.swipe-left::before { right: 0; justify-content: flex-end; }
.swipeable.swipe-armed[data-tone="good"]::before { background: var(--green); }
.swipeable.swipe-armed[data-tone="bad"]::before { background: var(--red); }
.swipeable.swipe-armed[data-tone="accent"]::before { background: var(--accent); }

.touch .ptr {
  position: fixed; z-index: 25; left: 50%; top: calc(env(safe-area-inset-top) + 40px);
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--raised); box-shadow: var(--shadow-lg); border: 1px solid var(--rule);
  transform: translate(-50%, 0); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.3s var(--ease-out);
}
.ptr-spin { width: 16px; height: 16px; border-radius: 50%;
            border: 2px solid var(--rule-strong); border-top-color: var(--accent); }
.ptr.armed .ptr-spin { border-color: var(--accent); border-right-color: transparent; }
.ptr.loading { opacity: 1 !important; }
.ptr.loading .ptr-spin { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Connections — type colours, list, picker, network map
   -------------------------------------------------------------------------- */
:root {
  --t-people: var(--accent); --t-companies: #4f7bb8; --t-notes: #4f9a6a;
  --t-deals: #c08a1e; --t-projects: #8a63b8; --t-tasks: #7a7064; --t-goals: #c2557a;
}
.gdot {
  flex: none; display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  font: 600 10px/1 var(--sans); color: #fff;
  background: var(--t-tasks);
}
.gdot.t-people { background: var(--t-people); }
.gdot.t-companies { background: var(--t-companies); border-radius: 6px; }
.gdot.t-notes { background: var(--t-notes); border-radius: 6px; }
.gdot.t-deals { background: var(--t-deals); }
.gdot.t-projects { background: var(--t-projects); }
.gdot.t-goals { background: var(--t-goals); }
.gdot.t-new { background: var(--hover); color: var(--text-2); border: 1px dashed var(--rule-strong); }

.connections .card-head .count:empty { display: none; }
.conn-group {
  margin: 12px 0 4px; font: 600 11px/1 var(--sans); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3);
}
.conn-group:first-child { margin-top: 2px; }
.conn {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; margin: 0 -8px; border-radius: var(--r-sm); cursor: pointer;
}
.conn:hover { background: var(--hover); }
.conn-main { flex: 1; min-width: 0; }
.conn-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-rel { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-x {
  opacity: 0; border: 0; background: none; cursor: pointer;
  width: 24px; height: 24px; border-radius: 6px; color: var(--text-3); font-size: 16px;
}
.conn:hover .conn-x { opacity: 1; }
.conn-x:hover { background: var(--bg); color: var(--red); }

.connect-box { max-width: 480px; }
.connect-box > input[type="search"] { margin-bottom: 8px; }
.pick-list { max-height: 320px; overflow-y: auto; margin: 0 -6px; }
.pick {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-radius: var(--r-sm); cursor: pointer;
}
.pick.sel { background: var(--accent-dim); }
.pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.rel-pill {
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--rule-strong);
  font: 500 13px var(--sans); color: var(--text-2);
}
.rel-pill:hover { border-color: var(--accent); color: var(--text); }
.rel-pill.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.netmap { margin: 0 -8px; }
.netsvg { display: block; width: 100%; height: auto; max-height: 460px; }
.netsvg line { stroke: var(--rule-strong); stroke-width: 1; }
.netsvg line.e1 { stroke: color-mix(in srgb, var(--accent) 45%, var(--rule-strong)); stroke-width: 1.4; }
.netsvg .gn { cursor: pointer; }
.netsvg .gn.root { cursor: default; }
.netsvg .gn circle { fill: var(--t-tasks); stroke: var(--surface); stroke-width: 2.5; transition: r 0.15s; }
.netsvg .gn.t-people circle { fill: var(--t-people); }
.netsvg .gn.t-companies circle { fill: var(--t-companies); }
.netsvg .gn.t-notes circle { fill: var(--t-notes); }
.netsvg .gn.t-deals circle { fill: var(--t-deals); }
.netsvg .gn.t-projects circle { fill: var(--t-projects); }
.netsvg .gn.t-goals circle { fill: var(--t-goals); }
.netsvg .gn text { font: 500 11.5px var(--sans); fill: var(--text-2); paint-order: stroke;
                   stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.netsvg .gn.root text { font: 600 14px var(--serif); fill: var(--text); }
.netsvg .gn.r2 text { font-size: 10.5px; fill: var(--text-3); }
.netsvg .gn:not(.root):hover text { fill: var(--accent-ink); }
.netsvg .gn:not(.root):hover circle { stroke: var(--accent-dim); stroke-width: 6; }

/* --------------------------------------------------------------------------
   Notes — two panes
   -------------------------------------------------------------------------- */
.notes-app {
  display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 22px;
  align-items: start;
}
.notes-side {
  position: sticky; top: 76px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 96px);
}
.notes-side .notes-search { flex: 1; min-width: 0; width: auto; }
.btn.daily { justify-content: space-between; width: 100%; }
.folders { display: flex; flex-direction: column; gap: 1px; }
.folder {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-2); cursor: pointer;
  font: 500 13.5px var(--sans); text-align: left;
}
.folder:hover { background: var(--hover); color: var(--text); }
.folder.on { background: var(--accent-dim); color: var(--accent-ink); }
.folder .n { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.folder.on .n { color: inherit; }
.template-pick { margin-top: 6px; font-size: 13px; color: var(--text-2); }
.notes-list {
  flex: 1; min-height: 120px; overflow-y: auto;
  border-top: 1px solid var(--rule); padding-top: 6px; margin: 0 -4px; padding-inline: 4px;
}
.nrow { padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; }
.nrow + .nrow { margin-top: 1px; }
.nrow:hover { background: var(--hover); }
.nrow.on { background: var(--surface); box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
.nrow-title { display: flex; gap: 6px; align-items: center; font-weight: 550; min-width: 0; }
.nrow-title .pin { color: var(--accent); font-size: 12px; }
.nrow-sub { display: flex; gap: 8px; margin-top: 2px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.nrow-sub .when { flex: none; }

.notes-main { min-width: 0; }
.note-pane {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 18px 34px 30px;
  display: flex; flex-direction: column; gap: 6px;
}
.note-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.note-crumbs { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 220px; }
.note-crumbs .sep { color: var(--text-3); }
.meta-input {
  width: auto; min-width: 0; max-width: 180px; height: 28px; padding: 0 8px;
  border-color: transparent; background: transparent; font-size: 13px; color: var(--text-2);
}
.meta-input:hover { border-color: var(--rule); }
.meta-input:focus { background: var(--raised); color: var(--text); }
.note-actions { display: flex; align-items: center; gap: 6px; }
.save-state { font-size: 12px; color: var(--text-3); margin-right: 6px; white-space: nowrap; }
.icon-btn.on { color: var(--accent); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-sm); background: var(--bg);
       border: 1px solid var(--rule); }
.seg button { border: 0; background: none; cursor: pointer; padding: 4px 10px; border-radius: 5px;
              font: 550 12.5px var(--sans); color: var(--text-2); }
.seg button.on { background: var(--raised); color: var(--text); box-shadow: var(--shadow); }

.note-title {
  height: auto; padding: 4px 0; border: 0; background: transparent; box-shadow: none !important;
  font: 600 32px/1.2 var(--serif); letter-spacing: -0.02em; color: var(--text);
}
.note-title:focus { outline: none; }
textarea.note-title { display: block; width: 100%; min-height: 0; resize: none; overflow: hidden; }
.write-wrap { position: relative; }
.note-editor {
  display: block; width: 100%; min-height: 320px; resize: none; overflow: hidden;
  padding: 6px 0; border: 0; background: transparent; box-shadow: none !important;
  font: 16px/1.75 var(--serif); color: var(--text);
}
.note-editor:focus { outline: none; }
.note-pane.read .write-wrap { display: none; }
.note-pane.write .note-read { display: none; }
.note-read { min-height: 200px; padding: 6px 0 10px; cursor: text; }
.note-read .task-line { cursor: pointer; padding: 2px 0; border-radius: 4px; }
.note-read .task-line:hover { background: var(--hover); }
.note-read .task-line.done { color: var(--text-3); text-decoration: line-through; }

a.wikilink {
  text-decoration: none !important; padding: 0 3px; border-radius: 4px;
  color: var(--accent-ink); background: var(--accent-dim); font-weight: 550;
}
a.wikilink.t-notes { color: var(--t-notes); background: color-mix(in srgb, var(--t-notes) 14%, transparent); }
a.wikilink.t-companies { color: var(--t-companies); background: color-mix(in srgb, var(--t-companies) 14%, transparent); }
a.wikilink.t-deals { color: var(--t-deals); background: color-mix(in srgb, var(--t-deals) 14%, transparent); }
a.wikilink.t-projects { color: var(--t-projects); background: color-mix(in srgb, var(--t-projects) 14%, transparent); }
a.wikilink.missing { color: var(--text-3); background: none; border-bottom: 1px dashed var(--rule-strong); border-radius: 0; }
a.wikilink:hover { filter: brightness(0.92); }

.wl-pop {
  position: absolute; z-index: 20; width: 300px;
  background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 4px;
}
.wl-head { padding: 6px 8px 4px; font: 600 11px var(--sans); letter-spacing: 0.06em;
           text-transform: uppercase; color: var(--text-3); }
.wl-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
           cursor: pointer; font-size: 14px; }
.wl-item.sel { background: var(--accent-dim); }

.unresolved { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.unresolved:empty { display: none; }
.chip.clickable { cursor: pointer; border: 0; }
.chip.clickable:hover { background: var(--accent-dim); color: var(--accent-ink); }

details.secret { margin: 10px 0 6px; border-top: 1px solid var(--rule); padding-top: 10px; }
details.secret summary { cursor: pointer; font-size: 13px; color: var(--text-2); }
.secret-input { margin-top: 8px; min-height: 90px; }
.note-pane > .connections { margin-top: 14px; box-shadow: none; background: var(--bg); }

.notes-welcome {
  padding: 60px 40px; text-align: center; border: 1px dashed var(--rule-strong);
  border-radius: var(--r-lg); display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.notes-welcome p { max-width: 460px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 34px; z-index: 30; min-width: 230px;
  background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 4px;
}
.menu-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: 500 13.5px var(--sans); cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--red); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
.only-mobile { display: none; }

@media (max-width: 960px) {
  .grid.c2, .grid.c3 { grid-template-columns: 1fr; gap: 14px; }
  .hero h1 { font-size: 32px; }
  .notes-app { grid-template-columns: 1fr; }
  .notes-side { position: static; max-height: none; }
  .notes-list { max-height: 260px; }
  .note-pane { padding: 14px 18px 22px; }
}

@media (max-width: 720px) {
  :root { --gutter: 16px; --row: 42px; }
  .shell { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40;
    transform: translateX(-101%); transition: transform 0.22s var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .field-row { grid-template-columns: 1fr; }
  .modal-box, .palette-box { margin-top: 5vh; }
  .drawer-box { inset: 0; width: 100%; border-radius: 0; }
  .toasts { bottom: calc(20px + env(safe-area-inset-bottom)); }
  .bulkbar { left: 12px; right: 12px; transform: none; overflow-x: auto; }
  .keys-grid { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
  .hero h1 { font-size: 28px; }
  #quick-add .label-text, #show-keys { display: none; }
}

/* --------------------------------------------------------------------------
   Phone — the native app shape: tab bar, sheets, safe areas
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  :root { --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom);
          --safe-l: env(safe-area-inset-left); --safe-r: env(safe-area-inset-right); }

  .sidebar, #menu-toggle, #quick-add, #show-keys { display: none !important; }

  /* iOS zooms into any field under 16px; native apps don't. */
  input, select, textarea { font-size: 16px; }

  .topbar {
    height: calc(52px + var(--safe-t));
    padding: var(--safe-t) max(10px, var(--safe-r)) 0 max(14px, var(--safe-l));
    gap: 2px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
  }
  .topbar h2 { font-size: 20px; }
  #nav-back { margin-left: -8px; }
  #nav-back .ico, #mobile-search .ico { width: 22px; height: 22px; }
  .topbar .icon-btn { width: 40px; height: 40px; }

  .view {
    padding: 4px max(14px, var(--safe-r)) calc(104px + var(--safe-b)) max(14px, var(--safe-l));
  }
  .view[data-dir="push"] { animation: push-in 0.3s var(--ease-out); }
  .view[data-dir="pop"] { animation: pop-in 0.3s var(--ease-out); }

  .tabbar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    height: calc(60px + var(--safe-b)); padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
    border-top: 1px solid var(--rule);
  }
  .tabbar a, .tabbar > button:not(.tab-fab) {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 100%; padding: 0; border: 0; background: none; cursor: pointer;
    font: 600 10.5px/1 var(--sans); letter-spacing: 0.01em; color: var(--text-3);
    transition: color 0.15s;
  }
  .tabbar .ico { width: 23px; height: 23px; opacity: 1; transition: transform 0.2s var(--ease-out); }
  .tabbar .active { color: var(--accent-ink); }
  .tabbar a:active .ico, .tabbar > button:active .ico { transform: scale(0.86); }
  .tab-fab {
    justify-self: center; display: grid; place-items: center;
    width: 54px; height: 54px; margin-top: -18px; border: 0; border-radius: 50%;
    background: var(--accent); color: var(--on-accent); cursor: pointer;
    box-shadow: 0 6px 18px -4px color-mix(in srgb, var(--accent) 60%, transparent),
                0 0 0 5px var(--bg);
    transition: transform 0.15s var(--ease-out);
  }
  .tab-fab .ico { width: 26px; height: 26px; }
  .tab-fab:active { transform: scale(0.9); }
  body.kb-open .tabbar { display: none; }
  body.kb-open .view { padding-bottom: 24px; }

  .toasts { bottom: calc(80px + var(--safe-b)); width: calc(100% - 28px); }
  body.kb-open .toasts { bottom: 16px; }

  /* Bottom sheets instead of side drawers and centred dialogs. */
  .drawer-box, .modal:not(#palette) .modal-box {
    position: absolute; inset: auto 0 0 0; margin: 0;
    width: 100%; max-width: none;
    max-height: calc(100dvh - var(--safe-t) - 18px); overflow-y: auto; overscroll-behavior: contain;
    padding: 28px max(18px, var(--safe-r)) calc(20px + var(--safe-b)) max(18px, var(--safe-l));
    border-radius: 20px 20px 0 0; border-bottom: 0;
    animation: sheet-in 0.34s var(--ease-out);
    transition: transform 0.25s var(--ease-out);
  }
  .drawer-box::before, .modal:not(#palette):not(#more) .modal-box::before {
    content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 5px; border-radius: 3px; background: var(--rule-strong);
  }
  .form-actions {
    position: sticky; bottom: calc(-20px - var(--safe-b)); margin-bottom: calc(-20px - var(--safe-b));
    padding: 14px 0 calc(14px + var(--safe-b)); background: var(--raised); z-index: 2;
  }
  .form-actions .btn { height: 42px; padding: 0 18px; }

  /* Search takes the whole screen, like a native search page. */
  .palette-box {
    margin: 0; width: 100%; max-width: none; height: 100dvh; border-radius: 0; border: 0;
    padding-top: var(--safe-t); display: flex; flex-direction: column;
  }
  .palette-results { flex: 1; max-height: none; padding-bottom: calc(12px + var(--safe-b)); }

  .more-box { padding-top: 14px; }
  .sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--rule-strong);
                margin: 0 auto 16px; }
  .more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
  .more-grid a {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px 6px 14px; border-radius: var(--r); color: var(--text);
    background: var(--surface); border: 1px solid var(--rule);
    font: 600 13px var(--sans); text-decoration: none;
  }
  .more-grid a .ico { width: 24px; height: 24px; opacity: 1; color: var(--text-2); }
  .more-grid a.active { border-color: var(--accent); color: var(--accent-ink); }
  .more-grid a.active .ico { color: var(--accent); }
  .more-grid a:active { transform: scale(0.96); }
  .more-list button {
    display: flex; align-items: center; gap: 14px; width: 100%; height: 52px; padding: 0 4px;
    border: 0; border-top: 1px solid var(--rule); background: none; cursor: pointer;
    font: 500 15px var(--sans); color: var(--text); text-align: left;
  }
  .more-list button .ico { width: 20px; height: 20px; color: var(--text-2); }
  .more-list button.danger { color: var(--red); }
  .more-list button.danger .ico { color: var(--red); }

  /* Rows: the title gets the whole first line; details drop to a subtitle. */
  .r:has(> .secondary) { flex-wrap: wrap; row-gap: 3px; padding-block: 9px; }
  .r .primary { flex: 1 1 0; font-size: 15px; }
  .r > .secondary { order: 10; flex: 1 0 100%; gap: 8px; overflow: hidden; white-space: nowrap; }
  .r:has(> .check) > .secondary { padding-left: 46px; }

  /* Bigger targets. */
  .r, .item { min-height: 50px; }
  .btn { min-height: 38px; }
  .btn.tiny { min-height: 32px; }
  .check { width: 22px; height: 22px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; max-width: 100%; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs > * { flex: none; }

  /* Notes: list and note take turns. */
  .notes-app.has-note .notes-side { display: none; }
  .notes-app:not(.has-note) .notes-main { display: none; }
  .notes-list { max-height: none; border-top: 0; }
  .nrow { padding: 12px 10px; }
  .note-pane { padding: 0; border: 0; background: none; box-shadow: none; }
  .note-title { font-size: 27px; }
  .note-top { gap: 8px; }
  .note-crumbs { min-width: 0; order: 2; flex-basis: 100%; }
  .note-actions { margin-left: auto; }
  .note-pane > .connections { background: var(--surface); }
  .netsvg .gn text { font-size: 13px; }

  .auth { padding-top: calc(24px + var(--safe-t)); padding-bottom: calc(24px + var(--safe-b)); }
}
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes push-in { from { opacity: 0; transform: translateX(26px); } }
@keyframes pop-in { from { opacity: 0; transform: translateX(-26px); } }

/* --------------------------------------------------------------------------
   Calendar
   -------------------------------------------------------------------------- */
.k-event    { --k: #4f7bb8; }
.k-task     { --k: var(--text-3); }
.k-reminder { --k: var(--amber); }
.k-birthday { --k: #c2557a; }
.k-date     { --k: #c2557a; }
.k-bill     { --k: var(--green); }
.k-deal     { --k: #c08a1e; }
.k-project  { --k: #8a63b8; }
.k-goal     { --k: #4f9a6a; }

.cal { display: flex; flex-direction: column; gap: 12px; }
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav .icon-btn { font-size: 20px; width: 32px; height: 32px; }
.cal-title { font: 600 21px/1.2 var(--serif); margin-left: 8px; white-space: nowrap; }
.cal-modes { margin: 0; }

.cal-quick { display: flex; flex-direction: column; gap: 6px; }
.cal-quick-input {
  width: 100%; height: 40px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface);
}
.cal-quick-input:focus { border-color: var(--accent); }
.cal-quick-preview:empty { display: none; }

.cal-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-filter {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 13px;
  border: 1px solid var(--rule); background: var(--surface);
  font-size: 12px; color: var(--text-2); cursor: pointer;
}
.cal-filter .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--k); }
.cal-filter.off { opacity: 0.45; }
.cal-filter.off .swatch { background: transparent; box-shadow: inset 0 0 0 1.5px var(--k); }

.cal-body[data-dir="next"] > * { animation: push-in 0.22s var(--ease-out); }
.cal-body[data-dir="prev"] > * { animation: pop-in 0.22s var(--ease-out); }

/* A chip on the month grid. */
.ev {
  --c: var(--ev, var(--k));
  display: flex; align-items: baseline; gap: 5px; width: 100%; min-width: 0;
  padding: 2px 6px; border: 0; border-radius: 5px;
  background: color-mix(in srgb, var(--c) 13%, transparent);
  color: var(--text); font-size: 12px; line-height: 1.35; text-align: left; cursor: pointer;
}
.ev:hover { background: color-mix(in srgb, var(--c) 22%, transparent); }
.ev.allday { background: var(--c); color: #fff; }
.ev.allday:hover { filter: brightness(1.06); }
.ev .t { flex: none; color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 11px; }
.ev .l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.k-task .l::before { content: "○ "; color: var(--text-3); }
.ev.tentative { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 14%, transparent) 0 6px,
  transparent 6px 10px); }
.ev.dragging { opacity: 0.4; }
.drop-over { background: var(--accent-dim) !important; box-shadow: inset 0 0 0 2px var(--accent); }

.month-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.month { border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--rule); }
.month-head > div {
  padding: 8px 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-3);
}
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(108px, 1fr); }
.month-grid .day {
  display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 6px;
  border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  cursor: default; transition: background 0.12s;
}
.month-grid .day:nth-child(7n) { border-right: 0; }
.month-grid .day:nth-last-child(-n + 7) { border-bottom: 0; }
.month-grid .day:hover { background: var(--hover); }
.month-grid .day.other { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.month-grid .day.other .num { color: var(--text-3); }
.month-grid .day.selected { box-shadow: inset 0 0 0 2px var(--accent-dim); }
.month-grid .num {
  align-self: flex-start; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.month-grid .day.today .num { background: var(--accent); color: var(--on-accent); }
.month-grid .evs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.month-grid .more {
  align-self: flex-start; border: 0; background: none; padding: 1px 6px;
  font-size: 11.5px; color: var(--text-2); cursor: pointer; border-radius: 5px;
}
.month-grid .more:hover { background: var(--selected); color: var(--text); }
.month-grid .dots { display: flex; gap: 3px; justify-content: center; }
.dot-ev { width: 5px; height: 5px; border-radius: 50%; background: var(--ev, var(--k)); }
.day-panel { position: sticky; top: 76px; }

/* Rows used by the agenda, the day panel, Today and person pages. */
.agenda-row {
  --c: var(--ev, var(--k));
  display: grid; grid-template-columns: 92px auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm); cursor: pointer;
}
.agenda-row:hover { background: var(--hover); }
.agenda-row .when { display: flex; flex-direction: column; font-size: 12.5px; color: var(--text-2);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.agenda-row .when .wday { font-size: 11px; color: var(--text-3); }
.agenda-row .bar { width: 4px; height: 26px; border-radius: 2px; background: var(--c); }
.agenda-row .check { border-color: var(--c); }
.agenda-row .body { min-width: 0; }
.agenda-row .primary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-row .sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-row.tentative .primary { font-style: italic; color: var(--text-2); }
.agenda-row.completing { opacity: 0.5; }
.agenda-row.leaving { opacity: 0; transition: opacity 0.3s; }
.card-body.list .agenda-row { padding: 8px 6px; }
.schedule-day {
  padding: 10px 6px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-3);
}
.schedule-day:first-child { padding-top: 2px; }

.agenda { display: flex; flex-direction: column; gap: 2px; max-width: 820px; }
.agenda-month { font: 600 18px/1.2 var(--serif); padding: 18px 0 6px; }
.agenda-month:first-child { padding-top: 0; }
.agenda-day {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--rule);
}
.agenda-date { text-align: center; padding-top: 6px; }
.agenda-date .dname { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.agenda-date .dnum { font-size: 22px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.agenda-day.today .dnum {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: 18px; margin-top: 2px;
}
.agenda-day.today .dname { color: var(--accent-ink); font-weight: 600; }
.agenda-list { display: flex; flex-direction: column; min-width: 0; }
.agenda-more { align-self: center; margin-top: 14px; }

/* Week grid */
.week {
  border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--surface); overflow: hidden;
  --cols: 52px repeat(var(--days, 7), minmax(0, 1fr));
}
.wk-head, .wk-allday, .wk-grid { display: grid; grid-template-columns: var(--cols); }
.wk-head { border-bottom: 1px solid var(--rule); }
/* Reserve the scroller's scrollbar width above it too, so columns line up. */
.wk-head, .wk-allday, .wk-scroll { overflow-y: hidden; scrollbar-gutter: stable; }
.wk-scroll { overflow-y: auto; }
.wk-day { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 8px 4px; }
.wk-day .dname { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.wk-day .dnum { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wk-day.today .dnum { color: var(--accent); }
.wk-allday { border-bottom: 1px solid var(--rule-strong); min-height: 30px; }
.wk-gutter { font-size: 10.5px; color: var(--text-3); text-align: right; padding: 6px 6px 0 0; }
.wk-allday-cell { display: flex; flex-direction: column; gap: 2px; padding: 3px; border-left: 1px solid var(--rule); min-width: 0; }
.wk-scroll { max-height: calc(100vh - 290px); min-height: 360px; overscroll-behavior: contain; }
.wk-grid { position: relative; }
.wk-hours { display: flex; flex-direction: column; }
.wk-hour { height: 48px; position: relative; }
.wk-hour span { position: absolute; top: -7px; right: 6px; font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.wk-col {
  position: relative; height: calc(48px * 24); border-left: 1px solid var(--rule);
  background-image: linear-gradient(var(--rule) 1px, transparent 1px);
  background-size: 100% 48px;
}
.wk-col.today { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.ev.block {
  position: absolute; flex-direction: column; align-items: stretch; gap: 0;
  padding: 3px 6px; overflow: hidden; border-left: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
}
.ev.block:hover { background: color-mix(in srgb, var(--c) 26%, var(--surface)); z-index: 2; }
.ev.block .l { font-weight: 600; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ev.block .t { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.block.short { flex-direction: row; align-items: baseline; gap: 6px; padding-top: 1px; }
.ev.block.short .l { -webkit-line-clamp: 1; flex: 1 1 auto; min-width: 2em; }
.ev.block.short .t { flex: 0 100 auto; min-width: 0; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 3; pointer-events: none; }
.now-line::before {
  content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--red);
}

/* Event editor */
.event-form { display: flex; flex-direction: column; gap: 12px; }
.big-input {
  font: 600 20px/1.3 var(--serif); padding: 8px 0; border: 0; border-bottom: 1px solid var(--rule);
  border-radius: 0; background: transparent; width: 100%;
}
.big-input:focus { border-bottom-color: var(--accent); outline: none; box-shadow: none; }
.when-grid { display: flex; flex-direction: column; gap: 8px; }
.when-line { display: grid; grid-template-columns: 52px minmax(0, 1fr) 120px; gap: 8px; align-items: center; }
.when-line:has(input.hidden) { grid-template-columns: 52px minmax(0, 1fr); }
.inline-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch-btn {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--rule-strong);
  background: var(--ev, var(--k-event, #4f7bb8));
}
.swatch-btn.none { background: conic-gradient(#4f7bb8 0 25%, #c2557a 0 50%, #4f9a6a 0 75%, #c08a1e 0); }
.swatch-btn.on { box-shadow: 0 0 0 2px var(--text); }
.people-picker { display: flex; flex-direction: column; gap: 6px; position: relative; }
.people-picker .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.people-picker .chips:empty { display: none; }
.person-chip { display: inline-flex; align-items: center; gap: 4px; padding-right: 3px; }
.chip-x { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 10px; padding: 2px 4px; border-radius: 50%; }
.chip-x:hover { background: var(--hover); color: var(--text); }
.people-picker .picker-results { display: flex; flex-direction: column; }
.picker-hit {
  text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer;
}
.picker-hit:hover, .picker-hit:focus { background: var(--hover); }
.form-actions.start { justify-content: flex-start; flex-wrap: wrap; border-top: 0; margin-top: 8px; padding-top: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 1100px) {
  .month-wrap { grid-template-columns: minmax(0, 1fr); }
  .day-panel { position: static; }
}

@media (max-width: 720px) {
  .cal { gap: 10px; }
  .cal-head { gap: 8px; }
  .cal-head > .grow, .cal-head > .btn.primary { display: none; }
  .cal-nav { width: 100%; }
  .cal-title { font-size: 20px; margin-left: 4px; order: -1; margin-right: auto; }
  .cal-modes { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .cal-modes .tab { justify-content: center; }
  .cal-filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px 2px; scrollbar-width: none; }
  .cal-filters::-webkit-scrollbar { display: none; }
  .cal-filter { flex: none; height: 30px; }
  .cal-quick-input { height: 44px; }

  .month { border-radius: var(--r); }
  .month-grid { grid-auto-rows: 52px; }
  .month-grid .day { align-items: center; padding: 5px 2px; gap: 4px; }
  .month-grid .num { align-self: center; height: 28px; min-width: 28px; font-size: 14px; }
  .month-grid .day.selected { box-shadow: none; }
  .month-grid .day.selected:not(.today) .num { background: var(--selected); }
  .month-grid .day:hover { background: none; }

  .agenda-row { grid-template-columns: 70px auto minmax(0, 1fr) auto; padding: 11px 6px; gap: 10px; }
  .agenda-row .when { font-size: 12px; white-space: normal; }
  .agenda-day { grid-template-columns: 44px minmax(0, 1fr); gap: 6px; }

  .week { --cols: 40px repeat(var(--days, 3), minmax(0, 1fr)); border-radius: var(--r); }
  .wk-scroll { max-height: calc(100dvh - 330px - var(--safe-b)); }
  .ev { font-size: 12.5px; }

  .when-line { grid-template-columns: 46px minmax(0, 1fr) 104px; }
}

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

.noscript { padding: 40px; text-align: center; color: var(--text-2); }
