/* ── Design System: Fira Code + Fira Sans, 浅蓝清新 ── */
[data-theme="light"] {
  --bg: #FAFBFD;
  --bg-card: #FFFFFF;
  --bg-hover: #F4F6FA;
  --bg-input: #F1F4F9;
  --bg-accent: #EFF4FF;
  --border: #E4E9F1;
  --border-hover: #CDD4E0;
  --text: #1A2138;
  --text-2: #4A5468;
  --text-3: #8E99AE;
  --accent: #4A90D9;
  --accent-bg: rgba(74,144,217,0.07);
  --accent-text: #3A7BC8;
  --accent-glow: rgba(74,144,217,0.1);
  --green: #2D9E6F;
  --green-bg: rgba(45,158,111,0.07);
  --yellow: #D08B2D;
  --yellow-bg: rgba(208,139,45,0.07);
  --red: #CC4444;
  --mark-bg: rgba(74,144,217,0.1);
  --mark-text: #3A7BC8;
  --shadow-sm: 0 1px 2px rgba(26,33,56,0.03);
  --shadow: 0 1px 3px rgba(26,33,56,0.05), 0 1px 2px rgba(26,33,56,0.03);
  --shadow-lg: 0 8px 32px rgba(26,33,56,0.06);
  --modal-bg: rgba(26,33,56,0.12);
}
[data-theme="dark"] {
  --bg: #0E1525;
  --bg-card: #172033;
  --bg-hover: #1E2A42;
  --bg-input: #172033;
  --bg-accent: rgba(74,144,217,0.08);
  --border: #253350;
  --border-hover: #334768;
  --text: #E2E7F0;
  --text-2: #94A0B8;
  --text-3: #5E6E8A;
  --accent: #6BADE8;
  --accent-bg: rgba(107,173,232,0.1);
  --accent-text: #8EC3F0;
  --accent-glow: rgba(107,173,232,0.12);
  --green: #4CD9A0;
  --green-bg: rgba(76,217,160,0.1);
  --yellow: #F0C050;
  --yellow-bg: rgba(240,192,80,0.1);
  --red: #F07070;
  --mark-bg: rgba(107,173,232,0.14);
  --mark-text: #8EC3F0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
  --modal-bg: rgba(0,0,0,0.4);
}
:root {
  --r: 10px;
  --font: 'Fira Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Fira Code', ui-monospace, monospace;
}

*,*::before,*::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.app { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

/* ── Header ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.logo {
  font-family: var(--mono); font-size: 20px; font-weight: 700;
  color: var(--text); letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 10px;
}
.logo span { color: var(--accent); }
.logo-icon { flex-shrink: 0; }
.logo-icon .core-pulse { r: 4.5; }
.logo-icon.active g:nth-child(1) { animation: spinCW 8s linear infinite; }
.logo-icon.active g:nth-child(2) { animation: spinCCW 6s linear infinite; }
.logo-icon.active g:nth-child(3) { animation: spinCW 10s linear infinite; }
.logo-icon.active .core-pulse { animation: corePulse 3s ease-in-out infinite; }
@keyframes spinCW { to { transform: rotate(360deg); } }
@keyframes spinCCW { to { transform: rotate(-360deg); } }
@keyframes corePulse { 0%,100% { r: 4; } 50% { r: 5.5; } }
.header-right { display: flex; align-items: center; gap: 10px; }
.nav-tabs { display: flex; gap: 2px; background: var(--bg-input); border-radius: 10px; padding: 3px; }
.nav-tab {
  padding: 6px 16px; border-radius: 8px; border: none; background: none;
  color: var(--text-3); cursor: pointer; font: 500 13px var(--font);
  transition: all 0.2s ease;
}
.nav-tab:hover { color: var(--text-2); }
.nav-tab.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow); }
.theme-btn {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-3); cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.2s ease; flex-shrink: 0;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.theme-btn svg { width: 16px; height: 16px; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
.gh-link {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  color: var(--text-3); text-decoration: none;
  transition: all 0.2s ease; flex-shrink: 0;
}
.gh-link:hover { color: var(--accent); background: var(--accent-bg); }
.health-indicator {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  text-decoration: none; transition: background 0.2s ease;
}
.health-indicator:hover { background: var(--bg-hover); }
.health-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.health-dot.healthy { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-dot.critical { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* ── Search ── */
.search-row { display: flex; gap: 10px; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; }
.search-box svg.s-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); width: 18px; height: 18px; pointer-events: none;
  transition: color 0.2s;
}
.search-box input:focus ~ svg.s-icon,
.search-box:focus-within svg.s-icon { color: var(--accent); }
.search-box input {
  width: 100%; padding: 12px 70px 12px 42px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text); font: 15px var(--font);
  outline: none; transition: all 0.2s ease;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-box input::placeholder { color: var(--text-3); font-weight: 300; }
.s-actions {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 4px;
}
.s-clear {
  display: none; background: none; border: none;
  color: var(--text-3); cursor: pointer; padding: 3px 5px;
  border-radius: 4px; font-size: 16px; line-height: 1;
}
.s-clear:hover { color: var(--text); }
.s-clear.show { display: block; }
.kbd {
  padding: 2px 7px; border-radius: 5px;
  font: 11px var(--mono); color: var(--text-3);
  background: var(--bg-input); border: 1px solid var(--border);
}
.col-select {
  padding: 0 30px 0 12px; height: 44px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text-2); font: 13px var(--font);
  cursor: pointer; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  transition: border-color 0.2s;
}
.col-select:focus { border-color: var(--accent); }

/* ── Meta ── */
.meta-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.badge { padding: 3px 10px; border-radius: 99px; font: 600 10px var(--mono); letter-spacing: 0.4px; text-transform: uppercase; }
.badge-hybrid { background: var(--accent-bg); color: var(--accent); }
.badge-bm25 { background: var(--yellow-bg); color: var(--yellow); }

/* ── Results ── */
.results { display: flex; flex-direction: column; gap: 6px; }
.result-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px; cursor: pointer;
  transition: all 0.15s ease; animation: fadeIn 0.2s ease both;
}
.result-card:hover { background: var(--bg-hover); border-color: var(--border-hover); transform: translateY(-1px); box-shadow: var(--shadow); }
.result-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.r-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.r-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.r-dot.high { background: var(--green); box-shadow: 0 0 6px var(--green-bg); }
.r-dot.medium { background: var(--yellow); }
.r-dot.low { background: var(--text-3); }
.r-src { font: 500 12px var(--mono); color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.r-tok { font: 11px var(--mono); color: var(--text-3); background: var(--bg-input); padding: 2px 7px; border-radius: 5px; }
.r-score { font: 11px var(--mono); color: var(--text-3); }
.r-sec { font: 11px var(--mono); color: var(--text-3); margin-bottom: 3px; padding-left: 15px; }
.r-sum { font-size: 13px; color: var(--text-2); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-left: 15px; }
.r-sum mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 2px; padding: 0 2px; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: var(--modal-bg); backdrop-filter: blur(8px);
  z-index: 100; justify-content: center; align-items: flex-start;
  padding: 60px 20px; overflow-y: auto;
}
.modal-overlay.open { display: flex; animation: mfade 0.15s ease; }
@keyframes mfade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 720px;
  padding: 28px; position: relative;
  box-shadow: var(--shadow-lg); animation: mslide 0.2s ease;
}
@keyframes mslide { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.m-bar { position: absolute; right: 14px; top: 14px; display: flex; gap: 4px; }
.m-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-3); cursor: pointer;
  padding: 6px 10px; border-radius: 7px;
  font: 12px var(--font); transition: all 0.15s;
  display: flex; align-items: center; gap: 4px;
}
.m-btn:hover { color: var(--text); background: var(--bg-hover); }
.m-btn.copied { color: var(--green); border-color: var(--green); }
.modal h2 { font: 600 15px var(--mono); margin-bottom: 16px; padding-right: 100px; color: var(--accent); word-break: break-all; }
.m-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin-bottom: 16px; padding: 12px 14px;
  background: var(--bg); border-radius: 8px; border: 1px solid var(--border);
}
.m-meta-item .label { font: 400 10px var(--font); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 2px; }
.m-meta-item .value { font: 13px var(--mono); color: var(--text); }
.m-content {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; font: 13px/1.7 var(--mono);
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 450px; overflow-y: auto; tab-size: 4;
}
.m-ctx { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font: 11px var(--mono); color: var(--text-3); display: flex; gap: 20px; }

/* ── Panels ── */
.panel { display: none; }
.panel.active { display: block; }

/* ── Status ── */
.obs-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px 24px; margin-bottom: 18px;
}
.obs-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.obs-title { font: 600 13px var(--font); color: var(--text); }
.obs-status { display: flex; align-items: center; gap: 6px; font: 500 12px var(--font); }
.obs-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.obs-layers { display: flex; gap: 10px; margin-bottom: 16px; }
.obs-layer { flex: 1; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); opacity: 0.45; transition: all 0.2s; }
.obs-layer.on { opacity: 1; border-color: color-mix(in srgb, var(--green) 30%, var(--border)); background: color-mix(in srgb, var(--green) 4%, var(--bg)); }
.obs-layer-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.obs-layer-name { font: 600 12px var(--font); color: var(--text); }
.obs-layer-status { font: 500 10px var(--font); margin-left: auto; }
.obs-layer-desc { font: 11px var(--mono); color: var(--text-3); }
.obs-active { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.obs-label { font: 500 10px var(--font); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.8px; }
.obs-provider { font: 600 14px var(--font); color: var(--accent); }
.obs-model { font: 12px var(--mono); color: var(--text-2); padding: 2px 8px; background: var(--bg); border-radius: 4px; }
.obs-chain { display: flex; gap: 8px; flex-wrap: wrap; }
.obs-prov {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  opacity: 0.4; transition: all 0.2s;
}
.obs-prov.avail { opacity: 0.6; }
.obs-prov.active { opacity: 1; border-color: var(--accent); background: var(--accent-bg); }
.obs-prov-name { font: 500 12px var(--font); color: var(--text); }
.obs-prov-model { font: 10px var(--mono); color: var(--text-3); }
.obs-hint { margin-top: 12px; font: 12px var(--font); color: var(--text-3); padding: 10px 14px; background: color-mix(in srgb, var(--red) 8%, transparent); border-radius: 6px; }
.ver-update { margin-top: 6px; font: 11px var(--mono); color: var(--accent); }
.ver-update code { padding: 2px 6px; background: var(--bg); border-radius: 4px; font-size: 10px; }
.logs-section { margin-top: 18px; }
.log-block { margin-bottom: 12px; }
.log-name { font: 500 11px var(--font); color: var(--text-3); text-transform: capitalize; margin-bottom: 6px; }
.log-pre {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; font: 11px/1.6 var(--mono); color: var(--text-2);
  max-height: 180px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; margin: 0;
}
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px 20px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-hover); }
.stat-card .label { font: 500 10px var(--font); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }
.stat-card .value { font: 700 28px var(--mono); letter-spacing: -1px; color: var(--accent); }
.stat-card .value.small { font-size: 13px; font-weight: 500; letter-spacing: 0; }
.stat-card .value.on { color: var(--green); }
.stat-card .value.off { color: var(--text-3); }
.stat-card .sub { font: 11px var(--mono); color: var(--text-3); margin-top: 4px; }
.s-refresh {
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 16px; padding: 7px 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-3); font: 12px var(--font);
  cursor: pointer; transition: all 0.15s;
}
.s-refresh:hover { color: var(--accent); border-color: var(--accent); }

.chk { display: flex; align-items: center; gap: 6px; font: 13px var(--font); color: var(--text-2); cursor: pointer; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 20px; font: 13px var(--font);
  color: var(--text); box-shadow: var(--shadow-lg);
  z-index: 200; opacity: 0; transition: all 0.3s ease; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Spinner ── */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty ── */
.empty { text-align: center; padding: 52px 20px; color: var(--text-3); font-size: 14px; }
.empty svg { margin-bottom: 12px; opacity: 0.4; }
.empty .hint { margin-top: 12px; font: 12px var(--mono); opacity: 0.35; }

/* ── View Modes ── */
.view-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.view-bar-left { font: 13px var(--font); color: var(--text-3); }
.view-bar-left b { color: var(--text-2); font-weight: 600; }
.view-modes { display: flex; gap: 2px; background: var(--bg-input); border-radius: 8px; padding: 3px; }
.view-mode {
  width: 30px; height: 28px; border: none; border-radius: 6px;
  background: none; color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.view-mode:hover { color: var(--text-2); }
.view-mode.active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow-sm); }
.view-mode svg { width: 15px; height: 15px; }

/* ── Table View ── */
.results-table { width: 100%; border-collapse: collapse; }
.results-table th {
  text-align: left; font: 500 10px var(--font); color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.results-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font: 13px var(--mono); color: var(--text-2); cursor: pointer;
  transition: background 0.1s;
}
.results-table tr:hover td { background: var(--bg-hover); }
.results-table .t-path { color: var(--accent); font-weight: 500; max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results-table .t-num { text-align: right; color: var(--text-3); font-size: 12px; }
.results-table .t-type { font-size: 11px; }

/* ── Grid View ── */
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.grid-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px; cursor: pointer;
  transition: all 0.15s; animation: fadeIn 0.2s ease both;
}
.grid-card:hover { background: var(--bg-hover); border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.grid-card .g-icon { font-size: 20px; margin-bottom: 6px; }
.grid-card .g-name { font: 500 12px var(--mono); color: var(--accent); margin-bottom: 6px; word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.grid-card .g-meta { font: 11px var(--font); color: var(--text-3); }

/* ── Project Cards ── */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.proj-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px 20px; cursor: pointer;
  transition: all 0.15s ease; animation: fadeIn 0.2s ease both;
}
.proj-card:hover { background: var(--bg-hover); border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.proj-name { font: 600 15px var(--mono); color: var(--accent); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.proj-name svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); opacity: 0.7; }
.proj-stats { display: flex; gap: 16px; }
.proj-stat { font: 12px var(--font); color: var(--text-3); }
.proj-stat b { color: var(--text-2); font-weight: 600; }
.proj-overview { margin-bottom: 8px; }
.proj-overview-title { font: 500 12px var(--font); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 10px; }
.proj-total { text-align: center; padding: 16px; margin-bottom: 16px; font: 13px var(--font); color: var(--text-3); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); }
.proj-total b { color: var(--accent); font: 700 20px var(--mono); }

/* ── Memory ── */
.mem-alert { background: color-mix(in srgb, var(--yellow) 10%, var(--bg-card)); border: 1px solid color-mix(in srgb, var(--yellow) 30%, var(--border)); border-radius: 8px; padding: 10px 16px; margin-bottom: 12px; font: 12px/1.6 var(--font); color: var(--text-2); }
.mem-alert code { font: 11px var(--mono); padding: 1px 5px; background: var(--bg); border-radius: 3px; }
.mem-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.mem-search-box { position: relative; flex: 0 1 260px; min-width: 180px; }
.mem-search-box svg.s-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-3); pointer-events: none; transition: color 0.2s;
}
.mem-search-box input:focus ~ svg.s-icon,
.mem-search-box:focus-within svg.s-icon { color: var(--accent); }
.mem-search-box input {
  width: 100%; height: 38px; padding: 0 32px 0 34px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-input); color: var(--text); font: 13px var(--font);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.mem-search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.mem-search-box input::placeholder { color: var(--text-3); font-weight: 300; }
.mem-search-box .s-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.mem-filters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.mem-select { height: 38px; font-size: 12px; min-width: 120px; }
.mem-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.mem-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 16px; }
.mem-stat {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px;
  transition: border-color 0.2s;
}
.mem-stat:hover { border-color: var(--border-hover); }
.mem-stat .label { font: 500 9px var(--font); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 4px; }
.mem-stat .value { font: 700 22px var(--mono); letter-spacing: -0.5px; color: var(--accent); }
.mem-facts { display: flex; flex-direction: column; gap: 4px; }
.fact-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 16px; cursor: pointer; transition: all 0.15s ease;
  animation: fadeIn 0.2s ease both; position: relative;
}
.fact-card:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.fact-card.fact-new { animation: factSlideIn 0.4s ease both; border-color: var(--accent); }
@keyframes factSlideIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.conf-bar { height: 4px; border-radius: 2px; background: var(--bg-input); overflow: hidden; }
.conf-fill { height: 100%; border-radius: 2px; }
.conf-high { background: var(--green); }
.conf-mid { background: var(--yellow); }
.conf-low { background: var(--red); }
.mem-pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 0; }
.mem-pager button {
  padding: 7px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-card); color: var(--text-2); font: 13px var(--font);
  cursor: pointer; transition: all 0.15s;
}
.mem-pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.mem-pager button:disabled { opacity: 0.3; cursor: not-allowed; }
.mem-pager .page-info { font: 12px var(--mono); color: var(--text-3); }

/* ── Time group header ── */
.time-group { font: 600 13px var(--font); color: var(--text-3); padding: 8px 0 4px; margin-top: 8px; border-bottom: 1px solid var(--border); }

/* ── Fact card collapsible ── */
.fact-card { cursor: pointer; }
.fact-row { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.fact-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; opacity: 0.7; }
.fact-title { flex: 1; font: 13px var(--font); color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.fact-links { font: 10px var(--mono); color: var(--accent); flex-shrink: 0; opacity: 0.7; }
.fact-conf-inline { width: 32px; height: 4px; border-radius: 2px; background: var(--bg-input); overflow: hidden; flex-shrink: 0; }
.fact-col { font: 10px var(--mono); color: var(--text-3); flex-shrink: 0; }
.fact-ago { font: 11px var(--mono); color: var(--text-3); flex-shrink: 0; min-width: 36px; text-align: right; }
.fact-detail { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.fact-card.expanded .fact-detail { display: block; }
.fact-card.expanded { border-color: var(--accent); border-left: 3px solid var(--accent); }
.fact-card.expanded .fact-title { white-space: normal; }
.fact-detail-text { font: 13px var(--font); color: var(--text-2); line-height: 1.7; white-space: pre-wrap; word-break: break-word; margin-bottom: 10px; }
.fact-detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.fact-detail-tag { font: 10px var(--mono); color: var(--text-3); background: var(--bg-input); padding: 2px 8px; border-radius: 4px; }
.fact-collapse-btn { font: 11px var(--font); color: var(--text-3); background: none; border: 1px solid var(--border); border-radius: 4px; padding: 3px 10px; cursor: pointer; }
.fact-collapse-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Q Bubble (user prompt in Memory timeline) ── */
.q-bubble {
  background: rgba(56,139,253,0.08); border: 1px solid rgba(56,139,253,0.25); border-left: 3px solid #58a6ff;
  border-radius: var(--r); padding: 12px 16px; animation: fadeIn 0.2s ease both; cursor: pointer;
}
.q-bubble .q-label { font: 600 10px var(--mono); color: #58a6ff; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.q-bubble .q-label svg { width: 12px; height: 12px; }
.q-bubble .q-text { font: 13px var(--font); color: var(--text-1); line-height: 1.6; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.q-bubble.expanded .q-text { -webkit-line-clamp: unset; display: block; }
.q-bubble.expanded { border-color: var(--accent); }
.q-bubble .q-time { font: 10px var(--mono); color: var(--text-3); margin-top: 6px; }

/* ── Observation Cards (#241) ── */
.obs-card {
  background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--green);
  border-radius: var(--r); padding: 12px 16px; cursor: pointer;
  transition: all 0.15s ease; animation: fadeIn 0.2s ease both;
}
.obs-card:hover { background: var(--bg-hover); border-color: var(--border-hover); border-left-color: var(--green); }
.obs-card.expanded { border-color: var(--green); }
.obs-header { display: flex; align-items: center; gap: 8px; }
.obs-icon { font-size: 14px; flex-shrink: 0; }
.obs-title { flex: 1; font: 600 13px var(--font); color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obs-meta { font: 10px var(--mono); color: var(--text-3); flex-shrink: 0; white-space: nowrap; }
.obs-narrative { font: 12px var(--font); color: var(--text-2); line-height: 1.6; margin-top: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.obs-card.expanded .obs-narrative { -webkit-line-clamp: unset; display: block; }
.obs-facts { margin-top: 8px; display: none; }
.obs-card.expanded .obs-facts { display: block; }
.obs-fact-item { font: 12px var(--font); color: var(--text-2); padding: 3px 0; display: flex; align-items: baseline; gap: 6px; }
.obs-fact-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; margin-top: 5px; }

/* ── Events ── */
.evt-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 16px; transition: all 0.15s ease;
  animation: fadeIn 0.2s ease both; position: relative;
}
.evt-card:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.evt-card.evt-new { animation: factSlideIn 0.4s ease both; border-color: var(--accent); }
.evt-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.evt-tool {
  padding: 2px 8px; border-radius: 5px; font: 600 11px var(--mono);
  letter-spacing: 0.3px; background: var(--accent-bg); color: var(--accent); flex-shrink: 0;
}
.evt-tool.t-bash { background: var(--green-bg); color: var(--green); }
.evt-tool.t-edit { background: var(--yellow-bg); color: var(--yellow); }
.evt-tool.t-write { background: rgba(188,140,255,0.1); color: #bc8cff; }
.evt-tool.t-user { background: rgba(56,139,253,0.15); color: #58a6ff; font-weight: 700; }
.evt-card.evt-prompt { border-left: 3px solid #58a6ff; }
.evt-tool.t-read { background: var(--bg-input); color: var(--text-3); }
.evt-tool.t-grep { background: var(--bg-input); color: var(--text-3); }
.evt-tool.t-glob { background: var(--bg-input); color: var(--text-3); }
.evt-importance {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.evt-importance.imp-high { background: var(--red); box-shadow: 0 0 6px rgba(248,81,73,0.3); }
.evt-importance.imp-mid { background: var(--yellow); }
.evt-importance.imp-low { background: var(--text-3); opacity: 0.4; }
.evt-time { font: 11px var(--mono); color: var(--text-3); margin-left: auto; flex-shrink: 0; }
.evt-summary { font: 13px var(--font); color: var(--text-2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.evt-collection { font: 10px var(--mono); color: var(--text-3); background: var(--bg-input); padding: 1px 6px; border-radius: 4px; }


/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .app { padding: 20px 16px; }
  .header { flex-wrap: wrap; gap: 12px; }
  .search-row { flex-direction: column; }
  .col-select { min-width: auto; height: 40px; }
  .stat-card .value { font-size: 22px; }
  .modal { padding: 20px; }
  .kbd { display: none; }
}
