/* S8 星云、关系图着色、概览（仪表盘）。终端风，深浅色都按 manage.css 的变量走。 */

/* 7 种记忆的颜色（星云、关系图、仪表盘共用）。浅色偏深、深色偏亮，都和背景拉开对比；红色留给冲突。 */
:root {
  --k-rule: #a86d0c; --k-preference: #8a4fc7; --k-fact: #1f6fc0; --k-decision: #1d8a5b;
  --k-lesson: #c23d7e; --k-example: #0f8f85; --k-progress: #6b6c72; --k-inspiration: #c0661f;
  --nebula-bg: radial-gradient(ellipse at 50% 40%, #f3f3f0 0%, #ecece8 70%, #e6e6e1 100%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --k-rule: #f2b84b; --k-preference: #c792ea; --k-fact: #5ab0f6; --k-decision: #3fb37f;
    --k-lesson: #f07ab0; --k-example: #4fd1c5; --k-progress: #a9aab0; --k-inspiration: #f4a259;
    --nebula-bg: radial-gradient(ellipse at 50% 40%, #121420 0%, #0b0c12 65%, #08080b 100%);
  }
}
:root[data-theme="dark"] {
  --k-rule: #f2b84b; --k-preference: #c792ea; --k-fact: #5ab0f6; --k-decision: #3fb37f;
  --k-lesson: #f07ab0; --k-example: #4fd1c5; --k-progress: #a9aab0; --k-inspiration: #f4a259;
  --nebula-bg: radial-gradient(ellipse at 50% 40%, #121420 0%, #0b0c12 65%, #08080b 100%);
}

/* 分段按钮组 */
.seg { display: inline-flex; gap: 0; }
.seg > .btn { border-radius: 0; margin-left: -1px; }
.seg > .btn:first-child { border-radius: var(--rb) 0 0 var(--rb); margin-left: 0; }
.seg > .btn:last-child { border-radius: 0 var(--rb) var(--rb) 0; }

/* 星云 */
.nebula-toolbar .nebula-search { flex: 1; min-width: 160px; }
.nebula-toolbar .seg > .btn { padding: 5px 9px; font-size: 12.5px; }
.nebula-kinds { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.nebula-kinds .chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--ln2); border-radius: 99px;
  font-size: 12px; color: var(--t2); background: var(--bg); }
.nebula-kinds .chip .n { color: var(--t3); font-size: 11px; }
.nebula-kinds .chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.swatch { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--t3); }
.swatch[data-kind="rule"] { background: var(--k-rule); } .swatch[data-kind="preference"] { background: var(--k-preference); }
.swatch[data-kind="fact"] { background: var(--k-fact); } .swatch[data-kind="decision"] { background: var(--k-decision); }
.swatch[data-kind="lesson"] { background: var(--k-lesson); } .swatch[data-kind="example"] { background: var(--k-example); }
.swatch[data-kind="progress"] { background: var(--k-progress); } .swatch[data-kind="inspiration"] { background: var(--k-inspiration); }
.swatch.twinkle { background: transparent; border: 1.5px solid var(--warn); animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .35; } }

.nebula-stage { position: relative; height: min(66vh, 640px); min-height: 18rem; border: 1px solid var(--ln); border-radius: var(--r); overflow: hidden;
  background: var(--nebula-bg); touch-action: none; user-select: none; -webkit-user-select: none; }
.nebula-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.nebula-canvas:focus-visible { outline-offset: -2px; }
.nebula-labels { position: absolute; inset: 0; pointer-events: none; }
.nebula-label { position: absolute; left: 0; top: 0; pointer-events: auto; font: 12px/1.3 var(--num); color: var(--tx); padding: 2px 7px;
  border-radius: 4px; background: color-mix(in srgb, var(--bg) 72%, transparent); border: 1px solid color-mix(in srgb, var(--ln2) 70%, transparent);
  white-space: nowrap; max-width: 16em; overflow: hidden; text-overflow: ellipsis; }
.nebula-label .n { margin-left: 5px; color: var(--t3); font-size: 11px; }
.nebula-label:hover { border-color: var(--t3); }
.nebula-tip { position: absolute; left: 0; top: 0; z-index: 3; max-width: 250px; padding: 7px 9px; border-radius: 6px; font-size: 12.5px; line-height: 1.5;
  background: var(--bg); border: 1px solid var(--ln2); box-shadow: 0 4px 16px rgba(0,0,0,.18); pointer-events: none; overflow-wrap: anywhere; }
.nebula-tip .m { display: block; font-size: 11px; }
.nebula-box { position: absolute; border: 1px dashed var(--warn); background: var(--warnbg); pointer-events: none; z-index: 2; }

.nebula-time { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.nebula-track { position: relative; flex: 1; min-width: 0; height: 30px; }
.nebula-hist { position: absolute; inset: 2px 0 12px; display: flex; align-items: flex-end; gap: 1px; opacity: .55; }
.nebula-hist i { flex: 1; background: var(--t3); min-height: 1px; border-radius: 1px 1px 0 0; }
.nebula-range { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; accent-color: var(--warn); }
.nebula-when { font-size: 12px; white-space: nowrap; }

.nebula-page > .notice { margin: 0 0 10px; }
.nebula-context { margin-top: 10px; border: 1px solid var(--ln); border-radius: var(--r); padding: 8px 12px; background: var(--bg); }
.nebula-context summary { cursor: pointer; font-family: var(--num); font-size: 12.5px; color: var(--t2); }
.nebula-context-body { display: grid; gap: 8px; margin-top: 8px; }
.nebula-context textarea, .nebula-context select { width: 100%; padding: 7px 10px; border: 1px solid var(--ln2); border-radius: var(--rb); background: var(--bg); }
.nebula-context .row { flex-wrap: wrap; align-items: center; }
.nebula-context .row select { flex: 1; min-width: 160px; width: auto; }
.detail .pair { border-bottom: 1px solid var(--ln); padding: 8px 0; }
.detail textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--ln2); border-radius: var(--rb); background: var(--bg); }
.detail .choice { display: flex; margin: 4px 0; }

/* 关系图：按种类 / 根分类着色 */
.graph-surface[data-color="kind"] .graph-node[data-kind="rule"] { --node: var(--k-rule); }
.graph-surface[data-color="kind"] .graph-node[data-kind="preference"] { --node: var(--k-preference); }
.graph-surface[data-color="kind"] .graph-node[data-kind="fact"] { --node: var(--k-fact); }
.graph-surface[data-color="kind"] .graph-node[data-kind="decision"] { --node: var(--k-decision); }
.graph-surface[data-color="kind"] .graph-node[data-kind="lesson"] { --node: var(--k-lesson); }
.graph-surface[data-color="kind"] .graph-node[data-kind="example"] { --node: var(--k-example); }
.graph-surface[data-color="kind"] .graph-node[data-kind="progress"] { --node: var(--k-progress); }
.graph-surface[data-color="space"] .graph-node[data-root="work"] { --node: var(--k-fact); }
.graph-surface[data-color="space"] .graph-node[data-root="personal"] { --node: var(--k-lesson); }
.graph-surface[data-color="space"] .graph-node[data-space-team="true"] { --node: var(--k-decision); }
.graph-node .fold { fill: var(--t2); font: 11px var(--num); }
.graph-node[data-collapsed="true"] .dot { stroke: var(--warn); stroke-width: 2; }

/* 概览 */
.dash { display: grid; gap: 14px; }
.dash .h { margin-bottom: 0; }
.dash-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 8px; }
.tile { border: 1px solid var(--ln2); border-radius: var(--r); padding: 10px 12px; background: var(--bg); display: grid; gap: 2px; align-content: start; }
.tile-n { font-size: 22px; font-weight: 600; line-height: 1.2; }
.tile-l { font-size: 12px; color: var(--t3); }
.tile .btn { justify-self: start; margin-top: 6px; padding: 3px 9px; font-size: 12px; }
.dash-card { border: 1px solid var(--ln2); border-radius: var(--r); padding: 12px 14px; background: var(--bg); min-width: 0; }
.dash-card h3 { font-family: var(--num); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.dash-card h4 { font-size: 11.5px; color: var(--t3); margin: 10px 0 6px; font-weight: 500; font-family: var(--num); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th { text-align: left; font: 500 11.5px var(--num); color: var(--t3); padding: 4px 8px 6px 0; border-bottom: 1px solid var(--ln); }
.dash-table td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--ln); vertical-align: middle; }
.small { font-size: 12px; margin-top: 6px; }

/* 图表 */
.chart-box { margin: 0; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart:focus-visible { outline-offset: 4px; }
.chart-grid { stroke: var(--ln); stroke-width: 1; }
.chart-tick { fill: var(--t3); font: 10.5px var(--num); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-cursor { stroke: var(--t3); stroke-dasharray: 2 3; }
.chart-dot { stroke: var(--bg); stroke-width: 1.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--t2); margin: 4px 0; }
.chart-key { display: inline-flex; align-items: center; gap: 5px; }
.chart-key i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-readout { min-height: 1.4em; font: 12px var(--num); color: var(--t2); }
.spark { width: 120px; height: 26px; display: block; }
.share { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--bg3); gap: 1px; }
.share-empty { flex: 1; }

@media (max-width: 860px) {
  .nebula-stage { height: 58vh; }
  .nebula-toolbar .seg { flex-wrap: wrap; }
  .nebula-time { flex-wrap: wrap; }
  .nebula-track { flex-basis: 100%; order: 2; }
}
@media (pointer: coarse) {
  .nebula-kinds .chip { min-height: 34px; }
  .nebula-toolbar .zoom-btn { display: none; } /* 触屏用双指缩放 */
}
@media (max-width: 640px) {
  .nebula-kinds { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -14px; padding-right: 14px; }
  .nebula-kinds::-webkit-scrollbar { display: none; }
  .nebula-kinds .chip { flex: none; }
  .nebula-page > .graph-summary:first-of-type { font-size: 11.5px; }
  .nebula-stage { height: 62vh; }
}
@media (prefers-reduced-motion: reduce) {
  .swatch.twinkle { animation: none; }
}
