:root {
  --bg: #0c1320;
  --bg2: #11192a;
  --panel: #16203440;
  --panel-solid: #151e30;
  --border: #25324a;
  --text: #e7edf7;
  --muted: #94a3bd;
  --accent: #4f8cff;
  --accent2: #36d399;
  --up: #f6b73c;
  --mid: #4f8cff;
  --down: #36d399;
  --danger: #ff7a85;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 15% -10%, #1a2640 0%, var(--bg) 55%) fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 24px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: #0e1626cc; backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; line-height: 1; }
.topbar h1 { font-size: 19px; margin: 0; font-weight: 900; letter-spacing: .5px; }
.tagline { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 700;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 16px; cursor: pointer; color: var(--text);
  background: var(--panel-solid); transition: .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #6aa0ff); border: none; color: #fff; }
.btn.ghost { background: transparent; }
.btn:active { transform: translateY(0); }

/* ---------- Hero / search ---------- */
.hero { max-width: 960px; margin: 0 auto; padding: 40px 24px 8px; text-align: center; }
.search-wrap {
  display: flex; gap: 10px; max-width: 720px; margin: 0 auto;
}
#themeInput {
  flex: 1; font-family: inherit; font-size: 16px; color: var(--text);
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 18px; outline: none; transition: .15s;
}
#themeInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #4f8cff33; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0 14px; }
.chip {
  font-size: 13px; font-weight: 500; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel-solid);
  color: var(--text); cursor: pointer; transition: .15s;
}
.chip:hover { border-color: var(--accent); color: #fff; transform: translateY(-1px); }
.chip small { color: var(--muted); margin-left: 6px; }
.disclaimer { font-size: 12.5px; color: var(--muted); max-width: 640px; margin: 6px auto 0; }
.disclaimer strong { color: var(--up); }

/* ---------- Board ---------- */
.board { max-width: 1180px; margin: 18px auto 60px; padding: 0 24px; }
.board-head { margin: 10px 0 18px; }
.map-title {
  font-size: 26px; font-weight: 900; color: var(--text);
  background: transparent; border: none; border-bottom: 2px dashed transparent;
  width: 100%; max-width: 640px; padding: 2px 0; outline: none; font-family: inherit;
}
.map-title:focus { border-bottom-color: var(--accent); }
.meta { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.badge {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: #4f8cff22; color: #9ec0ff; border: 1px solid #4f8cff44;
}
.saved-hint { font-size: 12px; color: var(--muted); }

.panel {
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }
textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  background: #0f1726; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; resize: vertical; outline: none; line-height: 1.6;
}
textarea:focus { border-color: var(--accent); }

/* ---------- Chain columns ---------- */
.chain {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 10px; align-items: stretch; margin-bottom: 18px;
}
.chain-col {
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.chain-col h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.chain-col h3 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.up { background: var(--up); }
.dot.mid { background: var(--mid); }
.dot.down { background: var(--down); }
.chain-arrow { align-self: center; color: var(--muted); font-size: 22px; }
.nodes { display: flex; flex-direction: column; gap: 10px; flex: 1; }

.node {
  background: #0f1726; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; position: relative;
}
.node .node-name {
  font-weight: 700; font-size: 14px; background: transparent; border: none;
  color: var(--text); width: 100%; outline: none; font-family: inherit; padding-right: 18px;
}
.node .companies { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px; }
.company {
  font-size: 12px; padding: 3px 9px; border-radius: 6px;
  background: #4f8cff1a; border: 1px solid #4f8cff33; color: #bcd3ff;
}
.node .node-note {
  font-size: 12px; color: var(--muted); background: transparent; border: none;
  width: 100%; outline: none; font-family: inherit; resize: none; line-height: 1.45;
}
.node-note:focus, .node-name:focus { color: var(--text); }
.del {
  position: absolute; top: 6px; right: 8px; cursor: pointer; color: var(--muted);
  font-size: 14px; line-height: 1; border: none; background: none; opacity: .5;
}
.del:hover { color: var(--danger); opacity: 1; }
.add-node, .add-item {
  margin-top: 10px; font-family: inherit; font-size: 13px; font-weight: 600;
  background: transparent; border: 1px dashed var(--border); color: var(--muted);
  border-radius: 8px; padding: 8px; cursor: pointer; transition: .15s; width: 100%;
}
.add-node:hover, .add-item:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Grid 3 (catalysts / risks / indicators) ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.editlist, .indlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.editlist li, .indlist li {
  display: flex; align-items: flex-start; gap: 8px;
  background: #0f1726; border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px;
}
.editlist li .li-text, .indlist li .li-text {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-family: inherit; font-size: 13px; outline: none; line-height: 1.5;
}
.indlist .cadence {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  background: #36d39922; color: #7ee2b8; border: 1px solid #36d39944; cursor: pointer;
  white-space: nowrap;
}
.editlist .bullet { color: var(--accent); font-weight: 900; line-height: 1.4; }
.editlist .bullet.r { color: var(--danger); }

/* ---------- Footer / toast ---------- */
.footer { text-align: center; padding: 28px 24px 50px; color: var(--muted); font-size: 13px; }
.footer .fine { font-size: 11.5px; opacity: .7; margin-top: 4px; }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1c2740; border: 1px solid var(--accent); color: #fff;
  padding: 11px 20px; border-radius: 10px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .chain { grid-template-columns: 1fr; }
  .chain-arrow { transform: rotate(90deg); padding: 2px 0; }
  .grid-3 { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 17px; }
  .hero { padding-top: 26px; }
  .search-wrap { flex-direction: column; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #111; }
  .topbar, .hero, .footer, .add-node, .add-item, .del, .toast { display: none !important; }
  .panel, .chain-col, .node { box-shadow: none; border-color: #ccc; background: #fff; }
  .board { margin: 0; max-width: 100%; }
  .company { background: #eef3ff; color: #234; }
  textarea, .li-text, .node-name, .node-note, .map-title { color: #111 !important; }
  .chain { grid-template-columns: 1fr 1fr 1fr; }
  .chain-arrow { display: none; }
}
