/* ==========================================================================
   HQ — design system
   Day: white + cool grays, radar blue. Night: deep navy, beam cyan (from the HQ mark).
   ========================================================================== */

@font-face {
  font-family: "Mona Sans";
  src: url("/assets/fonts/MonaSans.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/InstrumentSerif-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/JetBrainsMono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: light;

  --font-sans: "Mona Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", ui-serif, Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --surface-3: #e3e8ef;
  --ink: #0b1526;
  --ink-2: #46536a;
  --muted: #7b879b;
  --line: #e1e6ed;
  --line-strong: #ccd4df;

  --accent: #175fd6;
  --accent-hover: #124db3;
  --accent-ink: #ffffff;
  --accent-soft: rgba(23, 95, 214, 0.08);
  --accent-ring: rgba(23, 95, 214, 0.3);

  --chart: #175fd6;

  --chart-glow: transparent;
  --grid: #e8edf3;
  --axis: #c9d1dc;

  --pos: #0b7a33;
  --pos-soft: rgba(11, 122, 51, 0.09);
  --neg: #b42318;
  --neg-soft: rgba(180, 35, 24, 0.08);
  --warn: #a35a00;
  --warn-soft: rgba(212, 135, 0, 0.12);

  --btn-primary-bg: #0a2647;
  --btn-primary-ink: #ffffff;
  --btn-primary-hover: #0f3463;

  --shadow-sm: 0 1px 2px rgba(11, 21, 38, 0.05);
  --shadow: 0 1px 2px rgba(11, 21, 38, 0.04), 0 6px 20px -10px rgba(11, 21, 38, 0.14);
  --shadow-lg: 0 30px 70px -24px rgba(11, 21, 38, 0.3), 0 2px 6px rgba(11, 21, 38, 0.06);
  --inset: inset 0 1px 0 rgba(255, 255, 255, 0.8);

  /* Section identity colours — validated categorical order. */
  --c-blue: #2a78d6;
  --c-orange: #eb6834;
  --c-aqua: #1baf7a;
  --c-yellow: #eda100;
  --c-magenta: #e87ba4;
  --c-green: #008300;
  --c-violet: #4a3aa7;
  --c-red: #e34948;

  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;

  --sidebar-w: 256px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #050c18;
    --surface: #0a1526;
    --surface-2: #0e1c32;
    --surface-3: #15263f;
    --ink: #e6eef8;
    --ink-2: #a6b4c8;
    --muted: #6c7d96;
    --line: #14233a;
    --line-strong: #1f3352;
    --accent: #5ff3ff;
    --accent-hover: #93f7ff;
    --accent-ink: #03111d;
    --accent-soft: rgba(95, 243, 255, 0.1);
    --accent-ring: rgba(95, 243, 255, 0.4);
    --chart: #5ff3ff;
    --chart-glow: rgba(95, 243, 255, 0.55);
    --grid: #112038;
    --axis: #22385a;
    --pos: #3cc46b;
    --pos-soft: rgba(60, 196, 107, 0.12);
    --neg: #f47066;
    --neg-soft: rgba(244, 112, 102, 0.12);
    --warn: #f0b03c;
    --warn-soft: rgba(240, 176, 60, 0.12);
    --btn-primary-bg: #e6eef8;
    --btn-primary-ink: #050c18;
    --btn-primary-hover: #ffffff;
    --shadow-sm: none;
    --shadow: 0 0 0 1px rgba(95, 243, 255, 0.02), 0 8px 24px -12px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(95, 243, 255, 0.05);
    --inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --c-blue: #3987e5;
    --c-orange: #d95926;
    --c-aqua: #199e70;
    --c-yellow: #c98500;
    --c-magenta: #d55181;
    --c-green: #008300;
    --c-violet: #9085e9;
    --c-red: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050c18;
  --surface: #0a1526;
  --surface-2: #0e1c32;
  --surface-3: #15263f;
  --ink: #e6eef8;
  --ink-2: #a6b4c8;
  --muted: #6c7d96;
  --line: #14233a;
  --line-strong: #1f3352;
  --accent: #5ff3ff;
  --accent-hover: #93f7ff;
  --accent-ink: #03111d;
  --accent-soft: rgba(95, 243, 255, 0.1);
  --accent-ring: rgba(95, 243, 255, 0.4);
  --chart: #5ff3ff;
  --chart-glow: rgba(95, 243, 255, 0.55);
  --grid: #112038;
  --axis: #22385a;
  --pos: #3cc46b;
  --pos-soft: rgba(60, 196, 107, 0.12);
  --neg: #f47066;
  --neg-soft: rgba(244, 112, 102, 0.12);
  --warn: #f0b03c;
  --warn-soft: rgba(240, 176, 60, 0.12);
  --btn-primary-bg: #e6eef8;
  --btn-primary-ink: #050c18;
  --btn-primary-hover: #ffffff;
  --shadow-sm: none;
  --shadow: 0 0 0 1px rgba(95, 243, 255, 0.02), 0 8px 24px -12px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(95, 243, 255, 0.05);
  --inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --c-blue: #3987e5;
  --c-orange: #d95926;
  --c-aqua: #199e70;
  --c-yellow: #c98500;
  --c-magenta: #d55181;
  --c-green: #008300;
  --c-violet: #9085e9;
  --c-red: #e66767;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
.icon { flex-shrink: 0; }
[hidden] { display: none !important; }

::selection { background: var(--accent-soft); color: var(--ink); }

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

.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;
}

.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--font-serif); font-style: italic; font-weight: 400; letter-spacing: 0; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- App shell ---------- */

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 20px 14px 16px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  scrollbar-width: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 8px;
}
.brand-mark {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 650; font-size: 14.5px; letter-spacing: -0.015em; line-height: 1.1; }
.brand-sub { font-family: var(--font-serif); font-style: italic; color: var(--muted); font-size: 14px; line-height: 1.1; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px 8px; }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link .icon { color: var(--muted); transition: color 0.15s; }
.nav-link[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line), var(--inset);
}
.nav-link[aria-current="page"] .icon { color: var(--accent); }
.nav-link .kbd { margin-left: auto; }
.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.nav-sub { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; }
.nav-sub .nav-link { height: 32px; font-size: 13.5px; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--c, var(--muted));
}
.nav-sub .dot { margin: 0 4px 0 5px; }
.nav-add { color: var(--muted); }
.nav-add .icon { width: 15px; height: 15px; margin: 0 1px 0 2px; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.theme-switch button {
  display: grid;
  place-items: center;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 2px 10px;
}
.user-row .who { min-width: 0; flex: 1; }
.user-row .who strong { display: block; font-size: 13px; font-weight: 600; }
.user-row .who span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 64px;
  padding: 0 36px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.topbar.is-stuck { border-bottom-color: var(--line); }
.topbar .crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .crumbs a:hover { color: var(--ink); }
.topbar .crumbs .sep { color: var(--line-strong); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn.menu-btn { display: none; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 280px;
  height: 36px;
  padding: 0 8px 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.search-trigger:hover { box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-sm); }
.search-trigger span:first-of-type { flex: 1; text-align: left; }

.kbd {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.page {
  width: 100%;
  max-width: 1320px;
  padding: 10px 36px 72px;
  transition: opacity 0.2s var(--ease);
}
.page.is-loading { opacity: 0.5; pointer-events: none; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 14px 0 26px;
}
.page-head h1 { font-size: 30px; letter-spacing: -0.03em; font-weight: 620; }
.page-head h1 em { font-family: var(--font-serif); font-weight: 400; font-style: italic; letter-spacing: -0.01em; font-size: 1.12em; }
.page-head p { margin-top: 6px; color: var(--ink-2); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  font-size: 13.5px;
  white-space: nowrap;
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm), var(--inset);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, color 0.15s;
}
.btn:hover { background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:hover { background: var(--btn-primary-hover); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn-accent { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.btn-accent:hover { background: var(--accent-hover); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; color: var(--ink); }
.btn-danger { color: var(--neg); }
.btn-danger:hover { background: var(--neg-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn[disabled], .btn.is-busy { opacity: 0.55; pointer-events: none; }
.btn.is-busy .icon { animation: spin 0.9s linear infinite; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field + .field { margin-top: 16px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--muted); }

.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  outline: none;
  transition: box-shadow 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:hover, .select:hover, .textarea:hover { box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-sm); }
.input:focus, .select:focus, .textarea:focus { box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); }
.textarea { height: auto; padding: 12px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23858279' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.select-sm { height: 32px; font-size: 13px; padding-left: 10px; border-radius: 9px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Segmented control (range picker) */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 11px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.segmented a, .segmented button {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
}
.segmented a:hover, .segmented button:hover { color: var(--ink); }
.segmented [aria-current="true"], .segmented [aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
}

/* ---------- Cards & layout ---------- */

.grid { display: grid; gap: 20px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

.card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px var(--line), var(--shadow), var(--inset);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 0;
}
.card-head h2 { font-size: 15px; font-weight: 620; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--muted); }
.card-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 18px 22px 22px; }
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
  transition: color 0.15s, gap 0.2s var(--ease);
}
.link-arrow:hover { color: var(--accent); gap: 9px; }
.link-arrow .icon { width: 14px; height: 14px; }

/* ---------- Hero metric ---------- */

.hero { overflow: hidden; }
.hero::before {
  /* Dotted grid fading in from the top-right corner. */
  content: "";
  position: absolute;
  inset: 0 0 auto auto;
  width: 60%;
  height: 210px;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--line-strong) 1px, transparent 1.2px);
  background-size: 14px 14px;
  -webkit-mask-image: radial-gradient(ellipse at top right, #000 0%, transparent 70%);
  mask-image: radial-gradient(ellipse at top right, #000 0%, transparent 70%);
  opacity: 0.8;
}
.hero-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 26px 0;
}
.hero-value {
  margin-top: 12px;
  font-size: 54px;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
}
.hero-value .cents { color: var(--muted); font-size: 0.5em; letter-spacing: -0.02em; font-weight: 550; margin-left: 2px; }
.hero-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; text-align: right; }
.deltas { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 14px; }
.delta-group { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  color: var(--ink-2);
}
.delta .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.delta.up { background: var(--pos-soft); color: var(--pos); }
.delta.down { background: var(--neg-soft); color: var(--neg); }
.delta-text.up { color: var(--pos); }
.delta-text.down { color: var(--neg); }
.delta-text { font-variant-numeric: tabular-nums; font-weight: 550; }

/* ---------- Stat tiles ---------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.stat { padding: 18px 22px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat .value { margin-top: 8px; font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
.stat .foot { margin-top: 4px; font-size: 12.5px; color: var(--muted); }

/* ---------- Chart ---------- */

.chart {
  position: relative;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
}
.chart:focus-visible { outline-offset: -2px; border-radius: 12px; }
.chart svg { overflow: visible; }
.chart-wrap { padding: 8px 10px 14px 22px; }

.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-family: var(--font-mono); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 0 5px var(--chart-glow)); }
.chart .area-stop { stop-color: var(--chart); }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; opacity: 0.45; shape-rendering: crispEdges; }
.chart .marker { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart .end-dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart .end-pulse { fill: var(--chart); opacity: 0.25; transform-box: fill-box; transform-origin: center; animation: pulse 2.4s var(--ease) infinite; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 0; opacity: 0.7; }
.chart.is-drawn .line { animation: draw 1.1s var(--ease) both; }
.chart.is-drawn .area { animation: fade 1.1s 0.25s var(--ease) both; }

.chart-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  min-width: 150px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}
.chart-tip.is-visible { opacity: 1; transform: translateY(0); }
.chart-tip .tip-value { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }
.chart-tip .tip-date { margin-top: 2px; font-size: 12px; color: var(--muted); }
.chart-tip .tip-delta { margin-top: 6px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.chart-tip .tip-key { width: 12px; height: 2px; border-radius: 2px; background: var(--chart); }

.chart-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Lists ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
}
.list-row:first-child { border-top: 0; }
a.list-row { transition: background 0.15s; }
a.list-row:hover { background: var(--surface-2); }

.account-row .meta { min-width: 0; flex: 1; }
.account-row .name, .account-row .detail { display: block; }
.account-row .name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-row .detail { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-row .bal { text-align: right; }
.account-row .bal strong { display: block; font-weight: 620; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.account-row .bal span { font-size: 12px; }
.account-row.is-hidden { opacity: 0.5; }

.inst-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.spark { width: 84px; height: 28px; flex-shrink: 0; }
.spark .spark-line { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; opacity: 0.75; }
.spark .spark-dot { fill: var(--chart); stroke: var(--surface); stroke-width: 1.5; }

/* ---------- Pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--pos-soft); color: var(--pos); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--neg-soft); color: var(--neg); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.plain::before { display: none; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  position: sticky;
  top: 0;
  padding: 10px 22px;
  text-align: left;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.table td { padding: 11px 22px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .r { text-align: right; }
.table td.num, .table .num { font-variant-numeric: tabular-nums; }
.table .sym { font-family: var(--font-mono); font-weight: 600; font-size: 12px; }
.table .weight { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.table .bar { width: 64px; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.table .bar i { display: block; height: 100%; border-radius: 4px; background: var(--chart); }
.table-more { padding: 12px 22px; border-top: 1px solid var(--line); }

/* ---------- Connections ---------- */

.conn { display: flex; align-items: flex-start; gap: 14px; padding: 16px 22px; border-top: 1px solid var(--line); }
.conn:first-child { border-top: 0; }
.conn .meta { flex: 1; min-width: 0; }
.conn .name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 620; }
.conn .detail { margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.conn .error { margin-top: 8px; font-size: 12.5px; color: var(--neg); }
.conn .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.setup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.setup-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.setup-list .state {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
}
.setup-list .state.ok { background: var(--pos-soft); box-shadow: none; color: var(--pos); }
.setup-list .icon { width: 12px; height: 12px; stroke-width: 2.6; }
.setup-list code, .code-inline {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- Empty states ---------- */

.empty {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 28px;
}
.empty h3 { margin-top: 18px; font-size: 26px; font-weight: 400; font-family: var(--font-serif); font-style: italic; letter-spacing: -0.01em; }
.empty p { margin-top: 8px; max-width: 420px; color: var(--ink-2); }
.empty .actions { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.empty-art { width: 180px; height: 72px; color: var(--chart); }
.empty-art .ghost { stroke: var(--line-strong); }
.empty.compact { padding: 32px 22px; }
.empty.compact h3 { font-size: 21px; margin-top: 0; }

/* ---------- Notes ---------- */

.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }

.section-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 168px;
  padding: 20px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow), var(--inset);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.section-card::after {
  /* A soft wash of the section colour in the corner. */
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--c);
  opacity: 0.08;
  filter: blur(8px);
  transition: opacity 0.25s;
}
.section-card:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-lg); }
.section-card:hover::after { opacity: 0.14; }
.section-card .glyph {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--c) 13%, transparent);
  color: var(--c);
}
.section-card h3 { margin-top: 16px; font-size: 17px; font-weight: 620; }
.section-card p { margin-top: 4px; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.section-card .foot { margin-top: auto; padding-top: 16px; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.section-card.new {
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: 1.5px dashed var(--line-strong);
  outline-offset: -1.5px;
  color: var(--muted);
  font-weight: 550;
}
.section-card.new:hover { color: var(--ink); background: var(--surface); transform: none; box-shadow: none; }
.section-card.new::after { display: none; }

.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.note-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 150px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.note-card:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--line-strong), var(--shadow); }
.note-card .top { display: flex; align-items: center; justify-content: space-between; }
.note-card .star { color: var(--c-yellow); }
.note-card .star .icon { fill: currentColor; }
.note-card h3 { margin-top: 12px; font-size: 14.5px; font-weight: 620; line-height: 1.35; }
.note-card p { margin-top: 6px; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-card .foot { margin-top: auto; padding-top: 12px; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; }

.recent-row { display: flex; align-items: center; gap: 12px; padding: 11px 22px; border-top: 1px solid var(--line); transition: background 0.15s; }
.recent-row:first-child { border-top: 0; }
.recent-row:hover { background: var(--surface-2); }
.recent-row .title { flex: 1; min-width: 0; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-row time { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Two-pane section view */
.notes-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: calc(100vh - 210px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow), var(--inset);
}
.notes-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.notes-list-head { display: flex; align-items: center; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
.notes-list-head .input { height: 34px; font-size: 13px; }
.notes-list ul { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.note-item {
  display: block;
  padding: 12px 12px 12px 14px;
  border-radius: 12px;
  transition: background 0.15s;
}
.note-item + .note-item { margin-top: 2px; }
.note-item:hover { background: var(--surface-2); }
.note-item[aria-current="page"] { background: var(--accent-soft); }
.note-item[aria-current="page"] .t { color: var(--accent); }
.note-item .t { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.note-item .t span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .t .icon { color: var(--c-yellow); fill: currentColor; }
.note-item .x { margin-top: 3px; font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-item time { display: block; margin-top: 6px; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }

.reader { min-width: 0; display: flex; flex-direction: column; }
.reader-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 30px 40px 0;
}
.reader-head h1 { font-size: 28px; letter-spacing: -0.03em; font-weight: 640; }
.reader-meta { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.reader-tools { display: flex; gap: 4px; }
.reader-body { padding: 26px 40px 48px; }
.reader-empty { flex: 1; display: grid; place-items: center; }

.fav-btn.is-on { color: var(--c-yellow); }
.fav-btn.is-on .icon { fill: currentColor; }

/* Rendered markdown */
.prose { font-size: 15px; line-height: 1.72; color: var(--ink); max-width: 72ch; overflow-wrap: break-word; }
.prose > * + * { margin-top: 0.9em; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin-top: 1.6em; letter-spacing: -0.02em; }
.prose h1 { font-size: 1.6em; }
.prose h2 { font-size: 1.3em; }
.prose h3 { font-size: 1.1em; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.prose a:hover { text-decoration-color: var(--accent); }
.prose strong { font-weight: 650; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.3em; }
.prose li::marker { color: var(--muted); }
.prose ul:has(> li > input[type="checkbox"]) { list-style: none; padding-left: 0.2em; }
.prose li > input[type="checkbox"] { margin: 0 8px 0 0; accent-color: var(--accent); transform: translateY(1px); }
.prose blockquote { margin-left: 0; padding: 2px 0 2px 18px; border-left: 2px solid var(--accent); color: var(--ink-2); font-family: var(--font-serif); font-style: italic; font-size: 1.12em; }
.prose code { font-family: var(--font-mono); font-size: 0.84em; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.prose pre { position: relative; margin-left: 0; margin-right: 0; padding: 16px 18px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow-x: auto; line-height: 1.6; }
.prose pre code { padding: 0; background: none; box-shadow: none; font-size: 12.5px; }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2em 0; }
.prose table { border-collapse: collapse; font-size: 0.92em; width: 100%; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.prose th { font-weight: 600; color: var(--ink-2); }
.prose img { max-width: 100%; border-radius: 10px; }
.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
.prose pre:hover .copy-code, .copy-code:focus-visible { opacity: 1; }

/* Editor */
.editor { overflow: hidden; }
.editor-title {
  width: 100%;
  padding: 26px 30px 6px;
  border: 0;
  background: transparent;
  font-size: 28px;
  font-weight: 640;
  letter-spacing: -0.03em;
  outline: none;
}
.editor-title::placeholder { color: var(--line-strong); }
.editor-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 30px 14px;
  border-bottom: 1px solid var(--line);
}
.editor-bar .spacer { flex: 1; }
.editor-body { position: relative; }
.editor-text {
  display: block;
  width: 100%;
  min-height: 420px;
  padding: 24px 30px 40px;
  border: 0;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.75;
  outline: none;
  tab-size: 2;
}
.editor-text::placeholder { color: var(--muted); }
.editor-preview { padding: 24px 30px 40px; min-height: 420px; }
.editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 30px; border-top: 1px solid var(--line); }

/* ---------- Calendar ---------- */

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 6px; gap: 4px; }
.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px 12px;
  border-radius: 14px;
  transition: background 0.15s;
}
.week-day:hover { background: var(--surface-2); }
.week-num { font-size: 24px; font-weight: 620; letter-spacing: -0.03em; line-height: 1; }
.week-day.is-today { background: var(--accent-soft); }
.week-day.is-today .week-num, .week-day.is-today .eyebrow { color: var(--accent); }
.week-dots { display: flex; gap: 3px; height: 6px; }
.week-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.week-count { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }

.agenda-day { padding: 4px 0 8px; }
.agenda-day + .agenda-day { border-top: 1px solid var(--line); }
.agenda-head { display: flex; align-items: baseline; gap: 10px; padding: 14px 22px 6px; }
.agenda-label { font-weight: 650; font-size: 14px; letter-spacing: -0.01em; }
.agenda-label.is-today { color: var(--accent); }
.agenda-free { padding: 6px 22px 8px 108px; color: var(--muted); font-size: 13px; }

.event {
  display: grid;
  grid-template-columns: 74px 3px minmax(0, 1fr) auto;
  align-items: start;
  gap: 0 12px;
  padding: 9px 22px;
  transition: background 0.15s;
}
.event:hover { background: var(--surface-2); }
.event-time { display: flex; flex-direction: column; padding-top: 1px; font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.event-time .muted { font-size: 10.5px; }
.event-bar { align-self: stretch; min-height: 20px; border-radius: 3px; background: var(--c); }
.event-main { min-width: 0; }
.event-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 580; font-size: 13.5px; }
.event-title > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.event-meta { margin-top: 2px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-actions { display: flex; gap: 4px; align-items: center; }
.event.is-past { opacity: 0.5; }
.event.is-now { background: var(--accent-soft); }
.event-notes { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.event-notes summary { cursor: pointer; color: var(--muted); width: fit-content; }
.event-notes p { margin-top: 6px; max-width: 64ch; overflow-wrap: anywhere; }

.cal-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-range { margin-left: 8px; font-weight: 620; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.cal-jump { margin-left: auto; }
.agenda-pager { justify-content: space-between; }
.agenda-pager .btn .icon { width: 15px; height: 15px; }

.month { overflow: hidden; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-dow { padding: 12px 10px 8px; border-bottom: 1px solid var(--line); }
.month-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 112px;
  min-width: 0;
  padding: 8px 8px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.month-cell:nth-child(7n + 7) { border-right: 0; }
a.month-cell:hover { background: var(--surface-2); }
.month-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.month-cell.is-today .month-num { background: var(--accent); color: var(--accent-ink); }
.month-cell.is-other .month-num { color: var(--muted); }
.month-cell.is-outside { background: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-2) 8px 9px); }
.month-cell.is-outside .month-num { color: var(--line-strong); }
.month-ev {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  padding: 1px 6px 1px 7px;
  border-left: 2.5px solid var(--c);
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink);
}
.month-ev.is-all-day { border-left: 0; padding-left: 7px; background: color-mix(in srgb, var(--c) 16%, transparent); font-weight: 550; }
.month-ev.is-past { opacity: 0.5; }
.month-ev-time { flex-shrink: 0; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.month-ev-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-more { padding-left: 7px; font-size: 11px; font-weight: 600; color: var(--muted); }

.schedule .event { grid-template-columns: 58px 3px minmax(0, 1fr) auto; padding: 8px 22px; }
.schedule .agenda-head { padding: 12px 22px 4px; }
.schedule .agenda-free { padding: 4px 22px 8px 95px; }

.cal-account + .cal-account { border-top: 1px solid var(--line); }
.cal-account-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 22px 8px; }
.cal-account-head .meta { flex: 1; min-width: 0; }
.cal-account-head .name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.cal-account-head .detail { font-size: 12px; color: var(--muted); }
.cal-account-head .error { margin-top: 6px; font-size: 12px; color: var(--neg); }
.cal-list { list-style: none; margin: 0; padding: 0 10px 10px; }
.cal-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  transition: background 0.15s;
}
.cal-toggle:hover { background: var(--surface-2); }
.cal-check {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 5px;
  background: var(--c);
  color: #fff;
}
.cal-check .icon { stroke-width: 3; }
.cal-toggle[aria-pressed="false"] .cal-check { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.cal-toggle[aria-pressed="false"] .cal-check .icon { display: none; }
.cal-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 520; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-role { font-size: 11.5px; color: var(--muted); }
.cal-list .is-hidden .cal-name { color: var(--muted); }

.setup-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--ink-2); }

/* ---------- To-do ---------- */

.nav-due { color: var(--neg); font-weight: 600; }

.task-add { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px 10px 18px; }
.task-add-icon { display: grid; place-items: center; color: var(--muted); }
.task-add-input {
  flex: 1 1 260px;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 520;
  outline: none;
}
.task-add-input::placeholder { color: var(--muted); font-weight: 450; }
.task-add-when { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-chips { display: flex; gap: 4px; }
.date-chips button {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 550;
  transition: background 0.15s, color 0.15s;
}
.date-chips button:hover { color: var(--ink); }
.date-chips button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-ring); }
.input-date { width: auto; height: 34px; padding: 0 10px; font-size: 13px; color: var(--ink-2); }

.task-group + .task-group { border-top: 1px solid var(--line); }
.task-group { padding-bottom: 6px; }
.task-group-overdue { color: var(--neg); }
.task-group-today { color: var(--accent); }

.tasks { list-style: none; margin: 0; padding: 0; }
.task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 22px;
  transition: background 0.15s;
}
.task:hover { background: var(--surface-2); }
.task:target { background: var(--accent-soft); }
.task form { display: contents; }
.task-check {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex-shrink: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1.6px var(--line-strong);
  color: transparent;
  transition: background 0.18s var(--ease), box-shadow 0.18s, color 0.18s, transform 0.12s;
}
.task-check:hover { box-shadow: inset 0 0 0 1.6px var(--accent); color: var(--accent); }
.task-check:active { transform: scale(0.9); }
.task-check .icon { stroke-width: 3; }
.task.is-done .task-check { background: var(--accent); box-shadow: none; color: var(--accent-ink); }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.task-title { font-weight: 550; font-size: 13.5px; overflow-wrap: anywhere; transition: color 0.2s; }
.task-notes { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.task.is-done .task-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.task-actions { opacity: 0; transition: opacity 0.15s; margin: -4px -6px -4px 0; }
.task:hover .task-actions, .task:focus-within .task-actions { opacity: 1; }

.due {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.due-overdue { background: var(--neg-soft); color: var(--neg); }
.due-today { background: var(--accent-soft); color: var(--accent); }

.task-done summary { list-style: none; cursor: pointer; }
.task-done summary::-webkit-details-marker { display: none; }
.task-done[open] summary .link-arrow { visibility: hidden; }

.task-quick { display: flex; align-items: center; gap: 10px; margin: 6px 14px 14px; padding: 4px 6px 4px 12px; border-radius: 11px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.task-quick input[name=title] { flex: 1; min-width: 0; height: 34px; border: 0; background: transparent; outline: none; font-size: 13.5px; }
.task-quick input[name=title]::placeholder { color: var(--muted); }
.task-quick .input-date { box-shadow: none; background: transparent; height: 30px; }
.task-quick:focus-within { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }

/* ---------- Secure notes ---------- */

.lock-mark { display: inline-grid; color: var(--accent); flex: none !important; }
.lock-mark .icon { fill: none !important; }
.note-item .t .lock-mark .icon { color: var(--accent); }
.secure-hint { display: flex; align-items: center; gap: 6px; color: var(--accent) !important; }
.pill.accent.plain .icon { margin-right: 2px; }

.secure-toggle .icon { color: var(--muted); }
.editor.is-secure .secure-toggle, .editor.is-secure .secure-toggle .icon { color: var(--accent); }
.editor.is-secure { box-shadow: 0 0 0 1px var(--accent-ring), var(--shadow), var(--inset); }
.editor.is-secure .editor-text { font-family: var(--font-mono); font-size: 13.5px; }

.secure-unlock-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 30px 0;
  padding: 10px 10px 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 550;
}
.secure-unlock-bar span { flex: 1; }

.secure-box { max-width: 72ch; border-radius: 16px; box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.secure-box.is-unlocked { box-shadow: 0 0 0 1px var(--accent-ring); }
.secure-locked { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 24px; background: repeating-linear-gradient(135deg, transparent 0 10px, var(--surface-2) 10px 11px); }
.secure-locked-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.secure-locked h3 { margin-top: 14px; font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 24px; }
.secure-locked p { margin: 6px 0 16px; color: var(--ink-2); max-width: 360px; }
.secure-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 16px; background: var(--accent-soft); }
.secure-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.secure-tools { display: flex; gap: 2px; }
.secure-fields { padding: 8px 0; }
.secure-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 16px; }
.secure-row + .secure-row { border-top: 1px solid var(--line); }
.secure-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; overflow-wrap: anywhere; }
.secure-value { font-family: var(--font-mono); font-size: 13.5px; overflow-wrap: anywhere; user-select: all; }
.secure-value.is-masked { letter-spacing: 0.12em; color: var(--ink-2); user-select: none; }
.secure-actions { display: flex; gap: 2px; }
.secure-text { padding: 8px 16px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.editor-preview .secure-fields { max-width: 72ch; border-radius: 14px; box-shadow: 0 0 0 1px var(--line); }

.vault-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}
.vault-chip:hover { box-shadow: inset 0 0 0 1px var(--accent-ring); }

.vault-card-inner { display: flex; align-items: flex-start; gap: 18px; padding: 22px; flex-wrap: wrap; }
.vault-glyph { display: grid; place-items: center; width: 46px; height: 46px; flex-shrink: 0; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.vault-copy { flex: 1 1 360px; min-width: 0; }
.vault-copy h2 { font-size: 16px; }
.vault-copy p { margin-top: 6px; color: var(--ink-2); max-width: 70ch; }
.vault-copy .vault-status { color: var(--muted); font-size: 12.5px; }
.vault-actions { display: flex; gap: 8px; flex-wrap: wrap; align-self: center; }

/* ---------- Links ---------- */

.link-group + .link-group { margin-top: 26px; }
.link-group-head { margin: 0 2px 10px; }
.link-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.link-tile {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.link-tile:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--line-strong), var(--shadow); }
.link-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 6px 12px 12px; }
.link-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: var(--c);
  font-weight: 700;
  font-size: 14px;
}
.link-text { min-width: 0; display: flex; flex-direction: column; }
.link-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-host { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-tools { display: flex; gap: 2px; padding-right: 8px; }
.link-tools .btn:not(.is-on) { opacity: 0; transition: opacity 0.15s; }
.link-tile:hover .link-tools .btn, .link-tile:focus-within .link-tools .btn { opacity: 1; }
.link-grid [hidden] { display: none; }

.pinned-links { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 22px; }
.pinned-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 14px 0 5px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  font-weight: 550;
  font-size: 13px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.pinned-link:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--line-strong), var(--shadow); }
.pinned-link .link-badge { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
.pinned-more { padding: 0 11px; color: var(--muted); }

/* Dashboard columns */
.dash { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- Dialogs ---------- */

dialog {
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-lg);
  max-width: calc(100vw - 32px);
}
dialog::backdrop {
  background: color-mix(in srgb, var(--bg) 55%, rgba(0, 0, 0, 0.35));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
dialog[open] { animation: pop 0.22s var(--ease); }
.modal { width: 460px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 0; }
.modal-head h2 { font-size: 18px; }
.modal-head p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.modal-body { padding: 20px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-foot .left { margin-right: auto; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
}
.swatch span:hover { transform: scale(1.08); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Command palette */
.palette { width: 620px; margin-top: 12vh; overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.palette-input .icon { color: var(--muted); }
.palette-input input { flex: 1; height: 56px; border: 0; background: transparent; font-size: 16px; outline: none; }
.palette-results { max-height: min(440px, 60vh); overflow-y: auto; padding: 8px; }
.palette-group { padding: 10px 10px 6px; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
}
.palette-item .icon { color: var(--muted); }
.palette-item .pi-text { flex: 1; min-width: 0; }
.palette-item .pi-title { display: block; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-sub { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-meta { font-size: 12px; color: var(--muted); }
.palette-item[aria-selected="true"] { background: var(--accent-soft); }
.palette-item[aria-selected="true"] .icon { color: var(--accent); }
.palette-empty { padding: 28px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--surface-2); }
.palette-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(400px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-lg);
  font-size: 13.5px;
  animation: toast-in 0.35s var(--ease) both;
}
.toast.is-leaving { animation: toast-out 0.25s var(--ease) both; }
.toast .t-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; background: var(--surface-2); color: var(--ink-2); }
.toast .t-icon .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.toast.success .t-icon { background: var(--pos-soft); color: var(--pos); }
.toast.error .t-icon { background: var(--neg-soft); color: var(--neg); }
.toast.info .t-icon { background: var(--accent-soft); color: var(--accent); }
.toast .t-msg { flex: 1; padding-top: 1px; }
.toast button { border: 0; background: none; color: var(--muted); padding: 2px; border-radius: 6px; }
.toast button:hover { color: var(--ink); }

/* ---------- Auth ---------- */

.auth {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  min-height: 100vh;
}
.auth-art {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 52px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(900px 500px at 0% 100%, var(--accent-soft), transparent 60%),
    var(--surface);
}
.auth-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at 30% 60%, #000 10%, transparent 75%);
  mask-image: radial-gradient(ellipse at 30% 60%, #000 10%, transparent 75%);
  opacity: 0.6;
}
.auth-art > * { position: relative; }
.auth-quote { max-width: 520px; }
.auth-quote h1 { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: clamp(44px, 5vw, 72px); line-height: 0.98; letter-spacing: -0.02em; }
.auth-quote p { margin-top: 18px; color: var(--ink-2); font-size: 15px; max-width: 400px; }
.auth-chart { width: 100%; max-width: 560px; height: 140px; color: var(--chart); }
.auth-foot { display: flex; gap: 18px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 26px; letter-spacing: -0.03em; }
.auth-card > p { margin-top: 6px; color: var(--ink-2); }
.auth-card form { margin-top: 28px; }
.auth-card .btn { width: 100%; height: 42px; margin-top: 22px; }
.notice {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-2);
}
.notice .icon { width: 16px; height: 16px; margin-top: 1px; }
.notice.error { background: var(--neg-soft); box-shadow: none; color: var(--neg); }
.notice.warn { background: var(--warn-soft); box-shadow: none; color: var(--warn); }
.notice code { font-family: var(--font-mono); font-size: 12px; }

/* ---------- Motion ---------- */

.reveal { animation: rise 0.6s var(--ease) both; animation-delay: calc(var(--d, 0) * 70ms); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes draw { from { stroke-dashoffset: var(--len, 2000); stroke-dasharray: var(--len, 2000); } to { stroke-dashoffset: 0; stroke-dasharray: var(--len, 2000); } }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.35; } 70%, 100% { transform: scale(3.2); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
  /* Single column: balance first, then today's schedule, then the rest. */
  .dash { display: flex; flex-direction: column; }
  .dash-col { display: contents; }
  .dash .hero { order: -2; }
  .dash .schedule, .dash .todo-card { order: -1; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: var(--sidebar-w);
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.35); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
  .nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .btn.menu-btn { display: inline-flex; }
  .topbar, .page { padding-left: 18px; padding-right: 18px; }
  .search-trigger { width: auto; }
  .search-trigger span:first-of-type, .search-trigger .kbd { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .hero-head { flex-direction: column; }
  .hero-meta { align-items: flex-start; text-align: left; }
  .hero-value { font-size: 42px; }
  .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .notes-layout.has-note .notes-list { display: none; }
  .notes-layout:not(.has-note) .reader { display: none; }
  .reader-head, .reader-body { padding-left: 22px; padding-right: 22px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
}

@media (max-width: 560px) {
  .month-cell { min-height: 64px; padding: 6px 4px; }
  .month-ev-time, .month-more { display: none; }
  .month-ev { font-size: 10.5px; padding: 0 3px 0 4px; }
  .cal-jump { margin-left: 0; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat + .stat { border-left: 0; border-top: 1px solid var(--line); }
  .spark { display: none; }
  .table th, .table td { padding-left: 14px; padding-right: 14px; }
}

@media print {
  .sidebar, .topbar, .toasts, .page-actions, .reader-tools { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body::before { display: none; }
}

.btn-primary.btn-danger { background: var(--neg); color: #fff; }
.btn-primary.btn-danger:hover { background: color-mix(in srgb, var(--neg) 85%, #000); }
