.memory-page {
  display: grid;
  gap: 12px;
}

.memory-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px;
}

.memory-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto minmax(140px, 1fr);
  gap: 10px;
  align-items: end;
}

.memory-query-wrap {
  display: grid;
  gap: 6px;
}

.memory-query-wrap span,
.memory-inline-select span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.memory-query-wrap input,
.memory-inline-select select,
.memory-inline-select input {
  min-height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 6px 8px;
}

.memory-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  min-height: 34px;
}

.memory-status {
  color: var(--muted2);
  font-size: 12px;
  text-align: right;
}

.memory-health {
  font-size: 12px;
  color: var(--muted);
}

.memory-health.error {
  color: #f1adad;
}

.memory-tabs {
  display: flex;
  gap: 8px;
}

.memory-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(420px, 2fr) minmax(280px, 1fr);
  gap: 12px;
  min-height: 560px;
}

.memory-results-panel,
.memory-center-panel,
.memory-detail-panel {
  display: grid;
  gap: 10px;
  min-height: 0;
}

.memory-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.memory-panel-head h3 {
  margin: 0;
}

.memory-inline-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.memory-inline-select select {
  min-width: 110px;
}

.memory-inline-select input[type="range"] {
  min-width: 110px;
  padding: 0;
}

.memory-inline-select strong {
  font-size: 12px;
  color: var(--text);
  min-width: 28px;
  text-align: right;
}

.memory-meta {
  color: var(--muted2);
  font-size: 12px;
}

.memory-results {
  display: grid;
  gap: 8px;
  overflow: auto;
  max-height: 68vh;
  padding-right: 2px;
}

.memory-result {
  border: 1px solid rgba(53, 64, 88, 0.85);
  border-radius: 10px;
  background: rgba(18, 27, 40, 0.76);
  padding: 9px;
  display: grid;
  gap: 8px;
  cursor: pointer;
}

.memory-result:hover {
  border-color: rgba(107, 124, 255, 0.55);
}

.memory-result.is-selected {
  border-color: rgba(107, 124, 255, 0.76);
  box-shadow: 0 0 0 1px rgba(107, 124, 255, 0.2) inset;
}

.memory-result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.memory-result-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-result-meta {
  font-size: 11px;
  color: var(--muted2);
}

.memory-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.memory-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid rgba(51, 63, 88, 0.9);
  background: rgba(23, 31, 44, 0.8);
  color: var(--muted);
}

.memory-badge.is-score {
  color: #bfd2ff;
  border-color: rgba(85, 117, 190, 0.6);
}

.memory-badge.is-pinned {
  color: #c9f3d7;
  border-color: rgba(84, 162, 115, 0.7);
}

.memory-badge.is-hidden {
  color: #f2b1b1;
  border-color: rgba(196, 85, 85, 0.66);
}

.memory-result-snippet {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.35;
}

.memory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.memory-actions .btn {
  padding: 4px 10px;
  font-size: 11px;
}

.memory-view {
  display: grid;
  gap: 10px;
  min-height: 100%;
}

.memory-view.is-hidden {
  display: none;
}

.memory-empty-state {
  border: 1px dashed rgba(56, 68, 92, 0.9);
  border-radius: 12px;
  padding: 18px;
  color: var(--muted);
  min-height: 320px;
}

.memory-empty-state h3 {
  margin: 0 0 8px 0;
  color: var(--text);
}

.memory-map-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.memory-map-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.memory-insight-card {
  border: 1px solid rgba(50, 65, 95, 0.85);
  border-radius: 10px;
  background: rgba(16, 24, 37, 0.78);
  padding: 8px;
  display: grid;
  gap: 8px;
}

.memory-insight-card h4 {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.memory-insight-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.memory-insight-chip {
  border: 1px solid rgba(67, 90, 141, 0.75);
  border-radius: 999px;
  background: rgba(25, 38, 59, 0.85);
  color: #dbe8ff;
  padding: 3px 8px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.memory-insight-chip span {
  color: #9db8f4;
  font-weight: 600;
}

.memory-graph-evidence {
  border: 1px solid rgba(48, 61, 86, 0.9);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(16, 25, 39, 0.84), rgba(10, 16, 26, 0.95));
  padding: 10px;
  display: grid;
  gap: 8px;
}

.memory-edge-detail {
  display: grid;
  gap: 8px;
}

.memory-edge-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.memory-edge-row span {
  color: var(--muted2);
}

.memory-edge-evidence-list {
  display: grid;
  gap: 6px;
}

.memory-edge-evidence {
  border: 1px solid rgba(53, 64, 88, 0.8);
  border-radius: 10px;
  background: rgba(18, 25, 37, 0.74);
  padding: 8px;
}

.memory-edge-evidence p {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.memory-edge-list {
  display: grid;
  gap: 6px;
}

.memory-edge-link {
  border: 1px solid rgba(53, 64, 88, 0.8);
  border-radius: 10px;
  background: rgba(18, 25, 37, 0.74);
  color: var(--text);
  text-align: left;
  padding: 8px;
  font-size: 12px;
  display: grid;
  gap: 3px;
}

.memory-edge-link span {
  color: var(--muted2);
  font-size: 11px;
}

.memory-decision-list {
  display: grid;
  gap: 8px;
}

.memory-decision-section {
  border: 1px solid rgba(53, 64, 88, 0.75);
  border-radius: 10px;
  background: rgba(16, 24, 35, 0.72);
  padding: 8px;
  display: grid;
  gap: 7px;
}

.memory-decision-section h4 {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.memory-decision-rows {
  display: grid;
  gap: 6px;
}

.memory-decision-item {
  border: 1px solid rgba(54, 76, 119, 0.78);
  border-radius: 10px;
  background: rgba(20, 32, 51, 0.8);
  color: var(--text);
  text-align: left;
  padding: 7px 8px;
  display: grid;
  gap: 3px;
  font-size: 12px;
}

.memory-decision-item strong {
  font-weight: 650;
}

.memory-decision-item span {
  color: var(--muted2);
  font-size: 11px;
}

.memory-decision-item.is-active {
  border-color: rgba(132, 162, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(109, 142, 244, 0.35) inset;
}

.memory-graph-wrap {
  border: 1px solid rgba(48, 61, 86, 0.9);
  border-radius: 12px;
  background: radial-gradient(circle at 20% 10%, rgba(45, 67, 106, 0.27), rgba(11, 16, 26, 0.95));
  min-height: 420px;
  overflow: hidden;
}

#memory-graph {
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: block;
}

.memory-node {
  cursor: pointer;
}

.memory-node circle {
  stroke: rgba(187, 201, 228, 0.55);
  stroke-width: 1;
}

.memory-node text {
  fill: #dde6f8;
  font-size: 11px;
  paint-order: stroke;
  stroke: rgba(8, 14, 25, 0.75);
  stroke-width: 3px;
  pointer-events: none;
}

.memory-node.is-active circle {
  stroke: rgba(132, 162, 255, 0.95);
  stroke-width: 2;
  filter: drop-shadow(0 0 7px rgba(118, 151, 255, 0.45));
}

.memory-edge {
  stroke: rgba(111, 128, 160, 0.45);
  stroke-width: 1;
}

.memory-edge:hover {
  stroke: rgba(161, 182, 232, 0.9);
}

.memory-edge.is-active {
  stroke: rgba(221, 233, 255, 0.98);
  stroke-width: 3.2;
  filter: drop-shadow(0 0 6px rgba(140, 171, 246, 0.52));
}

.memory-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12px, 1fr));
  gap: 6px;
  align-items: end;
  min-height: 280px;
  padding: 14px;
  border: 1px solid rgba(48, 61, 86, 0.9);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(24, 35, 56, 0.62), rgba(10, 16, 26, 0.92));
}

.memory-timeline-bar {
  border: 1px solid rgba(84, 108, 154, 0.8);
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, rgba(129, 156, 255, 0.8), rgba(76, 105, 191, 0.9));
  cursor: pointer;
  min-height: 10px;
  transition: transform 120ms ease, filter 120ms ease;
}

.memory-timeline-bar:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.memory-timeline-bar.is-selected {
  border-color: rgba(196, 221, 255, 0.95);
  filter: brightness(1.15);
}

.memory-detail {
  display: grid;
  gap: 10px;
  overflow: auto;
  max-height: 68vh;
}

.memory-detail-title {
  margin: 0;
  font-size: 16px;
}

.memory-detail-pre {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(53, 64, 88, 0.8);
  background: rgba(18, 25, 37, 0.74);
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.4;
}

.memory-detail-list {
  display: grid;
  gap: 6px;
}

.memory-related-item {
  border: 1px solid rgba(53, 64, 88, 0.8);
  border-radius: 10px;
  background: rgba(16, 24, 35, 0.72);
  padding: 8px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .memory-grid {
    grid-template-columns: 1fr;
  }

  .memory-results,
  .memory-detail {
    max-height: none;
  }
}

:root[data-ui-shell="v2"][data-form-factor="phone"] .memory-toolbar {
  grid-template-columns: 1fr;
  align-items: stretch;
}

:root[data-ui-shell="v2"][data-form-factor="phone"] .memory-status {
  text-align: left;
}

:root[data-ui-shell="v2"][data-form-factor="phone"] .memory-map-controls,
:root[data-ui-shell="v2"][data-form-factor="phone"] .memory-inline-select {
  width: 100%;
}

:root[data-ui-shell="v2"][data-form-factor="phone"] .memory-inline-select {
  justify-content: space-between;
}

:root[data-ui-shell="v2"][data-form-factor="phone"] .memory-inline-select input[type="range"] {
  flex: 1;
  min-width: 0;
}

:root[data-ui-shell="v2"][data-form-factor="phone"] .memory-timeline {
  grid-template-columns: repeat(auto-fit, minmax(14px, 1fr));
  min-height: 220px;
  padding: 10px;
}

:root[data-ui-shell="v2"][data-form-factor="phone"] .memory-map-insights {
  grid-template-columns: 1fr;
}

:root[data-ui-skin="neo"] .memory-card,
:root[data-ui-skin="neo"] .memory-result,
:root[data-ui-skin="neo"] .memory-map,
:root[data-ui-skin="neo"] .memory-timeline,
:root[data-ui-skin="neo"] .memory-graph-wrap {
  background: linear-gradient(180deg, rgba(17, 31, 50, 0.9), rgba(7, 14, 26, 0.86));
  border-color: rgba(126, 176, 255, 0.18);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255,255,255,0.06);
}

:root[data-ui-skin="neo"] .memory-result.is-selected,
:root[data-ui-skin="neo"] .memory-result:hover {
  border-color: rgba(121, 246, 255, 0.44);
  box-shadow: 0 0 26px rgba(88, 231, 255, 0.12), inset 0 0 0 1px rgba(121, 246, 255, 0.18);
}
