/* Панда-Дхамма */
:root {
  --bg: #f6f0e2;
  --bg2: #efe6d0;
  --ink: #2c2418;
  --ink-soft: #6b5d45;
  --accent: #b3422f;
  --gold: #c9a227;
  --panel-bg: #fffdf6;
  --line: #cdbfa3;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Georgia, 'Times New Roman', serif;
  background: radial-gradient(ellipse at 30% 20%, var(--bg) 0%, var(--bg2) 100%);
  color: var(--ink);
  overflow: hidden;
}

/* ── шапка ── */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: linear-gradient(to bottom, rgba(246,240,226,.96), rgba(246,240,226,.82) 75%, transparent);
  pointer-events: none;
}
header > * { pointer-events: auto; }
.brand h1 {
  font-size: 21px; font-weight: 700; letter-spacing: .5px;
  color: var(--accent);
}
.brand h1 .yy { color: var(--ink); }
.brand .tag { font-size: 12.5px; color: var(--ink-soft); font-style: italic; }

.toolbar { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#search {
  font: inherit; font-size: 14px;
  padding: 7px 12px; width: 210px;
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--panel-bg); color: var(--ink);
  outline: none;
}
#search:focus { border-color: var(--gold); }
#tourbtn {
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 7px 14px; border-radius: 18px;
  border: 1px solid var(--accent);
  background: var(--accent); color: #fff;
  transition: background .2s;
}
#tourbtn:hover { background: #93351f; }
#tourbtn.active { background: var(--ink); border-color: var(--ink); }

/* ── легенда ── */
#legend {
  position: fixed; left: 14px; bottom: 14px; z-index: 20;
  display: flex; flex-direction: column; gap: 5px;
}
.leg {
  font: inherit; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 8px; border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--panel-bg); color: var(--ink-soft);
  opacity: .45; transition: opacity .15s;
  text-align: left;
}
.leg.on { opacity: 1; color: var(--ink); }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; }

/* ── зум ── */
#zoomctl {
  position: fixed; right: 14px; bottom: 14px; z-index: 20;
  display: flex; flex-direction: column; gap: 5px;
}
#zoomctl button {
  width: 36px; height: 36px; font-size: 17px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-bg); color: var(--ink);
}
#zoomctl button:hover { border-color: var(--gold); }

/* ── граф ── */
#graph { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }
.edge {
  stroke: #a89878; stroke-width: 1.1; opacity: .5;
  transition: opacity .2s, stroke .2s;
  cursor: pointer;
}
.edge.hl { stroke: var(--accent); stroke-width: 2.2; opacity: .95; }
.edge.dim { opacity: .08; }
.edge.hidden { display: none; }

.node { cursor: pointer; transition: opacity .2s; }
.node circle {
  stroke: rgba(44,36,24,.45); stroke-width: 1.4;
  transition: stroke .15s, stroke-width .15s;
}
.node:hover circle { stroke: var(--ink); stroke-width: 2.4; }
.node.selected circle { stroke: var(--accent); stroke-width: 3.4; }
.node.dim { opacity: .18; }
.node.hidden { display: none; }
.node text {
  font-family: Georgia, serif; font-size: 13.5px;
  text-anchor: middle; fill: var(--ink);
  paint-order: stroke; stroke: rgba(246,240,226,.85); stroke-width: 3.5px;
  pointer-events: none;
}
.node.selected text { font-weight: 700; fill: var(--accent); }

/* ── подсказка ребра ── */
#edgetip {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%) translateY(8px);
  z-index: 25; max-width: 80vw;
  padding: 8px 16px; border-radius: 18px;
  background: var(--ink); color: #f6f0e2;
  font-size: 13.5px; font-style: italic;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
#edgetip.show { opacity: .95; transform: translateX(-50%) translateY(0); }

/* ── панель ── */
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 30;
  width: min(440px, 92vw);
  background: var(--panel-bg);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(44,36,24,.14);
  padding: 26px 26px 40px;
  overflow-y: auto;
  transform: translateX(105%);
  transition: transform .3s cubic-bezier(.2,.8,.25,1);
}
#panel.open { transform: translateX(0); }
#panel .close {
  position: absolute; top: 12px; right: 14px;
  width: 34px; height: 34px; font-size: 20px; cursor: pointer;
  border: none; border-radius: 50%;
  background: var(--bg2); color: var(--ink);
}
#panel .cat-tag {
  display: inline-block; font-size: 11.5px; letter-spacing: .8px;
  text-transform: uppercase; color: #fff;
  padding: 3px 11px; border-radius: 11px; margin-bottom: 10px;
}
#panel h2 { font-size: 27px; color: var(--accent); line-height: 1.15; }
#panel .sub { font-size: 14.5px; color: var(--ink-soft); font-style: italic; margin: 3px 0 14px; }
#panel .desc p { font-size: 14.5px; line-height: 1.62; margin-bottom: 11px; }
#panel .desc b { color: var(--accent); }
#panel blockquote {
  margin: 16px 0; padding: 12px 16px;
  border-left: 3px solid var(--gold);
  background: var(--bg);
  font-style: italic; font-size: 14px; line-height: 1.55;
  color: var(--ink-soft);
  border-radius: 0 8px 8px 0;
}
#panel h3 {
  font-size: 15px; margin: 20px 0 10px;
  letter-spacing: .5px; color: var(--ink);
  border-top: 1px solid var(--line); padding-top: 16px;
}
#panel h3 .count {
  font-size: 12px; background: var(--bg2); border-radius: 10px;
  padding: 1px 8px; color: var(--ink-soft); font-weight: 400;
}
.conns { list-style: none; }
.conns li {
  display: grid; grid-template-columns: 15px auto; grid-template-rows: auto auto;
  column-gap: 8px; align-items: baseline;
  padding: 7px 9px; margin-bottom: 4px;
  border-radius: 8px; cursor: pointer;
  transition: background .12s;
}
.conns li:hover { background: var(--bg); }
.conns li .dot { grid-row: 1; position: relative; top: 1px; }
.conns li b { font-size: 14px; }
.conns li em { grid-column: 2; font-size: 12.5px; color: var(--ink-soft); }

/* ── тур ── */
#tourbar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(120%);
  z-index: 35; width: min(640px, 94vw);
  display: flex; align-items: stretch; gap: 8px;
  transition: transform .35s cubic-bezier(.2,.8,.25,1);
}
#tourbar.show { transform: translateX(-50%) translateY(0); }
#tourbar .tnote {
  flex: 1; background: var(--ink); color: #f3ecdb;
  border-radius: 14px; padding: 13px 18px;
  font-size: 14.5px; line-height: 1.5;
  box-shadow: 0 6px 24px rgba(44,36,24,.3);
}
#tourbar .tprog { font-size: 11.5px; opacity: .6; margin-top: 5px; }
#tourbar button {
  width: 46px; font-size: 22px; cursor: pointer;
  border: none; border-radius: 14px;
  background: var(--accent); color: #fff;
}
#tourbar button:disabled { opacity: .35; cursor: default; }

/* ── интро ── */
#intro {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(44,36,24,.45); backdrop-filter: blur(3px);
  transition: opacity .35s; padding: 16px;
}
#intro.hide { opacity: 0; pointer-events: none; }
.intro-card {
  max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--panel-bg); border-radius: 18px;
  padding: 36px 40px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.intro-card .sym { font-size: 44px; }
.intro-card h2 { font-size: 28px; color: var(--accent); margin: 8px 0 4px; }
.intro-card .epigraph {
  font-style: italic; color: var(--ink-soft); font-size: 14px;
  margin: 10px 0 18px; line-height: 1.5;
}
.intro-card p { font-size: 15px; line-height: 1.6; margin-bottom: 12px; text-align: left; }
.intro-stats {
  display: flex; justify-content: center; gap: 28px; margin: 18px 0;
}
.intro-stats div { text-align: center; }
.intro-stats .num { font-size: 26px; font-weight: 700; color: var(--gold); }
.intro-stats .lbl { font-size: 12px; color: var(--ink-soft); }
.intro-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.intro-actions button {
  font: inherit; font-size: 15px; cursor: pointer;
  padding: 11px 24px; border-radius: 22px;
}
#introtour { background: var(--accent); color: #fff; border: none; }
#introtour:hover { background: #93351f; }
#introclose { background: transparent; border: 1px solid var(--line); color: var(--ink); }

/* ── футер-кредит ── */
#credit {
  position: fixed; right: 16px; top: 64px; z-index: 18;
  font-size: 11.5px; color: var(--ink-soft); opacity: .75;
  writing-mode: vertical-rl; letter-spacing: 1px;
}

/* ── мобильное ── */
@media (max-width: 720px) {
  header { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand h1 { font-size: 17px; }
  .brand .tag { display: none; }
  #search { width: 140px; font-size: 13px; }
  #tourbtn { font-size: 13px; padding: 6px 11px; }
  #legend { flex-direction: row; flex-wrap: wrap; left: 8px; right: 60px; bottom: 8px; }
  .leg { font-size: 11px; padding: 4px 8px 4px 6px; }
  #panel { width: 100vw; border-left: none; }
  #credit { display: none; }
  .intro-card { padding: 26px 22px; }
}
