/* Rajesh Portal — the Karma theme.
   Thyasaphu: ink and hingul red on ivory lokta paper. Tokens are lifted from
   karmaaccounts/03-website-launch/karma-accounts-site/assets/css/site.css so
   the portal and the company site cannot drift apart.

   The public site pins itself to light on purpose — the palette IS the brand.
   This is a private tool I open at night, so it keeps a dark rendering, built
   as the same ledger inverted: lokta ink on a dark ground, hingul still the
   only red. Fonts are the site's own self-hosted subsets; nothing is fetched
   from a CDN. */

@font-face {
  font-family: "Newsreader";
  src: url("/static/fonts/newsreader-var.woff2") format("woff2");
  font-weight: 300 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Jost";
  src: url("/static/fonts/jost-var.woff2") format("woff2");
  font-weight: 300 600; font-style: normal; font-display: swap;
}

:root {
  --bg: #F7F4EC;              /* lokta */
  --surface: #FFFDF7;         /* paper */
  --surface-soft: #F0ECE1;    /* sunk */
  --ink: #17130E;
  --muted: #6E6759;
  --line: #E0DACE;
  --line-strong: #C8C0B2;     /* stone */

  /* Brand: blue-black since 22.9.2026 (it was pine #34423F). The canonical
     palette is 01-identity/PALETTE.md in the karmaaccounts brand repository. */
  --brand: #151C2B;           /* blue-black: the brand fill, links, active filters */
  --brand-dark: #151C2B;      /* the toast ground */
  --brand-hover: #1B2438;     /* secondary dark surface: the button lifts */
  --brand-soft: #E8ECF2;      /* pale blue: selected and highlighted rows */
  --on-brand: #F7F4EC;
  --brand-rgb: 21, 28, 43;    /* #151C2B as a triple, for tinted shadows */

  /* Hingul red is a RUBRIC, never decoration: it marks what is genuinely
     late and nothing else. Bronze carries labels and eyebrows. */
  --red: #AE3527;
  --red-soft: #F7E9E6;
  --amber: #8A6438;           /* bronze-text, AA on ivory */
  --amber-soft: #F1E9DC;
  --blue: #4A443B;
  --blue-soft: #EDE9DF;
  /* Done and verified keep their green: a state, not the brand. */
  --ok: #34423F;
  --ok-soft: #E4E8E5;

  --surface-veil: rgba(247, 244, 236, .96);
  --danger-wash: #FBF3F1;
  --danger-line: #E3C6C0;
  --overlay: rgba(23, 19, 14, .42);

  /* The ledger has no soft edges. Max 4px radius, hairlines instead of
     shadows — the same restraint as the site. */
  --shadow: none;
  --radius: 4px;
  --radius-sm: 3px;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bar-bg: #F7F4EC;
  --bar-ink: #17130E;
  --bar-dim: #6E6759;
  --bar-hover: rgba(23, 19, 14, .05);
  --bar-rule: #C8C0B2;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141109;
    --surface: #1C1811;
    --surface-soft: #241F17;
    --ink: #EFEAE0;           /* lokta, inverted */
    --muted: #9A9184;
    --line: #302A20;
    --line-strong: #46402F;
    --brand: #A2ABBE;           /* blue-black lifted to read on the dark ground */
    --brand-dark: #1B2438;      /* the toast: lifted off the canvas */
    --brand-hover: #BBC2D1;
    --brand-soft: #1B2438;      /* secondary dark surface */
    --on-brand: #141109;
    --red: #D4695B;
    --red-soft: #331B17;
    --amber: #C79A5E;
    --amber-soft: #2D2314;
    --blue: #B9B1A2;
    --blue-soft: #262117;
    --ok: #9DB0A9;
    --ok-soft: #232C29;
    --surface-veil: rgba(28, 24, 17, .96);
    --danger-wash: #251510;
    --danger-line: #4C2C24;
    --overlay: rgba(0, 0, 0, .62);
    --bar-bg: #1C1811;
    --bar-ink: #EFEAE0;
    --bar-dim: #9A9184;
    --bar-hover: rgba(239, 234, 224, .07);
    --bar-rule: #302A20;
  }
}
:root[data-theme="dark"] {
  --bg: #141109;
  --surface: #1C1811;
  --surface-soft: #241F17;
  --ink: #EFEAE0;
  --muted: #9A9184;
  --line: #302A20;
  --line-strong: #46402F;
  --brand: #A2ABBE;           /* blue-black lifted to read on the dark ground */
  --brand-dark: #1B2438;      /* the toast: lifted off the canvas */
  --brand-hover: #BBC2D1;
  --brand-soft: #1B2438;      /* secondary dark surface */
  --on-brand: #141109;
  --red: #D4695B;
  --red-soft: #331B17;
  --amber: #C79A5E;
  --amber-soft: #2D2314;
  --blue: #B9B1A2;
  --blue-soft: #262117;
  --ok: #9DB0A9;
  --ok-soft: #232C29;
  --surface-veil: rgba(28, 24, 17, .96);
  --danger-wash: #251510;
  --danger-line: #4C2C24;
  --overlay: rgba(0, 0, 0, .62);
  --bar-bg: #1C1811;
  --bar-ink: #EFEAE0;
  --bar-dim: #9A9184;
  --bar-hover: rgba(239, 234, 224, .07);
  --bar-rule: #302A20;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 82px;
}
main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 44px; }
a { color: var(--brand); text-decoration: none; }
h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-optical-sizing: auto;
     font-size: clamp(1.75rem, 4vw, 2.3rem); line-height: 1.14; letter-spacing: -.012em; text-wrap: balance; }
h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-optical-sizing: auto;
     font-size: 1.24rem; line-height: 1.22; letter-spacing: -.012em; text-wrap: balance; }
p { margin: 0; }
button, input, select, textarea { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Header */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--bar-bg); color: var(--bar-ink); border-bottom: 1px solid var(--bar-rule); }
.topbar-inner { max-width: 1160px; height: 66px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--bar-ink); font-weight: 500; letter-spacing: .03em; white-space: nowrap; }
.brand-mark { width: 26px; height: 24px; display: grid; place-items: center; color: var(--bar-ink); }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-name { font-size: .92rem; text-transform: uppercase; letter-spacing: .17em; }
.brand-name > span { opacity: .55; font-weight: 300; }
.linkbtn { border: 0; background: none; color: var(--bar-dim); cursor: pointer; padding: 8px 10px; font-size: .83rem; letter-spacing: .045em; }
.mobile-icons { display: none; margin-left: auto; align-items: center; }
.mobile-icons a { width: 40px; height: 40px; display: grid; place-items: center; color: var(--bar-ink); border-radius: 3px; font-size: 1rem; }

/* Page framing */
.page-hero { min-height: 104px; display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 18px; }
.page-hero p { color: var(--muted); margin-top: 7px; }
.compact-hero { min-height: 92px; }
.eyebrow, .section-kicker { display: block; color: var(--amber); font-size: .7rem; font-weight: 500; letter-spacing: .19em; text-transform: uppercase; margin-bottom: 8px; }
.danger-text { color: var(--red); }
/* The loud one: something that silently stops reminders or backups. Hingul,
   because it is late by definition — the thing it guards has already failed. */
.system-alert { max-width: 1080px; margin: 14px auto 0; padding: 13px 15px; display: grid;
  grid-template-columns: 26px minmax(0,1fr) auto; gap: 12px; align-items: center;
  background: var(--red-soft); color: var(--ink); border: 1px solid var(--red);
  border-left-width: 5px; border-radius: var(--radius-sm); }
.system-alert strong { color: var(--red); font-size: .95rem; }
.system-alert p { margin: 3px 0 0; font-size: .86rem; line-height: 1.45; }
.system-alert-mark { width: 26px; height: 26px; border-radius: 50%; background: var(--red);
  color: var(--red-soft); display: grid; place-items: center; font-weight: 700; }
.system-alert .btn { white-space: nowrap; }
@media (max-width: 820px) {
  .system-alert { margin: 10px 12px 0; grid-template-columns: 22px minmax(0,1fr); }
  .system-alert .btn { grid-column: 2; justify-self: start; }
  .system-alert-mark { width: 22px; height: 22px; }
}
.flash { max-width: 1080px; margin: 14px auto 0; padding: 11px 15px; background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok); border-radius: var(--radius-sm); font-size: .9rem; }

/* Cards */
.card, .capture-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card { padding: 18px; }
/* The section-closing device from the identity: the total line. */
.section-heading { border-bottom: 3px double var(--line-strong); padding-bottom: 9px; }
.card.danger { background: var(--danger-wash); border-color: var(--danger-line); }
.section { margin-top: 18px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.section-heading > a { font-size: .82rem; font-weight: 650; white-space: nowrap; padding-top: 4px; }

/* Capture */
.capture-card { padding: 15px; margin-bottom: 14px; border-color: var(--line); }
.capture-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.capture-heading > div { display: flex; flex-direction: column; }
.capture-heading strong { font-size: .91rem; }
.capture-heading small { color: var(--muted); font-size: .76rem; }
.capture-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 4px; }
.quickadd { display: flex; gap: 9px; }
.quickadd input { min-width: 0; flex: 1; height: 48px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink); background: var(--surface-soft); outline: none; }
.quickadd input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.prompt-chips { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.prompt-chips button { border: 0; color: var(--muted); background: var(--surface-soft); border-radius: 2px; padding: 6px 10px; font-size: .75rem; font-weight: 650; cursor: pointer; }
.prompt-chips button:hover { color: var(--brand); background: var(--brand-soft); }

/* Buttons */
button, .btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--brand); border-radius: 4px; padding: 9px 15px; background: var(--brand); color: var(--on-brand); font-weight: 680; cursor: pointer; text-align: center; }
button:hover, .btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.secondary, button.secondary { color: var(--brand); background: var(--surface); border-color: var(--line-strong); }
.btn.secondary:hover, button.secondary:hover { background: var(--brand-soft); }
.btn.danger, button.danger { color: var(--red); background: var(--surface); border-color: var(--danger-line); }
.btn.small, button.small { min-height: 34px; padding: 6px 10px; border-radius: 4px; font-size: .78rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 18px; }

/* Stats and dashboard */
.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat { min-height: 104px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-content: center; column-gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 15px; color: var(--ink); box-shadow: none; }
.stat:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat b { grid-row: 1 / 3; grid-column: 2; align-self: center; font-family: var(--serif); font-weight: 400;
          font-size: 2.1rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .83rem; font-weight: 720; }
.stat-foot { color: var(--muted); font-size: .72rem; }
.stat.primary { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.stat.red { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .8fr); gap: 14px; align-items: start; }
.dashboard-main, .dashboard-side { display: grid; gap: 14px; }

/* Task and meeting rows */
.task-row { min-height: 74px; display: grid; grid-template-columns: 38px minmax(0,1fr) 20px; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.complete-form { margin: 0; }
.complete-btn { width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 50%; border: 1.5px solid var(--line-strong); color: transparent; background: var(--surface); font-size: .9rem; }
.complete-btn:hover { color: var(--on-brand); border-color: var(--ok); background: var(--ok); }
.complete-btn.is-done { color: var(--on-brand); border-color: var(--ok); background: var(--ok); }
.task-body { min-width: 0; }
.task-title { display: block; color: var(--ink); font-size: .96rem; font-weight: 670; overflow-wrap: anywhere; }
.task-row.overdue .task-title { color: var(--red); }
.task-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 5px; color: var(--muted); font-size: .76rem; }
.time-pill, .date-label { color: var(--muted); font-variant-numeric: tabular-nums; }
.overdue-label { color: var(--red); font-weight: 620; }
.row-arrow { color: var(--muted); font-size: 1.35rem; font-weight: 350; }
.meeting-row, .upcoming-row { display: grid; align-items: center; gap: 11px; min-height: 66px; border-bottom: 1px solid var(--line); color: var(--ink); }
.meeting-row { grid-template-columns: 52px 1fr; }
.upcoming-row { grid-template-columns: 44px minmax(0,1fr) 15px; }
.meeting-row:last-child, .upcoming-row:last-child { border-bottom: 0; }
.meeting-time { color: var(--brand); font-weight: 760; font-size: .84rem; font-variant-numeric: tabular-nums; }
.meeting-row strong, .upcoming-row strong { display: block; font-size: .88rem; }
.meeting-row small, .upcoming-row small { display: block; color: var(--muted); margin-top: 2px; font-size: .74rem; }
.date-tile { width: 40px; height: 45px; display: grid; place-content: center; text-align: center; border-radius: 4px; background: var(--surface-soft); border: 1px solid var(--line); }
.date-tile b { font-size: .95rem; line-height: 1; }
.date-tile small { font-size: .58rem; color: var(--muted); margin-top: 2px; }
.connection-strip { min-height: 72px; display: grid; grid-template-columns: 38px minmax(0,1fr) 18px; align-items: center; gap: 10px; padding: 13px 15px; border-radius: 4px; color: var(--ink); border: 1px solid var(--line); background: var(--brand-soft); }
.connection-strip.disconnected { background: var(--amber-soft); border-color: var(--line); }
.connection-strip strong, .connection-strip small { display: block; }
.connection-strip strong { font-size: .86rem; }
.connection-strip small { color: var(--muted); font-size: .72rem; }
.connection-icon { width: 36px; height: 36px; display: grid; place-items: center; background: var(--surface); border-radius: 4px; }

/* Filters and task list */
.filters { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }
.segmented { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.filters a, .chip { flex: 0 0 auto; min-height: 36px; display: inline-flex; align-items: center; padding: 7px 13px; border-radius: 2px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .8rem; font-weight: 650; }
.filters a.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.filters a.red-chip.on { background: var(--red); border-color: var(--red); }
.filterbar { display: grid; grid-template-columns: auto auto auto minmax(200px,1fr); gap: 8px; align-items: center; margin-bottom: 12px; }
.filterbar > select, .inline-status select, .inline-move input { min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); font-size: .8rem; }
.search-field { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; align-items: center; min-height: 42px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); overflow: hidden; }
.search-field > span { text-align: right; color: var(--muted); }
.search-field input { min-width: 0; height: 40px; border: 0; padding: 0 10px; outline: none; color: var(--ink); background: transparent; }
.search-field button { min-height: 34px; margin-right: 4px; padding: 5px 10px; font-size: .75rem; border-radius: 4px; }
.task-list-card { padding: 4px 18px; }
.task-row.list-row { grid-template-columns: 38px minmax(200px,1fr) auto 18px; min-height: 88px; }
.task-quick-actions { display: flex; align-items: center; gap: 6px; }
.task-open { display: block; }

/* Meetings list */
.meeting-list { display: grid; gap: 10px; }
.meeting-card { display: grid; grid-template-columns: 84px minmax(0,1fr) auto; align-items: center; gap: 18px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }
.meeting-date { min-height: 78px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.meeting-date b { font-size: 1.45rem; line-height: 1; }
.meeting-date span { color: var(--muted); font-size: .68rem; }
.meeting-date small { color: var(--brand); font-size: .76rem; font-weight: 720; margin-top: 5px; }
.meeting-info > a { color: var(--ink); font-size: 1.02rem; font-weight: 720; }
.meeting-info p { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.meeting-info .text-link { display: inline-block; color: var(--brand); font-size: .75rem; margin-top: 7px; }

/* Legacy item rows and logs */
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .when { min-width: 78px; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.item .title { flex: 1; min-width: 0; }
.item .title > a { color: var(--ink); font-weight: 650; }
.item .title small { display: block; color: var(--muted); margin-top: 3px; font-size: .76rem; }
.loglist { list-style: none; margin: 0; padding: 0; }
.loglist li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .87rem; }
.loglist li:last-child { border-bottom: 0; }
.loglist .meta, .meta { color: var(--muted); font-size: .74rem; margin-top: 3px; }

/* Badges */
.badge { display: inline-flex; align-items: center; min-height: 20px; padding: 2px 7px; border-radius: 2px; font-size: .66rem; line-height: 1; font-weight: 720; white-space: nowrap; text-transform: capitalize; }
.badge.work, .badge.medium, .badge.scheduled { background: var(--blue-soft); color: var(--blue); }
.badge.personal, .badge.high { background: var(--amber-soft); color: var(--amber); }
.badge.low, .badge.open, .badge.cancelled { background: var(--surface-soft); color: var(--muted); }
.badge.critical, .badge.missed { background: var(--red-soft); color: var(--red); }
.badge.in_progress { background: var(--blue-soft); color: var(--blue); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.inbound { background: var(--brand-soft); color: var(--brand); }
.badge.outbound { background: var(--blue-soft); color: var(--blue); }

/* Forms */
form.stack label { display: block; margin: 14px 0 5px; color: var(--muted); font-size: .78rem; font-weight: 700; }
form.stack input[type=text], form.stack input[type=date], form.stack input[type=time], form.stack input[type=email], form.stack input[type=password], form.stack input[type=number], form.stack select, form.stack textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink); background: var(--surface); outline: none;
}
form.stack input:focus, form.stack select:focus, form.stack textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
form.stack textarea { min-height: 100px; resize: vertical; }
.formrow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.formrow3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.form-card { max-width: 780px; }
.form-note { padding: 11px 13px; border-radius: 4px; background: var(--surface-soft); color: var(--muted); font-size: .78rem; }

/* Empty and message states */
.empty, .muted { color: var(--muted); }
.empty { padding: 12px 0; font-size: .86rem; }
.empty-state { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 24px; }
.empty-state > span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand); margin-bottom: 9px; }
.empty-state strong { color: var(--ink); }
.empty-state small { margin-top: 3px; }
.empty-state .btn { margin-top: 12px; }
.empty-state.compact { min-height: 108px; padding: 12px; }
.empty-state.compact > span { width: 32px; height: 32px; margin-bottom: 6px; }
.small-note { color: var(--muted); font-size: .78rem; margin-top: 7px; }
.warn-banner, .error-banner { border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 12px; font-size: .85rem; }
.warn-banner { background: var(--amber-soft); border: 1px solid var(--amber); color: var(--amber); }
.error-banner { background: var(--red-soft); border: 1px solid var(--red); color: var(--red); }
.error-banner .btn { margin-left: 8px; }
.sandbox-card { background: var(--amber-soft); border: 1px solid var(--amber); border-radius: 4px; padding: 13px; margin: 12px 0; }
.sandbox-card p { margin: 5px 0 10px; font-size: .84rem; }
.delivery.failed, .delivery.undelivered { color: var(--red); font-weight: 700; }
.delivery.delivered, .delivery.read, .delivery.sent { color: var(--ok); font-weight: 650; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, var(--brand-soft), transparent 35%), var(--bg); }
.login-wrap { width: 100%; max-width: 410px; }
.login-wrap .card { padding: 28px; }
.login-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; }
.login-brand .brand-mark { width: 48px; height: 48px; margin-bottom: 10px; background: var(--brand); color: var(--on-brand); }
.login-brand strong { font-size: 1.18rem; }
.login-brand small { color: var(--muted); margin-top: 3px; }
.error { background: var(--red-soft); color: var(--red); border-radius: 4px; padding: 10px 12px; margin-bottom: 10px; font-size: .86rem; }

/* Mobile navigation and create menu */
.bottomnav, .quick-menu { display: none; }

@media (max-width: 820px) {
  body { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  main { padding: 18px 14px 34px; }
  .topbar-inner { height: 60px; padding: 0 15px; }
  .brand-mark { width: 32px; height: 32px; }
  .mobile-icons { display: flex; }
  .desktop-action { display: none; }
  .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-side { grid-template-columns: 1fr 1fr; align-items: start; }
  .connection-strip { grid-column: 1 / -1; }
  .bottomnav { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5,1fr); align-items: end; height: calc(70px + env(safe-area-inset-bottom)); padding: 7px 7px calc(7px + env(safe-area-inset-bottom)); background: var(--surface-veil); border-top: 1px solid var(--line); backdrop-filter: blur(14px); box-shadow: 0 -8px 30px rgba(var(--brand-rgb),.06); }
  .bottomnav a { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .62rem; font-weight: 620; }
  .bottomnav a.on { color: var(--brand); }
  .nav-icon { width: 27px; height: 27px; display: grid; place-items: center; font-size: 1.05rem; font-weight: 760; }
  .overdue-dot { border-radius: 50%; color: var(--on-brand); background: var(--red); font-size: .75rem; width: 20px; height: 20px; margin: 3px; }
  .fab { justify-self: center; align-self: start; width: 50px; height: 50px; min-height: 50px; padding: 0; margin-top: -25px; border: 4px solid var(--bg); border-radius: 50%; font-size: 1.55rem; box-shadow: 0 6px 18px rgba(var(--brand-rgb),.28); }
  .fab.open { transform: rotate(45deg); }
  .quick-menu { position: fixed; z-index: 49; left: 14px; right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); padding: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 15px 45px rgba(var(--brand-rgb),.18); }
  .quick-menu:not([hidden]) { display: grid; gap: 5px; }
  .quick-form { margin: 0; }
  .quick-form button { width: 100%; min-height: 0; text-align: left; font: inherit; border: 0; background: transparent; cursor: pointer; }
  .quick-menu a, .quick-form button { display: grid; grid-template-columns: 38px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 10px; color: var(--ink); border-radius: 4px; }
  .quick-menu a:hover, .quick-form button:hover { background: var(--surface-soft); }
  .quick-menu a > span, .quick-form button > span { grid-row: 1 / 3; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 4px; background: var(--brand-soft); color: var(--brand); font-weight: 760; }
  .quick-menu strong { font-size: .87rem; }
  .quick-menu small { color: var(--muted); font-size: .72rem; }
}

@media (max-width: 600px) {
  h1 { font-size: 1.65rem; }
  .page-hero { min-height: 88px; margin-bottom: 10px; }
  .compact-hero { align-items: flex-end; }
  .compact-hero .btn { min-height: 38px; padding: 7px 10px; font-size: .77rem; }
  .page-hero p { font-size: .82rem; }
  .capture-card { padding: 13px; }
  .capture-heading small { display: none; }
  .quickadd input { height: 46px; font-size: .91rem; }
  .quickadd button { min-height: 46px; padding: 8px 12px; font-size: .84rem; }
  .statrow { gap: 7px; }
  .stat { min-height: 82px; display: flex; flex-direction: column; align-items: flex-start; padding: 11px; }
  .stat b { order: -1; font-size: 1.55rem; }
  .stat-label { font-size: .73rem; }
  .stat-foot { display: none; }
  .card { padding: 15px; }
  .task-row { min-height: 72px; }
  .dashboard-side { grid-template-columns: 1fr; }
  .connection-strip { grid-column: auto; }
  .filterbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; grid-row: 1; }
  .task-list-card { padding: 3px 13px; }
  .task-row.list-row { grid-template-columns: 36px minmax(0,1fr) 16px; min-height: 76px; padding: 5px 0; }
  .task-quick-actions { display: none; }
  .meeting-card { grid-template-columns: 62px minmax(0,1fr); gap: 12px; padding: 14px; }
  .meeting-date { min-height: 70px; }
  .meeting-card > form { grid-column: 2; }
  .formrow, .formrow3 { grid-template-columns: 1fr; gap: 0; }
  .actions.mobile-sticky { position: sticky; bottom: 76px; z-index: 10; margin: 18px -15px -15px; padding: 10px 15px; background: var(--surface-veil); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
  .error-banner .btn { display: flex; margin: 8px 0 0; }
}

/* ------------------------------------------------------------------ *
 * Phase 1 additions: clients, command palette, toasts, day column.
 * ------------------------------------------------------------------ */

/* Top-bar tools */
.iconbtn {
  width: 38px; height: 38px; min-height: 38px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 3px; background: transparent; color: var(--bar-ink);
  font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.iconbtn:hover { background: var(--bar-hover); }
.mobile-icons .iconbtn { width: 40px; height: 40px; }

/* The day column: one ordered read, no side-by-side scanning. */
.day-column { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }

/* Clients */
.client-list-card { padding: 4px 18px; }
.client-row {
  display: grid; grid-template-columns: 40px minmax(0,1fr) auto 16px;
  align-items: center; gap: 14px; padding: 13px 0;
  border-bottom: 1px solid var(--line); color: var(--ink);
}
.client-row:last-child { border-bottom: 0; }
.client-row:hover { color: var(--brand); }
.client-row.is-archived { opacity: .55; }
.client-mark {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 4px;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 1rem;
}
.client-mark.kind-employer { background: var(--blue-soft); color: var(--blue); }
.client-mark.kind-own { background: var(--amber-soft); color: var(--amber); }
.client-mark.kind-study { background: var(--surface-soft); color: var(--muted); }
.client-body { display: grid; gap: 3px; min-width: 0; }
.client-body strong { font-size: .97rem; letter-spacing: -.01em; }
.client-body small { color: var(--muted); font-size: .78rem; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.client-count {
  min-width: 28px; height: 26px; padding: 0 8px; display: grid; place-items: center;
  border-radius: 2px; background: var(--surface-soft); color: var(--muted);
  font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.badge.kind { text-transform: capitalize; background: var(--surface-soft); color: var(--muted); }
.badge.kind-employer { background: var(--blue-soft); color: var(--blue); }
.badge.kind-own { background: var(--amber-soft); color: var(--amber); }
.badge.client-chip { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
a.badge.client-chip:hover { background: var(--brand); color: var(--on-brand); }

/* A completed row stays visible so Undo has something to point at. */
.task-row.is-complete .task-title { text-decoration: line-through; color: var(--muted); }
.task-row.is-complete { opacity: .62; }
.date-tile.done { background: var(--ok-soft); color: var(--ok); }

/* Forms shared by the client pages */
.form-card.tight { padding: 0; box-shadow: none; border: 0; background: transparent; }
.form-card label { display: block; margin-bottom: 12px; font-size: .82rem; font-weight: 650; color: var(--muted); }
.form-card label input, .form-card label select, .form-card label textarea { margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid select, .form-grid input { max-width: 100%; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.danger-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.linkbtn.subtle { color: var(--muted); font-size: .82rem; font-weight: 600; }
.linkbtn.subtle:hover { color: var(--red); }
.search-page-form { padding: 16px; }
.search-field.wide { grid-template-columns: 34px minmax(0,1fr) auto; min-height: 48px; }

/* Toasts */
.toast-host { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: 22px; display: grid; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px 11px 16px; border-radius: 4px;
  background: var(--brand-dark); color: #fff; font-size: .87rem; font-weight: 600;
  box-shadow: 0 14px 40px rgba(0,0,0,.28); max-width: min(92vw, 460px);
}
.toast span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast form { margin: 0; }
.toast-undo, .toast-close {
  min-height: 30px; padding: 4px 11px; border-radius: 4px; border: 1px solid rgba(255,255,255,.35);
  background: transparent; color: #fff; font-size: .82rem; font-weight: 700;
}
.toast-undo:hover, .toast-close:hover { background: rgba(255,255,255,.16); }
.toast-close { padding: 4px 9px; border-color: transparent; font-size: 1rem; }

/* Command palette */
.palette {
  width: min(620px, 94vw); padding: 0; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.30);
  margin-top: 11vh;
}
.palette::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.palette-form { display: grid; grid-template-columns: 40px minmax(0,1fr) auto; align-items: center; border-bottom: 1px solid var(--line); }
.palette-icon { display: grid; place-items: center; color: var(--muted); font-size: 1.05rem; }
.palette-form input {
  width: 100%; min-height: 56px; padding: 12px 4px; border: 0; outline: none;
  background: transparent; color: var(--ink); font-size: 1.02rem;
}
.palette-form kbd {
  margin-right: 13px; padding: 3px 7px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--surface-soft); color: var(--muted); font-size: .68rem; font-family: inherit;
}
.palette-results-host { max-height: min(52vh, 420px); overflow-y: auto; }
.palette-results { list-style: none; margin: 0; padding: 6px; }
.palette-results a {
  display: grid; grid-template-columns: 28px minmax(0,1fr) auto; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 4px; color: var(--ink);
}
.palette-results a:hover, .palette-results a:focus-visible { background: var(--brand-soft); outline: none; }
.palette-kind { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 4px; background: var(--surface-soft); color: var(--muted); font-size: .8rem; }
.palette-body { display: grid; gap: 2px; min-width: 0; }
.palette-body strong { font-size: .92rem; font-weight: 640; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-body small { color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-type { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; }
.palette-empty { padding: 26px 20px; text-align: center; color: var(--muted); font-size: .88rem; display: grid; gap: 11px; justify-items: center; }
.palette-empty p { margin: 0; }
.palette-foot { display: flex; gap: 16px; padding: 11px 16px; border-top: 1px solid var(--line); font-size: .8rem; font-weight: 640; }
.palette-static .palette-results { padding: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 760px) {
  .day-column { max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .toast-host { left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); transform: none; }
  .toast { max-width: none; }
  .palette { margin-top: 6vh; width: 96vw; }
  .client-row { grid-template-columns: 38px minmax(0,1fr) auto 14px; gap: 11px; }
}

/* ------------------------------------------------------------------ *
 * Phase 2: notes, links and the markdown editor.
 * ------------------------------------------------------------------ */

.hero-actions { display: flex; gap: 8px; align-items: center; }
.filter-label { align-self: center; color: var(--muted); font-size: .76rem; font-weight: 650; margin-right: 2px; }
.small-note { font-size: .82rem; margin-bottom: 10px; }

/* Notes list */
.note-list-card { padding: 4px 18px; }
.note-row {
  display: grid; grid-template-columns: 34px minmax(0,1fr) 16px; align-items: center;
  gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line); color: var(--ink);
}
.note-row:last-child { border-bottom: 0; }
.note-row:hover { color: var(--brand); }
.note-mark {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 4px;
  background: var(--surface-soft); color: var(--muted); font-size: .95rem;
}
.note-mark.daily { background: var(--amber-soft); color: var(--amber); }
.note-body { display: grid; gap: 3px; min-width: 0; }
.note-body strong { font-size: .95rem; letter-spacing: -.01em; }
.note-body small { color: var(--muted); font-size: .77rem; }
.pin { color: var(--amber); }

/* The rendered note */
.note-body-card { padding: 22px 24px; }
.note-body { font-size: 1rem; line-height: 1.62; }
.card.note-body { padding: 22px 24px; }
.note-body > *:first-child { margin-top: 0; }
.note-body > *:last-child { margin-bottom: 0; }
.note-body h1, .note-body h2, .note-body h3 {
  margin: 26px 0 10px; line-height: 1.22; letter-spacing: -.02em; text-wrap: balance;
}
.note-body h1 { font-size: 1.5rem; }
.note-body h2 { font-size: 1.2rem; }
.note-body h3 { font-size: 1.02rem; }
.note-body p { margin: 0 0 13px; }
.note-body ul, .note-body ol { margin: 0 0 13px; padding-left: 22px; }
.note-body li { margin-bottom: 5px; }
.note-body blockquote {
  margin: 0 0 14px; padding: 2px 0 2px 15px;
  border-left: 3px solid var(--line-strong); color: var(--muted);
}
.note-body code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .87em;
  background: var(--surface-soft); padding: .12em .36em; border-radius: 4px;
}
.note-body pre {
  background: var(--surface-soft); border: 1px solid var(--line); border-radius: 4px;
  padding: 13px 15px; overflow-x: auto; margin: 0 0 14px;
}
.note-body pre code { background: none; padding: 0; font-size: .84rem; line-height: 1.55; }
.note-body table { border-collapse: collapse; width: 100%; margin: 0 0 14px; font-size: .9rem; display: block; overflow-x: auto; }
.note-body th, .note-body td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.note-body th { background: var(--surface-soft); font-weight: 650; }
.note-body hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.note-body img { max-width: 100%; height: auto; border-radius: 4px; }

.wikilink {
  background: var(--brand-soft); color: var(--brand); padding: .06em .34em;
  border-radius: 4px; font-weight: 600; white-space: nowrap;
}
.wikilink:hover { background: var(--brand); color: var(--on-brand); }
.wikilink.unresolved {
  background: transparent; color: var(--muted);
  border-bottom: 1px dashed var(--line-strong); border-radius: 0; padding: 0;
}
.wikilink.unresolved:hover { color: var(--amber); border-bottom-color: var(--amber); }

/* Link and backlink rows */
.link-row {
  display: grid; grid-template-columns: auto minmax(0,1fr); gap: 10px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: .9rem;
}
.link-row:last-child { border-bottom: 0; }
.link-row:hover { color: var(--brand); }
.link-row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-kind {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  color: var(--muted); background: var(--surface-soft); padding: 3px 7px; border-radius: 4px;
}
.link-row.is-missing .link-kind { background: var(--amber-soft); color: var(--amber); }
.stacked-actions { display: grid; gap: 8px; }
.stacked-actions form { margin: 0; }
.stacked-actions .btn { width: 100%; }

/* Promote a checkbox into a task */
.promote-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 9px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.promote-row:last-child { border-bottom: 0; }
.promote-text { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.promote-row input[type="date"] {
  min-height: 36px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); color: var(--ink); font-size: .8rem;
}

/* Markdown editor */
.editor-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.editor-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.chipbtn {
  min-height: 32px; padding: 5px 11px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: .76rem; font-weight: 650;
}
.chipbtn:hover { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand); }
.chipbtn.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.markdown-input {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88rem; line-height: 1.6;
  min-height: 320px; resize: vertical; tab-size: 2;
}
.note-preview {
  margin-top: 14px; padding: 16px 18px; border: 1px dashed var(--line-strong);
  border-radius: 4px; background: var(--surface-soft);
}
.conflict-text {
  white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .82rem; line-height: 1.55; background: var(--surface-soft);
  border: 1px solid var(--line); border-radius: 4px; padding: 14px; overflow-x: auto;
  max-height: 420px; overflow-y: auto;
}
.syntax-help .loglist code { font-size: .82rem; }

@media (max-width: 760px) {
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; }
  .promote-row { grid-template-columns: 1fr; }
  .card.note-body { padding: 17px 16px; }
}

/* Checkboxes inside a rendered note. Disabled on purpose — ticking here would
   have nowhere to save to; "make a task" on the note page is the real action. */
.note-body li.task-item { list-style: none; margin-left: -22px; display: flex; gap: 9px; align-items: baseline; }
.note-body li.task-item input[type="checkbox"] { margin: 0; accent-color: var(--brand); flex: 0 0 auto; }
.note-body li.task-item.is-checked { color: var(--muted); text-decoration: line-through; }

/* ------------------------------------------------------------------ *
 * Karma theme — the pieces that are more than a change of colour.
 * ------------------------------------------------------------------ */

/* The wordmark: the mark leads, the name stays quiet. Same relationship as
   the locked lockup — KARMA at 500, the second word lighter. */
.brand-name > span { font-weight: 300; letter-spacing: .17em; }

.login-brand .brand-mark {
  width: 46px; height: 42px; margin-bottom: 14px; background: none;
  color: var(--ink); box-shadow: none;
}
.login-brand .brand-mark svg { width: 100%; height: 100%; display: block; }
.login-brand strong {
  font-family: var(--sans); font-weight: 500; font-size: 1rem;
  text-transform: uppercase; letter-spacing: .19em;
}
.login-brand strong > span { font-weight: 300; }
.login-brand small { color: var(--muted); font-style: italic; font-family: var(--serif); }

/* Eyebrow and section labels sit above a hairline, the way the site rules
   its sections. */
.page-hero { border-bottom: 1px solid var(--line); padding-bottom: 16px; }

/* Filters read as ruled tabs, not pills — the site uses rules, not chips. */
.filters.segmented { gap: 22px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.filters a, .chip {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 8px 0 9px; color: var(--muted);
  font-size: .82rem; font-weight: 400; letter-spacing: .04em;
}
.filters a:hover { color: var(--ink); }
.filters a.on {
  background: transparent; border-bottom-color: var(--amber); color: var(--ink); font-weight: 500;
}
.filters a.red-chip { color: var(--red); }

/* Labels are set, not bubbled. */
.badge {
  border-radius: 2px; font-weight: 500; letter-spacing: .05em;
  text-transform: uppercase; font-size: .66rem;
}

/* Every figure in the portal is a number in a ledger. */
.stat b, .client-count, .date-tile b, .fact dd { font-variant-numeric: tabular-nums; }

/* Hingul red is a rubric: it marks what is genuinely late, nothing else. */
.overdue-card { border-left: 2px solid var(--red); }

/* Buttons are set type on a ground, not lozenges. */
button, .btn { border-radius: 2px; font-weight: 500; letter-spacing: .04em; }
.btn.small, button.small { border-radius: 2px; }

/* The rendered note is the one place that gets the reading face. */
.note-body { font-family: var(--serif); font-size: 1.04rem; line-height: 1.68; }
.note-body code, .note-body pre { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.note-body h1, .note-body h2, .note-body h3 { font-family: var(--serif); font-weight: 500; }
.wikilink { border-radius: 2px; font-weight: 500; }

/* Almost no motion, as on the site. */
.stat:hover { transform: none; }

/* Waiting on someone else. Bronze, not red: it is not late, it is not mine. */
.badge.waiting {
  background: var(--amber-soft); color: var(--amber); text-transform: none;
  letter-spacing: .01em; max-width: 22ch; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.field-note { font-size: .8rem; margin: -6px 0 14px; line-height: 1.5; }

/* Client contact block — a label/value list, ruled like a ledger. */
.factlist { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 0 16px; margin: 0; }
.factlist dt {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
  padding: 9px 0; border-bottom: 1px solid var(--line); align-self: center;
}
.factlist dd {
  margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .9rem;
  overflow: hidden; text-overflow: ellipsis;
}
.factlist dt:last-of-type, .factlist dd:last-of-type { border-bottom: 0; }
.badge.form { background: var(--surface-soft); color: var(--ink); font-weight: 500; }

/* ------------------------------------------------------------------ *
 * Obligations — the statutory spine.
 * ------------------------------------------------------------------ */
.obligation-row {
  display: grid; grid-template-columns: 46px minmax(0,1fr) auto auto 16px;
  align-items: center; gap: 13px; padding: 12px 0;
  border-bottom: 1px solid var(--line); color: var(--ink);
}
.obligation-row:last-of-type { border-bottom: 0; }
.obligation-row:hover { color: var(--brand); }
.ob-date {
  display: grid; justify-items: center; padding: 5px 0; border: 1px solid var(--line);
  background: var(--surface-soft);
}
.ob-date b { font-family: var(--serif); font-size: 1.1rem; line-height: 1; }
.ob-date small { font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.ob-body { display: grid; gap: 2px; min-width: 0; }
.ob-body strong { font-size: .93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-body small { color: var(--muted); font-size: .77rem; }
.obligation-row.is-late .ob-date { background: var(--red-soft); border-color: var(--red); }
.obligation-row.is-late .ob-body strong { color: var(--red); }
.obligation-row.is-done { opacity: .5; }
.obligation-row.is-done .ob-body strong { text-decoration: line-through; }

.badge.unverified { background: var(--amber-soft); color: var(--amber); }
.badge.verified { background: var(--ok-soft); color: var(--ok); }

.series-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 12px;
  align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line);
}
.series-row:last-child { border-bottom: 0; }
.series-row.is-off { opacity: .5; }
.series-body { display: grid; gap: 2px; min-width: 0; color: var(--ink); }
.series-body small { color: var(--muted); font-size: .77rem; }
.series-list { margin-top: 14px; border-top: 1px solid var(--line); }

.rule { border-bottom: 1px solid var(--line); }
.rule:last-of-type { border-bottom: 0; }
.rule > summary {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 13px 0; cursor: pointer; list-style: none;
}
.rule > summary::-webkit-details-marker { display: none; }
.rule > summary::before { content: "▸"; color: var(--muted); font-size: .8rem; }
.rule[open] > summary::before { content: "▾"; }
.rule-name { font-weight: 500; font-size: .94rem; }
.rule-formula { margin-left: auto; color: var(--muted); font-size: .78rem; }
.rule-body { padding: 4px 0 18px 18px; display: grid; gap: 12px; }
.rule-form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 16px; }
.rule-form label { display: block; font-size: .78rem; font-weight: 500; color: var(--muted); }
.rule-form input, .rule-form select { margin-top: 5px; }
.rule-form label:last-of-type, .rule-form .form-actions { grid-column: 1 / -1; }
.rule-form .checkline { display: flex; align-items: center; gap: 8px; align-self: end; }
.rule-form .checkline input { margin: 0; width: auto; min-height: 0; }
.verify-form { padding-top: 4px; border-top: 1px solid var(--line); }
.add-series { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.add-series > summary { cursor: pointer; font-size: .84rem; font-weight: 500; color: var(--brand); }
.add-series .rule-form { margin-top: 12px; grid-template-columns: 1fr; }

@media (max-width: 760px) {
  .rule-form { grid-template-columns: 1fr; }
  .obligation-row { grid-template-columns: 42px minmax(0,1fr) auto 14px; }
}

.tokenrow { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.tokenval {
  flex: 1 1 260px; min-width: 0; overflow-x: auto; white-space: nowrap;
  padding: 9px 11px; border: 1px solid var(--line); background: var(--surface-soft);
  font-size: .78rem;
}
.checkline { display: flex; align-items: center; gap: 9px; }
.checkline input { width: auto; min-height: 0; margin: 0; }

/* Triage inbox — what arrived, and whether it has a client on it yet. */
.navcount {
  display: inline-block; min-width: 17px; padding: 1px 5px; border-radius: 2px;
  background: var(--amber); color: var(--on-brand); font-size: .66rem;
  font-weight: 600; line-height: 1.5; vertical-align: 1px;
}
.capture-row { padding: 16px 0; border-bottom: 1px solid var(--line); }
.capture-row:last-child { border-bottom: 0; }
.capture-row.is-done { opacity: .55; }
.capture-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 9px; }
.capture-when { margin-left: auto; color: var(--muted); font-size: .74rem; }
.capture-raw {
  margin: 0 0 9px; padding: 2px 0 2px 14px; border-left: 2px solid var(--line-strong);
  font-family: var(--serif); font-size: 1rem; line-height: 1.55; color: var(--ink);
}
.capture-result { font-size: .88rem; margin-bottom: 11px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.capture-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.capture-file { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.capture-file select, .capture-file input[type="date"] {
  min-height: 36px; padding: 5px 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: .82rem; border-radius: 2px;
}
@media (max-width: 760px) {
  .capture-file { width: 100%; }
  .capture-file select { flex: 1 1 100%; }
}

/* The page tree. Pages inside pages, the way a binder works. */
.page-tree { list-style: none; margin: 0; padding: 0; }
.page-tree .page-tree { margin-left: 15px; padding-left: 11px; border-left: 1px solid var(--line); }
.page-node {
  display: grid; grid-template-columns: 16px minmax(0,1fr) auto; align-items: center;
  gap: 8px; padding: 7px 0; color: var(--ink); font-size: .93rem;
}
.page-node:hover { color: var(--brand); }
.page-bullet { color: var(--muted); font-size: .74rem; text-align: center; }
.page-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-count {
  min-width: 20px; padding: 1px 6px; border-radius: 2px; background: var(--surface-soft);
  color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums;
}
.crumbs a { color: var(--amber); }
.crumbs span { color: var(--line-strong); }
.move-form { display: grid; gap: 7px; margin-bottom: 14px; }
.move-form label { font-size: .78rem; font-weight: 500; color: var(--muted); }

/* A postal address keeps the line breaks it was typed with. */
.factlist dd.address { white-space: pre-line; line-height: 1.45; }

/* ------------------------------------------------------------------ *
 * Portal: tracker, credentials, groups, activity.
 * The ledger rules hold here too: hairlines, no pills, bronze labels,
 * and no red anywhere, because nothing on the board is late by itself.
 * ------------------------------------------------------------------ */
.portal-tabs { margin-bottom: 16px; }
.portal-intro { margin: 0 0 16px; max-width: 72ch; }

/* Forms inside the section. Scoped, so the rest of the portal is untouched. */
.portal-form input[type=text], .portal-form input[type=search], .portal-form select,
.portal-form textarea, .comment-form textarea, .comment-form select {
  width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid var(--line-strong);
  border-radius: 2px; color: var(--ink); background: var(--surface); outline: none; font-size: .9rem;
}
.portal-form input:focus, .portal-form select:focus, .portal-form textarea:focus,
.comment-form textarea:focus, .comment-form select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.portal-form input:disabled { background: var(--surface-soft); cursor: not-allowed; }
.portal-form .form-grid { gap: 0 14px; }

/* Group colours: the Karma palette, never hingul. */
.gdot { width: 9px; height: 9px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: var(--muted); }
.gdot.tone-pine { background: var(--brand); }   /* the brand tone; key kept from pine, see tracker.GROUP_TONES */
.gdot.tone-bronze { background: var(--amber); }
.gdot.tone-ink { background: var(--ink); }
.gdot.tone-stone { background: var(--line-strong); }
.gchip { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--ink); }
.client-sub { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; }

/* Filters and the month stepper */
.tracker-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.tracker-filters > select { min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 2px;
  background: var(--surface); color: var(--ink); font-size: .8rem; }
.tracker-filters .search-field { flex: 1 1 220px; }
.period-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); background: var(--surface); }
.period-stepper select { min-height: 38px; padding: 6px 8px; border: 0; border-left: 1px solid var(--line);
  border-right: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--ink);
  font-size: .82rem; font-weight: 500; }
.period-step { width: 36px; display: grid; place-items: center; color: var(--ink); font-size: 1.1rem; }
.period-step:hover { background: var(--surface-soft); color: var(--brand); }
.period-stepper.compact select { min-height: 32px; font-size: .78rem; }
.period-stepper.compact .period-step { width: 30px; }

/* The month in figures, ruled like a total line. Each figure is a filter. */
.tracker-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 18px;
  border-top: 1px solid var(--line); border-bottom: 3px double var(--line-strong); }
.tracker-summary a { display: grid; gap: 1px; padding: 10px 14px; color: var(--ink); border-left: 1px solid var(--line); }
.tracker-summary a:first-child { border-left: 0; }
.tracker-summary a:hover { background: var(--surface-soft); }
.tracker-summary a.on { box-shadow: inset 0 -2px 0 var(--amber); background: var(--surface); }
.tracker-summary b { font-family: var(--serif); font-weight: 400; font-size: 1.55rem; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.tracker-summary small { color: var(--muted); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tracker-summary .sum-short { display: none; }
.tracker-summary .sum-waiting_client b { color: var(--amber); }
.tracker-summary .sum-done b { color: var(--ok); }

/* The board */
.board-section { margin-bottom: 22px; }
.board-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.board-head h2 { font-size: 1.12rem; }
.board-count { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.matrix-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
table.matrix { width: 100%; min-width: 900px; border-collapse: separate; border-spacing: 0; font-size: .84rem; }
.matrix th, .matrix td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.matrix thead th { color: var(--muted); font-size: .66rem; font-weight: 500; letter-spacing: .12em;
  text-transform: uppercase; white-space: nowrap; border-bottom: 3px double var(--line-strong); background: var(--surface); }
.matrix tbody tr:last-child th, .matrix tbody tr:last-child td { border-bottom: 0; }
.matrix tbody tr:hover td, .matrix tbody tr:hover th { background: var(--surface-soft); }
.matrix .num { text-align: center; width: 64px; }
/* The client column stays put while the six tasks scroll under it on a phone. */
.matrix .client-col, .matrix .client-cell { position: sticky; left: 0; z-index: 1; background: var(--surface);
  min-width: 170px; max-width: 240px; border-right: 1px solid var(--line); }
.matrix .client-cell { font-weight: 400; }
.matrix .client-cell a { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.matrix .client-cell a:hover { color: var(--brand); }
.matrix .client-cell small { display: block; color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.cell-form { margin: 0; }
.done-count { font-variant-numeric: tabular-nums; color: var(--muted); }
.done-count.all-done { color: var(--ok); font-weight: 500; }
.comment-count { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 6px;
  border: 1px solid var(--line); color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }
.comment-count.has { border-color: var(--amber); color: var(--amber); }

/* A status. The tone says where the work is; done recedes, waiting is bronze
   like every other "not mine" in the portal, N/A is dashed and quiet but
   still readable. */
.st-select { width: 100%; min-width: 116px; min-height: 34px; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 2px; background: var(--surface); color: var(--ink); font-size: .76rem; cursor: pointer; }
.st-select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.st-not_started { color: var(--muted); }
.st-in_progress { background: var(--blue-soft); color: var(--blue); border-color: var(--line-strong); }
.st-waiting_client { background: var(--amber-soft); color: var(--amber); border-color: var(--amber); }
.st-review { color: var(--brand); border-color: var(--brand); font-weight: 500; }
.st-done { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-soft); }
.st-na { background: transparent; color: var(--muted); border-style: dashed; font-style: italic; }
.htmx-request .st-select, .st-select.htmx-request { opacity: .55; }

/* One client's month */
.work-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, 230px); align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line); }
.work-row:last-of-type { border-bottom: 0; }
.work-label { font-size: .93rem; }
.work-row .cell-form { display: grid; gap: 3px; }
.cell-updated { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.section-heading .period-stepper { margin-top: 2px; }
.portal-links { margin-top: 14px; border-top: 1px solid var(--line); }

/* Comments */
.comment-form { display: grid; gap: 9px; margin: 12px 0 16px; }
.comment-controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.comment-controls label { display: grid; gap: 4px; color: var(--muted); font-size: .78rem; min-width: 190px; }
.comment { padding: 12px 0; border-top: 1px solid var(--line); }
.comment-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .76rem; }
.comment-when { margin-left: auto; font-variant-numeric: tabular-nums; }
.comment-body { margin: 6px 0 4px; white-space: pre-line; overflow-wrap: anywhere; font-family: var(--serif); font-size: 1rem; line-height: 1.55; }
.comment-actions { display: flex; align-items: flex-start; gap: 14px; }
.comment-actions details { flex: 1; }
.comment-actions summary, .login-edit summary, .group-edit summary { cursor: pointer; color: var(--brand); font-size: .8rem; }
.comment-actions form { margin: 0; }
.comment-actions .linkbtn { min-height: 0; padding: 0; font-size: .8rem; }

/* Credentials */
.credential-start { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.portal-search { grid-template-columns: 1fr; }
.login-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.login-row:last-of-type { border-bottom: 0; }
.login-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.login-head strong { font-size: 1rem; font-weight: 500; }
.login-link { font-size: .82rem; }
.login-fields { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 0 14px; margin: 0; }
.login-fields dt { color: var(--muted); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; padding: 8px 0; align-self: center; }
.login-fields dd { margin: 0; padding: 5px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.login-value { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .86rem; padding: 3px 7px;
  background: var(--surface-soft); border: 1px solid var(--line); overflow-wrap: anywhere; }
.login-secret .btn, .login-fields dd .btn { min-height: 30px; padding: 3px 10px; }
.login-notes { color: var(--muted); font-size: .86rem; }
.login-actions { display: flex; align-items: flex-start; gap: 16px; margin-top: 6px; }
.login-actions details { flex: 1; }
.login-actions form[data-confirm] { margin: 0; }
.login-actions .linkbtn { min-height: 0; padding: 0; font-size: .8rem; }
.login-edit .portal-form, .group-edit .portal-form { margin-top: 12px; }
.vault-fp { margin: 12px 0 0; }

/* Groups */
.group-row { padding: 13px 0; border-bottom: 1px solid var(--line); }
.group-row:last-of-type { border-bottom: 0; }
.group-main { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.group-body { display: grid; gap: 5px; min-width: 0; }
.group-body strong { font-weight: 500; }
.group-body small { display: flex; flex-wrap: wrap; gap: 5px; }
.badge.task { background: var(--surface-soft); color: var(--ink); text-transform: none; letter-spacing: .02em; }
.group-edit { margin: 8px 0 0 24px; }
.task-picks { border: 1px solid var(--line); padding: 10px 12px 4px; margin: 0 0 12px; display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 12px; }
.task-picks legend { padding: 0 6px; color: var(--muted); font-size: .78rem; }
.task-picks .checkline { margin: 0 0 6px; font-size: .86rem; color: var(--ink); font-weight: 400; }

/* Activity */
.activity-row { display: grid; grid-template-columns: 128px 64px minmax(0, 1fr); gap: 12px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.activity-row:last-child { border-bottom: 0; }
.activity-when { color: var(--muted); font-size: .78rem; }
.activity-row .badge { justify-self: start; }
.activity-what { overflow-wrap: anywhere; }
.activity-client { margin-left: 6px; font-size: .78rem; }

.mobile-icons a.on { color: var(--amber); }

@media (max-width: 760px) {
  .tracker-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tracker-summary a:nth-child(4) { border-left: 0; }
  .tracker-summary a { border-top: 1px solid var(--line); }
  .tracker-summary b { font-size: 1.25rem; }
  .tracker-summary .sum-full { display: none; }
  .tracker-summary .sum-short { display: inline; }
  .tracker-filters > select { flex: 1 1 45%; }
  .period-stepper { flex: 1 1 100%; }
  .period-stepper select { flex: 1; }
  .credential-start { grid-template-columns: 1fr; }
  .work-row { grid-template-columns: minmax(0, 1fr) 150px; }
  .login-fields { grid-template-columns: 1fr; }
  .login-fields dt { padding: 8px 0 0; }
  .task-picks { grid-template-columns: 1fr 1fr; }
  .activity-row { grid-template-columns: 1fr auto; }
  .activity-what { grid-column: 1 / -1; }
  .group-edit { margin-left: 0; }
}

.linkbtn { white-space: nowrap; }

/* Articles. The editor is long by nature — two languages, five fields each — so the
   language blocks are separated by a rule rather than by another box inside a box. */
.publish-card { display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  justify-content: space-between; }
.publish-card > div { flex: 1 1 320px; }
.publish-card form { margin: 0; }
.article-lang { border-top: 1px solid var(--line); padding-top: 18px; }
.finnish-gate { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 3px; background: var(--surface-soft); }
.finnish-gate .checkline { font-weight: 650; }
.finnish-gate p { margin: 6px 0 0; }
.article-livelinks { margin: -4px 0 10px; padding: 0 14px 0 62px; word-break: break-all; }

/* ------------------------------------------------------------------------- */
/* Notes: the page is the editor (static/notes-editor.js), with photos, PDFs   */
/* and Pencil sketches (static/notes-sketch.js).                              */
/* ------------------------------------------------------------------------- */
main.main-wide { max-width: 1480px; }
.note-shell { display: grid; grid-template-columns: 228px minmax(0, 1fr) 288px; gap: 28px; align-items: start; }
.note-tree-panel { position: sticky; top: 82px; max-height: calc(100vh - 100px); overflow: auto; padding: 4px 6px 20px 0; }
.note-tree-panel .page-node { padding: 5px 6px; border-radius: var(--radius-sm); font-size: .88rem; }
.note-tree-panel .page-node.is-current { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tree-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tree-home { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--amber); font-weight: 600; }
.inline-form { display: inline; margin: 0; }
.icon-btn { min-height: 32px; min-width: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; }
.icon-btn:hover { background: var(--surface-soft); color: var(--ink); }
.link-btn { border: 0; background: none; padding: 6px 0; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; min-height: 0; }
.link-btn:hover { color: var(--brand); }
.tree-toggle { display: none; }

.note-main { min-width: 0; }
.note-topline { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.note-topline .crumbs { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.save-state[data-state="busy"] { color: var(--amber); }
.save-state[data-state="error"] { color: var(--red); font-weight: 600; }
.note-title { font-family: var(--serif); font-size: 2.2rem; margin: 10px 0 14px; }
.note-title-input {
  display: block; width: 100%; margin: 8px 0 6px; padding: 4px 0; border: 0; outline: none;
  background: transparent; color: var(--ink); font-family: var(--serif); font-size: 2.3rem;
  font-weight: 500; letter-spacing: -.01em; line-height: 1.2;
}
.note-title-input::placeholder { color: var(--line-strong); }

.note-toolbar {
  position: sticky; top: 66px; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  margin: 0 -8px 8px; padding: 6px 8px; background: var(--surface-veil); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tb-btn { min-height: 34px; min-width: 34px; padding: 0 9px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); font: 600 .86rem/1 var(--sans); cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.tb-btn:hover { background: var(--surface-soft); border-color: var(--line); }
.tb-bold { font-weight: 800; } .tb-italic { font-style: italic; font-family: var(--serif); }
.tb-photo, .tb-sketch { border-color: var(--line-strong); background: var(--surface); }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 5px; }
.note-toolbar.touch .tb-btn { min-height: 44px; min-width: 44px; font-size: .95rem; }

.note-editor-root .cm-editor { background: transparent; font-family: var(--serif); font-size: 1.1rem; color: var(--ink); }
.note-editor-root .cm-editor.cm-focused { outline: none; }
.note-editor-root .cm-scroller { font-family: inherit; line-height: 1.7; overflow: visible; }
.note-editor-root .cm-content { padding: 6px 0 120px; caret-color: var(--brand); min-height: 50vh; }
.note-editor-root .cm-line { padding: 0 2px; }
.note-editor-root .cm-placeholder { color: var(--muted); font-style: italic; }
.note-editor-root .cm-selectionBackground, .note-editor-root .cm-focused .cm-selectionBackground { background: var(--brand-soft) !important; }
.cm-h { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; }
.cm-h1 { font-size: 1.75rem; line-height: 1.35; padding-top: .5em !important; }
.cm-h2 { font-size: 1.4rem; line-height: 1.4; padding-top: .45em !important; }
.cm-h3 { font-size: 1.18rem; padding-top: .3em !important; }
.cm-h4, .cm-h5, .cm-h6 { font-size: 1.05rem; }
.cm-quote { border-left: 3px solid var(--line-strong); padding-left: 14px !important; color: var(--muted); font-style: italic; }
.cm-codeblock { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .86rem; background: var(--surface-soft); }
.cm-md-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; background: var(--surface-soft); border-radius: 2px; padding: 0 3px; }
.cm-md-mark { color: var(--muted); }
.cm-md-link { color: var(--brand); text-decoration: underline; text-decoration-color: var(--line-strong); }
.cm-md-url { color: var(--muted); font-size: .9em; }
.cm-hr { color: var(--muted); border-bottom: 1px solid var(--line-strong); }
.cm-bullet { display: inline-block; width: 1em; color: var(--amber); font-weight: 700; }
.cm-task-box { width: 1.05em; height: 1.05em; margin: 0 .45em 0 0; vertical-align: -.12em; accent-color: var(--brand); cursor: pointer; }
.cm-task-done { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.cm-link-chip { color: var(--brand); border-bottom: 1px solid var(--line-strong); cursor: pointer; }
.cm-link-chip.is-missing { color: var(--amber); border-bottom-style: dashed; }
.cm-wikilink-src { color: var(--brand); }

.cm-media { position: relative; margin: 10px 0; width: fit-content; max-width: 100%; }
.cm-media img, .note-media img { display: block; max-width: 100%; max-height: 78vh; width: auto; height: auto; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.cm-media.kind-sketch img, .note-media.kind-sketch img { max-width: min(100%, 760px); }
.cm-media-cap, .note-media-cap { display: block; margin-top: 5px; color: var(--muted); font-size: .84rem; font-family: var(--sans); }
.cm-media-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.cm-media:hover .cm-media-actions, .cm-media:focus-within .cm-media-actions { opacity: 1; }
/* On a touch screen there is no hover, so the buttons sit under the picture
   instead of covering its top edge. */
@media (hover: none) {
  .cm-media-actions { position: static; opacity: 1; margin-top: 6px; flex-wrap: wrap; }
}
.cm-media-actions button { min-height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-veil); color: var(--ink); font: 600 .78rem/1 var(--sans); cursor: pointer; backdrop-filter: blur(6px); }
.cm-media-actions button.danger { color: var(--red); }
.cm-media.is-missing, .note-media.is-missing { color: var(--muted); font-style: italic; font-size: .9rem; }
.note-media { display: block; margin: 10px 0; }
.note-file { display: inline-grid; grid-template-columns: 42px auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  padding: 10px 14px 10px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-family: var(--sans); }
.note-file:hover { border-color: var(--brand); }
.note-file-icon { grid-row: 1 / 3; width: 42px; height: 42px; display: grid; place-items: center; border-radius: var(--radius-sm);
  background: var(--red-soft); color: var(--red); font-size: .72rem; font-weight: 800; letter-spacing: .04em; }
.note-file-name { font-weight: 600; font-size: .92rem; }
.note-file-meta { color: var(--muted); font-size: .76rem; }
.ext-image { color: var(--amber); border-bottom: 1px dashed var(--line-strong); }

.cm-tooltip.cm-tooltip-autocomplete { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: 0 12px 30px rgba(var(--brand-rgb), .16); overflow: hidden; }
.cm-tooltip-autocomplete > ul { font-family: var(--sans) !important; max-height: 18em !important; min-width: 240px; }
.cm-tooltip-autocomplete > ul > li { padding: 7px 12px !important; color: var(--ink); }
.cm-tooltip-autocomplete > ul > li[aria-selected] { background: var(--brand) !important; color: var(--on-brand) !important; }
.cm-completionDetail { margin-left: 10px; color: var(--muted); font-style: normal !important; font-size: .78em; }
.cm-completionMatchedText { text-decoration: none !important; font-weight: 700; }

.note-children { margin: 26px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.child-row { display: flex; gap: 10px; align-items: center; padding: 8px 4px; color: var(--ink); border-radius: var(--radius-sm); }
.child-row:hover { background: var(--surface-soft); }
.child-icon { color: var(--muted); }
.add-child { display: block; margin-top: 4px; }
.note-extra { margin-top: 18px; }
.note-fallback-links { display: flex; gap: 8px; margin-top: 16px; }
.note-side { display: grid; gap: 14px; min-width: 0; }
.note-side > * { min-width: 0; }
.file-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.file-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-soft); }
.file-thumb.pdf { display: grid; place-items: center; font-size: .66rem; font-weight: 800; color: var(--red); background: var(--red-soft); }
.file-name { font-size: .84rem; overflow: hidden; text-overflow: ellipsis; }
.file-name small { display: block; }
.upload-form { margin-top: 10px; }
.file-pick { position: relative; overflow: hidden; cursor: pointer; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.conflict-banner .conflict-actions { display: flex; gap: 8px; margin: 10px 0 6px; }
.note-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90;
  max-width: min(560px, calc(100vw - 32px)); padding: 11px 16px; border-radius: var(--radius); background: var(--brand-dark); color: var(--on-brand); font-size: .88rem; }
body.note-editing .note-rendered, body.note-editing .note-fallback-links { display: none; }

@media (max-width: 820px) {
  .note-toolbar { top: 60px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  /* On a phone the camera and the pen are what I reach for first. */
  .note-toolbar .tb-photo, .note-toolbar .tb-sketch { order: -1; }
  .note-title-input { font-size: 1.85rem; }
  .note-editor-root .cm-editor { font-size: 1.05rem; }
  .note-side { grid-template-columns: 1fr; }
}

/* Sketch pad: a sheet of paper stays a sheet of paper in dark mode too. */
html.sketch-open, html.sketch-open body { overflow: hidden; overscroll-behavior: none; }
.sketch-overlay { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; background: var(--surface-soft);
  padding-top: env(safe-area-inset-top); }
.sk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line-strong); }
.sk-group { display: flex; align-items: center; gap: 3px; padding: 0 6px; border-left: 1px solid var(--line); }
.sk-group[hidden] { display: none; }
.sk-btn { min-height: 40px; min-width: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); font: 600 .84rem/1 var(--sans); cursor: pointer; touch-action: manipulation; }
.sk-btn:hover { background: var(--surface-soft); }
.sk-btn.on { background: var(--brand); color: var(--on-brand); }
.sk-save { background: var(--brand); color: var(--on-brand); padding: 0 18px; }
.sk-save:disabled { opacity: .5; }
.sk-color { width: 30px; height: 30px; min-height: 30px; padding: 0; margin: 0 2px; border-radius: 50%; border: 2px solid var(--surface);
  background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }
.sk-color.on { box-shadow: 0 0 0 2px var(--brand); }
.sk-size i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }
.sk-paper { min-height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 0 8px; }
.sk-finger { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); padding: 0 6px; }
.sk-spacer { flex: 1; }
.sk-status { font-size: .8rem; color: var(--amber); }
.sk-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 16px 12px 60px; }
.sk-pages { display: grid; gap: 14px; justify-content: center; }
.sk-page { position: relative; background-color: #FFFDF7; box-shadow: 0 2px 14px rgba(23, 19, 14, .14); border-radius: 2px; }
.sk-page[data-paper="lined"] { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--step) - 1px), rgba(70, 90, 130, .16) calc(var(--step) - 1px), rgba(70, 90, 130, .16) var(--step)); background-position: 0 calc(var(--step) * 2); background-repeat: repeat-y; }
.sk-page[data-paper="grid"] { background-image: linear-gradient(rgba(70, 90, 130, .16) 1px, transparent 1px), linear-gradient(90deg, rgba(70, 90, 130, .16) 1px, transparent 1px); background-size: var(--step) var(--step); }
.sk-page[data-paper="dots"] { background-image: radial-gradient(rgba(70, 90, 130, .3) 1.4px, transparent 1.6px); background-size: var(--step) var(--step); }
.sk-page canvas { position: absolute; inset: 0; }
/* The page, not a canvas, takes the pointer: one shared live canvas moves
   between pages. No browser gestures, no text selection, no callout. */
.sk-page { touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sk-live { pointer-events: none; }
@media (max-width: 820px) { .sk-group { border-left: 0; padding: 0 2px; } .sk-finger { font-size: .74rem; } }

.not-shown { color: var(--amber); font-weight: 600; }
.put-back { color: var(--brand); font-weight: 600; font-size: .8rem; padding: 2px 0; }
.link-row.is-current { background: var(--brand-soft); }

/* ------------------------------------------------------------------------- */
/* Layout, 29.9.2026: the sections live in a sidebar on a laptop and in a     */
/* More sheet on a phone. Thirteen links had stopped fitting a top bar.       */
/* ------------------------------------------------------------------------- */
:root { --sidebar-w: 228px; }

.sidebar, .more-menu { display: none; }
.sidenav { display: flex; flex-direction: column; gap: 14px; }
.navgroup { display: flex; flex-direction: column; gap: 1px; }
.navgroup-label { color: var(--amber); font-size: .64rem; font-weight: 500; letter-spacing: .19em;
  text-transform: uppercase; padding: 0 10px 5px; }
.sidenav a { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 34px; padding: 6px 10px; border-radius: 3px; color: var(--bar-dim);
  font-size: .86rem; letter-spacing: .02em; border-left: 2px solid transparent; }
.sidenav a:hover { color: var(--bar-ink); background: var(--bar-hover); }
.sidenav a.on { color: var(--bar-ink); background: var(--bar-hover); border-left-color: var(--amber); font-weight: 500; }
.navcount { min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--surface-soft);
  color: var(--muted); font-size: .7rem; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.navcount.alert { background: var(--red); color: var(--on-brand); }
.side-tools { display: flex; align-items: center; justify-content: space-between; gap: 6px;
  border-top: 1px solid var(--bar-rule); padding-top: 10px; }
.side-tools .linkbtn { min-height: 34px; padding: 6px 10px; }
.side-tools .logout-form { margin: 0; }

@media (min-width: 821px) {
  :root { --sidebar-w: calc(228px + env(safe-area-inset-left)); }
  body { padding-left: var(--sidebar-w); padding-right: env(safe-area-inset-right); }
  .topbar { display: none; }
  .sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: var(--sidebar-w);
    display: flex; flex-direction: column; gap: 16px;
    /* An iPhone on its side is wider than 820px: keep the menu clear of the notch. */
    padding: calc(20px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
    background: var(--bar-bg); border-right: 1px solid var(--bar-rule); overflow-y: auto; }
  .sidebar .brand { padding: 2px 10px 6px; }
  .sidebar .sidenav { flex: 1; }
  .navgroup-foot { margin-top: auto; }
  .side-search { min-height: 36px; justify-content: flex-start; gap: 8px; padding: 6px 10px;
    border: 1px solid var(--line); background: var(--surface); color: var(--muted);
    font-weight: 400; font-size: .84rem; }
  .side-search:hover { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
  .side-search kbd { margin-left: auto; font: inherit; font-size: .7rem; color: var(--muted);
    border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
  main { padding-top: 28px; }
}

/* Phone: the fourth tab is More, a sheet with every section in it. */
.more-toggle { display: none; }
@media (max-width: 820px) {
  .bottomnav .more-toggle { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column;
    align-items: center; gap: 2px; padding: 0; border: 0; background: none; color: var(--muted);
    font-size: .62rem; font-weight: 620; }
  .bottomnav .more-toggle.open { color: var(--brand); }
  .more-dot { position: absolute; top: 3px; right: calc(50% - 16px); width: 8px; height: 8px;
    border-radius: 50%; background: var(--amber); }
  .more-menu { position: fixed; z-index: 49; left: calc(14px + env(safe-area-inset-left)); right: calc(14px + env(safe-area-inset-right)); bottom: calc(82px + env(safe-area-inset-bottom));
    max-height: calc(100vh - 160px - env(safe-area-inset-bottom)); overflow-y: auto; padding: 14px 10px 10px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
    box-shadow: 0 15px 45px rgba(var(--brand-rgb),.18); }
  .more-menu:not([hidden]) { display: flex; flex-direction: column; gap: 12px; }
  .more-menu .sidenav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 8px; }
  .more-menu .navgroup-label { min-height: 14px; }
  .more-menu .navgroup:first-child { padding-top: 19px; }
  .more-menu .sidenav a { min-height: 40px; padding: 6px 8px; font-size: .9rem; color: var(--ink); }
  .more-menu .side-tools { border-top-color: var(--line); }
}

/* Dashboard: the day in one line, capture as one bar, then two columns. */
.day-status { font-size: .95rem; }
.day-status a { color: var(--ink); border-bottom: 1px solid var(--line-strong); }
.day-status a.danger-text { color: var(--red); border-bottom-color: var(--danger-line); }
.capture-bar { flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.capture-bar input { flex: 1 1 0; min-width: 0; background: var(--surface); }
.capture-bar button[type=submit] { min-height: 48px; }
.capture-bar .prompt-chips { flex-basis: 100%; margin-top: 0; }
.capture-bar .prompt-chips button { min-height: 0; background: none; padding: 2px 8px 2px 0; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.dash-grid .day-column { max-width: none; }
.dash-side { display: flex; flex-direction: column; gap: 12px; }
.side-note { display: grid; grid-template-columns: minmax(0,1fr) 14px; column-gap: 8px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); }
.side-note strong { font-size: .86rem; }
.side-note small { grid-column: 1; color: var(--muted); font-size: .75rem; margin-top: 2px; }
.side-note .row-arrow { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.side-note.warn { background: var(--amber-soft); border-color: var(--amber); }
.side-note:hover { border-color: var(--line-strong); }
@media (max-width: 1080px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Patterns every page shares. */
.page-hero .btn, .page-hero button, .page-hero form { flex: 0 0 auto; white-space: nowrap; }
.page-hero { min-height: 0; padding-bottom: 16px; margin-bottom: 18px; }
.empty-state { min-height: 120px; padding: 18px; }
.empty-state.compact { min-height: 0; padding: 14px 12px; flex-direction: row; gap: 10px; justify-content: flex-start; text-align: left; }
.empty-state.compact > span { margin: 0; flex: 0 0 auto; width: 28px; height: 28px; font-size: .8rem; }
.empty-state.compact small { margin: 0 0 0 4px; }
/* Long explanations fold away: the work comes first, the manual is one tap away. */
details.help { margin: 0 0 14px; font-size: .84rem; line-height: 1.55; color: var(--muted); }
details.help > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
  color: var(--brand); font-size: .8rem; font-weight: 600; letter-spacing: .02em; }
details.help > summary::-webkit-details-marker { display: none; }
details.help > summary::before { content: "+"; display: inline-grid; place-items: center; width: 16px; height: 16px;
  border: 1px solid var(--line-strong); border-radius: 2px; font-size: .75rem; line-height: 1; }
details.help[open] > summary::before { content: "−"; }
details.help[open] > summary { margin-bottom: 8px; }
details.help > :not(summary) { max-width: 72ch; }

/* With the sidebar taking 228px, a laptop-narrow or iPad window has less room
   than these layouts were drawn for: they stack a little earlier. */
.factlist dd { min-width: 0; overflow-wrap: anywhere; }
.dashboard-side > * { min-width: 0; }
@media (min-width: 821px) and (max-width: 1100px) {
  .dashboard-layout { grid-template-columns: minmax(0, 1fr); }
  .dashboard-side { grid-template-columns: 1fr 1fr; align-items: start; }
  .filterbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filterbar .search-field { grid-column: 1 / -1; }
}


/* ------------------------------------------------------------------------- */
/* Notes, 29.9.2026: the page reads like a Notion page. One calm column, a    */
/* page list that folds away, icon and cover, and everything else behind ⋯    */
/* and ⓘ. Callouts, toggles and highlights come from the markdown.            */
/* ------------------------------------------------------------------------- */
main.main-wide { max-width: none; padding-top: 0; }
.note-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 0; align-items: start; margin: 0 -20px; }
.note-shell.tree-hidden { grid-template-columns: minmax(0, 1fr); }
.note-shell.tree-hidden .note-tree-panel { display: none; }
.tree-expand { display: none; }
.note-shell.tree-hidden .tree-expand { display: inline-block; }
.note-tree-panel { position: sticky; top: 0; height: 100vh; max-height: none; overflow: auto;
  padding: 16px 10px 40px 14px; border-right: 1px solid var(--line); background: var(--bar-bg); }
.tree-head { gap: 2px; padding: 0 4px 8px; }
.tree-home { flex: 1; }
.tree-section { margin-top: 10px; }
.tree-label { padding: 4px 6px; color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.note-tree-panel .page-tree .page-tree { margin-left: 12px; padding-left: 4px; border-left: 0; }
.note-tree-panel .page-node { display: flex; align-items: center; gap: 4px; padding: 3px 6px; min-height: 30px;
  border-radius: 3px; color: var(--ink); font-size: .87rem; font-weight: 400; cursor: pointer; }
.note-tree-panel .page-node:hover { background: var(--bar-hover); color: var(--ink); }
.note-tree-panel .page-node.is-current { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.page-link { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; color: inherit; }
.page-node .page-name { flex: 1; min-width: 0; }
.page-node .page-count { background: none; padding: 0 2px; opacity: .7; }
.tree-branch > summary { list-style: none; }
.tree-branch > summary::-webkit-details-marker { display: none; }
.tree-caret { flex: 0 0 16px; width: 16px; height: 18px; display: grid; place-items: center; color: var(--muted); font-size: .6rem; border-radius: 2px; }
.tree-caret::before { content: "▸"; transition: transform .12s; }
.tree-branch[open] > summary .tree-caret::before { transform: rotate(90deg); }
.tree-caret.is-leaf::before { content: ""; }
.tree-caret:hover { background: var(--bar-hover); color: var(--ink); }
.pg-icon { flex: 0 0 auto; width: 20px; text-align: center; font-size: 1rem; line-height: 1; }
.pg-icon.is-plain { color: var(--muted); font-size: .85rem; }
/* notes home uses the same tree inside a card */
.card .page-tree .page-node { display: flex; align-items: center; gap: 6px; }

.note-main { min-width: 0; padding: 0 20px 60px; }
.note-topline { position: sticky; top: 0; z-index: 30; gap: 4px; min-height: 46px; margin: 0 -20px; padding: 6px 14px;
  background: var(--surface-veil); backdrop-filter: blur(10px); }
.crumbs { display: flex; align-items: center; gap: 2px; font-size: .84rem; color: var(--muted); }
.crumbs a, .crumb-here { padding: 3px 5px; border-radius: 3px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.crumbs a:hover { background: var(--surface-soft); color: var(--ink); }
.crumb-here { color: var(--ink); }
.crumb-sep { color: var(--line-strong); }
.page-info-btn { position: relative; }
.dot-count { position: absolute; top: 2px; right: 0; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--surface-soft); color: var(--muted); font-size: .6rem; line-height: 15px; font-weight: 700; }

.note-cover { height: 0; margin: 0 -20px; background: var(--surface-soft) center / cover no-repeat; position: relative; }
.note-cover.has-cover { height: 30vh; min-height: 160px; max-height: 280px; }
.cover-actions { position: absolute; right: 16px; bottom: 12px; display: none; gap: 4px; }
.note-cover.has-cover:hover .cover-actions, .note-cover.has-cover:focus-within .cover-actions { display: flex; }
.cover-btn { min-height: 28px; padding: 3px 10px; border: 0; border-radius: 3px; background: rgba(255,255,255,.88); color: #17130E; font-size: .76rem; font-weight: 500; }
.cover-btn:hover { background: #fff; color: #17130E; }
.cover-grad-0 { background-image: linear-gradient(120deg, #151C2B, #3A4A6B); }
.cover-grad-1 { background-image: linear-gradient(120deg, #8A6438, #D9B98C); }
.cover-grad-2 { background-image: linear-gradient(120deg, #AE3527, #E3A08F); }
.cover-grad-3 { background-image: linear-gradient(120deg, #34423F, #8DA59E); }
.cover-grad-4 { background-image: linear-gradient(120deg, #F0ECE1, #C8C0B2); }
.cover-grad-5 { background-image: linear-gradient(135deg, #1B2438 0%, #8A6438 100%); }
.cover-grad-6 { background-image: radial-gradient(circle at 20% 30%, #E8ECF2, #9FB0CC); }
.cover-grad-7 { background-image: repeating-linear-gradient(0deg, #F7F4EC 0 22px, #E0DACE 22px 23px); }

.note-page { max-width: 760px; margin: 0 auto; }
.note-shell.is-wide .note-page { max-width: none; margin: 0 36px; }
.note-head { position: relative; padding-top: 44px; }
.note-cover.has-cover + .note-page .note-head { padding-top: 12px; }
.note-cover.has-cover + .note-page .note-head.has-icon { padding-top: 0; }
.note-icon { display: block; min-height: 0; padding: 0; border: 0; background: none; font-size: 4.2rem; line-height: 1.1; cursor: pointer; border-radius: 6px; }
.note-icon:hover { background: var(--surface-soft); }
.note-cover.has-cover + .note-page .note-icon { margin-top: -42px; position: relative; }
.face-actions { display: flex; gap: 4px; min-height: 30px; margin: 6px 0 0 -8px; opacity: 0; transition: opacity .12s; }
.note-head:hover .face-actions, .face-actions:focus-within { opacity: 1; }
@media (hover: none) { .face-actions { opacity: .75; } }
.face-btn { min-height: 28px; padding: 3px 8px; border: 0; background: none; color: var(--muted); font-size: .82rem; font-weight: 400; }
.face-btn:hover { background: var(--surface-soft); color: var(--ink); }
.note-head .note-title, .note-head .note-title-input { font-size: 2.6rem; margin: 4px 0 2px; font-weight: 600; letter-spacing: -.015em; }
.note-meta-line { display: flex; flex-wrap: wrap; gap: 12px; min-height: 8px; margin: 0 0 14px; font-size: .82rem; color: var(--muted); }
.note-meta-line a { color: var(--muted); border-bottom: 1px solid var(--line-strong); }
.meta-link { min-height: 0; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 400;
  border-bottom: 1px solid var(--line-strong); border-radius: 0; }
.meta-link:hover { background: none; color: var(--ink); }

/* The toolbar sits under the sticky crumbs and is quiet until it is wanted. */
.note-toolbar { top: 46px; margin: 0 0 6px; padding: 4px 0; border-bottom: 1px solid var(--line); background: var(--surface-veil); }
.note-toolbar .tb-btn { color: var(--muted); }
.note-toolbar .tb-btn:hover { color: var(--ink); }
.note-editor-root .cm-editor { font-family: var(--sans); font-size: 1.02rem; }
.note-editor-root .cm-scroller { line-height: 1.75; }
.note-body { font-family: var(--sans); font-size: 1.02rem; line-height: 1.75; }
.note-body h1, .note-body h2, .note-body h3 { font-family: var(--sans); font-weight: 600; }

/* Pages inside this one, as Notion page blocks. */
.note-children { margin: 28px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.child-row { gap: 8px; padding: 5px 6px; font-size: .96rem; border-bottom: 0; width: 100%; }
.child-title { border-bottom: 1px solid var(--line-strong); line-height: 1.3; }
.child-row .pin { color: var(--amber); font-size: .75rem; }
.add-row { min-height: 0; border: 0; background: none; color: var(--muted); font-weight: 400; justify-content: flex-start; }
.add-row .child-title { border-bottom: 0; }
.add-row:hover { background: var(--surface-soft); color: var(--ink); }
.loose-ends { margin-top: 20px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.loose-ends > summary { cursor: pointer; font-size: .86rem; color: var(--muted); }
.loose-ends[open] > summary { margin-bottom: 8px; }

/* Popover menus: page options, icon and cover pickers. */
.pop-menu { position: fixed; z-index: 80; min-width: 240px; max-width: min(340px, calc(100vw - 16px)); padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 12px 36px rgba(var(--brand-rgb), .18), 0 2px 6px rgba(var(--brand-rgb), .08); }
.pop-menu > form { margin: 0; }
.pop-menu button[role=menuitem], .pop-menu a[role=menuitem], .pop-menu summary[role=menuitem] {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; min-height: 34px; padding: 5px 10px; border: 0; border-radius: 4px;
  background: none; color: var(--ink); font: inherit; font-size: .88rem; font-weight: 400; text-align: left; cursor: pointer; list-style: none; }
.pop-menu [role=menuitem] > span:first-child { width: 18px; text-align: center; color: var(--muted); }
.pop-menu [role=menuitem]:hover, .pop-menu [role=menuitem]:focus-visible { background: var(--surface-soft); outline: none; }
.pop-menu .danger-text, .pop-menu .danger-text > span:first-child { color: var(--red); }
.pop-menu summary::-webkit-details-marker { display: none; }
.pop-menu .menu-move .move-form { padding: 4px 10px 8px 38px; margin: 0; }
.pop-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu-foot { margin: 4px 10px 2px; font-size: .72rem; color: var(--muted); }
.picker { width: 340px; padding: 10px; }
.picker-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.picker-head input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface-soft); color: var(--ink); }
.icon-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; }
.icon-grid button { min-height: 34px; padding: 0; border: 0; border-radius: 4px; background: none; font-size: 1.3rem; }
.icon-grid button:hover { background: var(--surface-soft); }
.cover-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.cover-swatch { min-height: 48px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background-size: cover; }
.cover-swatch:hover { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Page info drawer. */
.note-drawer { position: fixed; z-index: 70; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); overflow-y: auto;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(var(--brand-rgb), .14); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-section { padding: 12px 0; border-top: 1px solid var(--line); }
.drawer-section .section-kicker { margin-bottom: 6px; }

/* Callouts and toggles — rendered view and editor alike. */
.callout { margin: 10px 0 14px; padding: 12px 14px 12px 14px; border-radius: 6px; background: var(--callout-bg, var(--surface-soft));
  border: 1px solid var(--callout-line, transparent); }
.callout-title { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.callout-icon { flex: 0 0 auto; font-size: 1.15rem; line-height: 1.5; }
.callout-title-text { line-height: 1.6; }
.callout-body { padding-left: 32px; }
.callout-body > :first-child { margin-top: 4px; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-body:empty { display: none; }
.callout-note { --callout-bg: #EEF1F6; }
.callout-tip { --callout-bg: #F3EEDF; }
.callout-success { --callout-bg: #E8F0E9; }
.callout-question { --callout-bg: #EFEDF6; }
.callout-warning { --callout-bg: #F6ECDC; }
.callout-danger { --callout-bg: var(--red-soft); }
.callout-quote { --callout-bg: transparent; --callout-line: var(--line); font-style: italic; }
.callout.is-toggle { background: none; padding: 2px 0; border: 0; }
.callout.is-toggle > summary { cursor: pointer; list-style: none; font-weight: 500; }
.callout.is-toggle > summary::-webkit-details-marker { display: none; }
.callout.is-toggle > summary::before { content: "▸"; display: inline-block; width: 22px; color: var(--muted); font-size: .8rem; transition: transform .12s; }
.callout.is-toggle[open] > summary::before { transform: rotate(90deg); }
.callout.is-toggle .callout-body { padding-left: 22px; }
.callout.is-toggle.callout-note, .callout.is-toggle.callout-tip, .callout.is-toggle.callout-warning,
.callout.is-toggle.callout-danger, .callout.is-toggle.callout-success, .callout.is-toggle.callout-question {
  background: var(--callout-bg); padding: 10px 14px; }
mark, .cm-md-mark-hl { background: #F6E7A8; color: inherit; padding: 0 2px; border-radius: 2px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .callout-note { --callout-bg: #1E2533; }
  :root:not([data-theme="light"]) .callout-tip { --callout-bg: #2A2518; }
  :root:not([data-theme="light"]) .callout-success { --callout-bg: #1B2A20; }
  :root:not([data-theme="light"]) .callout-question { --callout-bg: #25222F; }
  :root:not([data-theme="light"]) .callout-warning { --callout-bg: #2E2416; }
  :root:not([data-theme="light"]) mark, :root:not([data-theme="light"]) .cm-md-mark-hl { background: #5A4A17; }
  :root:not([data-theme="light"]) .cover-btn { background: rgba(28,24,17,.85); color: #EFEAE0; }
}
:root[data-theme="dark"] .callout-note { --callout-bg: #1E2533; }
:root[data-theme="dark"] .callout-tip { --callout-bg: #2A2518; }
:root[data-theme="dark"] .callout-success { --callout-bg: #1B2A20; }
:root[data-theme="dark"] .callout-question { --callout-bg: #25222F; }
:root[data-theme="dark"] .callout-warning { --callout-bg: #2E2416; }
:root[data-theme="dark"] mark, :root[data-theme="dark"] .cm-md-mark-hl { background: #5A4A17; }
:root[data-theme="dark"] .cover-btn { background: rgba(28,24,17,.85); color: #EFEAE0; }

/* Below about 1100px the page list becomes a drawer again. */
@media (max-width: 1100px) {
  .note-shell, .note-shell.tree-hidden { grid-template-columns: minmax(0, 1fr); }
  .note-shell.tree-hidden .note-tree-panel { display: block; }
  .tree-toggle { display: inline-block; }
  .tree-collapse, .tree-expand, .note-shell.tree-hidden .tree-expand { display: none; }
  .note-tree-panel {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(300px, 84vw); height: auto;
    padding: calc(16px + env(safe-area-inset-top)) 12px 24px calc(12px + env(safe-area-inset-left));
    background: var(--surface); border-right: 1px solid var(--line-strong);
    transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(var(--brand-rgb), .18);
  }
  .note-shell.tree-open .note-tree-panel { transform: none; }
}
@media (max-width: 820px) {
  .note-shell { margin: 0 -14px; }
  .note-main { padding: 0 16px 40px; }
  .note-topline { top: 60px; margin: 0 -16px; }
  .note-cover { margin: 0 -16px; }
  .note-cover.has-cover { height: 22vh; min-height: 120px; }
  .note-toolbar { top: 106px; }
  .note-head { padding-top: 18px; }
  .note-head .note-title, .note-head .note-title-input { font-size: 2rem; }
  .note-icon { font-size: 3.2rem; }
  .note-shell.is-wide .note-page { margin: 0; }
  .crumbs a { display: none; }
  .crumbs .crumb-sep { display: none; }
  .picker { width: min(340px, calc(100vw - 16px)); }
  .icon-grid { grid-template-columns: repeat(7, 1fr); }
  .icon-grid button { min-height: 42px; }
  .cover-actions { display: flex; }
}
.face-actions:not(:has(> :not([hidden]))) { min-height: 0; margin: 0; }

/* Editor: callouts and toggles drawn over the markdown. */
.note-editor-root .cm-line.cm-callout { background: var(--callout-bg, var(--surface-soft)); padding-left: 44px; padding-right: 14px; }
.note-editor-root .cm-line.cm-callout-first { padding-top: 10px; border-radius: 6px 6px 0 0; font-weight: 600; }
.note-editor-root .cm-line.cm-callout-last { padding-bottom: 10px; border-radius: 0 0 6px 6px; margin-bottom: 4px; }
.note-editor-root .cm-line.cm-callout-first.cm-callout-last { border-radius: 6px; }
.note-editor-root .cm-line.cm-callout-first .cm-callout-icon { margin-left: -30px; display: inline-block; width: 30px; font-weight: 400; }
.note-editor-root .cm-line.cm-callout-toggle { background: transparent; padding-left: 26px; }
.note-editor-root .cm-line.cm-callout-toggle.cm-callout-first { font-weight: 500; }
.note-editor-root .cm-line.cm-callout-toggle.cm-callout-note, .note-editor-root .cm-line.cm-callout-toggle.cm-callout-tip,
.note-editor-root .cm-line.cm-callout-toggle.cm-callout-warning, .note-editor-root .cm-line.cm-callout-toggle.cm-callout-danger,
.note-editor-root .cm-line.cm-callout-toggle.cm-callout-success, .note-editor-root .cm-line.cm-callout-toggle.cm-callout-question { background: var(--callout-bg); }
.cm-toggle-arrow { display: inline-block; width: 22px; margin-left: -24px; color: var(--muted); font-size: .8rem; cursor: pointer; text-align: center; transition: transform .12s; user-select: none; }
.cm-toggle-arrow.is-open { transform: rotate(90deg); }
.cm-toggle-arrow:hover { color: var(--ink); }
.cm-folded { color: var(--muted); font-size: .8rem; font-weight: 400; font-style: italic; }
.note-editor-root .cm-callout-first .cm-callout-icon + * { margin-left: 0; }
.wl-icon { margin-right: 4px; }

/* Block handles: ⋮⋮ to drag, ＋ to add, in the margin like Notion. */
.cm-block-handle { position: absolute; z-index: 5; display: flex; gap: 0; }
.cm-block-handle[hidden] { display: none; }
.cm-block-handle button { min-height: 26px; min-width: 24px; width: 24px; height: 26px; padding: 0; border: 0; border-radius: 3px;
  background: transparent; color: var(--line-strong); font-size: .95rem; font-weight: 700; line-height: 1; cursor: pointer; }
.cm-block-handle button:hover { background: var(--surface-soft); color: var(--muted); }
.cm-block-handle .bh-grip { cursor: grab; letter-spacing: -3px; font-size: .8rem; touch-action: none; }
body.block-dragging, body.block-dragging * { cursor: grabbing !important; user-select: none; }
.cm-drop-line { position: absolute; left: 0; right: 0; height: 3px; margin-top: -2px; background: #6D8DD8; border-radius: 2px; z-index: 6; pointer-events: none; }
.cm-drop-line[hidden] { display: none; }

/* Notes home: favourites and recent pages as cards, like Notion's home. */
.page-cards-section { margin-bottom: 22px; }
.page-cards-section .section-kicker { margin-bottom: 10px; }
.page-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.page-card { position: relative; display: flex; flex-direction: column; min-height: 132px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); transition: border-color .12s, box-shadow .12s; }
.page-card:hover { border-color: var(--line-strong); box-shadow: 0 4px 16px rgba(var(--brand-rgb), .08); }
.page-card-cover { height: 44px; background: var(--surface-soft) center / cover no-repeat; }
.page-card-icon { margin: -16px 0 0 12px; font-size: 1.7rem; line-height: 1; }
.page-card strong { margin: 8px 12px 2px; font-size: .9rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.page-card small { margin: auto 12px 10px; color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-tree-card .page-tree .page-tree { margin-left: 14px; padding-left: 6px; border-left: 1px solid var(--line); }
.notes-tree-card .page-node { padding: 5px 4px; border-radius: 3px; }
.notes-tree-card .page-node:hover { background: var(--surface-soft); }
/* The hidden attribute always wins over a component's own display rule. */
[hidden] { display: none !important; }
textarea.note-title-input { resize: none; overflow: hidden; min-height: 0; field-sizing: content; }

/* Settings: one section per page, the sections listed beside it. */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; max-width: 980px; }
.settings-nav { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px;
  padding: 7px 10px; border-radius: 4px; border-left: 2px solid transparent; color: var(--muted); font-size: .88rem; }
.settings-nav a:hover { background: var(--surface-soft); color: var(--ink); }
.settings-nav a.on { background: var(--surface); color: var(--ink); border-left-color: var(--amber); font-weight: 500; box-shadow: 0 0 0 1px var(--line) inset; }
.set-state { font-size: .68rem; font-weight: 500; white-space: nowrap; color: var(--muted); }
.set-state.tone-ok { color: var(--ok); }
.set-state.tone-warn { color: var(--amber); }
.settings-panel { padding: 20px 22px; }
.settings-panel > .small-note:first-child, .settings-panel > p:first-child { margin-top: 0; }
@media (max-width: 820px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .settings-nav { position: relative; flex-direction: row; overflow-x: auto; gap: 6px; margin: 0 -14px; padding: 0 14px 4px;
    scrollbar-width: none; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav a { flex: 0 0 auto; min-height: 36px; border: 1px solid var(--line); border-radius: 18px; padding: 6px 12px; background: var(--surface); }
  .settings-nav a.on { border-color: var(--brand); box-shadow: none; }
  .settings-nav .set-state { display: none; }
  .settings-panel { padding: 16px; }
}

/* Tracker on a phone: the same table, drawn as one card per client — name
   and progress on top, the six tasks two by two with their names. One DOM,
   so the live status updates keep their targets. */
@media (max-width: 820px) {
  .matrix-wrap { overflow: visible; background: none; border: 0; }
  table.matrix { min-width: 0; display: block; }
  .matrix thead { display: none; }
  .matrix tbody { display: flex; flex-direction: column; gap: 10px; }
  .matrix tbody tr { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 10px; padding: 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
  .matrix tbody tr:hover td, .matrix tbody tr:hover th { background: none; }
  .matrix th, .matrix td { padding: 0; border: 0 !important; }
  .matrix .client-cell { position: static; grid-column: 1 / 5; grid-row: 1; min-width: 0; max-width: none;
    border-right: 0; background: none; align-self: center; }
  .matrix .client-cell a { font-size: .98rem; }
  .matrix .done-td { grid-column: 5 / 6; grid-row: 1; width: auto; align-self: center; text-align: right; }
  .matrix .notes-td { grid-column: 6 / 7; grid-row: 1; width: auto; align-self: center; text-align: right; }
  .matrix .task-td { grid-column: span 3; }
  .matrix .task-td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted);
    font-size: .66rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
  .matrix .task-td .st-select { min-width: 0; min-height: 40px; font-size: .84rem; }
  .matrix .client-cell small { margin-top: 1px; }
}
.settings-panel code, .settings-panel .small-note { overflow-wrap: anywhere; }
/* A long menu on a short screen (a phone on its side) scrolls inside itself. */
.pop-menu { max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 1100px) {
  .note-tree-panel { overflow-y: auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
