/* PrincipleX 国策图 —— 深色科技树风格 */
:root {
  --bg0: #0a0e1a;
  --bg1: #0f1530;
  --ink: #e6ebff;
  --muted: #8a93b2;
  --line: rgba(140, 160, 220, .18);
  --card: rgba(22, 28, 52, .82);
  --card-edge: rgba(150, 170, 230, .16);
  --topbar: rgba(10, 14, 26, .72);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 50% -10%, #1b2350 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 10%, #241a47 0%, transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  background-attachment: fixed;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: 56px; z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--topbar); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.progress {
  font-size: 12px; color: var(--muted); padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
}
.search {
  flex: 0 1 240px; min-width: 120px; height: 34px; padding: 0 12px;
  background: rgba(255,255,255,.04); color: var(--ink);
  border: 1px solid var(--card-edge); border-radius: 999px; outline: none;
}
.search:focus { border-color: rgba(122,162,247,.6); }
.spacer { flex: 1; }
.btn {
  height: 34px; padding: 0 14px; color: var(--ink);
  background: rgba(255,255,255,.05); border: 1px solid var(--card-edge);
  border-radius: 8px; white-space: nowrap; transition: .15s;
}
.btn:hover { background: rgba(255,255,255,.1); }
.btn.primary { background: linear-gradient(180deg,#5b76e6,#4257c9); border-color: #6f86f0; }
.btn.primary:hover { filter: brightness(1.08); }
.btn { display: inline-flex; align-items: center; gap: 5px; }
.btn .ico { font-size: 15px; line-height: 1; }

/* ---------- 今日一条 ---------- */
.today {
  position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 25;
  max-width: min(680px, 92vw); padding: 8px 16px; cursor: pointer;
  background: rgba(20,26,52,.86); border: 1px solid rgba(224,175,104,.5);
  border-radius: 999px; box-shadow: 0 0 22px rgba(224,175,104,.25);
  font-size: 13px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.today b { color: #e0af68; margin-right: 6px; }

/* ---------- 画布 / 平移缩放 ---------- */
.viewport {
  position: absolute; inset: 56px 0 0 0; overflow: hidden;
  touch-action: none; cursor: grab;
}
.viewport.grabbing { cursor: grabbing; }
.stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.links { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.nodes { position: absolute; top: 0; left: 0; }

/* ---------- 根 / 主干 / 原则 节点 ---------- */
.node { position: absolute; transform: translateX(-50%); }

.root {
  width: 220px; min-height: 70px; padding: 12px 18px; text-align: center;
  background: radial-gradient(120% 120% at 50% 0%, #2b366b, #161c34);
  border: 1px solid rgba(150,170,240,.5); border-radius: 16px;
  box-shadow: 0 0 30px rgba(120,150,255,.3), inset 0 1px 0 rgba(255,255,255,.08);
}
.root .r-title { font-size: 18px; font-weight: 800; letter-spacing: .06em; }
.root .r-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

.trunk {
  width: 252px; min-height: 92px; padding: 12px 16px;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 14px;
  box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 28%, transparent);
}
.trunk .t-head { display: flex; align-items: center; gap: 8px; }
.trunk .t-emoji { font-size: 22px; }
.trunk .t-name { font-weight: 700; color: color-mix(in srgb, var(--accent) 75%, white); }
.trunk .t-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.trunk .t-motto { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.card {
  position: relative;
  width: 244px; height: 104px; padding: 12px 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; overflow: hidden;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 40%, transparent);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
}
.card .c-title {
  font-size: 13.5px; line-height: 1.45; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .c-meta { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.card .c-src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .c-tags { display: flex; gap: 4px; overflow: hidden; }
.chip { font-size: 10.5px; color: var(--muted); padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }

.card .lit { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; color: var(--muted);
  background: rgba(255,255,255,.05); border: 1px solid var(--card-edge); }
.card.is-lit {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent);
}
.card.is-lit .lit { color: #0a0e1a; background: var(--accent); border-color: var(--accent); }
.card.is-lit::after { content: ""; }

.node.dim { opacity: .18; filter: grayscale(.5); }
.node.hit .card { border-color: #ffd166; box-shadow: 0 0 26px rgba(255,209,102,.45); }

.card.is-today, .node.is-today .card {
  animation: pulse 1.8s ease-in-out infinite;
  border-color: #e0af68;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 12px rgba(224,175,104,.35); }
  50% { box-shadow: 0 0 30px rgba(224,175,104,.7); }
}

/* ---------- 缩放控件 ---------- */
.zoom { position: fixed; right: 16px; bottom: 16px; z-index: 25; display: flex; flex-direction: column; gap: 6px; }
.zoom button {
  width: 38px; height: 38px; font-size: 18px; color: var(--ink);
  background: rgba(20,26,52,.8); border: 1px solid var(--card-edge); border-radius: 10px;
  backdrop-filter: blur(8px);
}
.zoom button:hover { background: rgba(40,50,90,.9); }

/* ---------- 抽屉(详情) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4,6,14,.5); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 92vw); z-index: 50;
  padding: 22px; overflow-y: auto;
  background: linear-gradient(180deg,#141a32,#0d1224);
  border-left: 1px solid var(--card-edge);
  box-shadow: -16px 0 40px rgba(0,0,0,.5);
}
.drawer .d-theme { font-size: 12px; font-weight: 600; }
.drawer .d-title { font-size: 20px; font-weight: 800; line-height: 1.5; margin: 10px 0 14px; }
.drawer .d-detail { font-size: 14px; line-height: 1.85; color: #cdd5f5; white-space: pre-wrap; }
.drawer .d-row { margin-top: 16px; font-size: 13px; color: var(--muted); }
.drawer .d-row b { color: var(--ink); font-weight: 600; }
.drawer .d-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.drawer .d-actions { display: flex; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.drawer .close { position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--muted); font-size: 22px; }

/* ---------- 模态框 ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(4,6,14,.6); padding: 16px; }
.modal {
  width: min(520px, 96vw); max-height: 90vh; overflow-y: auto; padding: 22px;
  background: linear-gradient(180deg,#161c34,#0e1326); border: 1px solid var(--card-edge);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; color: var(--ink);
  background: rgba(255,255,255,.04); border: 1px solid var(--card-edge); border-radius: 8px; outline: none;
  font-family: inherit; font-size: 14px;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(122,162,247,.6); }
.modal .m-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.hint { font-size: 12px; color: var(--muted); margin-top: -6px; margin-bottom: 12px; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(247,118,142,.16); border-color: rgba(247,118,142,.5); color: #ffb3c0; }

/* ---------- 列表视图 ---------- */
.list { position: absolute; inset: 56px 0 0 0; overflow-y: auto; padding: 24px 16px 80px; z-index: 10; }
.list .l-theme { max-width: 820px; margin: 0 auto 26px; }
.list .l-head { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; margin-bottom: 12px;
  color: color-mix(in srgb, var(--accent) 80%, white); }
.list .l-head .bar { flex: 1; height: 1px; background: color-mix(in srgb, var(--accent) 40%, transparent); }
.list .l-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 12px; }
.list .card { width: auto; height: auto; min-height: 96px; }

/* ---------- 灵感箱 ---------- */
.cap-item { padding: 12px 0; border-top: 1px solid var(--line); }
.cap-item:first-of-type { border-top: none; }
.cap-text { font-size: 14px; line-height: 1.7; color: #cdd5f5; white-space: pre-wrap; }
.cap-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; flex-wrap: wrap; }
.cap-time { font-size: 11.5px; color: var(--muted); }
.cap-acts { display: flex; align-items: center; gap: 12px; }
.link { background: none; border: none; padding: 0; cursor: pointer; font-size: 12px; color: #8fb4ff; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link.danger-link { color: #ffb3c0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80;
  max-width: 90vw; padding: 12px 18px; font-size: 13.5px;
  background: rgba(20,26,52,.95); border: 1px solid var(--card-edge); border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast a { color: #8fb4ff; }
.toast.err { border-color: rgba(247,118,142,.6); }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 0 8px; overflow-x: auto; }
  .brand, .progress, #btn-fit { display: none; }   /* 手机上省地方:品牌/进度/适应屏幕(底部 ⟳ 已能复位) */
  .spacer { display: none; }
  .search { flex: 1 1 auto; width: 0; min-width: 0; max-width: 46vw; }  /* 限宽,保证按钮一定有位置 */
  .topbar .btn { flex: 0 0 auto; padding: 0 11px; } /* 按钮固定大小、不缩 */
  .btn .lbl { display: none; }                      /* 按钮只剩图标,保证都在屏内 */
  .btn .ico { font-size: 18px; }
  .today { top: 62px; font-size: 12px; max-width: 94vw; }
}
