/* ==========================================================================
   Notes
   Ink and highlighter. Chrome stays quiet in a grotesk; note text is set in a
   serif so content reads differently from controls; timestamps, tags and
   counters are monospaced like the margin notes on a printed page.
   Fonts are local system stacks only, so no external font requests.
   ========================================================================== */

:root {
  --font-ui: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-note: "Lora", ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --shadow-1: 0 1px 2px rgba(16, 20, 18, .07), 0 1px 1px rgba(16, 20, 18, .04);
  --shadow-2: 0 6px 18px rgba(16, 20, 18, .12), 0 2px 6px rgba(16, 20, 18, .07);
  --shadow-3: 0 24px 60px rgba(16, 20, 18, .28), 0 4px 12px rgba(16, 20, 18, .12);

  --topbar-h: 60px;
  --sidebar-w: 254px;
  --speed: 160ms;
}

/* ---- Light ------------------------------------------------------------- */
:root,
[data-theme="light"] {
  --bg: #e8ebe5;
  --bg-2: #dfe3db;
  --surface: #ffffff;
  --surface-2: #f5f7f2;
  --ink: #171a18;
  --ink-2: #4c544e;
  --ink-3: #7c8681;
  --line: #d2d8cd;
  --line-2: #bcc4b7;
  --accent: #2e4a9e;
  --accent-soft: #dbe2f6;
  --on-accent: #ffffff;
  --hl: #f7e24b;
  --hl-soft: #fdf3ac;
  --vault: #6b3f86;
  --vault-soft: #ece0f2;
  --danger: #a8322b;
  --danger-soft: #f6dedc;
  --ok: #2f6b45;
  --ok-soft: #dcefe2;
  --overlay: rgba(23, 26, 24, .42);

  --c-default: #ffffff;
  --c-amber: #fdf1d4;
  --c-rose: #fbe0e2;
  --c-mint: #dcf0e2;
  --c-sky: #dbebf8;
  --c-violet: #e8e1f7;
  --c-slate: #e4e8ea;
  color-scheme: light;
}

/* ---- Dark -------------------------------------------------------------- */
[data-theme="dark"] {
  --bg: #15161b;
  --bg-2: #1b1d23;
  --surface: #202329;
  --surface-2: #272b32;
  --ink: #e9ebe6;
  --ink-2: #a8b0ab;
  --ink-3: #79837e;
  --line: #2f343b;
  --line-2: #3d434b;
  --accent: #8fa6f5;
  --accent-soft: #262c42;
  --on-accent: #14161b;
  --hl: #e5c93a;
  --hl-soft: #4a4020;
  --vault: #c19ada;
  --vault-soft: #2e2438;
  --danger: #e8776d;
  --danger-soft: #3a2321;
  --ok: #6fcf97;
  --ok-soft: #1f3328;
  --overlay: rgba(8, 9, 11, .66);

  --c-default: #202329;
  --c-amber: #3a3220;
  --c-rose: #3b2528;
  --c-mint: #1f3329;
  --c-sky: #1e2e3c;
  --c-violet: #2c2740;
  --c-slate: #272c30;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #15161b;
    --bg-2: #1b1d23;
    --surface: #202329;
    --surface-2: #272b32;
    --ink: #e9ebe6;
    --ink-2: #a8b0ab;
    --ink-3: #79837e;
    --line: #2f343b;
    --line-2: #3d434b;
    --accent: #8fa6f5;
    --accent-soft: #262c42;
    --on-accent: #14161b;
    --hl: #e5c93a;
    --hl-soft: #4a4020;
    --vault: #c19ada;
    --vault-soft: #2e2438;
    --danger: #e8776d;
    --danger-soft: #3a2321;
    --ok: #6fcf97;
    --ok-soft: #1f3328;
    --overlay: rgba(8, 9, 11, .66);
    --c-default: #202329;
    --c-amber: #3a3220;
    --c-rose: #3b2528;
    --c-mint: #1f3329;
    --c-sky: #1e2e3c;
    --c-violet: #2c2740;
    --c-slate: #272c30;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 6px 18px rgba(0, 0, 0, .45);
    --shadow-3: 0 24px 60px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; line-height: 1.2; }

a { color: var(--accent); }

button, input, textarea, select { font: inherit; color: inherit; }

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

::selection { background: var(--hl); color: #171a18; }

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

/* Scrollbars stay out of the way */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Icons never grow to fill a flex parent. Every container that holds one
   states the size it wants; this is the floor under all of them. */
svg { flex: 0 0 auto; }

.chip svg,
.card__foot svg,
.meta svg { width: 13px; height: 13px; stroke-width: 1.8; }

.btn svg { width: 16px; height: 16px; }
.btn--sm svg { width: 14px; height: 14px; }
.vaultbanner svg { width: 18px; height: 18px; }
.editor__tags > svg { width: 15px; height: 15px; color: var(--ink-3); }

/* Large, faint background art. Sits behind its container's content. */
.wash {
  position: absolute;
  left: 50%; top: 52%;
  width: min(300px, 62%); height: auto;
  transform: translate(-50%, -50%) rotate(-8deg);
  opacity: .07;
  stroke-width: .85;
  pointer-events: none;
  z-index: 0;
}
[data-theme="dark"] .wash { opacity: .09; }
@media (prefers-color-scheme: dark) { [data-theme="auto"] .wash { opacity: .09; } }

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

/* ==========================================================================
   The signature: a highlighter sweep
   ========================================================================== */

.hl, mark {
  background: linear-gradient(100deg,
      transparent 0%, var(--hl) 3%, var(--hl) 97%, transparent 100%);
  color: inherit;
  padding: 0 .12em;
  border-radius: .55em .18em .5em .2em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

[data-theme="dark"] .hl, [data-theme="dark"] mark { color: #f5f2e4; }

.swipe { position: relative; display: inline-block; }
.swipe::after {
  content: "";
  position: absolute;
  left: -.15em; right: -.15em; bottom: .04em;
  height: .42em;
  background: var(--hl);
  border-radius: .5em .2em .45em .18em;
  z-index: -1;
  transform: rotate(-.5deg);
}

/* ==========================================================================
   Buttons, fields, alerts
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
  font-size: .92rem;
  cursor: pointer;
  transition: background var(--speed), border-color var(--speed), transform var(--speed);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: .84rem; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-2);
  cursor: pointer;
  transition: background var(--speed), color var(--speed);
}
.iconbtn:hover { background: var(--bg-2); color: var(--ink); }
.iconbtn.is-on { color: var(--accent); background: var(--accent-soft); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn--sm { width: 32px; height: 32px; }
.iconbtn--sm svg { width: 17px; height: 17px; }

.field { display: block; margin-bottom: var(--sp-4); }
.field__label {
  display: block;
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.field__hint { text-transform: none; letter-spacing: 0; color: var(--ink-3); font-weight: 400; }
.field__input, .field__select, .field__area {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--speed), box-shadow var(--speed);
}
.field__area { min-height: 90px; resize: vertical; font-family: var(--font-note); }
.field__input:focus, .field__select:focus, .field__area:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checkline { display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-4); color: var(--ink-2); font-size: .9rem; }
.checkline input { width: 17px; height: 17px; accent-color: var(--accent); }

.alert {
  padding: 10px 13px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--line-2);
  background: var(--surface-2);
  font-size: .9rem;
  margin: 0 0 var(--sp-4);
}
.alert--bad { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.alert--ok { border-left-color: var(--ok); background: var(--ok-soft); color: var(--ok); }

.meta {
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .04em;
  color: var(--ink-3);
}

/* ==========================================================================
   Login and installer
   ========================================================================== */

.signed-out { display: grid; place-items: center; min-height: 100dvh; padding: var(--sp-4); }

.auth {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: var(--sp-6);
  width: min(920px, 100%);
  align-items: center;
}
.auth--single { grid-template-columns: minmax(0, 460px); justify-content: center; }

.auth__mark { padding: var(--sp-5); }

.markblock__rule { display: block; width: 54px; height: 4px; background: var(--hl); border-radius: 2px; margin-bottom: var(--sp-4); }
.markblock__name { font-size: clamp(2.6rem, 7vw, 3.9rem); letter-spacing: -.045em; }
.markblock__tag { font-family: var(--font-note); font-size: 1.06rem; color: var(--ink-2); margin: 6px 0 0; font-style: italic; }
.markblock__points { list-style: none; margin: var(--sp-5) 0 0; padding: 0; }
.markblock__points li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 10px;
  color: var(--ink-2);
  font-size: .92rem;
}
.markblock__points li::before {
  content: "";
  position: absolute; left: 0; top: .55em;
  width: 10px; height: 2px; background: var(--ink-3); border-radius: 2px;
}

.auth__panel { width: 100%; }

.loginform {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-2);
}
.loginform__title { font-size: 1.35rem; }
.loginform__sub { color: var(--ink-3); font-size: .88rem; margin: 4px 0 var(--sp-5); }
.loginform__foot { color: var(--ink-3); font-size: .8rem; margin: var(--sp-4) 0 0; text-align: center; }
.loginform__version { color: var(--ink-3); font-size: .72rem; margin: var(--sp-2) 0 0; text-align: center; letter-spacing: .04em; }

.sidebar__version {
  color: var(--ink-3);
  font-size: .72rem;
  letter-spacing: .04em;
  padding: var(--sp-4) 14px var(--sp-2);
}

.checklist-setup { list-style: none; margin: 0 0 var(--sp-4); padding: 0; }
.checklist-setup li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 0 8px 26px;
  position: relative;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.checklist-setup li::before {
  content: "";
  position: absolute; left: 2px; top: 13px;
  width: 12px; height: 12px; border-radius: 3px;
}
.checklist-setup li.is-ok::before { background: var(--ok); }
.checklist-setup li.is-bad::before { background: var(--danger); }
.checklist-setup__fix { color: var(--ink-3); font-size: .78rem; }

@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; gap: var(--sp-4); }
  .auth__mark { padding: 0 var(--sp-2); text-align: left; }
  .markblock__points { display: none; }
}

/* ==========================================================================
   Shell
   ========================================================================== */

.bootsplash {
  position: fixed; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: var(--bg);
  z-index: 90;
}
.bootsplash__mark { font-size: 1.7rem; font-weight: 700; letter-spacing: -.04em; }
.bootsplash__bar { width: 120px; height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; position: relative; }
.bootsplash__bar::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: var(--hl); border-radius: 2px;
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(280%); } }

.shell { min-height: 100dvh; }

/* ---- Top bar ----------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--topbar-h);
  padding: 0 var(--sp-3);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; user-select: none; }
.brand__dot { width: 11px; height: 11px; border-radius: 3px; background: var(--hl); box-shadow: 0 0 0 3px var(--hl-soft); }
.brand__name { font-size: 1.12rem; font-weight: 700; letter-spacing: -.035em; }

.search {
  flex: 1;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  display: flex; align-items: center;
}
.search__icon { position: absolute; left: 13px; width: 17px; height: 17px; color: var(--ink-3); pointer-events: none; fill: none; stroke: currentColor; stroke-width: 1.8; }
.search__input {
  width: 100%;
  padding: 10px 40px 10px 40px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--bg-2);
  transition: background var(--speed), border-color var(--speed), box-shadow var(--speed);
}
.search__input::placeholder { color: var(--ink-3); }
.search__input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--line-2);
  box-shadow: var(--shadow-1);
}
.search__clear { position: absolute; right: 4px; }

.topbar__right { display: flex; align-items: center; gap: 2px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-mono); font-size: .78rem; font-weight: 700;
  display: grid; place-items: center;
}

/* ---- Layout ------------------------------------------------------------ */

.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-2) var(--sp-6);
  transition: width var(--speed) ease, flex-basis var(--speed) ease;
}

/* ---- Collapsed sidebar (desktop): icons and color dots only -------------
   Toggled by the menu button in the topbar, remembered per browser.
   Below 901px the sidebar is the slide-in drawer and always shows text. */
@media (min-width: 901px) {
  body.sidebar-collapsed .sidebar {
    width: 60px;
    flex-basis: 60px;
    overflow-x: hidden;
  }
  body.sidebar-collapsed .navitem__label,
  body.sidebar-collapsed .navitem__count,
  body.sidebar-collapsed .navgroup__head span,
  body.sidebar-collapsed .sidebar__version,
  body.sidebar-collapsed .navgroup > p.meta {
    display: none;
  }
  body.sidebar-collapsed .navitem {
    justify-content: center;
    padding: 9px 0;
    border-radius: var(--r-md, 10px);
  }
  body.sidebar-collapsed .navgroup__head {
    justify-content: center;
    padding: 0 0 6px;
  }
  body.sidebar-collapsed .dot { width: 12px; height: 12px; flex-basis: 12px; }
}

.navgroup { margin-bottom: var(--sp-4); }
.navgroup__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 6px;
  font-family: var(--font-mono);
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
}
.navgroup__add { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.navgroup__add:hover { color: var(--accent); background: var(--surface-2); }

.navitem {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 1px;
  border: 0; border-radius: 0 999px 999px 0;
  background: transparent;
  color: var(--ink-2);
  font-size: .9rem; font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--speed), color var(--speed);
}
.navitem:hover { background: var(--bg-2); color: var(--ink); }
.navitem.is-active { background: var(--accent-soft); color: var(--ink); font-weight: 620; }
.navitem.is-active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 2px 2px 0; background: var(--accent);
}
.navitem svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.navitem__label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem__count { font-family: var(--font-mono); font-size: .7rem; color: var(--ink-3); }
.navitem--vault.is-active { background: var(--vault-soft); }
.navitem--vault.is-active::before { background: var(--vault); }
.navitem--vault svg { color: var(--vault); }

.dot {
  width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px;
  background: var(--line-2);
}
.dot--slate { background: #8b969b; }
.dot--amber { background: #dfa73a; }
.dot--rose { background: #d2706f; }
.dot--mint { background: #4e9e70; }
.dot--sky { background: #4b8fc4; }
.dot--violet { background: #8a70cb; }

.content {
  flex: 1;
  min-width: 0;
  padding: var(--sp-4) var(--sp-4) var(--sp-7);
}

.viewhead {
  display: flex; align-items: baseline; gap: var(--sp-3);
  margin: 0 auto var(--sp-4);
  max-width: 1180px;
  flex-wrap: wrap;
}
.viewhead__title { font-size: 1.28rem; letter-spacing: -.03em; }
.viewhead__meta { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); }
.viewhead__actions { margin-left: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---- Composer ---------------------------------------------------------- */

.composer {
  max-width: 620px;
  margin: 0 auto var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 8px 6px 18px;
  cursor: text;
  transition: box-shadow var(--speed), border-color var(--speed);
}
.composer:hover { box-shadow: var(--shadow-2); }
.composer__text { flex: 1; color: var(--ink-3); font-family: var(--font-note); padding: 8px 0; }
.composer__input {
  flex: 1;
  border: 0; background: transparent; outline: none;
  color: var(--ink);
  font-family: var(--font-note);
  font-size: .95rem;
  padding: 8px 0;
  min-width: 0;
}
.composer__input::placeholder { color: var(--ink-3); }
.composer__input:disabled { opacity: .6; }

/* ---- Feed layout: one chronological column ------------------------------ */
.feed { max-width: 640px; margin: 0 auto; }
.feed .card { margin-bottom: var(--sp-3); }
.feed .card__body { max-height: 22em; }

/* ---- Note grid --------------------------------------------------------- */

.grid { max-width: 1180px; margin: 0 auto; columns: 250px; column-gap: var(--sp-4); }
.grid__section { break-inside: avoid; }

.gridlabel {
  font-family: var(--font-mono);
  font-size: .66rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 var(--sp-2) 4px;
  max-width: 1180px;
}

.card {
  break-inside: avoid;
  display: block;
  width: 100%;
  color: var(--ink);
  margin: 0 0 var(--sp-4);
  padding: 14px 16px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card-bg, var(--surface));
  box-shadow: var(--shadow-1);
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: box-shadow var(--speed), transform var(--speed), border-color var(--speed);
  animation: card-in 240ms cubic-bezier(.2, .8, .3, 1) backwards;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.card:hover { box-shadow: var(--shadow-2); border-color: var(--line-2); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card--default { --card-bg: var(--c-default); }
.card--amber { --card-bg: var(--c-amber); }
.card--rose { --card-bg: var(--c-rose); }
.card--mint { --card-bg: var(--c-mint); }
.card--sky { --card-bg: var(--c-sky); }
.card--violet { --card-bg: var(--c-violet); }
.card--slate { --card-bg: var(--c-slate); }

/* A custom hex background carries its own text scheme so anything the person
   picks stays readable in either theme. */
.on-dark {
  --ink: #f5f7f4;
  --ink-2: #d3d9d4;
  --ink-3: #aab2ad;
  --line: rgba(255, 255, 255, .18);
  --line-2: rgba(255, 255, 255, .3);
  --surface: rgba(255, 255, 255, .1);
  --surface-2: rgba(255, 255, 255, .12);
  --accent-soft: rgba(255, 255, 255, .16);
}
.on-light {
  --ink: #141715;
  --ink-2: #47504a;
  --ink-3: #6f7873;
  --line: rgba(0, 0, 0, .13);
  --line-2: rgba(0, 0, 0, .22);
  --surface: rgba(255, 255, 255, .55);
  --surface-2: rgba(0, 0, 0, .05);
  --accent-soft: rgba(0, 0, 0, .07);
}
.card.on-dark .hl, .card.on-light .hl,
.modal.on-dark .hl, .modal.on-light .hl { color: #171a18; }

.card__pin {
  position: absolute; top: 8px; right: 8px;
  opacity: 0; transition: opacity var(--speed);
}
.card:hover .card__pin, .card__pin.is-on, .card:focus-within .card__pin { opacity: 1; }
.card__pin.is-on { color: var(--accent); }

.card__title {
  font-size: 1rem; font-weight: 650; letter-spacing: -.015em;
  margin: 0 26px 2px 0;
  overflow-wrap: anywhere;
}
.card__titlewrap {
  margin: -14px -16px 10px;
  padding: 12px 16px 8px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 1px solid var(--line);
}
.card__titlewrap--bare { padding: 5px 16px; }
.card__titlewrap .card__title { margin-right: 26px; }
.card__titlewrap .card__subtitle { margin-bottom: 0; }
.card__titlewrap.on-dark, .card__titlewrap.on-dark .card__subtitle { color: #f2f2ef; }
.card__titlewrap.on-light, .card__titlewrap.on-light .card__subtitle { color: #1c1e22; }
.card__subtitle {
  font-family: var(--font-note);
  font-style: italic;
  font-size: .86rem;
  color: var(--ink-2);
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}
.card__body {
  font-family: var(--font-note);
  font-size: .9rem;
  line-height: 1.55;
  color: var(--ink);
  max-height: 15.5em;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
}
.card__body p { margin: 0 0 .5em; }
.card__body ul, .card__body ol { margin: 0 0 .5em; padding-left: 1.15em; }
.card__body img { max-width: 100%; border-radius: var(--r-sm); display: block; margin: 6px 0; }
.card__body h1, .card__body h2, .card__body h3 { font-size: 1rem; margin: .3em 0; }

.card__thumb {
  width: calc(100% + 32px);
  margin: -14px -16px 10px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: block;
  max-height: 190px;
  object-fit: cover;
}

.card__foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--ink-2);
  white-space: nowrap;
}
.chip--cat { background: transparent; }
.chip--tag {
  background: hsla(var(--tag-h, 210), 60%, 50%, .12);
  border-color: hsla(var(--tag-h, 210), 55%, 45%, .55);
  color: hsl(var(--tag-h, 210), 60%, 32%);
}
[data-theme="dark"] .chip--tag { color: hsl(var(--tag-h, 210), 55%, 68%); }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .chip--tag { color: hsl(var(--tag-h, 210), 55%, 68%); }
}
.navitem--tag svg { color: hsl(var(--tag-h, 210), 55%, 45%); }
[data-theme="dark"] .navitem--tag svg { color: hsl(var(--tag-h, 210), 55%, 62%); }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .navitem--tag svg { color: hsl(var(--tag-h, 210), 55%, 62%); }
}
.chip--due { border-color: var(--accent); color: var(--accent); }
.chip--overdue { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.chip--vault { border-color: var(--vault); color: var(--vault); }
a.chip--link {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
  max-width: 220px;
}
a.chip--link span { overflow: hidden; text-overflow: ellipsis; }
a.chip--link:hover { background: var(--accent-soft); }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 0 0 2px; font-size: .9em; }

.card__tools {
  display: flex; gap: 2px; margin-top: 8px; margin-left: -6px;
  opacity: 0; transition: opacity var(--speed);
}
.card:hover .card__tools, .card:focus-within .card__tools { opacity: 1; }
@media (hover: none) { .card__tools, .card__pin { opacity: 1; } }

.card--locked .card__body { filter: blur(5px); user-select: none; }

.empty {
  position: relative;
  max-width: 460px; margin: var(--sp-7) auto; text-align: center; color: var(--ink-3);
  padding: var(--sp-6) var(--sp-4);
  isolation: isolate;
}
.empty > *:not(.wash) { position: relative; z-index: 1; }
.empty__mark { width: 46px; height: 46px; margin: 0 auto var(--sp-3); color: var(--line-2); }
.empty__mark svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.4; }
.empty h3 { font-size: 1.05rem; color: var(--ink-2); margin-bottom: 6px; }
.empty p { margin: 0; font-size: .9rem; }

/* ---- Floating action --------------------------------------------------- */

.fab {
  position: fixed; right: 20px; bottom: 22px; z-index: 30;
  width: 56px; height: 56px; border-radius: 18px;
  border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-2);
  display: none; place-items: center;
}
.fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fab svg { transition: transform 180ms cubic-bezier(.2, .8, .3, 1); }
body.fab-open .fab svg { transform: rotate(45deg); }

/* ---- FAB speed dial: labeled options fan out above the button ----------- */
/* Two-class selector so this wins over the base .scrim rules no matter where
   either sits in the file. Ordering alone burned us here once already. */
.scrim.scrim--fab { display: none; }
body.fab-open .scrim.scrim--fab {
  display: block; position: fixed; inset: 0; z-index: 28;
  background: var(--overlay);
  animation: fade 140ms ease-out;
}
.fabdial {
  position: fixed; right: 20px; bottom: 90px; z-index: 29;
  display: none; flex-direction: column; align-items: flex-end; gap: 12px;
}
body.fab-open .fabdial { display: flex; }
.fabdial__opt {
  display: inline-flex; align-items: center; gap: 10px;
  border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  border-radius: 999px;
  padding: 12px 20px;
  font: inherit; font-size: .92rem; font-weight: 600;
  box-shadow: var(--shadow-2);
  animation: dial-in 180ms cubic-bezier(.2, .8, .3, 1) backwards;
}
.fabdial__opt:nth-child(4) { animation-delay: 0ms; }
.fabdial__opt:nth-child(3) { animation-delay: 40ms; }
.fabdial__opt:nth-child(2) { animation-delay: 80ms; }
.fabdial__opt:nth-child(1) { animation-delay: 120ms; }
@keyframes dial-in {
  from { opacity: 0; transform: translateY(10px) scale(.95); }
  to   { opacity: 1; transform: none; }
}
.fabdial__opt svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ==========================================================================
   Modal, editor
   ========================================================================== */

.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: var(--overlay);
  display: grid; place-items: center;
  padding: var(--sp-4);
  animation: fade var(--speed) ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Closing: the scrim fades while the panel sinks, then JS removes both. */
.scrim.is-closing { animation: fade-out 180ms ease-in forwards; }
.scrim.is-closing .modal { animation: sink 180ms cubic-bezier(.4, 0, .8, .6) forwards; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sink { to { transform: translateY(10px) scale(.98); opacity: 0; } }

.modal {
  color: var(--ink);
  width: min(760px, 100%);
  max-height: min(88dvh, 900px);
  display: flex; flex-direction: column;
  background: var(--modal-bg, var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: rise var(--speed) cubic-bezier(.2, .8, .3, 1);
}
@keyframes rise { from { transform: translateY(10px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal--sm { width: min(440px, 100%); }
.modal--lg { width: min(1080px, 100%); }

.modal__head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.modal__title { font-size: 1.02rem; flex: 1; }
.modal__body { padding: var(--sp-5); overflow-y: auto; }
.modal__foot {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.modal__foot .spacer { flex: 1; }

/* ---- Editor ------------------------------------------------------------ */

.editor { display: flex; flex-direction: column; min-height: 0; }

/* The modal is a column flexbox. Only the scroll area may flex; if the rows
   below it are allowed to grow, the toolbar and footer get pushed off screen. */
.modal > .modal__head,
.modal > .modal__foot,
.modal > .toolbar,
.modal > .editor__bar,
.modal > .editor__suggest { flex: 0 0 auto; }

.editor__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
}

.editor__title, .editor__subtitle {
  width: 100%; border: 0; background: transparent; padding: 0;
  outline: none;
}
.editor__titlewrap.has-color {
  margin: calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5)) var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.editor__titlewrap.on-dark .editor__title,
.editor__titlewrap.on-dark .editor__subtitle { color: #f2f2ef; }
.editor__titlewrap.on-dark .editor__title::placeholder,
.editor__titlewrap.on-dark .editor__subtitle::placeholder { color: rgba(242,242,239,.55); }
.editor__titlewrap.on-light .editor__title,
.editor__titlewrap.on-light .editor__subtitle { color: #1c1e22; }
.editor__title { font-size: 1.34rem; font-weight: 680; letter-spacing: -.03em; margin-bottom: 4px; }
.editor__subtitle { font-family: var(--font-note); font-style: italic; color: var(--ink-2); font-size: .96rem; margin-bottom: var(--sp-3); }
.editor__title::placeholder, .editor__subtitle::placeholder { color: var(--ink-3); }

.editor__content {
  font-family: var(--font-note);
  font-size: 1rem;
  line-height: 1.65;
  min-height: 180px;
  outline: none;
  overflow-wrap: anywhere;
}
.editor__content:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-3);
}
.editor__content img { max-width: 100%; height: auto; border-radius: var(--r-md); margin: 8px 0; display: block; }
.editor__content img.is-selected { outline: 3px solid var(--accent); }
.editor__content blockquote {
  margin: .6em 0; padding: .2em 0 .2em 1em;
  border-left: 3px solid var(--hl); color: var(--ink-2);
}
.editor__content pre {
  font-family: var(--font-mono); font-size: .84rem;
  background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-md); overflow-x: auto;
}
.editor__content code { font-family: var(--font-mono); font-size: .86em; background: var(--surface-2); padding: .08em .3em; border-radius: 4px; }
.editor__content ul.checklist { list-style: none; padding-left: 4px; }
.editor__content ul.checklist li {
  position: relative; padding-left: 28px; margin-bottom: 4px; cursor: pointer;
}
.editor__content ul.checklist li::before {
  content: ""; position: absolute; left: 2px; top: .3em;
  width: 16px; height: 16px; border: 1.7px solid var(--line-2); border-radius: 4px;
}
.editor__content ul.checklist li[data-checked="1"] { color: var(--ink-3); text-decoration: line-through; }
.editor__content ul.checklist li[data-checked="1"]::before {
  background: var(--accent); border-color: var(--accent);
}
.editor__content ul.checklist li[data-checked="1"]::after {
  content: ""; position: absolute; left: 7px; top: .48em;
  width: 5px; height: 9px; border: solid var(--on-accent);
  border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.card__body ul.checklist { list-style: none; padding-left: 2px; }
.card__body ul.checklist li { position: relative; padding-left: 22px; }
.card__body ul.checklist li::before {
  content: ""; position: absolute; left: 0; top: .35em;
  width: 13px; height: 13px; border: 1.5px solid var(--line-2); border-radius: 3px;
}
.card__body ul.checklist li[data-checked="1"] { color: var(--ink-3); text-decoration: line-through; }
.card__body ul.checklist li[data-checked="1"]::before { background: var(--ink-3); border-color: var(--ink-3); }

.toolbar {
  display: flex; align-items: center; gap: 1px; flex-wrap: wrap;
  padding: 6px var(--sp-3);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.toolbar__sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 5px; }
.toolbar__btn {
  min-width: 32px; height: 32px; padding: 0 7px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-size: .82rem;
}
.toolbar__btn:hover { background: var(--bg-2); color: var(--ink); }
.toolbar__btn.is-on { background: var(--accent-soft); color: var(--accent); }
.toolbar__btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toolbar__btn--text { font-weight: 700; font-family: var(--font-ui); }
.toolbar__btn--serif { font-family: var(--font-note); }

/* Tags, category, and reminder on one uniform line. The bar wraps only when
   a narrow screen forces it. */
.editor__bar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5) 0;
}
.editor__bar .editor__tags { padding: 0; flex: 0 1 auto; }
.editor__bar .editor__meta { padding: 0; flex: 1 1 auto; min-width: 0; }
.editor__meta {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
}
.editor__meta .reminderbtn { margin-left: auto; }

.tagadd {
  width: 24px; height: 24px;
  display: inline-grid; place-items: center;
  border: 1px dashed var(--line-2); border-radius: 50%;
  background: transparent; color: var(--ink-3);
  font-size: .95rem; line-height: 1; cursor: pointer;
}
.tagadd:hover { color: var(--accent); border-color: var(--accent); }

.editor__tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: var(--sp-3) var(--sp-5) 0; }
.taginput {
  border: 1px dashed var(--line-2);
  border-radius: 999px;
  padding: 3px 10px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: .72rem;
  width: 120px;
  outline: none;
}
.taginput:focus { border-color: var(--accent); border-style: solid; }

.suggestbar {
  margin: var(--sp-3) var(--sp-5) 0;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.suggestbar__head {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px;
}
.suggestbar__row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.suggestbar__pick {
  border: 1px solid var(--line-2); background: var(--surface);
  border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: .82rem;
  text-align: left;
}
.suggestbar__pick:hover { border-color: var(--accent); color: var(--accent); }
.suggestbar__kind { font-family: var(--font-mono); font-size: .64rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; margin-right: 4px; align-self: center; }

.picker { padding: 6px 10px 10px; min-width: 216px; }
.picker__label {
  font-family: var(--font-mono);
  font-size: .64rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
  margin: 12px 0 6px;
}
.picker__custom { display: flex; align-items: center; gap: 7px; }

.hexfield {
  flex: 1; min-width: 0;
  padding: 5px 9px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: .78rem;
  text-transform: lowercase;
}
.hexfield:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--line-2); cursor: pointer; padding: 0;
}
.swatch.is-on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }
.swatch--recent { border-style: solid; }

/* "No color": a transparent circle with a diagonal strike through it. */
.swatch--none {
  position: relative;
  background: transparent;
}
.swatch--none::after {
  content: "";
  position: absolute;
  left: 3px; right: 3px; top: 50%;
  height: 1.5px;
  background: var(--danger, #c05555);
  transform: rotate(-45deg);
}

/* The native picker, dressed as one more swatch. */
input.swatch.swatch--pick {
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
  background: none;
  overflow: hidden;
}
input.swatch.swatch--pick::-webkit-color-swatch-wrapper { padding: 0; }
input.swatch.swatch--pick::-webkit-color-swatch { border: 0; border-radius: 50%; }
input.swatch.swatch--pick::-moz-color-swatch { border: 0; border-radius: 50%; }

/* ---- Popover menu ------------------------------------------------------ */

.menu {
  position: fixed; z-index: 70;
  min-width: 208px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
}
.menu__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--r-sm);
  background: none; color: var(--ink); text-align: left;
  font-size: .88rem; cursor: pointer;
}
.menu__item:hover { background: var(--surface-2); }
.menu__item--danger { color: var(--danger); }
.menu__item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.menu__sep { height: 1px; background: var(--line); margin: 5px 2px; }
.menu__head { padding: 8px 10px 6px; }
.menu__head strong { display: block; font-size: .92rem; }
.menu__head span { font-family: var(--font-mono); font-size: .7rem; color: var(--ink-3); }

/* ---- Toast ------------------------------------------------------------- */

.toasts {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: .86rem;
  box-shadow: var(--shadow-2);
  animation: rise var(--speed) ease-out;
}
.toast button { border: 0; background: none; color: var(--hl); font-weight: 650; cursor: pointer; }
.toast--bad { background: var(--danger); color: #fff; }

/* ==========================================================================
   Vault
   ========================================================================== */

.vaultgate {
  position: relative;
  text-align: center;
  max-width: 380px;
  margin: var(--sp-6) auto;
  padding: var(--sp-6) var(--sp-4) var(--sp-5);
  isolation: isolate;
}
.vaultgate > *:not(.wash) { position: relative; z-index: 1; }
.vaultgate .wash { color: var(--vault); width: min(280px, 78%); }
.vaultgate__badge {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  margin: 0 auto var(--sp-3);
  border-radius: 12px;
  background: var(--vault-soft);
  color: var(--vault);
}
.vaultgate__badge svg { width: 21px; height: 21px; }
.vaultgate h3 { font-size: 1.15rem; margin-bottom: 6px; }
.vaultgate p { color: var(--ink-3); font-size: .9rem; margin: 0 0 var(--sp-4); }

.pinbox {
  display: flex; gap: 10px; justify-content: center; margin-bottom: var(--sp-4);
}
.pinbox input {
  width: 46px; height: 56px;
  text-align: center;
  font-family: var(--font-mono); font-size: 1.4rem;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface);
}
.pinbox input:focus { outline: none; border-color: var(--vault); box-shadow: 0 0 0 3px var(--vault-soft); }
.pinbox.is-wrong { animation: shake 320ms; }
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.vaultbanner {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  max-width: 1180px; margin: 0 auto var(--sp-4);
  padding: 10px 16px;
  border: 1px solid var(--vault);
  background: var(--vault-soft);
  border-radius: var(--r-lg);
  font-size: .86rem;
}
.vaultbanner__spacer { flex: 1; }

/* ==========================================================================
   Admin
   ========================================================================== */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.tab {
  border: 0; background: none; cursor: pointer;
  padding: 9px 14px; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-3); font-size: .9rem; font-weight: 550;
}
.tab.is-active { color: var(--ink); border-bottom-color: var(--hl); }
.tab:hover { color: var(--ink); }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.stat {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.stat__value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; }
.stat__label { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th {
  text-align: left; padding: 8px 10px;
  font-family: var(--font-mono); font-size: .67rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--surface-2); }
.table__actions { display: flex; gap: 4px; justify-content: flex-end; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .05em;
  border: 1px solid var(--line-2); color: var(--ink-2);
}
.badge--admin { border-color: var(--accent); color: var(--accent); }
.badge--off { border-color: var(--danger); color: var(--danger); }
.badge--vault { border-color: var(--vault); color: var(--vault); }

.logline {
  display: grid; grid-template-columns: 150px 130px 1fr; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line);
  font-size: .82rem;
}
.logline time, .logline .who { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); }

/* ==========================================================================
   Responsive
   ========================================================================== */

.scrim--drawer { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    height: 100dvh;
    z-index: 65;
    width: 280px; flex-basis: 280px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding-top: var(--sp-4);
    transform: translateX(-102%);
    transition: transform 220ms cubic-bezier(.2, .8, .3, 1);
    box-shadow: var(--shadow-3);
  }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim--drawer { display: block; position: fixed; inset: 0; z-index: 64; background: var(--overlay); }
  .content { padding: var(--sp-3) var(--sp-3) 96px; }
  .fab { display: grid; }
  .composer { padding: 4px 6px 4px 14px; margin-bottom: var(--sp-4); }

  /* Keep-style density: always two columns, compact cards. */
  .grid { columns: 2; column-gap: var(--sp-2); }
  .card { padding: 10px 12px 8px; margin-bottom: var(--sp-2); border-radius: var(--r-md, 12px); }
  .card__title { font-size: .88rem; margin-right: 20px; }
  .card__subtitle { font-size: .76rem; }
  .card__body { font-size: .8rem; max-height: 12em; }
  .card__foot { gap: 4px; margin-top: 6px; }
  .card__foot .chip { font-size: .66rem; padding: 2px 8px; }
  .card__foot .meta { font-size: .66rem; }
  .card__titlewrap { margin: -10px -12px 8px; padding: 8px 12px 6px; border-radius: var(--r-md, 12px) var(--r-md, 12px) 0 0; }
  .card__titlewrap--bare { padding: 4px 12px; }
  .card__pin { display: none; } /* pin from the open note; taps on cards are for opening */

  /* Keep-style open note: formatting stays hidden until the Aa button. */
  .toolbar { display: none; }
  .toolbar.is-open { display: flex; }
  .scrim { padding: 0; }
  .modal {
    width: 100%; max-width: 100%;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: 0;
  }
  .brand__name { display: none; }
  .topbar { padding: 0 var(--sp-2); }
  .logline { grid-template-columns: 1fr; gap: 2px; }
}

/* The Aa toggle only matters where the toolbar hides; desktop hides the toggle. */
.fmt-toggle { font-weight: 700; font-size: .82rem; width: auto; padding: 0 10px; }
.fmt-toggle.is-on { color: var(--accent); }
@media (min-width: 901px) {
  .fmt-toggle { display: none; }
}

/* The menu button stays visible at every width: on desktop it collapses the
   sidebar to an icon rail, below 901px it opens the drawer. */

@media (max-width: 480px) {
  /* Two columns even on narrow phones: this is where Keep-style density
     matters most. The 1.5.0 regression happened because the old
     { columns: 1; } here silently beat the columns: 2 rule in the
     900px block above. */
  .grid { columns: 2; }
  .card__body { max-height: 9em; }
}

@media print {
  .topbar, .sidebar, .fab, .card__tools, .composer { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}
