:root {
  --bg: #fff8fc;
  --panel: rgba(255,255,255,0.9);
  --line: #f0d7e5;
  --text: #362431;
  --muted: #8c6a78;
  --accent: #db5e9f;
  --accent-2: #7e71ff;
  --accent-3: #5fc4a8;
  --shadow: 0 20px 45px rgba(163, 107, 138, 0.14);
  --shadow-heavy: 0 24px 60px rgba(92, 47, 72, 0.22);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #fffefe 0%, #fff7fb 42%, #fff5f8 100%);
}
button, input, textarea { font: inherit; }
.hidden { display: none !important; }
.app-shell { display: grid; grid-template-columns: 292px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.76);
  backdrop-filter: blur(18px);
  padding: 18px;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.brand { display:flex; gap:14px; align-items:flex-start; margin-bottom:18px; }
.brand h1 { margin:0; font-size:1.06rem; }
.brand p { margin:6px 0 0; font-size:.85rem; color:var(--muted); line-height:1.5; }
.brand-badge {
  width:48px; height:48px; border-radius:16px; display:grid; place-items:center; font-size:1.35rem;
  background: linear-gradient(135deg, #ffd4e8, #d9d0ff); box-shadow: var(--shadow);
}
.section-title { font-size:.82rem; color:var(--muted); margin-bottom:8px; text-transform:uppercase; letter-spacing:.08em; }
.nav-tabs { display:flex; gap:8px; margin-bottom:12px; }
.nav-tabs.multi-line { flex-wrap: wrap; }
.nav-btn, .soft-btn, .ghost-btn {
  border:1px solid var(--line); background:white; color:var(--text); border-radius:12px; padding:8px 12px; cursor:pointer;
}
.nav-btn.active, .soft-btn:hover { background: linear-gradient(135deg, #ffe5f1, #ece8ff); }
.ghost-btn { background: transparent; }
.tree-node, .list-item { padding:10px 11px; border-radius:12px; cursor:pointer; margin-bottom:4px; }
.tree-node:hover, .list-item:hover { background:#fff1f8; }
.tree-dir { font-weight:700; color:#91586f; margin-top:8px; }
.tree-file { padding-left:14px; color:var(--text); }
.main-area { display:flex; flex-direction:column; min-width:0; }
.topbar {
  position:sticky; top:0; z-index:20; display:grid; grid-template-columns:minmax(220px,1fr) minmax(340px,560px) auto;
  gap:16px; align-items:center; padding:16px 20px; background:rgba(255,248,252,0.93); backdrop-filter:blur(18px); border-bottom:1px solid var(--line);
}
.page-title { font-size:1.2rem; font-weight:800; letter-spacing:-.01em; }
.page-meta { color:var(--muted); font-size:.86rem; margin-top:4px; }
.topbar-right { display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap; }
.search-wrap { position:relative; }
.search-box {
  display:flex; align-items:center; gap:10px; border:1px solid var(--line); background:white; border-radius:14px; padding:11px 13px;
}
.search-box input { border:none; outline:none; width:100%; background:transparent; }
.top-search { box-shadow: var(--shadow); }
.search-popover {
  position:absolute; top:calc(100% + 8px); left:0; right:0; max-height:420px; overflow:auto;
  background:rgba(255,255,255,0.985); border:1px solid var(--line); border-radius:16px; box-shadow:var(--shadow-heavy); padding:8px;
}
.content-grid { padding:22px; }
.content-grid.single-focus { display:block; }
.reader-card {
  background:var(--panel); border:1px solid rgba(240,204,224,.92); border-radius:24px; box-shadow:var(--shadow); padding:16px;
  max-width: 1180px; margin: 0 auto;
}
.content-mode-label { font-size:.82rem; color:var(--muted); margin-bottom:10px; text-transform:uppercase; letter-spacing:.08em; }
.page-meta-badges { display:flex; flex-wrap:wrap; gap:8px; margin: 0 0 12px; }
.meta-badge {
  display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:999px;
  border:1px solid var(--line); background:white; color:#6a4f5d; font-size:.84rem;
}
.split-view { display:grid; gap:16px; min-height:0; }
.split-active { grid-template-columns:minmax(0,1.42fr) minmax(320px,.86fr); }
.split-readonly { grid-template-columns:minmax(0,1fr); }
.reader-stack { display:grid; gap:16px; min-width:0; }
.rendered-pane, .editor-pane {
  min-height:0; height:calc(100vh - 185px); overflow:auto; border:1px solid var(--line); border-radius:18px; background:white;
}
.rendered-pane {
  padding: 34px 40px;
  font-size: 18px;
  line-height: 1.82;
}
.editor-pane { padding:20px; resize:none; color:#412834; line-height:1.7; }
.markdown-body { color: var(--text); max-width: 820px; margin: 0 auto; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { color:#4b3140; letter-spacing:-0.015em; }
.markdown-body h1 { font-size: 2rem; margin-bottom: .8rem; }
.markdown-body h2 { font-size: 1.5rem; margin-top: 2.2rem; border-bottom: 1px solid #f4deea; padding-bottom: .4rem; }
.markdown-body p, .markdown-body li { color:#4e3643; }
.markdown-body blockquote {
  border-left: 4px solid #e9a6c8; background: #fff7fb; color:#7d5867; padding: 12px 16px; border-radius: 0 12px 12px 0;
}
.markdown-body pre {
  background: #fffafc !important; border:1px solid #f2dce7; border-radius:16px; padding:16px 18px; overflow:auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
}
.markdown-body :not(pre) > code {
  background: #fff3f9; color: #9f3e73; border:1px solid #f3d3e5; padding:2px 6px; border-radius:8px;
}
.markdown-body table { display:block; overflow:auto; border-radius:14px; }
.markdown-body table th { background:#fff5fa; }
.markdown-body a { color:#b65087; text-decoration:none; }
.markdown-body a:hover { text-decoration:underline; }
.link-chip, .search-item, .system-card, .news-day-card {
  border:1px solid var(--line); border-radius:14px; padding:11px; background:rgba(255,255,255,0.84); cursor:pointer;
}
.link-chip:hover, .search-item:hover, .list-item:hover { background:#fff1f7; }
.page-links-grid { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:14px; }
.link-panel { border:1px solid var(--line); border-radius:18px; background:#fffafc; padding:14px; }
.link-list { display:grid; gap:10px; }
.muted { color:var(--muted); }
.codeish {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size:.84rem; color:#6c4f60;
  background:#fff6fb; border:1px solid var(--line); border-radius:8px; padding:2px 6px;
}
.system-card { margin-bottom:8px; }
.status-dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:8px; }
.status-online { background:#48c78e; }
.status-errored, .status-stopped { background:#ff6b81; }
.graph-drawer {
  position: fixed; right: 18px; top: 18px; bottom: 18px; width: min(980px, calc(100vw - 40px));
  background: rgba(255,255,255,0.97); border:1px solid var(--line); border-radius:28px; box-shadow:var(--shadow-heavy);
  z-index: 50; display:flex; flex-direction:column; backdrop-filter: blur(20px);
}
.graph-drawer-header {
  display:flex; justify-content:space-between; align-items:center; gap:12px; padding:18px 20px 14px; border-bottom:1px solid var(--line);
}
.drawer-title { font-weight: 800; font-size: 1.1rem; }
.drawer-subtitle { color: var(--muted); font-size: .87rem; margin-top: 4px; }
.drawer-actions { display:flex; gap:8px; }
.graph-stage-wrap { padding: 16px 18px 6px; display:grid; grid-template-columns: minmax(0, 1fr) 180px; gap:14px; min-height:0; }
#graphCanvas {
  width: 100%; height: 100%; min-height: 560px; background: radial-gradient(circle at top, #fffefd, #fff7fb 62%, #fff3f8 100%);
  border:1px solid var(--line); border-radius:20px;
}
.graph-legend {
  display:flex; flex-direction:column; gap:10px; align-content:flex-start; overflow:auto;
}
.graph-legend-item {
  display:flex; align-items:center; gap:8px; font-size:.86rem; color:#5a4350; border:1px solid var(--line); border-radius:12px; padding:10px; background:#fff;
}
.legend-dot { width:12px; height:12px; border-radius:50%; }
.graph-detail {
  margin: 0 18px 18px; border:1px solid var(--line); background:#fffafc; border-radius:16px; padding:14px 16px; color:#5d4250; min-height:72px;
}
.news-day-card { margin-bottom: 10px; cursor: default; }
.news-item { margin-top: 8px; padding-top: 8px; border-top:1px dashed #efd9e6; cursor:pointer; }
.news-item:first-of-type { border-top:none; padding-top:0; }
@media (max-width: 1180px) {
  .app-shell { grid-template-columns:1fr; }
  .sidebar { position:static; height:auto; border-right:none; border-bottom:1px solid var(--line); }
  .topbar { grid-template-columns:1fr; }
  .topbar-right { justify-content:flex-start; }
  .split-active, .split-readonly { grid-template-columns:1fr; }
  .rendered-pane, .editor-pane { height: 430px; }
  .page-links-grid { grid-template-columns:1fr; }
  .graph-stage-wrap { grid-template-columns: 1fr; }
  .graph-drawer { left: 12px; right: 12px; top: 12px; bottom: 12px; width:auto; }
  #graphCanvas { min-height: 420px; }
}
