/**
 * Locked design tokens for the three-pane MemoryWorkspace browser.
 *
 * Scoped under `.memory-workspace-root` so the rest of the app's surfaces
 * (which use the global stone/primary palette) are unaffected.
 */
.memory-workspace-root {
  /* Match the rest of the app's stone palette — dropped the cream tones
     (#faf7f2 / #f4f0e9) that read yellowish next to the bottom nav bar. */
  --paper: #fafaf9; /* stone-50 — base surface */
  --paper-elevated: #ffffff; /* white — active/selected/list */
  --paper-recessed: #f5f5f4; /* stone-100 — hover */
  --paper-recessed-darker: #e7e5e4; /* stone-200 — pressed */
  --hairline: #e7e5e4; /* stone-200 — borders */
  --ink: #1c1917;
  --ink-soft: #44403c;
  --ink-whisper: #78716c;
  --ocean: #4a83dd;
  --ocean-deep: #2e5baa;
  --ocean-mist: rgba(74, 131, 221, 0.08);
  --sage: #7a9b7e;
  --amber: #c8954d;
  --coral: #c26b5c;
  --shadow-rest: 0 1px 2px rgba(26, 31, 46, 0.04);
  --r-tight: 4px;
  --r-card: 8px;
  --r-room: 12px;
}

.memory-workspace-root,
.memory-workspace-root * {
  box-sizing: border-box;
}

.memory-workspace-root {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--r-room);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-rest);
  overflow: hidden;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    system-ui,
    sans-serif;
}

.memory-workspace-grid {
  display: grid;
  grid-template-columns: 280px 380px 1fr;
  min-height: 640px;
  height: calc(100vh - 240px);
  max-height: 900px;
}

.memory-workspace-grid > * + * {
  border-left: 1px solid var(--hairline);
}

@media (max-width: 1100px) {
  .memory-workspace-grid {
    grid-template-columns: 1fr 1fr;
  }
  .memory-workspace-grid .mw-pane-detail {
    display: none;
  }
  .memory-workspace-grid.mw-show-detail {
    grid-template-columns: 1fr;
  }
  .memory-workspace-grid.mw-show-detail .mw-pane-navigator,
  .memory-workspace-grid.mw-show-detail .mw-pane-results {
    display: none;
  }
  .memory-workspace-grid.mw-show-detail .mw-pane-detail {
    display: flex;
  }
}

.mw-pane-navigator {
  background: var(--paper-recessed);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mw-pane-results {
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mw-pane-detail {
  background: var(--paper-elevated);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mw-pane-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Section headings — Inter uppercase, modern app-rail style. Replaces
   the Cabinet Grotesk lowercase tracked treatment which read like a
   magazine masthead in a left-rail context. */
.mw-section-heading {
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-whisper);
  padding: 10px 16px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: color 120ms ease;
}
.mw-section-heading:hover {
  color: var(--ink-soft);
}
.mw-section-chev {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.5;
  transition: transform 120ms ease;
}
.mw-section-chev.open {
  transform: rotate(90deg);
}

.mw-section {
  border-bottom: 1px solid var(--hairline);
}
.mw-section:last-child {
  border-bottom: none;
}

/* Nested sections — sources expanded shows Email/Slack/etc. as
   sub-collapsibles. Indent + tone-shift the nested level so the
   hierarchy reads visually. */
.mw-section .mw-section {
  border-bottom: 1px solid var(--hairline);
  border-left: 2px solid var(--hairline);
  margin: 0 0 0 12px;
  background: var(--paper-recessed);
}
.mw-section .mw-section:last-child {
  border-bottom: none;
}
.mw-section .mw-section .mw-section-heading {
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 6px 12px 4px;
  color: var(--ink-soft);
}
.mw-section .mw-section .mw-section-heading:hover {
  color: var(--ink);
}
.mw-section .mw-section .mw-list-item {
  /* Source rows under a kind heading need a stronger indent so the
     hierarchy is unambiguous: kind heading at one level, individual
     senders deeper. Bump left padding so each row sits visibly under
     the kind's chevron, with a sub-rail line to continue the nesting. */
  padding: 5px 12px 5px 26px;
  position: relative;
}
.mw-section .mw-section .mw-list-item::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--hairline);
  opacity: 0.7;
}
.mw-section .mw-section .mw-list-item.is-active::before {
  background: var(--ocean);
  opacity: 1;
}

.mw-search-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
}
.mw-search-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 6px 0;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  font-style: italic;
}
.mw-search-input:focus {
  border-bottom-color: var(--ocean);
}
.mw-search-input::placeholder {
  color: var(--ink-whisper);
  font-style: italic;
}

.mw-heatmap-host {
  padding: 8px 12px 12px;
  border-bottom: 1px solid var(--hairline);
}
.mw-heatmap-host > div {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}
.mw-heatmap-host h3 {
  display: none;
}
.mw-heatmap-host p {
  font-size: 10px !important;
  color: var(--ink-whisper) !important;
  margin: 0 !important;
}

.mw-recent-summary {
  padding: 8px 16px 14px;
  font-size: 12px;
  color: var(--ink-soft);
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}
.mw-recent-summary span + span {
  margin-left: 8px;
  color: var(--ink-whisper);
}

.mw-list {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
}
.mw-list-item {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition:
    background 80ms,
    border-color 80ms;
  background: transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
  width: 100%;
  text-align: left;
}
.mw-list-item:hover {
  background: var(--paper-recessed-darker);
}
.mw-list-item.is-active {
  background: var(--paper-elevated); /* white — matches bottom nav active state */
  border-left-color: var(--ocean);
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.04);
}
.mw-list-item.is-active .mw-list-name {
  font-weight: 600;
  color: var(--ink);
}
.mw-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ink-whisper);
}
.mw-dot.dot-admitted {
  background: var(--sage);
}
.mw-dot.dot-pending {
  background: var(--amber);
}
.mw-dot.dot-buffered {
  background: var(--ocean);
}
.mw-dot.dot-dropped {
  background: var(--coral);
}
.mw-list-name {
  font-size: 14px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.mw-list-count {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 11px;
  color: var(--ink-whisper);
}

/* Result list */
.mw-results-empty,
.mw-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--ink-soft);
}
.mw-results-empty {
  font-size: 13px;
  color: var(--ink-whisper);
}
.mw-detail-empty {
  font-family: 'Cabinet Grotesk', Inter, system-ui, sans-serif;
}
.mw-detail-empty .mw-empty-title {
  font-size: 22px;
  margin: 0 0 12px;
  color: var(--ink-soft);
}
.mw-detail-empty .mw-empty-body {
  font-size: 14px;
  color: var(--ink-whisper);
  max-width: 320px;
  line-height: 1.6;
}

.mw-results-section {
  border-bottom: 1px solid var(--hairline);
}
.mw-results-section-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  font-family: 'Cabinet Grotesk', Inter, sans-serif;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-whisper);
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--hairline);
}
.mw-result-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--hairline);
  transition: background 80ms;
  background: transparent;
  border-right: none;
  border-top: none;
  width: 100%;
  text-align: left;
}
.mw-result-row:last-child {
  border-bottom: none;
}
.mw-result-row:hover {
  background: var(--paper-recessed);
}
.mw-result-row.is-active {
  background: var(--ocean-mist);
  border-left-color: var(--ocean);
}
.mw-result-row.is-active .mw-result-subject {
  font-weight: 600;
  color: var(--ink);
}
.mw-result-time {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--ink-whisper);
  padding-top: 1px;
}
.mw-result-content {
  min-width: 0;
}
.mw-result-subject {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.mw-result-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mw-result-kind {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-whisper);
  padding: 1px 6px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--paper);
  margin-right: 2px;
}

/* Chunk detail letter */
.mw-detail-scroll {
  padding: 40px 48px;
}
.mw-letter {
  max-width: 720px;
  margin: 0 auto;
}
.mw-letterhead {
  margin-bottom: 24px;
}
.mw-letterhead-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: baseline;
}
.mw-letterhead-label {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 11px;
  text-transform: lowercase;
  color: var(--ink-whisper);
  letter-spacing: 0.05em;
}
.mw-letterhead-label::after {
  content: '';
  display: block;
  border-bottom: 1px solid var(--hairline);
  width: 40px;
  margin-top: 2px;
}
.mw-letterhead-value {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
}
.mw-letterhead-value-secondary {
  font-size: 12px;
  color: var(--ink-soft);
  display: block;
  margin-top: 2px;
}
.mw-letterhead-date {
  margin-top: 12px;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
}

.mw-rule {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 24px 0;
}

.mw-letter-subject {
  font-family: 'Cabinet Grotesk', Inter, system-ui, sans-serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 16px;
  line-height: 1.35;
}

.mw-letter-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  /* `word-wrap` is the legacy alias of `overflow-wrap`; modern engines
     respect `overflow-wrap` directly without the legacy fallback. */
  overflow-wrap: break-word;
}
.mw-letter-body p {
  margin: 0 0 12px;
}

/* Mentioned section */
.mw-mentioned-heading,
.mw-whykept-heading {
  font-family: 'Cabinet Grotesk', Inter, sans-serif;
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--ink-whisper);
  text-transform: lowercase;
  margin: 16px 0 12px;
  font-weight: 500;
}

.mw-mentioned-table {
  width: 100%;
  border-collapse: collapse;
}
.mw-mentioned-row {
  cursor: pointer;
  background: transparent;
  border: none;
  /* Single padding declaration — was duplicated (`padding: 0` then
     `padding: 6px 0` later in the block). Combined into the right
     value below. */
  padding: 6px 0;
  width: 100%;
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 12px;
  font-size: 13px;
  color: var(--ink);
  align-items: baseline;
  text-align: left;
  border-bottom: 1px dotted var(--hairline);
}
.mw-mentioned-row:last-child {
  border-bottom: none;
}
.mw-mentioned-row:hover {
  background: var(--paper-recessed);
}
.mw-mentioned-kind {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 11px;
  color: var(--ink-whisper);
  text-transform: lowercase;
}
.mw-mentioned-surface {
  color: var(--ink);
  font-size: 13px;
}
.mw-mentioned-count {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 11px;
  color: var(--ink-whisper);
}

/* Score bars */
.mw-scorebar-row {
  display: grid;
  grid-template-columns: 110px 1fr 60px;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.mw-scorebar-label {
  font-size: 13px;
  color: var(--ink-soft);
}
.mw-scorebar-value {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--ink);
  text-align: right;
}
.mw-scorebar-threshold {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 11px;
  color: var(--ink-whisper);
  text-align: center;
  margin-top: 12px;
  letter-spacing: 0.05em;
}

/* Footer */
.mw-letter-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 11px;
  color: var(--ink-whisper);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.mw-letter-footer button {
  background: transparent;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.mw-letter-footer button:hover {
  color: var(--ocean);
}
