/* ============================================================================
   Geniuz dashboard — Tool register.

   One register. No themes, no picker, no decoration that doesn't earn its
   place. Knowledge-worker tool aesthetic: at home in a stack of Linear,
   Notion, Slack, Granola, Cursor.

   The window itself is transparent (tauri.conf.json `transparent: true`)
   and NSVisualEffectView / Acrylic provides the OS-native vibrancy
   material at the chrome level (src/lib.rs setup). Every CSS surface
   here is layered above that vibrancy:

   - body / app-shell: transparent. Let the OS material show through.
   - sidebar + main: transparent. Same.
   - rows / cards: semi-translucent so vibrancy bleeds through subtly.
   - hover / active: opaque-ish only on the part being touched.

   No webfonts. System fonts only — SF Pro Text/Display on macOS,
   Segoe UI on Windows, system stack everywhere.

   Accent: defers to the OS via CSS `AccentColor` keyword, with a
   neutral fallback so the dashboard adopts whatever colour the user
   picked in System Settings.
   ============================================================================ */

/* ============================================================================
   Tokens
   ============================================================================ */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI',
             system-ui, Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display',
                  'Segoe UI', system-ui, Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --fs-micro: 11px;
  --fs-body:  13px;
  --fs-medium:14px;
  --fs-large: 17px;
  --fs-xl:    22px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  --sidebar-w: 220px;

  --bg-window:    rgba(246, 244, 239, 0.90);
  --bg-surface:   rgba(255, 255, 255, 0.04);
  --bg-elevated:  rgba(255, 255, 255, 0.08);
  --bg-active:    rgba(255, 255, 255, 0.12);
  --bg-emphatic:  rgba(255, 255, 255, 0.18);

  --ink-1: rgba(0, 0, 0, 0.92);
  --ink-2: rgba(0, 0, 0, 0.65);
  --ink-3: rgba(0, 0, 0, 0.42);
  --ink-4: rgba(0, 0, 0, 0.22);

  --hairline-1: rgba(0, 0, 0, 0.08);
  --hairline-2: rgba(0, 0, 0, 0.14);

  --accent: AccentColor;
  --accent-faint: color-mix(in oklab, AccentColor 14%, transparent);
  --accent-bg:    color-mix(in oklab, AccentColor 8%,  transparent);

  --status-ok:    color-mix(in oklab, #34c759 70%, transparent);
  --status-warn:  color-mix(in oklab, #ff9500 70%, transparent);
  --status-bad:   color-mix(in oklab, #ff3b30 70%, transparent);

  --t-hover: 120ms;
  --t-cross: 180ms;
  --ease:    cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark-mode tokens. Scoped with :not(.os-linux) because webkit2gtk inherits
   the GTK dark theme as prefers-color-scheme: dark, which would override our
   .os-linux solid-light surfaces and produce white text on light backgrounds.
   See tauri-apps/tauri#9255, #9427. The .os-linux block paints explicit light
   surfaces; this guard prevents the media query from rewriting ink tokens to
   white when GTK is in dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not(.os-linux) {
    /* Dark slate window base (brand #1B2A30) at near-opacity so a hint of OS
       vibrancy stays, matching the menubar popover level. */
    --bg-window:    rgba(27, 42, 48, 0.90);
    --bg-surface:   rgba(255, 255, 255, 0.04);
    --bg-elevated:  rgba(255, 255, 255, 0.08);
    --bg-active:    rgba(255, 255, 255, 0.14);
    --bg-emphatic:  rgba(255, 255, 255, 0.22);

    --ink-1: rgba(255, 255, 255, 0.92);
    --ink-2: rgba(255, 255, 255, 0.65);
    --ink-3: rgba(255, 255, 255, 0.42);
    --ink-4: rgba(255, 255, 255, 0.22);

    --hairline-1: rgba(255, 255, 255, 0.08);
    --hairline-2: rgba(255, 255, 255, 0.14);
  }
}

/* ============================================================================
   Reset / base
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-family: var(--font-ui); font-size: var(--fs-body); }

html, body {
  background: var(--bg-window);
  color: var(--ink-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'tnum' 1;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-faint); }

/* ============================================================================
   Window frame + app shell
   ============================================================================ */

.window-frame {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.app-shell {
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  /* Bound the single row to the frame height. Without an explicit row track
     the implicit row is `auto` and sizes to content, so tall surfaces grow
     past 100vh and clip against .window-frame's overflow:hidden instead of
     scrolling. The minmax(0,...) floor lets children shrink below content so
     .main-body's overflow-y:auto engages. Pairs with flex:1 on .main. */
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
}

/* ============================================================================
   Sidebar
   ============================================================================ */

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 38px var(--s-2) var(--s-3) var(--s-2);
  border-right: 1px solid var(--hairline-1);
  background: transparent;
  min-width: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-2) var(--s-4) var(--s-2);
}
.sidebar-brand__mark {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.sidebar-brand__mark svg { display: block; width: 100%; height: 100%; }
.sidebar-brand__name {
  font-family: "Newsreader", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}
.sidebar-brand__name::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #CF5535;
  align-self: center;
}
.sidebar-brand__version {
  margin-left: auto;
  font-family: "Hanken Grotesk", var(--font-ui);
  font-size: var(--fs-micro);
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: var(--s-3);
}
.sidebar-section__label {
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--s-2) var(--s-2) var(--s-1) var(--s-2);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px var(--s-2);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: var(--fs-body);
  color: var(--ink-2);
  width: 100%;
  text-align: left;
  transition: background-color var(--t-hover) var(--ease),
              color           var(--t-hover) var(--ease);
}
.sidebar-item:hover {
  background: var(--bg-elevated);
  color: var(--ink-1);
}
.sidebar-item.is-active {
  background: var(--bg-active);
  color: var(--ink-1);
  font-weight: 500;
}
.sidebar-item__icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.78;
}
.sidebar-item.is-active .sidebar-item__icon {
  opacity: 1;
  color: var(--accent);
}
.sidebar-item__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-item__count {
  font-size: var(--fs-micro);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--s-3) var(--s-2) 0 var(--s-2);
  font-size: var(--fs-micro);
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
/* (sidebar-footer__dot removed — the green status dot competed with the
   wordmark's clay dot and the tagline it accompanied was a hosted brand
   promise; the footer now carries the always-on storage line.) */

/* ============================================================================
   Main pane
   ============================================================================ */

.main {
  display: flex;
  flex-direction: column;
  /* Bind to #main-host's height so .main-body's overflow-y:auto engages.
     Without this, .main sizes to content and tall surfaces (memories list,
     detail) overflow the overflow:hidden and clip instead of scrolling. */
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding-top: 38px;
}

.main-header {
  padding: var(--s-4) var(--s-6) var(--s-3) var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.main-header__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.015em;
  margin: 0;
}
.main-header__sub {
  font-size: var(--fs-body);
  color: var(--ink-2);
  margin: 0;
}

.main-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--s-6) var(--s-6) var(--s-6);
}

/* ============================================================================
   Stats strip
   ============================================================================ */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-5);
  /* Fixed in the header region now (not inside the scroll body), so it carries
     its own horizontal padding to align with the header title and the list. */
  padding: var(--s-2) var(--s-6) var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--hairline-1);
  margin-bottom: 0;
}
.stats-strip__cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stats-strip__value {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stats-strip__label {
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================================
   Memory list (dense rows)
   ============================================================================ */

.day-section { margin-top: var(--s-4); }
.day-section:first-of-type { margin-top: 0; }

.day-section__label {
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--s-2) 0;
}

.memory-list {
  display: flex;
  flex-direction: column;
}

/* Two-line row: meta strip (number · date · category) on top, gist below.
   Meta is muted micro-type; gist is body. Gist clamps to 2 lines so density
   stays readable without truncating personality. */
.memory-row {
  appearance: none;
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--hairline-1);
  border-radius: 0;
  padding: var(--s-3) var(--s-2);
  margin: 0 calc(var(--s-2) * -1);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink-1);
  transition: background-color var(--t-hover) var(--ease);
}
.memory-row:hover { background: var(--bg-elevated); }
.memory-row:last-child { border-bottom-color: transparent; }

.memory-row__meta {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  font-size: var(--fs-micro);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.memory-row__num {
  color: var(--ink-2);
  font-weight: 500;
  font-feature-settings: 'tnum' 1;
  /* Fixed width keeps the dots aligned across rows of varying digit count. */
  min-width: 3.5ch;
  display: inline-block;
}
.memory-row__date {
  white-space: nowrap;
}
.memory-row__chip {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: var(--fs-micro);
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0;
  /* Subtle outline so the chip reads against vibrancy. */
  box-shadow: inset 0 0 0 1px var(--accent-faint);
}
.memory-row__chip--empty {
  background: transparent;
  color: var(--ink-4);
  box-shadow: none;
}
.memory-row__sep {
  color: var(--ink-4);
  user-select: none;
}
.memory-row__gist {
  font-size: var(--fs-body);
  color: var(--ink-1);
  font-weight: 400;
  line-height: 1.45;
  /* Clamp to two lines with ellipsis. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================================
   Loading / error / empty
   ============================================================================ */

.surface-loading,
.surface-error,
.surface-empty {
  padding: var(--s-6);
  color: var(--ink-2);
  font-size: var(--fs-body);
}
.surface-error h2 {
  font-family: var(--font-display);
  font-size: var(--fs-large);
  font-weight: 600;
  color: var(--ink-1);
  margin: 0 0 var(--s-2) 0;
}
.surface-error p { margin: var(--s-1) 0; }
.surface-error code {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  padding: 2px 5px;
  background: var(--bg-elevated);
  border-radius: 3px;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
  appearance: none;
  border: 1px solid var(--hairline-2);
  background: var(--bg-elevated);
  color: var(--ink-1);
  padding: 6px var(--s-3);
  border-radius: 5px;
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t-hover) var(--ease),
              border-color var(--t-hover) var(--ease);
}
.btn:hover { background: var(--bg-active); }
.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: white;
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn--ghost:hover { background: var(--bg-elevated); color: var(--ink-1); }

/* ============================================================================
   Form controls
   ============================================================================ */

.input {
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--hairline-1);
  border-radius: 5px;
  padding: 6px var(--s-3);
  color: var(--ink-1);
  font-size: var(--fs-body);
  transition: border-color var(--t-hover) var(--ease),
              background-color var(--t-hover) var(--ease);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.toggle {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--hairline-2);
  border-radius: 999px;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: background-color var(--t-hover) var(--ease);
}
.toggle::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform var(--t-hover) var(--ease);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.toggle.is-on { background: var(--accent); }
.toggle.is-on::before { transform: translateX(14px); }

.select {
  /* Native <select> rendering — WKWebView shows the system chevron and
     menu, which is exactly the system aesthetic the Tool register wants.
     We don't strip `appearance` here on purpose; trying to overlay our
     own chevron stacked two arrows. */
  background: var(--bg-surface);
  border: 1px solid var(--hairline-1);
  border-radius: 5px;
  padding: 6px var(--s-3);
  color: var(--ink-1);
  font-size: var(--fs-body);
  cursor: pointer;
}

/* ============================================================================
   Find surface
   ============================================================================ */

.find-input-wrap {
  display: flex;
  gap: var(--s-2);
  padding: var(--s-3) 0 var(--s-4) 0;
}
.find-input {
  flex: 1;
  font-size: var(--fs-large);
  padding: var(--s-3);
  background: var(--bg-surface);
  border: 1px solid var(--hairline-2);
  border-radius: 6px;
  color: var(--ink-1);
}
.find-input:focus { outline: none; border-color: var(--accent); }
.find-submit {
  font: inherit;
  padding: 0 var(--s-4);
  background: var(--accent, AccentColor);
  border: 1px solid var(--accent, AccentColor);
  color: white;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 120ms ease;
}
.find-submit:hover { filter: brightness(1.08); }
.find-mode-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin: var(--s-2) 0 var(--s-3);
  background: var(--bg-surface);
  border: 1px solid var(--hairline-2);
  border-radius: 7px;
  align-self: flex-start;
}
.find-mode-toggle button {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  font-size: var(--fs-meta);
  font: inherit;
  padding: 5px 12px;
  border-radius: 5px;
  transition: background 120ms ease, color 120ms ease;
}
.find-mode-toggle button:hover {
  color: var(--ink-1);
  background: color-mix(in srgb, var(--ink-1) 6%, transparent);
}
.find-mode-toggle button.is-active {
  background: var(--bg-elevated, white);
  color: var(--ink-1);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ============================================================================
   Detail surface
   ============================================================================ */

.detail-meta {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-2) 0 var(--s-3) 0;
  border-bottom: 1px solid var(--hairline-1);
  font-size: var(--fs-micro);
  color: var(--ink-3);
  font-family: var(--font-mono);
  flex-wrap: wrap;
}
.detail-meta__chip {
  padding: 2px 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  border: 1px solid var(--hairline-1);
}
.detail-gist {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.015em;
  margin: var(--s-4) 0 var(--s-2) 0;
}
.detail-body {
  font-size: var(--fs-medium);
  line-height: 1.55;
  color: var(--ink-1);
  margin: var(--s-3) 0;
  white-space: pre-wrap;
}
.detail-thread {
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--hairline-1);
}
.detail-thread__label {
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--s-2);
}

/* ============================================================================
   Status surface
   ============================================================================ */

.status-section { margin: var(--s-4) 0; }
.status-section__label {
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--s-2);
}
.status-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--hairline-1);
  font-size: var(--fs-body);
}
.status-row__label { color: var(--ink-2); }
.status-row__value { color: var(--ink-1); font-variant-numeric: tabular-nums; }
.status-row__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-ok);
}
.status-row__dot.is-warn { background: var(--status-warn); }
.status-row__dot.is-bad  { background: var(--status-bad); }

/* ============================================================================
   Settings surface
   ============================================================================ */

.settings-shell {
  max-width: 720px;
  margin: 0 auto;
}
.settings-section {
  margin: var(--s-5) 0;
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--hairline-1);
}
.settings-section:last-child { border-bottom: 0; }
.settings-section__label {
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--s-3);
}
.settings-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: var(--s-4);
  align-items: start;
  padding: var(--s-2) 0;
}
.settings-row__main { display: flex; flex-direction: column; gap: 2px; }
.settings-row__title { font-size: var(--fs-body); color: var(--ink-1); }
.settings-row__help {
  font-size: var(--fs-micro);
  color: var(--ink-3);
  line-height: 1.4;
}
.settings-row__control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.kv-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--ink-2);
}
.kv-list__row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--s-3);
  padding: 2px 0;
}
.kv-list__key { color: var(--ink-3); }
.kv-list__val { color: var(--ink-1); word-break: break-all; }

/* ============================================================================
   Data & Export surface
   ============================================================================ */

.data-card {
  background: var(--bg-surface);
  border: 1px solid var(--hairline-1);
  border-radius: 8px;
  padding: var(--s-5);
  margin: var(--s-4) 0;
  max-width: 720px;
}
.data-card__title {
  font-family: var(--font-display);
  font-size: var(--fs-large);
  font-weight: 600;
  color: var(--ink-1);
  margin: 0 0 var(--s-2) 0;
  letter-spacing: -0.01em;
}
.data-card__body {
  font-size: var(--fs-body);
  color: var(--ink-2);
  line-height: 1.5;
}
.data-card__path {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--ink-1);
}
.data-card__actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

/* ============================================================================
   Scrollbar
   ============================================================================ */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--hairline-2);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: padding-box; }

/* Current row — marks the memory the user is/was viewing in Detail so
   they can find their place when they return to a list. Uses the same
   subtle background-tint as hover so it reads as "where you were"
   without asserting. Stays clickable. */
.memory-row.is-current {
  background: var(--bg-elevated);
}
.memory-row.is-current:hover { background: var(--bg-active); }

/* ============================================================================
   List controls — sort toggle, etc.
   ============================================================================ */

.list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Horizontal padding to align with the header + stats now that it lives in
     the fixed band rather than inside the padded scroll body. */
  padding: 0 var(--s-6) var(--s-2) var(--s-6);
  border-bottom: 1px solid var(--hairline-1);
  margin-bottom: var(--s-2);
}
.sort-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 4px;
  font-size: var(--fs-micro);
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color var(--t-hover) var(--ease),
              color var(--t-hover) var(--ease);
}
.sort-toggle:hover {
  background: var(--bg-elevated);
  color: var(--ink-1);
}
.sort-toggle__icon {
  width: 11px;
  height: 11px;
  opacity: 0.7;
}
.sort-toggle:hover .sort-toggle__icon { opacity: 1; }

/* ============================================================================
   Back button — top-left of detail / drill-down surfaces.
   ============================================================================ */

.back-button {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 4px 8px 4px 4px;
  border-radius: 5px;
  font-size: var(--fs-body);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 var(--s-3) -4px;
  transition: background-color var(--t-hover) var(--ease),
              color var(--t-hover) var(--ease);
}
.back-button:hover {
  background: var(--bg-elevated);
  color: var(--ink-1);
}
.back-button__icon {
  width: 16px;
  height: 16px;
}

/* Gist category tag — the prefix before the first colon, bolded inline. */
.memory-row__gist-tag {
  font-weight: 600;
  color: var(--ink-1);
}

/* --- Linux-specific contrast overlay ----------------------------------------
   The design is built around macOS NSVisualEffectMaterial vibrancy: surfaces
   are alpha-blended white-over-vibrancy, hairlines are alpha-black. On Linux
   without a vibrancy backend, the window sits on a solid mid-light gray
   (set in Rust). These overrides give the alpha-blended elements concrete
   colors so they stay visible. Applied via the `os-linux` class injected
   by setup() once the webview loads.
   --------------------------------------------------------------------------- */
html.os-linux body {
  background: rgb(228, 228, 232);
}
html.os-linux .sidebar,
html.os-linux .stats-strip,
html.os-linux .data-card,
html.os-linux .memory-row,
html.os-linux .memory-row.is-current,
html.os-linux .find-input,
html.os-linux .find-mode-toggle,
html.os-linux .remember-field__input,
html.os-linux .remember-field__textarea {
  background: rgba(255, 255, 255, 0.55);
}
html.os-linux .memory-row:hover {
  background: rgba(255, 255, 255, 0.85);
}
html.os-linux .memory-row.is-current {
  background: rgba(255, 255, 255, 0.92);
}
html.os-linux .find-mode-toggle button.is-active {
  background: white;
}
html.os-linux {
  --hairline-1: rgba(0, 0, 0, 0.14);
  --hairline-2: rgba(0, 0, 0, 0.22);
  --rule: rgba(0, 0, 0, 0.18);
}

/* --- Remember surface ---------------------------------------------------- */

.remember-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 12px;
}

.remember-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.remember-field__label {
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--ink-1);
}

.remember-field__hint {
  font-weight: 400;
  color: var(--ink-3);
  margin-left: 4px;
}

.remember-field__input,
.remember-field__textarea {
  font: inherit;
  color: var(--ink-1);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.remember-field__textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.5;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--fs-body);
}

.remember-field__input:focus,
.remember-field__textarea:focus {
  border-color: var(--accent, AccentColor);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, AccentColor) 20%, transparent);
}

.remember-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.remember-actions__cancel,
.remember-actions__submit {
  font: inherit;
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  color: var(--ink-1);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.remember-actions__cancel:hover {
  background: var(--bg-hover, var(--bg-elevated));
}

.remember-actions__submit {
  background: var(--accent, AccentColor);
  border-color: var(--accent, AccentColor);
  color: white;
  font-weight: 600;
}

.remember-actions__submit:hover:not(:disabled) {
  filter: brightness(1.08);
}

.remember-actions__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.remember-status {
  min-height: 18px;
  font-size: var(--fs-meta);
  color: var(--ink-3);
}

.surface-empty__link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, AccentColor);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
