:root {
  --bg: #0b1020;
  --panel: #121a2f;
  --panel-2: #18233d;
  --border: #24314f;
  --text: #e8eefc;
  --muted: #93a0c0;
  --accent: #818cf8;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --shadow: 0 10px 40px rgba(0,0,0,.35);
  --radius: 14px;
  --sidebar-w: 260px;
  --font: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2450 0%, transparent 50%),
              radial-gradient(900px 500px at 100% 0%, #0f3a4a 0%, transparent 45%),
              var(--bg);
  color: var(--text);
  overflow: hidden;
}
#app { display: flex; height: 100%; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #10182c, #0d1426);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  z-index: 20;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 800; color: #0b1020;
  box-shadow: 0 0 24px rgba(129,140,248,.35);
}
.brand-title { font-weight: 700; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: auto; }
.nav-item, .nav-sub {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: 14px;
  transition: .15s ease;
}
.nav-item:hover, .nav-sub:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active, .nav-sub.active {
  background: linear-gradient(90deg, rgba(129,140,248,.18), transparent);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-sub { padding-left: 36px; font-size: 13px; }
.nav-children { display: none; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.nav-group.open .nav-children { display: flex; }
.icon { width: 1.2em; text-align: center; opacity: .9; }
.badge {
  margin-left: auto; font-style: normal; font-size: 10px;
  background: #24314f; color: var(--warn); padding: 2px 6px; border-radius: 999px;
}
.sidebar-foot { font-size: 11px; color: #66748f; padding: 12px 8px 4px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 18px; border-bottom: 1px solid var(--border);
  background: rgba(11,16,32,.65); backdrop-filter: blur(10px);
}
.menu-toggle {
  display: none; background: var(--panel); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; width: 36px; height: 36px; cursor: pointer;
}
.breadcrumb { font-weight: 600; font-size: 15px; }
.topbar-right { margin-left: auto; }
.pill {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  background: rgba(34,211,238,.12); color: var(--accent-2);
  border: 1px solid rgba(34,211,238,.25);
}
.content { flex: 1; overflow: auto; padding: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.hero { padding: 28px; margin-bottom: 18px; }
.hero h1 { margin: 0 0 8px; font-size: 26px; }
.hero p { margin: 0; color: var(--muted); line-height: 1.6; max-width: 720px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.tile {
  padding: 18px; text-decoration: none; color: inherit;
  transition: .15s ease; display: block;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile h3 { margin: 0 0 6px; font-size: 16px; }
.tile p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.tile .tag {
  display: inline-block; margin-top: 12px; font-size: 11px;
  color: var(--accent); background: rgba(129,140,248,.12);
  padding: 3px 8px; border-radius: 999px;
}
.demo-wrap {
  display: grid; grid-template-rows: auto 1fr; height: calc(100vh - 56px - 40px);
  gap: 12px; min-height: 480px;
}
.demo-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 14px;
}
.demo-toolbar h2 { margin: 0; font-size: 16px; flex: 1; }
.btn {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.canvas-host {
  position: relative; overflow: hidden; min-height: 420px;
  background: #060a14;
}
.canvas-host canvas { display: block; width: 100% !important; height: 100% !important; }
.placeholder {
  padding: 40px 28px; text-align: center; color: var(--muted);
}
.placeholder h2 { color: var(--text); margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); }
@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-grid; place-items: center; }
}

/* UI component demos */
.ui-demo { color: var(--text); }
.ui-demo h3 { margin: 0 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; }
.ui-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; align-items: center; }
.u-btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  transition: .15s ease;
}
.u-btn:hover { border-color: var(--accent); }
.u-btn.primary { background: linear-gradient(135deg, #6366f1, #22d3ee); color: #0b1020; border: none; font-weight: 600; }
.u-btn.ghost { background: transparent; }
.u-btn.danger { background: #7f1d1d; border-color: #b91c1c; }
.u-btn:disabled { opacity: .45; cursor: not-allowed; }
.u-btn.sm { padding: 5px 10px; font-size: 12px; }
.u-btn.lg { padding: 12px 18px; font-size: 15px; }
.ui-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.u-card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px;
}
.u-card h3 { margin: 0 0 8px; color: var(--text); font-size: 16px; }
.u-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.u-card.accent { border-color: rgba(129,140,248,.55); box-shadow: inset 0 0 0 1px rgba(129,140,248,.15); }
.u-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.55);
  display: grid; place-items: center; z-index: 5;
}
.u-modal {
  width: min(420px, 92%); background: #121a2f; border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; box-shadow: var(--shadow);
}
.u-modal h3 { margin: 0 0 8px; color: var(--text); }
.u-modal p { margin: 0 0 16px; color: var(--muted); line-height: 1.55; }
.canvas-host { position: relative; }

/* ---- v2: categories, overview, mobile ---- */
.nav-item .count {
  margin-left: auto; font-style: normal; font-size: 10px; color: var(--muted);
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 999px;
}
.nav-item.active .count { color: var(--accent); border-color: rgba(129,140,248,.4); }
.tile-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tile-head h3 { margin: 0; }
.tile-icon {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(129,140,248,.25), rgba(34,211,238,.15));
  border: 1px solid var(--border); font-size: 15px; flex: none;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; color: var(--muted);
  border: 1px solid var(--border); background: rgba(255,255,255,.03);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.chip.accent { color: var(--accent-2); border-color: rgba(34,211,238,.3); }
.stats { display: flex; gap: 28px; margin-top: 18px; flex-wrap: wrap; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 26px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats span { font-size: 12px; color: var(--muted); }
.overview { margin-top: 18px; padding: 20px; }
.overview h2 { margin: 0 0 12px; font-size: 17px; }
.table-wrap { overflow-x: auto; }
.overview table { width: 100%; border-collapse: collapse; font-size: 13px; }
.overview th, .overview td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.overview th { color: var(--muted); font-weight: 600; font-size: 12px; }
.overview td a { color: var(--text); text-decoration: none; white-space: nowrap; }
.overview td a:hover { color: var(--accent); }
.overview .num { text-align: center; width: 60px; }
.overview .muted { color: var(--muted); }
a.btn { text-decoration: none; display: inline-block; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
.loading.err { color: #fca5a5; }
.sidebar-backdrop { display: none; }
.demo-wrap { height: calc(100vh - 56px - 40px); height: calc(100dvh - 56px - 40px); }
.canvas-host > .fx-root { position: absolute; inset: 0; }
.canvas-host .fx-scroll { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.fx-bar {
  position: absolute; left: 12px; top: 12px; z-index: 3; display: flex; gap: 6px; flex-wrap: wrap;
  max-width: calc(100% - 24px);
}
.fx-bar .btn, .fx-bar select, .fx-bar input[type=color] { background: rgba(18,26,47,.85); backdrop-filter: blur(6px); }
.fx-bar select { color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; font-size: 12px; }
.fx-bar input[type=color] { width: 34px; height: 30px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.fx-bar input[type=range] { width: 110px; }
.fx-bar label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; background: rgba(18,26,47,.85); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; }
.btn.on { border-color: var(--accent); color: var(--accent); }
@media (max-width: 860px) {
  .sidebar { width: min(280px, 84vw); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 15; }
  .content { padding: 12px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 22px; }
  .demo-wrap { height: calc(100dvh - 56px - 24px); min-height: 420px; }
  .demo-toolbar .hint { width: 100%; order: 5; }
  .canvas-host { min-height: 360px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }
