:root {
  --accent: #1867C0;
  --accent-tint: #E8F0FE;
  --accent-hover: #155AA9;
  --ink: #202124;
  --ink-2: #5F6368;
  --ink-3: #80868B;
  --line: #E8EAED;
  --line-2: #DADCE0;
  --bg: #F8F9FA;
  --surface: #FFFFFF;
  --ok: #1E8E6E;
  --ok-tint: #E6F4EF;
  --warn: #8A4B08;
  --warn-tint: #FFF4E5;
  --err: #C5221F;
  --err-tint: #FCE8E6;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-pill: 999px;
  --topbar-height: 56px;
  --control-height: 40px;
  --control-padding-x: 12px;
  --shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-2: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px rgba(0, 0, 0, 0.14), 0 1px 5px rgba(0, 0, 0, 0.12);
  --shadow-3: 0 3px 3px -2px rgba(0, 0, 0, 0.2), 0 3px 4px rgba(0, 0, 0, 0.14), 0 1px 8px rgba(0, 0, 0, 0.12);
  --state-hover: rgba(24, 103, 192, 0.08);
  --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

html {
  scroll-padding-top: var(--topbar-height);
  scrollbar-color: rgba(95, 99, 104, 0.38) transparent;
  scrollbar-width: thin;
}
html::-webkit-scrollbar {
  width: 10px;
}
html::-webkit-scrollbar-track {
  background: transparent;
}
html::-webkit-scrollbar-thumb {
  min-height: 48px;
  border: 3px solid var(--bg);
  border-radius: var(--radius-pill);
  background: rgba(95, 99, 104, 0.34);
}
html::-webkit-scrollbar-thumb:hover {
  background: rgba(95, 99, 104, 0.5);
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
body.app-shell {
  overflow-x: clip;
  overflow-y: visible;
}
body.auth-page {
  overflow-x: clip;
  overflow-y: visible;
}

a { color: inherit; text-decoration: none; }
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(24, 103, 192, 0.28);
  outline-offset: 2px;
}
h1 { font-size: 28px; line-height: 1.2; font-weight: 500; margin: 0 0 4px; }
h2 { font-size: 20px; line-height: 1.35; font-weight: 500; margin: 0 0 12px; }
h3 { font-size: 16px; line-height: 1.4; font-weight: 500; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
code {
  background: var(--accent-tint);
  color: var(--accent-hover);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- Auth ---- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(100%, 380px);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-2);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  color: var(--accent-hover);
  font-size: 18px;
  font-weight: 500;
}
.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.auth-link {
  color: var(--accent-hover);
  font-size: 14px;
  font-weight: 500;
}
.reset-token {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}
.reset-token a { color: var(--accent-hover); font-weight: 500; }

/* ---- App shell ---- */
.skip-link {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 2000;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-160%);
}
.skip-link:focus {
  transform: none;
}
.app-status {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1800;
  width: min(420px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 1px solid #B7DFD2;
  border-radius: 10px;
  background: var(--ok-tint);
  color: #16624E;
  box-shadow: var(--shadow-2);
  font-size: 14px;
}
.app-status.is-error {
  border-color: #F0B8B4;
  background: var(--err-tint);
  color: var(--err);
}
.app-status[hidden] { display: none; }
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  isolation: isolate;
  transform: translateZ(0);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 500; }
.brand-icon { color: var(--accent); display: inline-flex; }
.brand-icon svg { width: 20px; height: 20px; }
.avatar {
  margin-left: auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500;
}
.logout-form { margin: 0; }
.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: rgba(60, 64, 67, 0.08); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
}
.menu-btn:hover, .menu-btn.active {
  background: var(--state-hover);
  color: var(--accent-hover);
}
.menu-btn svg { width: 20px; height: 20px; }

.layout {
  position: relative;
  z-index: 0;
  display: flex;
  min-height: 100vh;
  padding-top: var(--topbar-height);
  box-sizing: border-box;
  overflow: visible;
}
.nav-scrim { display: none; }
.rail {
  position: sticky;
  top: var(--topbar-height);
  z-index: 900;
  align-self: flex-start;
  flex: 0 0 240px;
  width: 240px;
  border-right: 1px solid var(--line);
  padding: 12px 8px;
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  background: var(--surface);
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14px;
  transition: background-color .18s ease, color .18s ease;
}
.nav-item:hover { background: rgba(60, 64, 67, 0.08); }
.nav-item.active {
  background: var(--accent-tint);
  color: var(--accent-hover);
  font-weight: 500;
}
.nav-item svg { width: 18px; height: 18px; }

.main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - var(--topbar-height));
  overflow: visible;
  overscroll-behavior: auto;
  scroll-padding-top: 180px;
  background: var(--bg);
  isolation: isolate;
}
.main.index-main {
  overflow: visible;
}
.main:has(> .content.index-page) {
  overflow: visible;
}
.content {
  --content-pad-x: clamp(24px, 3vw, 56px);
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 32px var(--content-pad-x);
}
.content.index-page {
  position: relative;
  display: block;
  width: 100%;
  max-width: none;
  min-height: 100%;
  margin: 0;
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
  overflow: visible;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb a {
  color: var(--accent-hover);
  font-weight: 500;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span[aria-current="page"] {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-separator {
  color: var(--ink-3);
  flex: 0 0 auto;
}
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.spacer { margin-left: auto; }
.index-header {
  position: sticky;
  top: var(--topbar-height);
  z-index: 50;
  width: 100%;
  margin: 0;
  padding: 24px max(var(--content-pad-x), calc((100% - 1180px) / 2 + var(--content-pad-x))) 16px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  box-shadow: none;
  isolation: isolate;
  transform: translateZ(0);
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.index-header.is-scrolled {
  background: rgba(255, 255, 255, 0.96);
  border-bottom-color: var(--line);
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.16), 0 2px 6px rgba(60, 64, 67, 0.12);
}
@supports (backdrop-filter: blur(8px)) {
  .index-header.is-scrolled {
    backdrop-filter: blur(8px);
  }
}
.index-header::before,
.index-header::after {
  content: none;
}
.index-header > * { position: relative; z-index: 1; }
.index-header .breadcrumb { margin-bottom: 6px; }
.index-header .page-head { margin-bottom: 12px; }
.index-header > .card {
  margin-top: 0;
  padding: 14px 16px;
  border-color: var(--line);
  box-shadow: none;
}
.content.index-page .index-body {
  --index-body-top-gap: 24px;
  position: relative;
  z-index: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 0;
  overflow-x: visible;
  overflow-y: visible;
  overscroll-behavior: auto;
  padding-top: 20px;
  padding-left: max(var(--content-pad-x), calc((100% - 1180px) / 2 + var(--content-pad-x)));
  padding-right: max(var(--content-pad-x), calc((100% - 1180px) / 2 + var(--content-pad-x)));
  padding-bottom: 104px;
  scroll-padding-top: 24px;
}
.content.index-page .index-body:has(.business-grid),
.content.index-page .index-body:has(.project-grid),
.content.index-page .index-body:has(.vault-grid) {
  padding-bottom: 192px;
}
.content.index-page .index-body:has(.task-list),
.content.index-page .index-body:has(.template-list) {
  padding-bottom: 176px;
}
.content.index-page .index-body > .card:has(form.toolbar) {
  margin-bottom: 18px;
}
@supports (height: 100dvh) {
  .layout {
    min-height: 100dvh;
  }

  .main {
    min-height: calc(100dvh - var(--topbar-height));
  }

  .rail {
    height: calc(100dvh - var(--topbar-height));
  }
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: stretch;
  gap: 16px;
}
.card-grid > .card,
.stats-grid > .card,
.home-stats-grid > .card {
  margin-top: 0;
}
.card-grid > .card { align-self: stretch; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.12);
  font: inherit; font-weight: 500; font-size: 14px; line-height: 1.2;
  cursor: pointer;
  background: var(--surface); color: var(--ink);
  white-space: nowrap;
  transition: background-color .15s ease, box-shadow .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.btn:hover { background: rgba(60, 64, 67, 0.08); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-2);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-3); }
.btn-primary:active { box-shadow: var(--shadow); }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--accent-hover); }
.btn-ghost:hover { background: var(--accent-tint); }
.btn-danger { background: var(--surface); border-color: var(--line-2); color: var(--err); }
.btn-danger:hover { background: var(--err-tint); }

/* ---- Chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 13px; padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid var(--line-2); color: var(--ink-2);
  background: transparent; cursor: pointer;
}
.chip.active { background: var(--accent-tint); color: var(--accent-hover); border-color: transparent; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="tel"],
input[type="url"],
input[type="time"],
select {
  width: 100%;
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 0 var(--control-padding-x);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font: inherit; line-height: 1.2; color: var(--ink); background: var(--surface);
  outline: none;
}
textarea {
  width: 100%;
  min-height: calc(var(--control-height) * 2);
  padding: 10px var(--control-padding-x);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font: inherit; line-height: 1.5; color: var(--ink); background: var(--surface);
  outline: none;
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="color"] {
  width: 100%;
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}
input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 4px;
}
input[type="file"] {
  width: 100%;
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 4px var(--control-padding-x);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  height: calc(var(--control-height) - 10px);
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--line); }
.field-error { color: var(--err); font-size: 12px; margin-top: 4px; }
.field-help { color: var(--ink-2); font-size: 12px; margin-top: 5px; }
.field-static {
  min-height: var(--control-height);
  display: flex;
  align-items: center;
  padding: 0 var(--control-padding-x);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink-2);
}

/* ---- Flash ---- */
.flash {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 12px;
}
.flash-ok { background: var(--ok-tint); color: var(--ok); }
.flash-error { background: var(--err-tint); color: var(--err); }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 42px 24px; color: var(--ink-2); }
.empty svg { width: 40px; height: 40px; color: var(--ink-3); margin-bottom: 12px; }
.empty h3 { color: var(--ink); }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span {
  min-width: 32px; height: 32px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 14px; color: var(--ink-2);
}
.pagination a:hover { background: rgba(60, 64, 67, 0.08); }
.pagination .current {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  box-shadow: var(--shadow-2);
}
.pagination .disabled { color: var(--line-2); pointer-events: none; }

/* ---- Misc ---- */
.out {
  margin-top: 12px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px; min-height: 20px; font-size: 13px; white-space: pre-wrap;
}
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.form-actions .btn {
  min-width: 112px;
}
.htmx-indicator {
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  visibility: visible;
}

/* ---- Home ---- */
.home-page {
  width: min(100%, 1240px);
  padding-top: 28px;
  padding-bottom: 80px;
}
.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 18px;
  padding: 26px 28px;
  border: 1px solid #DDE7F5;
  border-radius: 16px;
  background: linear-gradient(135deg, #FFFFFF 25%, #F1F6FE 100%);
}
.home-date,
.home-panel-kicker {
  margin: 0 0 4px;
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1.4;
  text-transform: uppercase;
}
.home-hero h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 500;
  letter-spacing: -.02em;
}
.home-summary {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 15px;
}
.home-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.home-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.home-stat-card {
  min-height: 82px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.home-stat-card span {
  color: var(--ink-2);
  font-size: 13px;
}
.home-stat-card strong {
  font-size: 24px;
  line-height: 1;
  font-weight: 500;
}
.home-stat-card.is-attention {
  border-color: #F2D3A2;
  background: var(--warn-tint);
}
.home-stat-card.is-attention span,
.home-stat-card.is-attention strong {
  color: var(--warn);
}
.home-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, .85fr);
  gap: 16px;
  align-items: start;
}
.home-side-stack {
  display: grid;
  gap: 16px;
}
.home-panel {
  padding: 20px;
  border-color: var(--line);
  border-radius: 12px;
  box-shadow: none;
}
.home-panel + .home-panel {
  margin-top: 0;
}
.home-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.home-panel-head.compact {
  align-items: center;
}
.home-panel-head h2 {
  margin: 0;
}
.home-panel-link {
  flex: 0 0 auto;
  padding: 5px 2px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.home-panel-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.home-focus-panel {
  min-height: 420px;
}
.home-focus-list {
  display: grid;
  margin: 0 -8px -6px;
}
.home-focus-item {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  border-radius: 8px;
  transition: background-color .15s ease;
}
.home-focus-item:hover {
  background: #F6F9FD;
}
.home-focus-marker {
  align-self: stretch;
  min-height: 36px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}
.home-focus-marker.is-attention {
  background: #D97706;
}
.home-focus-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.home-focus-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-focus-copy > span {
  overflow: hidden;
  color: var(--ink-2);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-focus-meta {
  display: grid;
  justify-items: end;
  gap: 2px;
  padding-left: 10px;
}
.home-status {
  color: var(--ink-2);
  font-size: 12px;
}
.home-due {
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.home-due.is-overdue {
  color: var(--warn);
}
.home-calm-state {
  min-height: 260px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 5px;
  padding: 28px;
  text-align: center;
  color: var(--ink-2);
}
.home-calm-state strong {
  color: var(--ink);
  font-weight: 500;
}
.home-quick-list,
.home-deadline-list {
  display: grid;
}
.home-quick-list a,
.home-deadline-list a {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 4px;
  border-top: 1px solid var(--line);
  color: var(--accent-hover);
}
.home-quick-list a:first-child,
.home-deadline-list a:first-child {
  border-top: 0;
}
.home-quick-list a:hover strong,
.home-deadline-list a:hover strong {
  color: var(--accent-hover);
}
.home-quick-list a > span:first-child,
.home-deadline-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.home-quick-list strong,
.home-deadline-list strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-quick-list small,
.home-deadline-list small {
  color: var(--ink-2);
  font-size: 12px;
}
.home-mini-progress {
  flex: 0 0 58px;
  height: 5px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--line);
}
.home-mini-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ok);
}
.home-inline-empty {
  margin: 0;
  padding: 12px 0 4px;
  color: var(--ink-2);
  font-size: 14px;
}
.home-recent-panel {
  margin-top: 16px;
}
.home-recent-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.home-recent-grid a {
  min-width: 0;
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #FBFCFE;
  transition: border-color .15s ease, background-color .15s ease;
}
.home-recent-grid a:hover {
  border-color: #C8D8EE;
  background: #F5F8FC;
}
.home-recent-grid strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-recent-grid span {
  color: var(--ink-2);
  font-size: 12px;
}

/* ---- Vaults ---- */
.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px) auto;
  gap: 10px;
  align-items: center;
  margin: 0;
}
.search-field {
  position: relative;
  min-width: 0;
}
.search-field input[type="search"] {
  padding-right: 48px;
}
.search-indicator {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 26px;
  height: 4px;
  transform: translateY(-50%);
  pointer-events: none;
  accent-color: var(--accent);
}
.search-indicator::-webkit-progress-bar {
  background: var(--line);
  border-radius: var(--radius-pill);
}
.search-indicator::-webkit-progress-value {
  background: var(--accent);
  border-radius: var(--radius-pill);
}
.search-indicator::-moz-progress-bar {
  background: var(--accent);
  border-radius: var(--radius-pill);
}
.vault-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  margin-top: 16px;
}
.vault-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  min-height: 118px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.vault-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.vault-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-tint);
  color: var(--accent-hover);
  font-weight: 500;
}
.vault-card > div:last-child {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}
.vault-card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}
.vault-card p {
  margin: 0;
  line-height: 1.4;
}
.vault-form {
  display: grid;
  gap: 16px;
}
.vault-form-card {
  display: grid;
  gap: 16px;
}
.vault-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.vault-form-head h2 {
  margin: 0;
}
.vault-form-head .chip {
  cursor: default;
}
.vault-details-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 14px;
  align-items: start;
}
.vault-details-grid .field,
.vault-notes-field {
  margin-bottom: 0;
}
.vault-notes-field textarea {
  min-height: 104px;
}
.vault-fields { display: grid; gap: 10px; }
.vault-field-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.vault-field-index {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.vault-field-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(150px, 220px) minmax(240px, 1.4fr);
  gap: 12px;
  align-items: start;
}
.vault-field-row .field,
.vault-field-grid .field { margin-bottom: 0; }
.vault-field-body {
  min-width: 0;
  display: grid;
  gap: 12px;
}
.vault-field-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.vault-field-summary > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.vault-field-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vault-field-summary .muted {
  font-size: 13px;
}
.vault-field-kind {
  cursor: default;
  flex: 0 0 auto;
}
.vault-value-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.vault-value-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.vault-field-action {
  min-width: 72px;
  padding-inline: 12px;
}
.vault-value-field textarea {
  min-height: 74px;
  resize: vertical;
}
.vault-attachment-details {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.vault-attachment-details summary {
  width: fit-content;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.vault-file-field {
  margin-top: 8px;
}
.vault-form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 12px 0 0;
  background: linear-gradient(to top, var(--bg) 70%, rgba(248, 249, 250, 0));
}
.field-count {
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
}
.field-list { display: grid; gap: 10px; }
.field-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.field-item:last-child { border-bottom: 0; }
.field-item-heading {
  min-width: 180px;
  flex: 0 1 240px;
}
.vault-display-value {
  flex: 1 1 420px;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.vault-display-control[readonly] {
  color: var(--ink);
  background: var(--surface);
}
.vault-display-value textarea {
  min-height: 74px;
  resize: vertical;
}
.action-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Businesses ---- */
.business-toolbar {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) minmax(130px, 180px) auto;
}
.business-grid { margin-top: 16px; }
.business-card {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 14px;
  height: 144px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.business-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.business-card > div:last-child,
.project-card-head > div:last-child {
  min-width: 0;
}
.business-card h2,
.project-card h2,
.note-card h2,
.vault-card h2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.business-color {
  width: 10px;
  min-height: 78px;
  border-radius: var(--radius-pill);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}
.detail-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.detail-list div { display: grid; gap: 2px; }

/* ---- Projects ---- */
.project-toolbar {
  grid-template-columns: minmax(220px, 1.5fr) minmax(110px, 140px) minmax(120px, 150px) minmax(140px, 170px) minmax(115px, 140px) auto;
}
.project-grid { margin-top: 16px; }
.project-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  height: 176px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.project-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.project-card-head {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 14px;
  align-items: start;
}
.project-color {
  width: 10px;
  min-height: 48px;
  border-radius: var(--radius-pill);
}
.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--line);
}
.progress-track span {
  display: block;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: inherit;
  background: var(--ok);
}

/* ---- Tasks ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  display: grid;
  gap: 4px;
  min-height: 96px;
  padding: 14px 16px;
}
.stat-card strong { font-size: 24px; font-weight: 500; }
.stat-card.home-stat-card {
  min-height: 86px;
  align-content: space-between;
  gap: 8px;
}
.stat-card.home-stat-card span {
  color: var(--ink-2);
  font-size: 14px;
}
.stat-card.home-stat-card strong {
  font-size: 24px;
  line-height: 1;
  font-weight: 500;
}
.task-toolbar {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) minmax(150px, 220px) auto;
}
.task-list { display: grid; gap: 8px; }
.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 180px);
  gap: 14px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.task-row:last-child { border-bottom: 0; }
.task-progress {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 44px;
  gap: 8px;
  align-items: center;
  min-width: 150px;
}
.progress-value {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}
.task-detail-stack {
  display: grid;
  gap: 16px;
}
.task-detail-stack > .card + .card {
  margin-top: 0;
}
.task-secondary-details {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}
.task-secondary-details summary {
  width: fit-content;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.task-secondary-details p {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
}
.action-list {
  display: grid;
  gap: 10px;
}
.action-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.action-main {
  min-width: 0;
}
.action-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 3px;
  color: var(--ink-2);
  font-size: 13px;
}
.action-status-chip {
  padding: 2px 10px;
  border: 0;
  background: var(--accent-tint);
  color: var(--accent-hover);
  cursor: default;
}
.action-description {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}
.action-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.action-status-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.action-status-form select {
  width: auto;
  min-width: 160px;
}
.action-create-form {
  margin: 0;
}
.action-create-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) minmax(150px, 200px) auto;
  gap: 14px;
  align-items: end;
}
.action-create-grid .field,
.action-description-details .field {
  margin-bottom: 0;
}
.action-create-actions {
  margin-top: 0;
}
.action-description-details textarea {
  margin-top: 8px;
}

/* ---- Task templates ---- */
.template-toolbar {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) minmax(130px, 180px) auto;
}
.list-meta,
.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.list-meta {
  margin-bottom: 10px;
}
.list-meta .chip,
.list-footer .chip {
  cursor: default;
}
.list-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.list-footer .pagination {
  margin-top: 0;
}
.template-row {
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
}
.template-row strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.template-meta .chip {
  cursor: default;
}
.weekday-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
}
.check-row input { width: auto; }

/* ---- Notes ---- */
.note-toolbar {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) minmax(150px, 220px) auto;
}
.note-results-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 12px;
  padding: 8px 0 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.index-header .note-results-head {
  margin: 14px 0 0;
  padding: 0;
  border-bottom: 0;
}
.note-results-head h2,
.note-results-head p {
  margin: 0;
}
.note-grid {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  margin-top: 0;
}
.note-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 238px;
  padding: 18px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.note-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.note-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
  min-width: 0;
}
.note-card-head h2 {
  min-width: 0;
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}
.note-card-type {
  margin: 0;
  line-height: 1.4;
}
.note-excerpt {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.note-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.note-content {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.note-content > :first-child { margin-top: 0; }
.note-content > :last-child { margin-bottom: 0; }
.note-content p { margin: 0 0 12px; }
.note-content h1,
.note-content h2,
.note-content h3,
.note-content h4,
.note-content h5,
.note-content h6 {
  color: var(--ink);
  line-height: 1.25;
  margin: 22px 0 10px;
}
.note-content h1 { font-size: 30px; }
.note-content h2 { font-size: 24px; }
.note-content h3 { font-size: 20px; }
.note-content h4,
.note-content h5,
.note-content h6 { font-size: 17px; }
.note-content ul,
.note-content ol {
  margin: 0 0 14px 24px;
  padding: 0;
}
.note-content li { margin: 4px 0; }
.note-content blockquote {
  margin: 16px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  color: var(--ink-2);
  background: var(--accent-tint);
}
.note-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.note-content code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
}
.note-content pre {
  overflow-x: auto;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line);
}
.note-content pre code {
  display: block;
  padding: 0;
  border-radius: 0;
  background: transparent;
}
.note-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}
.note-content th,
.note-content td {
  padding: 10px;
  border: 1px solid var(--line);
  text-align: left;
}
.note-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}
.note-content iframe {
  width: min(100%, 720px);
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: var(--radius-sm);
}
.note-content-rich.ql-snow {
  border: 0;
}
.note-content-rich .ql-editor {
  min-height: 0;
  padding: 0;
  color: inherit;
  font-family: var(--font);
  font-size: inherit;
  line-height: inherit;
  overflow: visible;
}
.note-content-rich .ql-editor.ql-blank::before {
  display: none;
}
.note-flags { margin-bottom: 16px; }
.note-editor-field { margin-bottom: 18px; }
.note-editor-hidden { display: none !important; }
.note-editor-field .EasyMDEContainer {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.note-editor-field .editor-toolbar {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  opacity: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.note-editor-field .editor-toolbar button {
  min-width: 32px;
  min-height: 32px;
  border-radius: 4px;
  color: var(--ink-2) !important;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
}
.note-editor-field .editor-toolbar button:hover,
.note-editor-field .editor-toolbar button.active {
  background: var(--accent-tint);
  border-color: transparent;
  color: var(--accent-hover) !important;
}
.note-editor-field .editor-toolbar button::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  min-height: 18px;
  color: currentColor;
  font-family: var(--font);
}
.note-editor-field .editor-toolbar .bold::before { content: "B"; font-weight: 700; }
.note-editor-field .editor-toolbar .undo::before { content: "<-"; }
.note-editor-field .editor-toolbar .redo::before { content: "->"; }
.note-editor-field .editor-toolbar .italic::before { content: "I"; font-style: italic; }
.note-editor-field .editor-toolbar .strikethrough::before { content: "S"; text-decoration: line-through; }
.note-editor-field .editor-toolbar .heading::before { content: "H"; }
.note-editor-field .editor-toolbar .heading-smaller::before { content: "H-"; }
.note-editor-field .editor-toolbar .heading-bigger::before { content: "H+"; }
.note-editor-field .editor-toolbar .heading-1::before { content: "H1"; }
.note-editor-field .editor-toolbar .heading-2::before { content: "H2"; }
.note-editor-field .editor-toolbar .heading-3::before { content: "H3"; }
.note-editor-field .editor-toolbar .heading-4::before { content: "H4"; }
.note-editor-field .editor-toolbar .heading-5::before { content: "H5"; }
.note-editor-field .editor-toolbar .heading-6::before { content: "H6"; }
.note-editor-field .editor-toolbar .quote::before { content: ">"; }
.note-editor-field .editor-toolbar .unordered-list::before { content: "UL"; }
.note-editor-field .editor-toolbar .ordered-list::before { content: "1."; }
.note-editor-field .editor-toolbar .clean-block::before { content: "Tx"; }
.note-editor-field .editor-toolbar .link::before { content: "ln"; }
.note-editor-field .editor-toolbar .image::before { content: "img"; }
.note-editor-field .editor-toolbar .code::before { content: "</>"; }
.note-editor-field .editor-toolbar .table::before { content: "Tb"; }
.note-editor-field .editor-toolbar .horizontal-rule::before { content: "Hr"; }
.note-editor-field .editor-toolbar .preview::before { content: "Pr"; }
.note-editor-field .editor-toolbar .side-by-side::before { content: "Sp"; }
.note-editor-field .editor-toolbar .fullscreen::before { content: "Fs"; }
.note-editor-field .editor-toolbar .guide::before { content: "?"; }
.note-editor-field .CodeMirror {
  min-height: 360px;
  border: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}
.note-editor-field .CodeMirror-focused {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.note-editor-field .editor-preview,
.note-editor-field .editor-preview-side {
  background: var(--surface);
}
.note-rich-shell {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.note-rich-shell .ql-toolbar.ql-snow {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--font);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 2px;
  padding: 8px 10px;
}
.note-rich-shell .ql-toolbar.ql-snow .ql-formats {
  display: inline-flex;
  align-items: center;
  margin: 0 8px 0 0;
}
.note-rich-shell .ql-toolbar.ql-snow button {
  min-width: 28px;
  min-height: 28px;
  border-radius: 4px;
}
.note-rich-shell .ql-toolbar.ql-snow .ql-picker {
  color: var(--ink-2);
  height: 28px;
}
.note-rich-shell .ql-container.ql-snow {
  min-height: 360px;
  border: 0;
  font-family: var(--font);
  font-size: 16px;
}
.note-rich-shell .ql-editor {
  min-height: 360px;
  line-height: 1.6;
}
.note-rich-shell .ql-editor.ql-blank::before {
  color: var(--ink-3);
  font-style: normal;
}

/* ---- Responsive ---- */
@media (max-width: 980px) {
  .content {
    width: 100%;
    padding: 24px;
  }
  .index-header > .card {
    box-shadow: var(--shadow);
  }
  .home-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-dashboard-grid {
    grid-template-columns: 1fr;
  }
  .home-side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-recent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .page-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .page-head h1 {
    flex: 1 1 100%;
  }
  .page-head .spacer {
    display: none;
  }
  form.toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  form.toolbar .search-field {
    grid-column: 1 / -1;
  }
  form.toolbar .btn {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .topbar {
    gap: 10px;
    padding: 0 12px;
  }
  .brand {
    font-size: 16px;
  }
  .avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }
  .icon-btn {
    width: 30px;
    height: 30px;
  }
  .layout {
    display: block;
  }
  .nav-scrim {
    position: fixed;
    inset: 56px 0 0;
    z-index: 850;
    display: block;
    width: 100%;
    border: 0;
    background: rgba(32, 33, 36, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .nav-scrim.open {
    opacity: 1;
    pointer-events: auto;
  }
  .rail {
    position: fixed; top: 56px; left: 0; bottom: 0; z-index: 900;
    width: min(84vw, 280px);
    min-height: calc(100vh - 56px);
    padding: 10px;
    background: var(--surface);
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 8px 0 24px rgba(60, 64, 67, 0.16);
  }
  .rail.open { transform: none; }
  .nav-item {
    min-height: 44px;
    padding: 10px 12px;
  }
  .content {
    --content-pad-x: 16px;
    width: 100%;
    padding: 16px;
  }
  .home-page {
    padding-top: 16px;
  }
  .home-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
    padding: 22px;
  }
  .home-hero-actions {
    width: 100%;
  }
  .home-hero-actions .btn {
    flex: 1 1 0;
  }
  .home-side-stack {
    grid-template-columns: 1fr;
  }
  .home-focus-panel {
    min-height: 0;
  }
  .home-focus-item {
    grid-template-columns: 4px minmax(0, 1fr);
  }
  .home-focus-meta {
    grid-column: 2;
    justify-items: start;
    padding-left: 0;
  }
  .home-calm-state {
    min-height: 190px;
  }
  .business-card,
  .project-card,
  .note-card,
  .vault-card {
    height: auto;
    min-height: 92px;
  }
  .note-grid {
    grid-template-columns: 1fr;
  }
  .note-card {
    min-height: auto;
  }
  .card {
    padding: 16px;
  }
  .note-editor-field .CodeMirror,
  .note-rich-shell .ql-container.ql-snow,
  .note-rich-shell .ql-editor {
    min-height: 280px;
  }
  .page-head {
    gap: 10px;
    margin-bottom: 14px;
  }
  .index-header {
    position: static;
    padding-top: 16px;
    padding-bottom: 12px;
    background: var(--bg);
    border-bottom: 0;
    box-shadow: none;
    backdrop-filter: none;
  }
  .index-header.is-scrolled {
    background: var(--bg);
    border-bottom: 0;
    box-shadow: none;
    backdrop-filter: none;
  }
  .index-header .page-head {
    align-items: center;
    flex-wrap: nowrap;
    margin-bottom: 10px;
  }
  .index-header .page-head h1 {
    flex: 1 1 auto;
    min-width: 0;
  }
  .index-header .page-head > .btn {
    flex: 0 0 auto;
    width: auto;
  }
  .index-header > .card {
    padding: 12px;
    border-color: var(--line-2);
    box-shadow: var(--shadow);
  }
  .content.index-page .index-body {
    padding-top: 12px;
    padding-bottom: 72px;
  }
  .page-head > .btn,
  .page-head > form {
    flex: 1 1 150px;
  }
  .page-head > form .btn {
    width: 100%;
    justify-content: center;
  }
  .btn {
    height: var(--control-height);
    min-height: var(--control-height);
    justify-content: center;
  }
  .empty {
    padding: 34px 16px;
  }
  .toolbar, .vault-field-row, .vault-details-grid, .vault-field-grid, .business-toolbar, .project-toolbar, .task-toolbar, .template-toolbar, .note-toolbar, .form-grid, .task-row, .template-row, .action-item, .action-create-grid { grid-template-columns: 1fr; }
  .toolbar {
    gap: 8px;
  }
  form.toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  form.toolbar .search-field {
    grid-column: 1 / -1;
  }
  form.toolbar .btn {
    grid-column: 1 / -1;
    width: 100%;
  }
  .template-row {
    gap: 8px;
    align-items: start;
  }
  .template-meta {
    justify-content: flex-start;
  }
  .list-meta,
  .list-footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .vault-form-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .vault-field-summary {
    flex-direction: column;
  }
  .vault-value-entry {
    grid-template-columns: 1fr;
  }
  .vault-display-value {
    width: 100%;
    grid-template-columns: 1fr;
  }
  .vault-value-actions {
    width: 100%;
  }
  .vault-field-action {
    flex: 1 1 0;
  }
  .vault-field-index {
    width: 28px;
    height: 28px;
  }
  .field-item, .action-controls, .action-status-form { align-items: stretch; flex-direction: column; }
  .action-status-form select,
  .action-status-form .btn,
  .action-controls form,
  .action-controls .btn,
  .action-create-actions,
  .action-create-actions .btn {
    width: 100%;
  }
  .vault-form-actions .btn {
    width: 100%;
  }
  .field-count { display: none; }
}

@media (max-width: 480px) {
  .content {
    --content-pad-x: 12px;
    padding: 12px;
  }
  .page-head > .btn,
  .page-head > form {
    flex-basis: 100%;
  }
  .card-grid,
  .stats-grid,
  .home-recent-grid {
    grid-template-columns: 1fr;
  }
  .home-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-hero {
    padding: 18px;
  }
  .home-hero-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .home-panel {
    padding: 16px;
  }
  .home-panel-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .home-panel-head.compact {
    align-items: flex-start;
  }
  .auth-card {
    padding: 22px;
  }
}

@media (max-width: 360px) {
  form.toolbar {
    grid-template-columns: 1fr;
  }
}

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