/* Memory Tools — web interface */

:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f9;
  --border: #e4e7f0;
  --border-strong: #cbd2e0;
  --text: #0f172a;
  --muted: #5b6478;
  --muted-2: #8a93a6;
  --accent: #5b5bd6;
  --accent-hover: #4a4ac4;
  --accent-soft: #eef0ff;
  --accent-soft-2: #dfe3ff;
  --teal: #0f9d8a;
  --teal-soft: #e6faf6;
  --amber: #b45309;
  --amber-soft: #fff7e6;
  --violet: #7c3aed;
  --violet-soft: #f3ecff;
  --success: #0f9d58;
  --success-soft: #e9f9f0;
  --danger: #d93025;
  --danger-soft: #fdecea;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 22px 50px -30px rgba(15, 23, 42, 0.32);
  --radius: 18px;
  --radius-md: 13px;
  --radius-sm: 9px;
  --topbar-height: 70px;
  --ring: 0 0 0 4px rgba(91, 91, 214, 0.16);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.22; letter-spacing: -0.018em; }
h1 { font-size: 1.95rem; font-weight: 750; }
h2 { font-size: 1.08rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 700; }

p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

code {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.84em;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.08em 0.35em;
  overflow-wrap: anywhere;
}

pre {
  margin: 10px 0;
  padding: 12px 14px;
  background: #111827;
  color: #e5e7eb;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.55;
}
pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.05em 0.45em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.76em;
  text-align: center;
}

.muted-note { color: var(--muted-2); font-size: 0.86rem; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 2px 0; width: 100%; }

/* --------------------------------------------------------------- skip link */
.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
}
.skip-link:focus { left: 16px; }

/* ----------------------------------------------------------------- top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand strong { font-weight: 750; color: var(--accent); }

.brand-badge {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent-soft), var(--teal-soft));
  color: var(--accent);
  flex: 0 0 auto;
}
.brand-badge svg { width: 22px; height: 22px; }

.nav { display: flex; align-items: center; gap: 3px; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 10px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-link:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.nav-link.is-active { color: var(--accent); background: var(--accent-soft); }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; }

.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
  flex: 0 0 auto;
}

.badge {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 8px;
}
.badge-admin { color: var(--accent); background: var(--accent-soft); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1;
  border-radius: 10px;
  padding: 11px 17px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.06s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.btn-sm { padding: 8px 12px; font-size: 0.82rem; border-radius: 8px; }
.btn-block { width: 100%; }

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 3px 0;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.link-button:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
.link-arrow { transition: transform 0.15s ease; }
.link-button:hover .link-arrow { transform: translateX(2px); }

/* -------------------------------------------------------------------- page */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 36px;
  color: var(--muted-2);
  font-size: 0.78rem;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.footer a { color: var(--muted); font-weight: 600; }
.footer-dot { opacity: 0.6; }
.footer-spacer { flex: 1; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.page-head { margin-bottom: 22px; }
.page-sub { margin: 8px 0 0; color: var(--muted); max-width: 760px; }

/* -------------------------------------------------------------------- hero */
.hero {
  position: relative;
  overflow: hidden;
  padding: 36px 38px 30px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #ffffff 0%, #f4f2ff 52%, #edf9ff 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -110px;
  top: -120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 91, 214, 0.13), transparent 68%);
  pointer-events: none;
}
.hero-copy { position: relative; z-index: 1; max-width: 780px; }
.hero h1 { margin: 2px 0 10px; font-size: clamp(2rem, 4vw, 2.85rem); letter-spacing: -0.035em; }
.hero-sub { margin: 0; color: var(--muted); font-size: 1.02rem; max-width: 660px; }

.search-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 880px;
  margin-top: 22px;
  padding: 8px 8px 8px 46px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px -18px rgba(15, 23, 42, 0.35);
}
.search-bar:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search-icon {
  position: absolute;
  left: 16px;
  width: 19px;
  height: 19px;
  color: var(--muted-2);
  pointer-events: none;
}
.search-bar input[type="search"] {
  flex: 1;
  min-width: 0;
  width: auto;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  color: var(--text);
  padding: 9px 0;
  box-shadow: none;
}
.search-bar input[type="search"]:focus { box-shadow: none; }
.search-bar input::placeholder { color: var(--muted-2); }
.search-bar input::-webkit-search-cancel-button { display: none; }

.example-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
}
.example-label { color: var(--muted-2); font-size: 0.78rem; font-weight: 650; }
.example-chip {
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.example-chip:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-soft-2); }
.example-chip:focus-visible { outline: none; box-shadow: var(--ring); }

/* ------------------------------------------------------------- guide strip */
.guide-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.guide-step {
  display: flex;
  gap: 12px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.step-number {
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 750;
}
.guide-step h2 { font-size: 0.93rem; margin-bottom: 2px; }
.guide-step p { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.guide-link {
  grid-column: 1 / -1;
  justify-self: start;
  font-size: 0.84rem;
  font-weight: 650;
}
.guide-strip-compact { margin-bottom: 18px; }
.guide-strip-compact .guide-step { padding: 13px 15px; }

/* ------------------------------------------------------------------- stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  column-gap: 12px;
  row-gap: 1px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  grid-row: 1 / 4;
  align-self: start;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}
.stat-icon svg { width: 21px; height: 21px; }
.stat-icon-indigo { background: var(--accent-soft); color: var(--accent); }
.stat-icon-teal { background: var(--teal-soft); color: var(--teal); }
.stat-icon-amber { background: var(--amber-soft); color: var(--amber); }
.stat-icon-violet { background: var(--violet-soft); color: var(--violet); }

.stat-label {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.035em; line-height: 1.15; }
.stat-hint { color: var(--muted-2); font-size: 0.75rem; }

/* --------------------------------------------------------------- home grid */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 1.04rem; }
.panel-meta { color: var(--muted-2); font-size: 0.79rem; }

.side-column { display: flex; flex-direction: column; gap: 16px; }
.side-panel { display: flex; flex-direction: column; gap: 12px; }
.side-panel .panel-head { margin-bottom: 0; }
.side-panel-soft {
  background: linear-gradient(180deg, #fbfbff 0%, #f5f6ff 100%);
}
.side-copy { margin: 0; color: var(--muted); font-size: 0.88rem; }
.side-heading { color: var(--muted); font-size: 0.76rem; letter-spacing: 0.07em; text-transform: uppercase; }

.side-links { display: flex; flex-direction: column; gap: 8px; }
.side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.side-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
  text-decoration: none;
}
.side-link > span:last-child { color: var(--accent); font-weight: 700; }
.side-link strong { display: block; font-size: 0.87rem; }
.side-link small { display: block; color: var(--muted); font-size: 0.75rem; line-height: 1.4; }
.keyboard-hint { margin: 0; color: var(--muted-2); font-size: 0.75rem; }

.entity-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.entity-cloud-center { justify-content: center; margin-top: 14px; }

.entity-chip {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entity-chip:hover { background: var(--accent-soft-2); }
.entity-chip:focus-visible { outline: none; box-shadow: var(--ring); }
.entity-chip .count { color: var(--muted); margin-left: 5px; font-weight: 500; }

/* ------------------------------------------------------------ memory cards */
.memory-list { display: flex; flex-direction: column; gap: 12px; }

.memory-card {
  padding: 16px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  animation: fade-up 0.22s ease both;
}
.memory-card:hover {
  border-left-color: var(--accent-soft-2);
  box-shadow: 0 14px 30px -26px rgba(15, 23, 42, 0.55);
}
.memory-content {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.62;
  overflow-wrap: anywhere;
}
.memory-content.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.memory-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 12px;
  margin-top: 10px;
  color: var(--muted-2);
  font-size: 0.76rem;
}
.sim-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  background: var(--success-soft);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 700;
  font-size: 0.74rem;
}
.memory-owner {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}
.entity-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.entity-tag {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 3px 8px;
  cursor: pointer;
}
.entity-tag:hover { background: var(--accent-soft-2); }
.entity-tag:focus-visible { outline: none; box-shadow: var(--ring); }
.memory-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

/* ------------------------------------------------------- states & banners */
.skeleton {
  height: 78px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.empty-state {
  padding: 30px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
}
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 0.95rem; }
.empty-state p { margin: 0 auto 12px; max-width: 420px; font-size: 0.87rem; }

.error-banner {
  padding: 12px 14px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f5c6c2;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

/* ------------------------------------------------------------ graph layout */
.graph-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.graph-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mini-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mini-steps li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}
.mini-steps .step-number {
  width: 22px;
  height: 22px;
  font-size: 0.68rem;
}
.mini-steps strong { color: var(--text); }

.field-label {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.field-hint { margin: 0; color: var(--muted-2); font-size: 0.78rem; }

.entity-form { display: flex; flex-direction: column; gap: 8px; }

.input-wrap { position: relative; }
.input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted-2);
  pointer-events: none;
}
#entityInput { padding-left: 40px; }

input[type="search"],
input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: var(--muted-2); }
input:focus { border-color: var(--accent); box-shadow: var(--ring); }

.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  max-height: 238px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.suggestion-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--surface-3);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.87rem;
  text-align: left;
  cursor: pointer;
}
.suggestion-item:last-child { border-bottom: 0; }
.suggestion-item:hover,
.suggestion-item:focus-visible { background: var(--accent-soft); outline: none; }
.suggestion-empty { padding: 10px 12px; color: var(--muted); font-size: 0.83rem; }

.suggested-block { display: flex; flex-direction: column; gap: 7px; }

.button-row { display: flex; gap: 8px; margin-top: 2px; }
.button-row .btn { flex: 1; }

.graph-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.81rem;
}

.inline-help {
  padding: 10px 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.81rem;
}
.inline-help summary { cursor: pointer; color: var(--text); font-weight: 650; }
.inline-help ul { margin: 8px 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.entity-details { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }
.entity-details h3 { font-size: 1.02rem; }
.memory-count { color: var(--muted-2); font-size: 0.78rem; margin-top: -7px; }

.entity-memory {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 9px 11px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-soft-2);
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.entity-memory:hover { background: var(--surface); border-left-color: var(--accent); }
.entity-memory:focus-visible { outline: none; box-shadow: var(--ring); }
.entity-memory-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  color: var(--muted);
}
.entity-memory time { color: var(--muted-2); font-size: 0.72rem; }

.graph-stage {
  position: relative;
  min-height: 540px;
  padding: 0;
  overflow: hidden;
}

.graph-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 6;
  display: flex;
  gap: 3px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}
.tool-btn {
  min-width: 32px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 1.05rem;
  cursor: pointer;
}
.tool-btn:hover { background: var(--surface-3); color: var(--text); }
.tool-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.tool-btn-wide { padding: 0 10px; font-size: 0.77rem; font-weight: 650; }

.cy {
  width: 100%;
  height: calc(100vh - 250px);
  min-height: 520px;
  background-color: var(--surface);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
}

.graph-legend {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 6;
  display: flex;
  gap: 14px;
  padding: 5px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.73rem;
  backdrop-filter: blur(6px);
}
.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 18px; border-top: 2px solid var(--muted-2); display: inline-block; }
.legend-line.dashed { border-top-style: dashed; }

.graph-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.94));
}
.graph-empty[hidden] { display: none; }
.graph-empty-inner {
  max-width: 430px;
  text-align: center;
  color: var(--muted);
}
.graph-empty-inner svg { width: 58px; height: 58px; margin-bottom: 10px; }
.graph-empty-inner h3 { margin-bottom: 6px; color: var(--text); font-size: 1.1rem; }
.graph-empty-inner p { margin: 0; font-size: 0.88rem; line-height: 1.55; }
.graph-empty-inner .entity-cloud { pointer-events: auto; }

/* ------------------------------------------------------------------- help */
.help-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.help-toc {
  position: sticky;
  top: calc(var(--topbar-height) + 18px);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.help-toc .field-label { margin-bottom: 6px; }
.help-toc a {
  padding: 5px 8px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.87rem;
}
.help-toc a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.help-content { display: flex; flex-direction: column; gap: 18px; }
.help-section {
  padding: 24px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 92px;
}
.help-section h2 { margin-bottom: 10px; font-size: 1.3rem; }
.help-section p { color: var(--muted); }
.help-section p:last-child { margin-bottom: 0; }
.help-list { margin: 8px 0 0 20px; padding: 0; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }

.help-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.help-steps li { display: flex; gap: 12px; align-items: flex-start; }
.help-steps strong { display: block; font-size: 0.94rem; }
.help-steps p { margin: 2px 0 0; font-size: 0.86rem; }

.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.help-card {
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.help-card h3 { margin-bottom: 4px; font-size: 0.9rem; }
.help-card p { margin: 0; font-size: 0.83rem; }
.help-card pre { margin: 8px 0 0; }

.callout {
  margin-top: 12px;
  padding: 12px 14px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  font-size: 0.86rem;
}
.callout strong { color: var(--text); }
.callout-tip { color: #0e5e55; background: var(--teal-soft); border-color: #c8f0e8; border-left-color: var(--teal); }
.callout-tip strong { color: #0e5e55; }

.shortcut-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.shortcut {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.86rem;
}

.help-faq { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.help-faq details {
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.help-faq summary { cursor: pointer; color: var(--text); font-size: 0.89rem; font-weight: 650; }
.help-faq p { margin: 8px 0 0; font-size: 0.85rem; }
.help-back { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ login */
.login-body { background: var(--bg); }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(91, 91, 214, 0.14), transparent 70%),
    radial-gradient(600px 300px at 92% 112%, rgba(15, 157, 138, 0.1), transparent 70%);
}
.login-card {
  width: 100%;
  max-width: 430px;
  padding: 32px 30px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 0.92rem;
}
.login-brand strong { color: var(--accent); }
.login-brand .brand-badge { width: 32px; height: 32px; }
.login-card h1 { margin-bottom: 6px; font-size: 1.7rem; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 0.92rem; }

#loginForm { display: flex; flex-direction: column; gap: 8px; }
#loginForm .btn { margin-top: 8px; }
.input-with-action { position: relative; }
.input-with-action input { padding-right: 62px; }
.input-action {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}
.input-action:hover { background: var(--accent-soft); }
.input-action:focus-visible { outline: none; box-shadow: var(--ring); }

.form-error {
  margin: 0;
  padding: 9px 11px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f5c6c2;
  border-radius: 8px;
  font-size: 0.83rem;
}

.login-help {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.81rem;
}
.login-help summary { cursor: pointer; color: var(--accent); font-weight: 650; }
.login-help p { margin: 8px 0; }
.login-help pre { margin: 8px 0; font-size: 0.74rem; }
.login-hint { margin: 16px 0 0; color: var(--muted-2); font-size: 0.75rem; line-height: 1.5; }

/* -------------------------------------------------------------- memory modal */
.memory-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: min(82vh, 760px);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 40px 90px -40px rgba(15, 23, 42, 0.6);
}
.memory-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
}
.memory-dialog[open] { animation: pop 0.18s ease both; }

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
}
.dialog-title { font-size: 1.02rem; }
.dialog-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.dialog-close:hover { background: #e9edf5; color: var(--text); }
.dialog-close:focus-visible { outline: none; box-shadow: var(--ring); }

.dialog-body {
  max-height: calc(82vh - 64px);
  padding: 20px 22px 22px;
  overflow-y: auto;
}
.dialog-content {
  margin: 0 0 16px;
  font-size: 0.97rem;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.dialog-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.dialog-hint { margin: 10px 0 0; color: var(--muted-2); font-size: 0.78rem; }
.detail-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
}
.detail-grid dt { color: var(--muted-2); font-weight: 600; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ------------------------------------------------------------------ admin */
.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.admin-head .page-sub { margin-bottom: 0; }
.admin-head .btn { flex: 0 0 auto; margin-top: 4px; }

.admin-info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin: 18px 0;
}
.admin-audit { margin-top: 0; }

.admin-users { min-height: 60px; }
.table-wrap { width: 100%; overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  padding: 0 12px 9px;
  color: var(--muted-2);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--surface-3);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .num-cell { text-align: center; color: var(--muted); }
.data-table .actions-cell { text-align: right; white-space: nowrap; }
.user-row.is-disabled { opacity: 0.72; }

.user-identity { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.user-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-soft), var(--teal-soft));
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}
.user-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-name { display: flex; align-items: center; gap: 6px; font-weight: 650; }
.user-username {
  color: var(--muted-2);
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}
.user-sub { color: var(--muted-2); font-size: 0.7rem; }
.you-badge {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill.is-active { color: var(--success); background: var(--success-soft); }
.status-pill.is-disabled { color: var(--muted); background: var(--surface-3); }
.role-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.63rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.token-pill {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.73rem;
  white-space: nowrap;
}
.row-actions { display: flex; justify-content: flex-end; gap: 4px; flex-wrap: wrap; }
.actions-cell .muted-note { white-space: nowrap; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b3261e; }
.btn-danger-ghost {
  color: var(--danger);
  background: transparent;
  border-color: transparent;
}
.btn-danger-ghost:hover {
  background: var(--danger-soft);
  border-color: #f5c6c2;
}

.server-list {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
  font-size: 0.81rem;
}
.server-list dt { color: var(--muted-2); font-weight: 600; }
.server-list dd { margin: 0; overflow-wrap: anywhere; }
.server-list dd.mono { font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; font-size: 0.74rem; }

.audit-table { font-size: 0.8rem; }
.audit-table td { padding: 9px 12px; }
.audit-detail { color: var(--muted); max-width: 280px; }

.admin-dialog { width: min(560px, calc(100vw - 32px)); }
.confirm-dialog { width: min(430px, calc(100vw - 32px)); }
.admin-dialog .dialog-body { display: flex; flex-direction: column; gap: 7px; }
.admin-dialog pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-dialog .field-label { margin-top: 6px; }
.admin-dialog .dialog-actions { justify-content: flex-end; margin-top: 14px; }
.admin-dialog .dialog-hint { margin: 0 0 4px; }
.admin-dialog input,
.admin-dialog select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  outline: none;
}
.admin-dialog input:focus,
.admin-dialog select:focus { border-color: var(--accent); box-shadow: var(--ring); }
.admin-dialog select:disabled { opacity: 0.55; }

.token-value {
  display: block;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  user-select: all;
}
.token-actions { margin-top: 10px; }
.callout-warm {
  background: var(--amber-soft);
  border-color: #f3ddb3;
  border-left-color: var(--amber);
  color: #7a4a08;
  margin-top: 0;
}
.callout-warm strong { color: #7a4a08; }

.choice-group { border: 0; padding: 0; margin: 4px 0; }
.choice-group legend { padding: 0; margin-bottom: 6px; }
.choice-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 6px;
  cursor: pointer;
}
.choice-row:hover { background: var(--surface-2); }
.choice-row input { width: auto; margin-top: 4px; accent-color: var(--accent); }
.choice-row strong { display: block; font-size: 0.87rem; }
.choice-row small { display: block; color: var(--muted); font-size: 0.77rem; line-height: 1.4; }

/* -------------------------------------------------------------- animations */
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* -------------------------------------------------------------- responsive */
@media (max-width: 1020px) {
  .home-grid { grid-template-columns: 1fr; }
  .graph-shell { grid-template-columns: 1fr; }
  .graph-sidebar { position: static; }
  .cy { height: 62vh; min-height: 480px; }
  .help-layout { grid-template-columns: 1fr; }
  .help-toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }
  .help-toc .field-label { width: 100%; margin-bottom: 2px; }
}

@media (max-width: 760px) {
  .guide-strip { grid-template-columns: 1fr; gap: 8px; }
  .guide-link { margin-top: 0; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 28px 22px 24px; }
  .search-bar { flex-wrap: wrap; padding-left: 42px; }
  .search-bar input[type="search"] { flex: 1 0 100%; }
  .search-bar .btn { flex: 1; }
  .help-grid, .shortcut-grid { grid-template-columns: 1fr; }
  .help-section { padding: 20px; }
  .admin-info-grid { grid-template-columns: 1fr; }
  .admin-head { flex-direction: column; align-items: stretch; }
  .admin-head .btn { align-self: flex-start; }
  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding-left: 8px; padding-right: 8px; }
  .topbar-inner { padding: 0 16px; gap: 14px; }
  .page { padding: 26px 16px 48px; }
  .footer { padding: 0 16px 28px; }
  .graph-legend { display: none; }
}

@media (max-width: 600px) {
  .brand-text { display: none; }
  .nav-link span { display: none; }
  .nav-link { padding: 9px 10px; }
  .user-chip { max-width: 92px; }
  .topbar-inner { gap: 10px; }
  .hero h1 { font-size: 1.9rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 13px; column-gap: 9px; }
  .stat-icon { width: 36px; height: 36px; border-radius: 10px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-value { font-size: 1.45rem; }
  .stat-label { font-size: 0.68rem; white-space: normal; }
  .detail-grid { grid-template-columns: 1fr; gap: 2px; }
  .detail-grid dd { margin-bottom: 8px; }
  .dialog-head { padding: 14px 16px; }
  .dialog-body { padding: 16px; }
}
