/* panel-memory-view.css — Memory, a view in the column (panel-memory-view.js).
   Built from Search's parts and nothing new where Search already has one: the
   .search-view shell and head, the .find-box, .find-note and .find-list, and
   rows drawn as .find-row draws them (no ground until hover, a glyph, the name,
   a quiet line under it, a mono meta at the right). Theme tokens only. */

/* ---- the rail row, under Bibliography ----
   A .new-thread like its siblings; the 14px that closed the run under
   Bibliography now closes it under this row. */
.new-thread.bib-btn { margin-bottom: 0; }
.new-thread.mem-btn { margin-top: 0; }
.mem-btn:focus-visible {
  outline: 1px solid rgba(var(--rim-rgb), .6); outline-offset: 2px; border-radius: var(--r-ctl);
}

/* ---- the view: what it covers is hidden as well as covered, as for Search ---- */
.main.px-memory-open > :not(#memoryView) { visibility: hidden; }
.mem-list-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mem-list-view[hidden] { display: none; }

/* Tabs and New memory, between the box and the list: the rail's register. */
.mem-bar {
  flex-shrink: 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: 16px;
  margin: 0 16px 6px;
}
.mem-tabs { display: flex; gap: 16px; min-width: 0; }
.mem-tab, .mem-new { white-space: nowrap; }
.mem-tab {
  padding: 8px 0 7px;
  background: none; border: none; border-bottom: 1px solid transparent; border-radius: 0;
  font: 400 var(--fs-2xs)/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  /* A control, so the readable grey, not the labels' faint one. */
  color: var(--t-secondary);
  cursor: pointer;
}
.mem-tab:hover { color: var(--bone); }
.mem-tab[aria-selected="true"], .mem-tab[aria-pressed="true"] { color: var(--bone); border-bottom-color: var(--t-secondary); }
.mem-tab:focus-visible { outline: 1px solid var(--rim); outline-offset: 3px; border-radius: 2px; }
.mem-tab[hidden] { display: none; }

.mem-new {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
  background: none; border: none;
  font: 400 var(--fs-2xs)/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--t-strong);
  cursor: pointer;
}
.mem-new svg { width: 12px; height: 12px; stroke: currentColor; }
.mem-new:hover { color: var(--bone); }
.mem-new:focus-visible { outline: 1px solid var(--rim); outline-offset: 3px; border-radius: 2px; }
.mem-new[hidden] { display: none; }

.mem-files[hidden] { display: none; }

/* ---- files, by category: rows as .find-row draws them ---- */
#memoryView .set-memory { margin-top: 0; }
#memoryView .set-mem-category { margin-top: 10px; }
#memoryView .set-mem-category[hidden], #memoryView .set-mem-row[hidden] { display: none; }
#memoryView .set-mem-heading {
  margin: 0; padding: 4px 8px 6px;
  font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--t-faint);
}
#memoryView .set-mem-row { margin: 0 0 2px; border-radius: var(--r-md); }
#memoryView .set-mem-file {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  column-gap: 10px; row-gap: 3px;
  align-items: start;
  /* A rail row's shape; its glass is the focused row's (glass-surface.css). */
  padding: 9px 40px 9px 8px;
  border-radius: var(--r-md);
  color: var(--t-secondary);
}
/* The glyph: a page, drawn as the rail draws its icons (a mask, so it takes the text colour). */
#memoryView .set-mem-file::before {
  content: "";
  grid-row: 1; grid-column: 1;
  width: 13px; height: 13px; margin-top: 4px;
  background: currentColor;
  opacity: .55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E") center / contain no-repeat;
}
#memoryView .set-mem-row:hover .set-mem-file, #memoryView .set-mem-file:focus-visible {
  background: var(--s-quiet); color: var(--t-primary);
}
#memoryView .set-mem-filename { grid-row: 1; grid-column: 2; font: 400 var(--fs-body)/1.3 var(--serif); color: var(--t-primary); }
#memoryView .set-mem-description { grid-row: 2; grid-column: 2 / -1; font: 400 var(--fs-md)/1.5 var(--sans); color: var(--t-faint); }
#memoryView .set-mem-date {
  grid-row: 1; grid-column: 3; padding-top: 4px;
  font: 400 var(--fs-2xs)/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--t-faint);
}
#memoryView .set-mem-delete { top: 6px; right: 6px; }

/* The review's suggestion: a card, as the find box is. */
#memoryView .set-mem-suggest { margin: 2px 8px 10px; background: var(--s-card); box-shadow: var(--lit-card); border-radius: var(--r-card); }
#memoryView .set-mem-suggest h3 { font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--t-faint); }

/* ---- a file, open over the list ---- */
.set-file.mem-file { flex: 1 1 0; min-height: 0; padding: 0 16px 14px; gap: 10px; }
.mem-file .set-file-head { flex-wrap: wrap; row-gap: 6px; padding-bottom: 12px; }
.mem-back {
  flex-shrink: 0;
  padding: 6px 0;
  background: none; border: none;
  font: 400 var(--fs-2xs)/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--t-secondary);
  cursor: pointer;
}
.mem-back:hover { color: var(--bone); }
.mem-back:focus-visible { outline: 1px solid var(--rim); outline-offset: 3px; border-radius: 2px; }
/* The file's name is its title, set as a chat's is. */
.mem-file .set-file-path { flex-basis: 100%; order: 3; font: 400 var(--fs-2xl)/1.3 var(--serif); color: var(--bone); min-width: 0; }
.mem-file #setDocDownload { margin-left: auto; }
.mem-file .set-file-toolbar { gap: 18px; }
.mem-file .set-file-foot { flex-wrap: wrap; row-gap: 6px; }

/* ---- Connections, the other tab: the map on top, the list below ----
   A slim row of controls, then the map and the list sharing what is left,
   half each. The body stops scrolling as one; the list scrolls on its own. */
#memoryView.is-connections #memBody { overflow: hidden; display: flex; flex-direction: column; padding-bottom: 0; }
#memoryView.is-connections #setMemoryGraphHost:not([hidden]) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 0; }

#memoryView .set-mgraph-tools {
  flex-shrink: 0;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 0 8px;
}
#memoryView .set-mgraph-tools [hidden] { display: none; }
/* The parts of you, as tabs over the map: one line, scrolling sideways if
   there are many, never wrapping into the map. */
#memoryView .set-mgraph-segments {
  flex-shrink: 0;
  display: flex; gap: 16px; align-items: center;
  margin: 0 16px; padding-bottom: 2px;
  overflow-x: auto; scrollbar-width: none;
}
#memoryView .set-mgraph-segments::-webkit-scrollbar { display: none; }
#memoryView .set-mgraph-seg { flex-shrink: 0; }
#memoryView .set-mgraph-segcount { color: var(--t-faint); }

/* Where you are, and the way back up: You › Projects › the chosen line. */
#memoryView .set-mgraph-crumbs {
  position: absolute; top: 8px; left: 8px; z-index: 4; max-width: calc(100% - 140px);
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--t-faint);
  white-space: nowrap; overflow: hidden;
}
#memoryView .set-mgraph-crumb { padding: 4px 2px; background: none; border: none; font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--t-secondary); cursor: pointer; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#memoryView button.set-mgraph-crumb:hover { color: var(--bone); }
#memoryView button.set-mgraph-crumb:focus-visible { outline: 1px solid var(--rim); outline-offset: 2px; border-radius: 2px; }
#memoryView span.set-mgraph-crumb { color: var(--t-primary); cursor: default; }
#memoryView .set-mgraph-crumbsep { color: var(--t-faint); }

/* Zoom: in, out and fit, in the map's bottom-right corner. */
#memoryView .set-mgraph-zoom { position: absolute; right: 8px; bottom: 8px; z-index: 4; display: flex; gap: 4px; }
#memoryView .set-mgraph-zoom .px-btn { height: 26px; min-height: 0; min-width: 26px; padding: 0 8px; }
#memoryView .set-mgraph-stage:has(> .set-mgraph-details.is-sheet:not([hidden])) > .set-mgraph-zoom { display: none; }

/* Back to the whole map: a small button in the map's top-right corner, only while something is chosen. */
#memoryView .set-mgraph-all { position: absolute; top: 8px; right: 8px; z-index: 4; height: 26px; min-height: 0; padding: 0 10px; }
#memoryView .set-mgraph-all[hidden] { display: none; }
#memoryView .set-mgraph-stage > .set-mgraph-details:not([hidden]):not(.is-sheet) ~ .set-mgraph-all,
#memoryView .set-mgraph-stage:has(> .set-mgraph-details:not([hidden]):not(.is-sheet)) > .set-mgraph-all { right: calc(min(300px, 44%) + 16px); }

#memoryView .set-mgraph-stage {
  position: relative;
  flex: 1 1 0;
  min-height: 180px;
  margin: 0 8px;
  /* No card and no glass (2026-11-13, by request): the map sits on the
     view's own ground, as Obsidian's graph does; a hairline marks where the
     list begins. */
  border-bottom: 1px solid var(--hair);
  overflow: hidden;
}
#memoryView .set-mgraph-canvas { position: absolute; inset: 0; height: auto; border: none; border-radius: inherit; background: none; box-shadow: none; }
/* Soft edges (2026-11-13, by request): the map fades out over its last 28 px
   on every side instead of cutting off hard. */
#memoryView .set-mgraph-canvas {
  -webkit-mask-image: linear-gradient(to right, transparent, black 28px, black calc(100% - 28px), transparent),
                      linear-gradient(to bottom, transparent, black 28px, black calc(100% - 28px), transparent);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to right, transparent, black 28px, black calc(100% - 28px), transparent),
                      linear-gradient(to bottom, transparent, black 28px, black calc(100% - 28px), transparent);
          mask-composite: intersect;
}
#memoryView .set-mgraph-canvas:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--rim); }

/* What the canvas says, on its bottom edge. */
#memoryView .set-mgraph-live {
  position: absolute; left: 12px; bottom: 8px; right: 12px; z-index: 1;
  min-height: 0; padding: 0;
  font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--t-faint);
  pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* The chosen thing's details: docked over the map's right side when the map
   is wide (pxMGraphDockDetails moves it), else a card atop the list. */
#memoryView .set-mgraph-details {
  padding: 12px 14px;
  border: none; border-radius: var(--r-card);
  background: var(--ink); box-shadow: var(--lit-card);
}
#memoryView .set-mgraph-details[hidden] { display: none; }
#memoryView .set-mgraph-stage > .set-mgraph-details {
  position: absolute; z-index: 3; top: 8px; right: 8px; bottom: 8px; width: min(300px, 44%);
  overflow-y: auto; overscroll-behavior: contain;
}
#memoryView .set-mgraph-stage:has(> .set-mgraph-details:not([hidden]):not(.is-sheet)) > .set-mgraph-live { right: calc(min(300px, 44%) + 20px); }
/* Narrow: a sheet along the bottom, short enough to leave the map its top. */
#memoryView .set-mgraph-stage > .set-mgraph-details.is-sheet { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 70%; padding: 10px 14px; }
#memoryView .set-mgraph-details.is-sheet:not(.is-open) { max-height: 84px; overflow: hidden; }
#memoryView .set-mgraph-details.is-sheet:not(.is-open) .set-mgraph-dtitle { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 0; }
#memoryView .set-mgraph-details.is-sheet:not(.is-open) > :not(.set-mgraph-dhead):not(.set-mgraph-dtitle) { display: none; }
#memoryView .set-mgraph-more-toggle { display: none; padding: 4px 0; }
#memoryView .set-mgraph-details.is-sheet .set-mgraph-more-toggle { display: inline-block; }
#memoryView .set-mgraph-dbtns { display: inline-flex; align-items: center; gap: 12px; }
#memoryView .set-mgraph-stage:has(> .set-mgraph-details.is-sheet:not([hidden])) > .set-mgraph-live { display: none; }
#memoryView .set-mgraph-dhead {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--t-faint);
}
#memoryView .set-mgraph-dclose { margin: -4px -6px -4px 0; }
#memoryView .set-mgraph-dtitle { font: 400 var(--fs-xl)/1.35 var(--sans); color: var(--bone); }
#memoryView blockquote.set-mgraph-dtitle { border-left: none; padding-left: 0; margin: 6px 0 8px; }

/* The lower half: what the map holds, as rows, scrolling. */
#memoryView .set-mgraph-lower { flex: 1 1 0; min-height: 140px; overflow-y: auto; overscroll-behavior: contain; padding: var(--scroll-pad) 10px; }
#memoryView .set-mgraph-lowerhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
#memoryView .set-mgraph-status { padding: 0 8px 4px; }
#memoryView .set-mgraph-legend { display: flex; gap: 12px; padding: 0 8px 4px; font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--t-faint); }
#memoryView .set-mgraph-legend span { display: inline-flex; align-items: center; gap: 5px; }
#memoryView .set-mgraph-legend span::before { content: ""; width: 8px; height: 8px; border: 1.4px solid var(--t-secondary); box-sizing: border-box; }
#memoryView .set-mgraph-legend [data-kind="fact"]::before { width: 10px; height: 5px; border-radius: 2px; background: var(--t-strong); border: none; }
#memoryView .set-mgraph-legend [data-kind="entity"]::before { border-radius: 50%; border-color: var(--bone); }
#memoryView .set-mgraph-legend [data-kind="source"]::before { transform: rotate(45deg); width: 7px; height: 7px; background: var(--rim); border: none; }
#memoryView .set-mgraph-legend [data-kind="file"]::before { width: 7px; height: 9px; }
@media (max-width: 420px) { #memoryView .set-mgraph-legend { display: none; } }

#memoryView .set-mgraph-list { max-height: none; padding: 0; border: none; background: none; }
#memoryView .set-mgraph-group { padding: 10px 8px 6px; font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .16em; color: var(--t-faint); }
/* A rail row's shape and type; the chosen row wears the rail's glass
   (glass-surface.css), the others a quiet wash on hover. */
#memoryView .set-mgraph-row { padding: 9px 8px; margin: 0 0 2px; border-radius: var(--r-md); font: 400 var(--fs-body)/1.3 var(--sans); color: var(--t-secondary); align-items: center; }
#memoryView .set-mgraph-row:hover { background: var(--s-quiet); color: var(--t-primary); }
#memoryView .set-mgraph-row[aria-selected="true"] { color: var(--t-primary); }
#memoryView .set-mgraph-row .set-mgraph-kind { align-self: center; }
/* Keyboard position in the list: an outline inside the row, so the scroller can't clip it. */
#memoryView .set-mgraph-list:focus .set-mgraph-row.is-active { box-shadow: inset 0 0 0 1px var(--rim); }
#memoryView .set-mgraph-list:not(:focus) .set-mgraph-row.is-active { box-shadow: none; }
#memoryView .set-mgraph-meta { font: 400 var(--fs-2xs)/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; }
#memoryView .set-mem-suggest-actions { flex-wrap: wrap; }
/* The canvas's spoken line leaves room for the zoom buttons; both step left of a docked card. */
#memoryView .set-mgraph-live { right: 112px; }
#memoryView .set-mgraph-stage:has(> .set-mgraph-details:not([hidden]):not(.is-sheet)) > .set-mgraph-zoom { right: calc(min(300px, 44%) + 16px); }
/* With the card docked on the right, the way back stops short of Whole map. */
#memoryView .set-mgraph-stage:has(> .set-mgraph-details:not([hidden]):not(.is-sheet)) > .set-mgraph-crumbs { max-width: calc(100% - min(300px, 44%) - 130px); }
/* The nightly tidy-up (panel-memory-tidy.js, memory step 4): a card like the
   suggestions, after the files. */
#memoryView .set-mem-tidy { margin: 12px 8px 10px; background: var(--s-card); box-shadow: var(--lit-card); border-radius: var(--r-card); }
#memoryView .set-mem-tidy h3 { font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--t-faint); }

/* ---- ask for a change: a dock under the list ----
   Top to bottom: a fade (the list runs out into the view's ground), one line of
   what the server is doing or did, then the bar. The field is the search box
   (.find-box, glass `field`) at the composer's height; Send is the prompt bar's
   own .send tile, blue once it is .armed. */
.mem-ask-dock { position: relative; flex-shrink: 0; background: var(--ink); }
.mem-ask-dock::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 44px;
  background: linear-gradient(to bottom, transparent, var(--ink)); pointer-events: none;
}
.mem-ask-status {
  margin: 0 16px; padding: 6px 4px 2px;
  font: 400 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--t-secondary);
}
.mem-ask-status[hidden] { display: none; }
.mem-ask-status.is-busy { animation: mem-ask-pulse 1.6s ease-in-out infinite; }
@keyframes mem-ask-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .mem-ask-status.is-busy { animation: none; } }
.mem-ask-undo {
  padding: 0; background: none; border: none; cursor: pointer;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--bone); text-decoration: underline; text-underline-offset: 3px;
}
.mem-ask-undo:disabled { opacity: .5; cursor: default; }
.mem-ask-undo:focus-visible { outline: 1px solid var(--rim); outline-offset: 3px; border-radius: 2px; }
.mem-ask { margin: 0; padding: 8px 16px 14px; }
.mem-ask-field { margin: 0; min-height: 46px; padding: 0 8px 0 16px; }
.mem-ask .find-input { padding: 10px 0; }
.mem-ask .send:disabled { cursor: default; }
.mem-view.is-connections .mem-ask-dock { display: none; }

/* Whose memory (D70): the scope filter, beside New memory. */
.mem-scope { margin-left: auto; margin-right: 8px; max-width: 46%; }
.mem-scope[hidden] { display: none; }
