/*
 * Table & Code Block beauty layer for zizai.cc
 * Enhances Hexo highlight.js code blocks and Markdown tables
 * Works with Paper OS (zz-*) variables from huashu-polish.css
 */

/* ═══════════════════════════════════════════════
   CODE BLOCKS: .code-shell wrapper (Hexo codeblock tag)
   ═══════════════════════════════════════════════ */

/* Outer shell */
.upx-prose .code-shell {
  margin: 28px 0;
  border: 3px solid var(--zz-blue, #0284c7);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--zz-blue, #0284c7);
  background: #0f172a;
  overflow: hidden;
}

/* Top bar: language label + copy button */
.upx-prose .code-bar {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(2, 132, 199, .1);
  border-bottom: 2px solid rgba(2, 132, 199, .2);
  color: var(--zz-blue, #0284c7);
  font: 900 12px/1 var(--zz-mono, 'JetBrains Mono', monospace);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.upx-prose .code-bar span {
  color: var(--zz-blue, #0284c7);
  font: 900 12px/1 var(--zz-mono, 'JetBrains Mono', monospace);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.upx-prose .code-bar button {
  border: 2px solid var(--zz-blue, #0284c7);
  border-radius: 4px;
  background: var(--zz-yellow, #fde68a);
  box-shadow: 2px 2px 0 var(--zz-blue, #0284c7);
  color: var(--zz-blue, #0284c7);
  font: 900 11px/1 var(--zz-sans, sans-serif);
  padding: 4px 10px;
  cursor: pointer;
  transition: .12s transform, .12s box-shadow;
}
.upx-prose .code-bar button:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--zz-blue, #0284c7);
}

/* Code inside shell — scrollable! */
.upx-prose .code-shell pre,
.upx-prose .code-shell figure.highlight td.code pre {
  margin: 0;
  padding: 18px 20px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #0f172a !important;
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.7;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  white-space: pre !important;
  max-width: 100%;
}
.upx-prose .code-shell pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font-weight: 500;
  font-size: inherit;
}

/* When figure.highlight is INSIDE .code-shell, strip its own frame */
.upx-prose .code-shell figure.highlight,
.upx-prose .code-shell figure.highlight.csharp,
.upx-prose .code-shell figure.highlight.ts,
.upx-prose .code-shell figure.highlight.python {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  overflow: visible;
}
.upx-prose .code-shell figure.highlight::before {
  display: none !important;
}
.upx-prose .code-shell figure.highlight table {
  display: table;
  width: 100%;
}

/* ═══════════════════════════════════════════════
   CODE BLOCKS: figure.highlight (standalone, no code-shell)
   ═══════════════════════════════════════════════ */

.upx-prose figure.highlight {
  position: relative;
  margin: 28px 0;
  border: 3px solid var(--zz-blue, #0284c7);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--zz-blue, #0284c7);
  background: #0f172a;
  overflow: hidden;
}

/* Language badge ONLY when figure.highlight is NOT inside .code-shell */
.upx-prose figure.highlight:not(.code-shell figure.highlight)::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  background: var(--zz-yellow, #fde68a);
  border-bottom: 2px solid var(--zz-blue, #0284c7);
  border-left: 2px solid var(--zz-blue, #0284c7);
  border-radius: 0 5px 0 6px;
  color: var(--zz-blue, #0284c7);
  font: 900 11px/1 var(--zz-mono, 'JetBrains Mono', monospace);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.upx-prose figure.highlight.csharp:not(.code-shell figure.highlight)::before  { content: "C#"; }
.upx-prose figure.highlight.cs:not(.code-shell figure.highlight)::before      { content: "C#"; }
.upx-prose figure.highlight.typescript:not(.code-shell figure.highlight)::before { content: "TS"; }
.upx-prose figure.highlight.ts:not(.code-shell figure.highlight)::before      { content: "TS"; }
.upx-prose figure.highlight.javascript:not(.code-shell figure.highlight)::before { content: "JS"; }
.upx-prose figure.highlight.js:not(.code-shell figure.highlight)::before      { content: "JS"; }
.upx-prose figure.highlight.python:not(.code-shell figure.highlight)::before   { content: "PY"; }
.upx-prose figure.highlight.py:not(.code-shell figure.highlight)::before       { content: "PY"; }
.upx-prose figure.highlight.bash:not(.code-shell figure.highlight)::before     { content: "SH"; }
.upx-prose figure.highlight.shell:not(.code-shell figure.highlight)::before    { content: "SH"; }
.upx-prose figure.highlight.sh:not(.code-shell figure.highlight)::before       { content: "SH"; }
.upx-prose figure.highlight.json:not(.code-shell figure.highlight)::before     { content: "JSON"; }
.upx-prose figure.highlight.yaml:not(.code-shell figure.highlight)::before     { content: "YAML"; }
.upx-prose figure.highlight.yml:not(.code-shell figure.highlight)::before      { content: "YAML"; }
.upx-prose figure.highlight.xml:not(.code-shell figure.highlight)::before      { content: "XML"; }
.upx-prose figure.highlight.html:not(.code-shell figure.highlight)::before     { content: "HTML"; }
.upx-prose figure.highlight.css:not(.code-shell figure.highlight)::before      { content: "CSS"; }
.upx-prose figure.highlight.scss:not(.code-shell figure.highlight)::before     { content: "SCSS"; }
.upx-prose figure.highlight.sql:not(.code-shell figure.highlight)::before      { content: "SQL"; }
.upx-prose figure.highlight.c:not(.code-shell figure.highlight)::before        { content: "C"; }
.upx-prose figure.highlight.cpp:not(.code-shell figure.highlight)::before      { content: "C++"; }
.upx-prose figure.highlight.go:not(.code-shell figure.highlight)::before       { content: "GO"; }
.upx-prose figure.highlight.rust:not(.code-shell figure.highlight)::before     { content: "RS"; }
.upx-prose figure.highlight.java:not(.code-shell figure.highlight)::before     { content: "JAVA"; }
.upx-prose figure.highlight.dockerfile:not(.code-shell figure.highlight)::before { content: "DOCKER"; }
.upx-prose figure.highlight.markdown:not(.code-shell figure.highlight)::before { content: "MD"; }
.upx-prose figure.highlight.md:not(.code-shell figure.highlight)::before       { content: "MD"; }
.upx-prose figure.highlight.plaintext:not(.code-shell figure.highlight)::before { content: "TEXT"; }

/* Inner table layout */
.upx-prose figure.highlight table {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  width: 100%;
  display: table;
  white-space: pre;
  margin: 0;
}

/* Gutter (line numbers) */
.upx-prose figure.highlight td.gutter {
  width: 52px;
  min-width: 52px;
  padding: 18px 0;
  background: rgba(2, 132, 199, .08);
  border-right: 2px solid rgba(2, 132, 199, .22);
  text-align: center;
  vertical-align: top;
  user-select: none;
}
.upx-prose figure.highlight td.gutter pre {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  color: rgba(255, 255, 255, .3);
  font-size: 12px;
  line-height: 1.7;
  overflow: hidden;
}
.upx-prose figure.highlight td.gutter .line {
  display: block;
  color: rgba(255, 255, 255, .28);
  font-weight: 600;
}

/* Code cell — scrollable */
.upx-prose figure.highlight td.code {
  padding: 0;
  vertical-align: top;
  overflow: hidden;
}
.upx-prose figure.highlight td.code pre {
  margin: 0;
  padding: 18px 20px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}
.upx-prose figure.highlight td.code pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font-weight: 500;
  font-size: inherit;
  white-space: pre;
}

/* Syntax colors */
.upx-prose figure.highlight .keyword   { color: #c084fc; font-weight: 700; }
.upx-prose figure.highlight .type      { color: #67e8f9; }
.upx-prose figure.highlight .title     { color: #fbbf24; }
.upx-prose figure.highlight .params    { color: #94a3b8; }
.upx-prose figure.highlight .string    { color: #86efac; }
.upx-prose figure.highlight .comment   { color: #64748b; font-style: italic; }
.upx-prose figure.highlight .number    { color: #fdba74; }
.upx-prose figure.highlight .literal   { color: #fdba74; }
.upx-prose figure.highlight .built_in  { color: #67e8f9; }
.upx-prose figure.highlight .function  { color: #fbbf24; }
.upx-prose figure.highlight .attr      { color: #93c5fd; }
.upx-prose figure.highlight .selector-class { color: #86efac; }
.upx-prose figure.highlight .selector-tag   { color: #c084fc; }
.upx-prose figure.highlight .meta      { color: #94a3b8; }
.upx-prose figure.highlight .variable  { color: #e2e8f0; }
.upx-prose figure.highlight .addition  { color: #86efac; background: rgba(34, 197, 94, .1); }
.upx-prose figure.highlight .deletion  { color: #fca5a5; background: rgba(239, 68, 68, .1); }

/* ═══════════════════════════════════════════════
   CODE: Light mode — code blocks stay dark (readability)
   but bar/border adapt to light background
   ═══════════════════════════════════════════════ */

/* Light mode: code-bar background adapts */
.upx-prose .code-bar {
  background: rgba(2, 132, 199, .08);
  border-bottom-color: rgba(2, 132, 199, .2);
}

/* ═══════════════════════════════════════════════
   CODE: Dark mode
   ═══════════════════════════════════════════════ */

html[data-theme=dark] .upx-prose .code-shell {
  background: #0f172a;
  border-color: #38bdf8;
  box-shadow: 4px 4px 0 #38bdf8;
}
html[data-theme=dark] .upx-prose .code-bar {
  background: rgba(56, 189, 248, .08);
  border-bottom-color: rgba(56, 189, 248, .2);
}
html[data-theme=dark] .upx-prose .code-bar span {
  color: #38bdf8;
}
html[data-theme=dark] .upx-prose .code-bar button {
  background: #facc15;
  border-color: #38bdf8;
  color: #38bdf8;
}
html[data-theme=dark] .upx-prose .code-shell pre {
  background: #0f172a;
  color: #e2e8f0;
}

html[data-theme=dark] .upx-prose figure.highlight {
  background: #0f172a;
  border-color: #38bdf8;
  box-shadow: 4px 4px 0 #38bdf8;
}
html[data-theme=dark] .upx-prose figure.highlight:not(.code-shell figure.highlight)::before {
  background: #facc15;
  border-color: #38bdf8;
  color: #38bdf8;
}
html[data-theme=dark] .upx-prose figure.highlight td.gutter {
  background: rgba(56, 189, 248, .06);
  border-right-color: rgba(56, 189, 248, .18);
}
html[data-theme=dark] .upx-prose figure.highlight td.gutter .line {
  color: rgba(255, 255, 255, .22);
}
html[data-theme=dark] .upx-prose figure.highlight td.code pre {
  background: #0f172a;
  color: #e2e8f0;
}

/* ═══════════════════════════════════════════════
   TABLES: enhanced Markdown content tables
   ═══════════════════════════════════════════════ */

.upx-prose > table:not(figure table),
.upx-prose > div > table:not(figure table) {
  display: table;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 3px solid var(--zz-blue, #0284c7);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--zz-blue, #0284c7);
  background: var(--zz-card, #fffdf8);
  overflow: hidden;
  margin: 28px 0;
  font-size: 15px;
}

.upx-prose table:not(figure table) thead tr {
  background: linear-gradient(135deg, var(--zz-yellow, #fde68a), #fcd34d);
}
.upx-prose table:not(figure table) th {
  background: transparent;
  color: var(--zz-blue, #0284c7);
  font-weight: 950;
  font-size: 14px;
  letter-spacing: .02em;
  padding: 14px 16px;
  border-bottom: 3px solid var(--zz-blue, #0284c7);
  text-align: left;
  white-space: nowrap;
}
.upx-prose table:not(figure table) thead tr th:first-child {
  border-top-left-radius: 5px;
}
.upx-prose table:not(figure table) thead tr th:last-child {
  border-top-right-radius: 5px;
}

.upx-prose table:not(figure table) td {
  padding: 12px 16px;
  border-bottom: 1.5px solid rgba(2, 132, 199, .12);
  color: var(--zz-ink, #263648);
  font-size: 15px;
  line-height: 1.6;
  vertical-align: top;
}
.upx-prose table:not(figure table) tbody tr:nth-child(even) {
  background: rgba(2, 132, 199, .04);
}
.upx-prose table:not(figure table) tbody tr:hover {
  background: rgba(2, 132, 199, .08);
}
.upx-prose table:not(figure table) tbody tr:last-child td {
  border-bottom: 0;
}
.upx-prose table:not(figure table) tbody tr:last-child td:first-child {
  border-bottom-left-radius: 5px;
}
.upx-prose table:not(figure table) tbody tr:last-child td:last-child {
  border-bottom-right-radius: 5px;
}

/* Table dark mode */
html[data-theme=dark] .upx-prose table:not(figure table) {
  background: var(--zz-card, #172536);
  border-color: #38bdf8;
  box-shadow: 4px 4px 0 #38bdf8;
}
html[data-theme=dark] .upx-prose table:not(figure table) thead tr {
  background: linear-gradient(135deg, rgba(250, 204, 21, .15), rgba(250, 204, 21, .08));
}
html[data-theme=dark] .upx-prose table:not(figure table) th {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
}
html[data-theme=dark] .upx-prose table:not(figure table) td {
  color: #e8f1f8;
  border-bottom-color: rgba(56, 189, 248, .12);
}
html[data-theme=dark] .upx-prose table:not(figure table) tbody tr:nth-child(even) {
  background: rgba(56, 189, 248, .04);
}
html[data-theme=dark] .upx-prose table:not(figure table) tbody tr:hover {
  background: rgba(56, 189, 248, .08);
}

/* ═══════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════ */

@media (max-width: 640px) {
  .upx-prose > table:not(figure table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 13px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--zz-blue, #0284c7);
  }
  .upx-prose table:not(figure table) th,
  .upx-prose table:not(figure table) td {
    padding: 10px 12px;
    min-width: 100px;
  }

  .upx-prose .code-shell,
  .upx-prose figure.highlight {
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--zz-blue, #0284c7);
  }
  .upx-prose .code-bar {
    height: 32px;
    padding: 0 10px;
  }
  .upx-prose .code-bar span {
    font-size: 10px;
  }
  .upx-prose .code-shell pre {
    padding: 14px 12px;
    font-size: 13px;
  }
  .upx-prose figure.highlight td.gutter {
    width: 40px;
    min-width: 40px;
    padding: 14px 0;
  }
  .upx-prose figure.highlight td.gutter pre {
    font-size: 11px;
  }
  .upx-prose figure.highlight td.code pre {
    padding: 14px 12px;
    font-size: 13px;
  }
  .upx-prose figure.highlight:not(.code-shell figure.highlight)::before {
    font-size: 10px;
    height: 26px;
    padding: 0 8px;
  }
}


/* ═══════════════════════════════════════════════
   CODE BLOCKS v2: IDE-style header, language pill, copy affordance
   ═══════════════════════════════════════════════ */
.upx-prose .code-shell {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(14, 165, 233, .42);
  box-shadow: 0 18px 45px rgba(15, 23, 42, .18), 0 0 0 1px rgba(255,255,255,.04) inset;
  background:
    radial-gradient(circle at 16px 10px, rgba(56,189,248,.22), transparent 180px),
    linear-gradient(180deg, #111827 0%, #0f172a 100%);
  overflow: hidden;
}
.upx-prose .code-shell::before {
  content: "";
  position: absolute;
  inset: 38px 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56,189,248,.45), transparent);
  pointer-events: none;
}
.upx-prose .code-bar {
  height: 42px;
  padding: 0 12px 0 14px;
  background: linear-gradient(180deg, rgba(30,41,59,.96), rgba(15,23,42,.92));
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  color: #cbd5e1;
}
.upx-prose .code-bar-left {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}
.upx-prose .code-dots {
  display: inline-flex;
  gap: 6px;
  flex: 0 0 auto;
}
.upx-prose .code-dots i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,.15) inset;
}
.upx-prose .code-dots i:nth-child(1) { background: #fb7185; }
.upx-prose .code-dots i:nth-child(2) { background: #fbbf24; }
.upx-prose .code-dots i:nth-child(3) { background: #34d399; }
.upx-prose .code-lang,
.upx-prose .code-bar span.code-lang {
  display: inline-flex;
  align-items: center;
  max-width: 46vw;
  height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(56,189,248,.28);
  border-radius: 999px;
  background: rgba(14,165,233,.10);
  color: #7dd3fc;
  font: 800 11px/1 var(--zz-mono, 'JetBrains Mono', monospace);
  letter-spacing: .055em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upx-prose .code-copy,
.upx-prose .code-bar button {
  border: 1px solid rgba(125, 211, 252, .45);
  border-radius: 999px;
  background: rgba(2, 132, 199, .14);
  box-shadow: none;
  color: #e0f2fe;
  font: 800 12px/1 var(--zz-sans, sans-serif);
  padding: 7px 12px;
  cursor: pointer;
  transition: .15s ease;
}
.upx-prose .code-copy:hover,
.upx-prose .code-bar button:hover {
  transform: translateY(-1px);
  background: rgba(14, 165, 233, .24);
  border-color: rgba(125, 211, 252, .75);
}
.upx-prose .code-copy.copied {
  color: #86efac;
  border-color: rgba(134,239,172,.65);
  background: rgba(22,163,74,.16);
}
.upx-prose .code-shell pre,
.upx-prose .code-shell figure.highlight td.code pre,
.upx-prose figure.highlight td.code pre {
  padding: 20px 22px;
  color: #e5e7eb;
  font-size: 14px;
  line-height: 1.78;
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: rgba(56,189,248,.55) rgba(15,23,42,.8);
}
.upx-prose .code-shell pre::-webkit-scrollbar,
.upx-prose figure.highlight td.code pre::-webkit-scrollbar { height: 9px; }
.upx-prose .code-shell pre::-webkit-scrollbar-track,
.upx-prose figure.highlight td.code pre::-webkit-scrollbar-track { background: rgba(15,23,42,.8); }
.upx-prose .code-shell pre::-webkit-scrollbar-thumb,
.upx-prose figure.highlight td.code pre::-webkit-scrollbar-thumb {
  background: rgba(56,189,248,.55);
  border-radius: 999px;
}
.upx-prose figure.highlight td.gutter {
  background: rgba(15, 23, 42, .72);
  border-right: 1px solid rgba(148, 163, 184, .15);
}
.upx-prose figure.highlight td.gutter .line {
  color: rgba(203,213,225,.38);
}
.upx-prose figure.highlight:not(.code-shell figure.highlight)::before {
  top: 9px;
  right: 10px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid rgba(56,189,248,.28);
  border-radius: 999px;
  background: rgba(14,165,233,.14);
  color: #7dd3fc;
}
.upx-prose figure.highlight .keyword,
.upx-prose figure.highlight .selector-tag,
.upx-prose figure.highlight .subst { color: #c084fc; font-weight: 700; }
.upx-prose figure.highlight .type,
.upx-prose figure.highlight .built_in,
.upx-prose figure.highlight .name { color: #67e8f9; }
.upx-prose figure.highlight .title,
.upx-prose figure.highlight .section { color: #fbbf24; font-weight: 650; }
.upx-prose figure.highlight .string,
.upx-prose figure.highlight .regexp,
.upx-prose figure.highlight .symbol { color: #86efac; }
.upx-prose figure.highlight .comment,
.upx-prose figure.highlight .quote { color: #64748b; font-style: italic; }
.upx-prose figure.highlight .number,
.upx-prose figure.highlight .literal { color: #fdba74; }
.upx-prose figure.highlight .attr,
.upx-prose figure.highlight .attribute { color: #93c5fd; }
.upx-prose figure.highlight .params,
.upx-prose figure.highlight .meta { color: #94a3b8; }

@media (max-width: 640px) {
  .upx-prose .code-shell { border-radius: 12px; }
  .upx-prose .code-bar { height: 38px; padding: 0 9px 0 11px; }
  .upx-prose .code-dots { gap: 4px; }
  .upx-prose .code-dots i { width: 8px; height: 8px; }
  .upx-prose .code-lang,
  .upx-prose .code-bar span.code-lang { max-width: 38vw; height: 22px; font-size: 10px; padding: 0 7px; }
  .upx-prose .code-copy,
  .upx-prose .code-bar button { padding: 6px 9px; font-size: 11px; }
  .upx-prose .code-shell pre,
  .upx-prose .code-shell figure.highlight td.code pre,
  .upx-prose figure.highlight td.code pre { padding: 16px 14px; font-size: 13px; line-height: 1.72; }
}

/* ═══════════════════════════════════════════════
   KNOWLEDGE GRAPH
   ═══════════════════════════════════════════════ */

.kg-container {
  position: relative;
  border: 3px solid var(--zz-blue, #0284c7);
  border-radius: 8px;
  background: #0c1a2e;
  box-shadow: 4px 4px 0 var(--zz-blue, #0284c7);
  overflow: hidden;
  margin: 22px 0 48px;
}
html[data-theme=dark] .kg-container {
  background: #0a1628;
  border-color: #38bdf8;
}

.kg-legend {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 2;
  display: flex;
  gap: 16px;
  padding: 6px 14px;
  border: 2px solid rgba(56, 189, 248, .3);
  border-radius: 4px;
  background: rgba(12, 26, 46, .85);
  backdrop-filter: blur(8px);
}
.kg-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, .7);
  font-size: 12px;
  font-weight: 700;
}
.kg-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.kg-dot-cat { background: #fbbf24; }
.kg-dot-post { background: #38bdf8; }
.kg-dot-tag { background: #a78bfa; }

.kg-tooltip {
  display: none;
  position: absolute;
  z-index: 10;
  padding: 8px 12px;
  border: 2px solid var(--zz-blue, #38bdf8);
  border-radius: 4px;
  background: rgba(12, 26, 46, .92);
  backdrop-filter: blur(8px);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgba(56, 189, 248, .3);
}
.kg-tooltip strong {
  color: #38bdf8;
  font-weight: 900;
}

#knowledge-graph {
  display: block;
  width: 100%;
}

@media (max-width: 640px) {
  .kg-legend {
    gap: 10px;
    padding: 4px 10px;
  }
  .kg-legend-item {
    font-size: 10px;
  }
}

/* ═══════════════════════════════════════════════
   BACK TO TOP
   ═══════════════════════════════════════════════ */

.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 3px solid var(--zz-blue, #0284c7);
  border-radius: 50%;
  background: var(--zz-card, #fffdf8);
  box-shadow: 3px 3px 0 var(--zz-blue, #0284c7),
              0 4px 20px rgba(0, 0, 0, .12);
  color: var(--zz-blue, #0284c7);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: .25s opacity, .25s visibility, .25s transform, .12s box-shadow;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0 var(--zz-blue, #0284c7),
              0 8px 30px rgba(0, 0, 0, .18);
}
.back-to-top:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--zz-blue, #0284c7);
}

html[data-theme=dark] .back-to-top {
  background: var(--zz-card, #172536);
  border-color: #38bdf8;
  box-shadow: 3px 3px 0 #38bdf8,
              0 4px 20px rgba(0, 0, 0, .3);
  color: #38bdf8;
}
html[data-theme=dark] .back-to-top:hover {
  box-shadow: 4px 4px 0 #38bdf8,
              0 8px 30px rgba(0, 0, 0, .4);
}

@media (max-width: 640px) {
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
  }
  .back-to-top svg {
    width: 18px;
    height: 18px;
  }
}

/* ═══════════════════════════════════════════════
   SEARCH OVERLAY (kept for reference, search removed)
   ═══════════════════════════════════════════════ */

html[data-theme=dark] .search-card {
  background: var(--zz-card, #172536) !important;
  border-color: #38bdf8 !important;
}
html[data-theme=dark] .search-input-wrap {
  background: var(--zz-paper, #111f2b) !important;
  border-bottom-color: #38bdf8 !important;
}
html[data-theme=dark] .search-input-wrap svg {
  fill: #38bdf8 !important;
}
html[data-theme=dark] .search-input-wrap input {
  color: #ffffff !important;
}
html[data-theme=dark] .search-input-wrap button,
html[data-theme=dark] .search-card .icon-button {
  background: #facc15 !important;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
}
html[data-theme=dark] .search-hint,
html[data-theme=dark] .search-card p {
  background: var(--zz-paper, #111f2b) !important;
  color: #7f95a7 !important;
}
html[data-theme=dark] .search-results {
  background: var(--zz-card, #172536) !important;
}
html[data-theme=dark] .search-result:hover {
  background: var(--zz-paper, #111f2b) !important;
  border-color: #38bdf8 !important;
}
html[data-theme=dark] .search-result strong {
  color: #ffffff !important;
}
html[data-theme=dark] .search-result span {
  color: #a9bac9 !important;
}
html[data-theme=dark] .upx-search-inline {
  background: var(--zz-card, #172536) !important;
  border-color: #38bdf8 !important;
}
html[data-theme=dark] .upx-search-inline input {
  background: var(--zz-paper, #111f2b) !important;
  border-color: rgba(56, 189, 248, .28) !important;
  color: #e8f1f8 !important;
}
