/* ============================================================
   学习记忆中枢 —— 长期记忆 / 自动画像 / 任务上下文 / 工作记忆
   复用 style.css 的设计令牌，独立文件避免污染既有视图样式
   ============================================================ */
#v-memhub svg { width: 16px; height: 16px; flex: none; }
.mh-wrap { max-width: 1180px; }

.mh-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.mh-eyebrow { font-size: 10px; font-weight: 800; letter-spacing: .18em; color: var(--brand); text-transform: uppercase; margin-bottom: 4px; }
.mh-head h2 { font-size: 24px; line-height: 1.25; letter-spacing: -.01em; }
.mh-head p { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin-top: 4px; max-width: 720px; }
.mh-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.mh-hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: 132px minmax(0, 1fr);
  gap: 24px; align-items: center; padding: 24px 26px; border-radius: 18px;
  color: #eef4ff; background:
    radial-gradient(520px 260px at 88% 0%, rgba(62,198,214,.22), transparent 62%),
    linear-gradient(120deg, #101828 0%, #1b2a4e 55%, #1d4b6b 100%);
  box-shadow: 0 18px 48px -20px rgba(16,24,40,.55);
}
.mh-hero::after {
  content: ""; position: absolute; right: -80px; top: -90px; width: 300px; height: 300px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.12); pointer-events: none;
}
.mh-ring {
  position: relative; width: 122px; height: 122px; border-radius: 50%;
  display: grid; place-items: center; margin: 0 auto;
  background: conic-gradient(#7aa0ff calc(var(--pct, 0) * 1%), rgba(255,255,255,.14) 0);
}
.mh-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: #16203a; }
.mh-ring-in { position: relative; z-index: 1; text-align: center; }
.mh-ring-in b { display: block; font-size: 28px; line-height: 1.1; letter-spacing: -.02em; }
.mh-ring-in span { font-size: 10.5px; color: rgba(238,244,255,.62); }
.mh-hero-main { position: relative; z-index: 1; min-width: 0; }
.mh-hero-main h3 { font-size: 21px; line-height: 1.35; letter-spacing: -.01em; }
.mh-hero-main p { font-size: 12.5px; color: rgba(238,244,255,.72); line-height: 1.75; margin-top: 6px; max-width: 640px; }
.mh-hero-stats { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 14px; }
.mh-hero-stat b { display: block; font-size: 19px; line-height: 1.2; }
.mh-hero-stat span { font-size: 10.5px; color: rgba(238,244,255,.6); }
.mh-hero-tag { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); font-size: 10.5px; color: rgba(238,244,255,.78); }

.mh-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0 16px; }
.mh-kpi { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.mh-kpi b { display: block; font-size: 22px; line-height: 1.2; letter-spacing: -.02em; }
.mh-kpi span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.mh-kpi small { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; }

.mh-tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); }
.mh-tab { height: 34px; padding: 0 16px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.mh-tab:hover { color: var(--ink); }
.mh-tab.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

.mh-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mh-card { padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.mh-card.is-empty { background: var(--panel2); border-style: dashed; box-shadow: none; }
.mh-card > h3 { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; margin-bottom: 10px; }
.mh-card > h3 svg { color: var(--brand); }
.mh-count { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--muted); background: var(--chip-bg); padding: 2px 7px; border-radius: 99px; }
.mh-item { padding: 10px 0; border-top: 1px solid var(--line); }
.mh-item:first-of-type { border-top: 0; padding-top: 0; }
.mh-item b { display: block; font-size: 12.5px; font-weight: 700; line-height: 1.5; }
.mh-item p { font-size: 12.5px; color: var(--ink2); line-height: 1.7; margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mh-item small { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.5; margin-top: 5px; }
.mh-item .mh-item-act { margin-top: 5px; display: flex; gap: 6px; }
.mh-empty { font-size: 12px; color: var(--muted); line-height: 1.75; }
.mh-auto { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; color: var(--sky); background: var(--brand-soft); padding: 1px 6px; border-radius: 4px; }
.mh-auto.manual { color: var(--ok-ink); background: var(--ok-soft); }

.mh-suggest { display: flex; gap: 11px; padding: 13px 14px; border: 1px dashed var(--line-strong); border-radius: 11px; background: var(--panel2); margin-bottom: 8px; }
.mh-suggest:last-child { margin-bottom: 0; }
.mh-suggest-q { font-size: 19px; line-height: 1; color: var(--warn); flex: none; margin-top: 2px; }
.mh-suggest b { font-size: 12.5px; display: block; }
.mh-suggest p { font-size: 11.5px; color: var(--muted); line-height: 1.65; margin-top: 2px; }
.mh-suggest .mh-suggest-act { margin-top: 7px; }

/* ---------- 长期记忆 ---------- */
.mh-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 13px; align-items: center; }
.mh-search { position: relative; flex: 1; min-width: 180px; }
.mh-search input {
  width: 100%; height: 36px; padding: 0 12px 0 34px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); font-size: 13px;
}
.mh-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.mh-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.mh-select {
  height: 36px; padding: 0 28px 0 10px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink2); font-size: 12px; appearance: none; cursor: pointer;
}
.mh-select:focus { outline: none; border-color: var(--brand); }
.mh-mem-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mh-mem {
  display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast), box-shadow var(--t-fast);
}
.mh-mem:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-pop); }
.mh-mem-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mh-kind { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; color: var(--muted); }
.mh-kind i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.mh-kind.goal i { background: var(--warn); }
.mh-kind.preference i { background: #7a6bd6; }
.mh-kind.constraint i { background: var(--bad); }
.mh-kind.weakness i { background: var(--bad); }
.mh-kind.habit i { background: var(--ok); }
.mh-kind.identity i { background: var(--brand); }
.mh-kind.other i { background: var(--muted); }
.mh-conf { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--chip-bg); color: var(--chip-ink); }
.mh-conf.explicit { background: var(--ok-soft); color: var(--ok-ink); }
.mh-conf.inferred { background: var(--warn-soft); color: var(--warn-ink); }
.mh-mem h3 { font-size: 14px; line-height: 1.45; letter-spacing: -.005em; }
.mh-mem > p { font-size: 12.5px; color: var(--ink2); line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mh-evidence { display: flex; gap: 7px; padding: 8px 10px; border-radius: 8px; background: var(--panel2); border-left: 2px solid var(--warn); font-size: 11px; color: var(--muted); line-height: 1.55; }
.mh-evidence .q { font-size: 15px; line-height: 1; color: var(--warn); }
.mh-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.mh-tag { font-size: 10px; padding: 1px 7px; border-radius: 5px; background: var(--chip-bg); color: var(--chip-ink); }
.mh-mem-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--muted); }
.mh-mem-actions { display: flex; gap: 1px; opacity: 0; transition: opacity var(--t-fast); }
.mh-mem:hover .mh-mem-actions, .mh-mem:focus-within .mh-mem-actions { opacity: 1; }
.mh-mini { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); }
.mh-mini:hover { background: var(--panel3); color: var(--ink); }
.mh-mini.danger:hover { background: var(--bad-soft); color: var(--bad); }
.mh-mini svg { width: 13px; height: 13px; }

/* ---------- 工作台 ---------- */
.mh-work { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 13px; align-items: start; }
.mh-task-list { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; box-shadow: var(--shadow); }
.mh-task-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 13px; border-bottom: 1px solid var(--line); }
.mh-task-list-head b { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mh-task-item { display: block; width: 100%; padding: 11px 13px; border-bottom: 1px solid var(--line); border-left: 2px solid transparent; text-align: left; }
.mh-task-item:last-child { border-bottom: 0; }
.mh-task-item:hover { background: var(--panel2); }
.mh-task-item.on { background: var(--brand-soft); border-left-color: var(--brand); }
.mh-task-item b { display: block; font-size: 12.5px; line-height: 1.45; }
.mh-task-item span { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }
.mh-task-item.on span { color: var(--brand-ink); }
.mh-work-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.mh-task-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 17px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); flex-wrap: wrap; }
.mh-task-head h3 { font-size: 18px; line-height: 1.35; }
.mh-task-head p { font-size: 12px; color: var(--muted); line-height: 1.65; margin-top: 4px; }
.mh-task-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.mh-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--chip-bg); color: var(--chip-ink); }
.mh-badge.green { background: var(--ok-soft); color: var(--ok-ink); }
.mh-badge.blue { background: var(--brand-soft); color: var(--brand-ink); }
.mh-badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.mh-composer { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.mh-composer-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.mh-composer textarea {
  width: 100%; min-height: 62px; resize: vertical; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--panel2); color: var(--ink); font-size: 12.5px; line-height: 1.6;
}
.mh-composer textarea:focus { outline: none; border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }
.mh-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.mh-switch input { display: none; }
.mh-switch i { width: 30px; height: 17px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background var(--t-fast); }
.mh-switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform var(--t-fast); }
.mh-switch input:checked + i { background: var(--brand); }
.mh-switch input:checked + i::after { transform: translateX(13px); }
.mh-work-item { display: flex; gap: 10px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; margin-bottom: 8px; box-shadow: var(--shadow); }
.mh-work-item.pinned { border-left: 3px solid var(--warn); }
.mh-work-kind { align-self: flex-start; font-size: 9.5px; font-weight: 800; padding: 2px 7px; border-radius: 5px; background: var(--chip-bg); color: var(--chip-ink); flex: none; }
.mh-work-kind.decision { background: var(--warn-soft); color: var(--warn-ink); }
.mh-work-kind.next { background: var(--brand-soft); color: var(--brand-ink); }
.mh-work-kind.question { background: #efeafd; color: #5d4bb5; }
.mh-work-kind.blocker { background: var(--bad-soft); color: var(--bad-ink); }
.mh-work-kind.fact { background: var(--ok-soft); color: var(--ok-ink); }
.mh-work-body { flex: 1; min-width: 0; }
.mh-work-body p { font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.mh-work-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 10px; color: var(--muted); flex-wrap: wrap; }
.mh-work-actions { display: flex; gap: 1px; align-self: flex-start; opacity: 0; }
.mh-work-item:hover .mh-work-actions, .mh-work-item:focus-within .mh-work-actions { opacity: 1; }
.mh-context { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; box-shadow: var(--shadow); }
.mh-context-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mh-context-head b { font-size: 13px; }
.mh-context-stats { display: flex; gap: 12px; font-size: 10.5px; color: var(--muted); flex-wrap: wrap; }
.mh-context-stats strong { color: var(--ink2); }
.mh-context pre {
  margin: 0; padding: 15px 16px; max-height: 420px; overflow: auto; background: var(--panel2);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: 11px; line-height: 1.7;
  color: var(--ink2); white-space: pre-wrap; overflow-wrap: anywhere;
}
.mh-empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 46px 16px; text-align: center; }
.mh-empty-state .ic { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: var(--panel3); color: var(--muted); }
.mh-empty-state .ic svg { width: 22px; height: 22px; }
.mh-empty-state b { font-size: 15px; }
.mh-empty-state p { font-size: 12px; color: var(--muted); max-width: 380px; line-height: 1.7; }

/* ---------- 弹层与表单 ---------- */
.mh-modal-backdrop {
  position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(8, 12, 20, .52); backdrop-filter: blur(3px);
}
.mh-modal {
  width: min(580px, 100%); max-height: 90vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow-pop);
}
.mh-modal.wide { width: min(760px, 100%); }
.mh-modal.narrow { width: min(400px, 100%); }
.mh-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 17px 19px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.mh-modal-head h3 { font-size: 17px; line-height: 1.35; }
.mh-modal-head p { font-size: 11px; color: var(--muted); margin-top: 2px; }
.mh-x { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); flex: none; }
.mh-x:hover { background: var(--panel3); color: var(--ink); }
.mh-x svg { width: 16px; height: 16px; }
.mh-modal-body { padding: 16px 19px; }
.mh-modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 19px; border-top: 1px solid var(--line); background: var(--panel2); position: sticky; bottom: 0; }
.mh-modal-foot .left { margin-right: auto; }
.mh-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.mh-field label { font-size: 11.5px; font-weight: 700; color: var(--ink2); }
.mh-field label .opt { font-weight: 400; color: var(--muted); margin-left: 4px; }
.mh-field input, .mh-field select, .mh-field textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel2);
  color: var(--ink); padding: 9px 11px; font-size: 13px;
}
.mh-field textarea { resize: vertical; min-height: 84px; line-height: 1.65; }
.mh-field input:focus, .mh-field select:focus, .mh-field textarea:focus {
  outline: none; border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft);
}
.mh-field .hint { font-size: 10.5px; color: var(--muted); line-height: 1.5; }
.mh-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.mh-form-grid .span2 { grid-column: span 2; }
.mh-detail-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.mh-meta-box { padding: 9px 11px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--line); }
.mh-meta-box span { display: block; font-size: 9.5px; color: var(--muted); }
.mh-meta-box b { display: block; font-size: 11.5px; margin-top: 1px; font-weight: 700; }
.mh-quote { padding: 12px 14px; border-radius: 9px; background: var(--warn-soft); color: var(--ink2); font-size: 12px; line-height: 1.75; white-space: pre-wrap; }
.mh-detail-body { font-size: 13px; line-height: 1.8; color: var(--ink2); white-space: pre-wrap; overflow-wrap: anywhere; }
.mh-detail-title { font-size: 20px; line-height: 1.4; margin-bottom: 6px; }
.mh-section-label { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .mh-work { grid-template-columns: 232px minmax(0, 1fr); }
  .mh-hero { grid-template-columns: 112px minmax(0, 1fr); gap: 18px; padding: 20px; }
  .mh-ring { width: 104px; height: 104px; }
  .mh-ring-in b { font-size: 24px; }
}
@media (max-width: 820px) {
  .mh-head { align-items: flex-start; }
  .mh-head h2 { font-size: 21px; }
  .mh-hero { grid-template-columns: minmax(0, 1fr); text-align: center; }
  .mh-hero-main p { margin-left: auto; margin-right: auto; }
  .mh-hero-stats { justify-content: center; }
  .mh-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mh-grid { grid-template-columns: minmax(0, 1fr); }
  .mh-mem-grid { grid-template-columns: minmax(0, 1fr); }
  .mh-work { grid-template-columns: minmax(0, 1fr); }
  .mh-task-list { max-height: 250px; overflow-y: auto; }
  .mh-mem-actions, .mh-work-actions { opacity: 1; }
  .mh-tabs { display: flex; width: 100%; }
  .mh-tab { flex: 1; justify-content: center; padding: 0 8px; }
  .mh-modal-backdrop { padding: 0; align-items: flex-end; }
  .mh-modal, .mh-modal.wide, .mh-modal.narrow { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; border-bottom: 0; }
  .mh-form-grid { grid-template-columns: minmax(0, 1fr); }
  .mh-form-grid .span2 { grid-column: auto; }
}
@media (max-width: 480px) {
  .mh-kpis { grid-template-columns: minmax(0, 1fr); }
  .mh-toolbar .mh-search { flex-basis: 100%; }
  .mh-toolbar .mh-select { flex: 1; }
  .mh-head-actions .btn { flex: 1; }
  .mh-detail-meta { grid-template-columns: minmax(0, 1fr); }
  .mh-hero-stats { gap: 12px; }
  .mh-hero-stat b { font-size: 17px; }
}
:root[data-theme="dark"] .mh-hero { background: radial-gradient(520px 260px at 88% 0%, rgba(62,198,214,.16), transparent 62%), linear-gradient(120deg, #0b1220 0%, #14213c 55%, #17384d 100%); }
:root[data-theme="dark"] .mh-ring::before { background: #111a2c; }
:root[data-theme="dark"] .mh-work-kind.question { background: #2b2547; color: #c9bdf7; }
:root[data-theme="dark"] .mh-suggest-q { color: var(--warn); }

.mh-task-head .grow { flex: 1; min-width: 0; }
.mh-task-head .row { display: flex; align-items: center; gap: 6px; }
