/* ─── 中保通 · интерактивни блокови схеми (.zbt-diagram → .zd-root) ─────────── */
/* raw spec скрит (рендерерът го заменя; без JS не показваме суров JSON) */
.content pre.zbt-diagram { display: none; }

.zd-root{
  --zd-bg:#fbf8f7; --zd-surface:#fff; --zd-surface2:#f5eeeb; --zd-ink:#241c1a; --zd-soft:#6b5c58;
  --zd-line:#e8dcd7; --zd-accent:#D04A2E; --zd-accent-soft:#f7e4de;
  --zd-subj:#3a6ea5; --zd-opt:#b07d2b; --zd-ba:#D04A2E; --zd-obj:#2e7d66; --zd-verb:#6a4c93; --zd-other:#5a6b7a;
  --zd-good:#2e7d5b; --zd-bad:#c0392b;
  --zd-cjk:'Noto Sans SC','PingFang SC','Microsoft YaHei',sans-serif;
  margin:1.2em 0; padding:20px; background:var(--zd-surface); color:var(--zd-ink);
  border:1px solid var(--zd-line); border-radius:16px;
  box-shadow:0 1px 2px rgba(60,30,20,.05),0 8px 26px rgba(60,30,20,.07);
}
:root.skin-theme-clientpref-night .zd-root{
  --zd-bg:#17110f; --zd-surface:#201815; --zd-surface2:#2a201c; --zd-ink:#f3e9e5; --zd-soft:#b7a49d;
  --zd-line:#3a2c27; --zd-accent:#e8674a; --zd-accent-soft:#3a211a;
  --zd-subj:#7fa9d6; --zd-opt:#d6a24e; --zd-ba:#e8674a; --zd-obj:#5fbf9f; --zd-verb:#a98cd6; --zd-other:#93a4b3;
  --zd-good:#57c99b; --zd-bad:#e8756a;
  box-shadow:0 1px 2px rgba(0,0,0,.3),0 8px 26px rgba(0,0,0,.4);
}
@media (prefers-color-scheme:dark){:root.skin-theme-clientpref-os .zd-root{
  --zd-bg:#17110f; --zd-surface:#201815; --zd-surface2:#2a201c; --zd-ink:#f3e9e5; --zd-soft:#b7a49d;
  --zd-line:#3a2c27; --zd-accent:#e8674a; --zd-accent-soft:#3a211a;
  --zd-subj:#7fa9d6; --zd-opt:#d6a24e; --zd-ba:#e8674a; --zd-obj:#5fbf9f; --zd-verb:#a98cd6; --zd-other:#93a4b3;
  --zd-good:#57c99b; --zd-bad:#e8756a;
}}
.zd-root .zh{ font-family:var(--zd-cjk); }
.zd-root *{ box-sizing:border-box; }

.zd-title{ font-size:1.3rem; font-weight:600; margin-bottom:2px; }
.zd-title .zh{ color:var(--zd-accent); }
.zd-title .zd-sub{ font-size:.9rem; color:var(--zd-soft); font-weight:400; }
.zd-label{ font-size:.72rem; text-transform:uppercase; letter-spacing:.1em; color:var(--zd-soft);
  font-weight:700; margin:16px 0 7px; }
.zd-label.zd-center{ text-align:center; }

/* toolbar / buttons */
.zd-bar{ display:flex; flex-wrap:wrap; gap:8px; margin:12px 0 4px; }
.zd-btn{ font:inherit; font-size:.85rem; cursor:pointer; border:1px solid var(--zd-line);
  background:var(--zd-surface2); color:var(--zd-ink); border-radius:8px; padding:6px 13px;
  transition:background .15s,border-color .15s,color .15s,opacity .15s; }
.zd-btn:hover{ border-color:var(--zd-accent); }
.zd-btn:focus-visible{ outline:2px solid var(--zd-accent); outline-offset:2px; }
.zd-btn:disabled{ opacity:.4; cursor:default; }
.zd-btn.zd-primary{ background:var(--zd-accent); border-color:var(--zd-accent); color:#fff; }
.zd-btn[aria-pressed="true"]{ background:var(--zd-accent); border-color:var(--zd-accent); color:#fff; }

/* stage / example */
.zd-stage{ background:var(--zd-bg); border:1px solid var(--zd-line); border-radius:12px;
  padding:16px 12px; margin:8px 0; }
.zd-example{ display:flex; flex-wrap:wrap; justify-content:center; gap:7px; }
.zd-word{ display:flex; flex-direction:column; align-items:center; gap:1px; padding:7px 12px;
  border-radius:10px; background:var(--zd-surface2); border:1px solid transparent;
  transition:transform .15s,box-shadow .15s,border-color .15s,background .15s,opacity .3s; }
.zd-word .zd-w-hz{ font-size:1.5rem; font-weight:600; line-height:1.15; color:var(--role,var(--zd-ink)); }
.zd-word .zd-w-py{ font-size:.72rem; color:var(--zd-soft); }
.zd-word .zd-w-trad{ font-size:.72rem; color:var(--zd-soft); opacity:.85; }
.zd-word[data-role="subj"]{ --role:var(--zd-subj);} .zd-word[data-role="opt"]{ --role:var(--zd-opt);}
.zd-word[data-role="ba"]{ --role:var(--zd-ba);} .zd-word[data-role="obj"]{ --role:var(--zd-obj);}
.zd-word[data-role="verb"]{ --role:var(--zd-verb);} .zd-word[data-role="other"]{ --role:var(--zd-other);}
.zd-word.zd-linked{ background:var(--zd-accent-soft); border-color:var(--zd-accent);
  transform:translateY(-2px); box-shadow:0 4px 14px rgba(208,74,46,.18); }
.zd-caption{ text-align:center; font-size:.9rem; color:var(--zd-soft); margin-top:10px; min-height:1.3em; }
.zd-caption b{ color:var(--zd-accent); }
.zd-nav{ display:flex; justify-content:center; gap:8px; margin-top:12px; }

/* traditional / pinyin honour the site-wide 文 toggles */
.zd-word .zd-w-trad{ display:none; }
body.zbt-hide-py .zd-word .zd-w-py{ display:none; }
body:not(.zbt-hide-trad) .zd-word .zd-w-trad:not(:empty){ display:block; }

/* branch pills */
.zd-pills{ display:flex; flex-wrap:wrap; justify-content:center; gap:6px; }
.zd-pill{ font:inherit; font-size:.8rem; cursor:pointer; border:1px solid var(--zd-opt); color:var(--zd-opt);
  background:transparent; border-radius:999px; padding:5px 13px; transition:background .15s,color .15s; }
.zd-pill[aria-pressed="true"]{ background:var(--zd-opt); color:#fff; }
.zd-pill:focus-visible{ outline:2px solid var(--zd-accent); outline-offset:2px; }
.zd-pillnote{ text-align:center; font-size:.82rem; color:var(--zd-soft); margin-top:6px; min-height:1.1em; }

/* schema box */
.zd-schema{ display:flex; flex-wrap:wrap; justify-content:center; align-items:stretch; gap:8px;
  padding:16px; border:1.5px dashed var(--zd-line); border-radius:14px; background:var(--zd-surface2); }
.zd-slot{ position:relative; font:inherit; cursor:pointer; min-width:76px; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:3px; text-align:center; padding:10px 13px; border-radius:10px;
  background:var(--zd-surface); border:1.5px solid var(--role,var(--zd-ink));
  transition:transform .15s,box-shadow .15s,background .15s,opacity .3s; }
.zd-slot[data-role="subj"]{ --role:var(--zd-subj);} .zd-slot[data-role="opt"]{ --role:var(--zd-opt);}
.zd-slot[data-role="ba"]{ --role:var(--zd-ba);} .zd-slot[data-role="obj"]{ --role:var(--zd-obj);}
.zd-slot[data-role="verb"]{ --role:var(--zd-verb);} .zd-slot[data-role="other"]{ --role:var(--zd-other);}
.zd-slot.zd-branch{ border-style:dashed; }
.zd-s-cn{ font-weight:600; font-size:.98rem; color:var(--role,var(--zd-ink)); }
.zd-s-lbl{ font-size:.74rem; color:var(--zd-soft); }
.zd-slot:hover,.zd-slot.zd-linked{ transform:translateY(-2px); background:var(--zd-accent-soft);
  box-shadow:0 4px 14px rgba(208,74,46,.15); }
.zd-slot:focus-visible{ outline:2px solid var(--zd-accent); outline-offset:2px; }
.zd-op{ align-self:center; color:var(--zd-soft); font-weight:600; font-size:1.05rem; }
.zd-tip{ position:absolute; bottom:calc(100% + 9px); left:50%; transform:translateX(-50%) translateY(4px);
  background:var(--zd-ink); color:var(--zd-bg); font-size:.75rem; line-height:1.4; padding:7px 10px;
  border-radius:8px; max-width:230px; width:max-content; opacity:0; pointer-events:none;
  transition:opacity .15s,transform .15s; z-index:6; box-shadow:0 6px 20px rgba(0,0,0,.25); }
.zd-tip b{ color:var(--zd-accent); }
.zd-slot:hover .zd-tip,.zd-slot:focus-visible .zd-tip{ opacity:1; transform:translateX(-50%) translateY(0); }
.zd-tip::after{ content:""; position:absolute; top:100%; left:50%; transform:translateX(-50%);
  border:6px solid transparent; border-top-color:var(--zd-ink); }

/* legend */
.zd-legend{ display:flex; flex-wrap:wrap; gap:12px; margin-top:10px; font-size:.76rem; color:var(--zd-soft); }
.zd-legend span{ display:inline-flex; gap:5px; align-items:center; }
.zd-legend i{ width:11px; height:11px; border-radius:3px; display:inline-block; background:var(--c,#999); }
.zd-legend i[data-role="subj"]{ --c:var(--zd-subj);} .zd-legend i[data-role="opt"]{ --c:var(--zd-opt);}
.zd-legend i[data-role="ba"]{ --c:var(--zd-ba);} .zd-legend i[data-role="obj"]{ --c:var(--zd-obj);}
.zd-legend i[data-role="verb"]{ --c:var(--zd-verb);} .zd-legend i[data-role="other"]{ --c:var(--zd-other);}

/* connector — orthogonal elbows with rounded corners + solid arrowheads */
.zd-connector{ display:block; height:42px; margin:2px 0 -4px; }
.zd-connector svg{ width:100%; height:100%; display:block; overflow:visible; }
.zd-conn-path{ fill:none; stroke:var(--zd-soft); stroke-width:1.8; vector-effect:non-scaling-stroke;
  stroke-linecap:round; stroke-linejoin:round; }
.zd-conn-arrow{ fill:var(--zd-accent); stroke:none; }
@media (max-width:560px){ .zd-connector{ display:none; } }

/* features */
.zd-features{ display:grid; grid-template-columns:repeat(var(--n,3),minmax(0,1fr)); gap:12px; }
@media (max-width:560px){ .zd-features{ grid-template-columns:1fr; } }
.zd-feat{ text-align:left; border:1px solid var(--zd-line); border-radius:12px; background:var(--zd-surface);
  padding:13px 14px; cursor:pointer; transition:border-color .15s,box-shadow .15s,transform .15s; }
.zd-feat:hover{ border-color:var(--zd-accent); transform:translateY(-2px);
  box-shadow:0 6px 18px rgba(60,30,20,.08); }
.zd-feat[aria-expanded="true"]{ border-color:var(--zd-accent); box-shadow:0 0 0 1px var(--zd-accent) inset; }
.zd-feat:focus-visible{ outline:2px solid var(--zd-accent); outline-offset:2px; }
.zd-tag{ display:inline-block; font-size:.68rem; font-weight:700; letter-spacing:.06em; color:#fff;
  background:var(--zd-accent); border-radius:5px; padding:1px 7px; margin-bottom:6px; }
.zd-chev{ float:right; color:var(--zd-soft); transition:transform .2s; }
.zd-feat[aria-expanded="true"] .zd-chev{ transform:rotate(90deg); }
.zd-ftitle{ font-weight:600; font-size:.97rem; }
.zd-ftitle .zh{ color:var(--zd-accent); }
.zd-fdesc{ font-size:.84rem; color:var(--zd-soft); margin-top:5px; max-height:0; overflow:hidden;
  transition:max-height .28s ease; }
.zd-feat[aria-expanded="true"] .zd-fdesc{ max-height:320px; }
.zd-subs{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin-top:10px; }
@media (max-width:560px){ .zd-subs{ grid-template-columns:1fr 1fr; } }
.zd-sub{ border:1px solid var(--zd-line); border-radius:9px; padding:8px 6px; background:var(--zd-surface2);
  text-align:center; }
.zd-sd{ display:block; font-size:.68rem; font-weight:700; color:var(--zd-accent); letter-spacing:.04em; }
.zd-sz{ display:block; font-weight:600; margin:2px 0; }
.zd-sl{ display:block; font-size:.73rem; color:var(--zd-soft); }

/* contrast */
.zd-contrast{ display:grid; gap:10px; margin-top:10px; }
.zd-contrast.zd-hidden{ display:none; }
.zd-crow{ display:flex; gap:11px; align-items:flex-start; padding:11px 13px; border-radius:11px;
  border:1px solid var(--zd-line); background:var(--zd-surface2); }
.zd-mark{ flex:0 0 auto; font-weight:800; width:24px; height:24px; border-radius:50%; display:grid;
  place-items:center; color:#fff; }
.zd-crow.ok .zd-mark{ background:var(--zd-good); } .zd-crow.no .zd-mark{ background:var(--zd-bad); }
.zd-cn{ font-size:1.15rem; } .zd-crow.no .zd-cn{ text-decoration:line-through;
  text-decoration-color:var(--zd-bad); text-decoration-thickness:1.5px; }
.zd-why{ display:block; font-size:.82rem; color:var(--zd-soft); margin-top:2px; }
.zd-why b{ color:var(--zd-ink); }

.zd-credit{ font-size:.76rem; color:var(--zd-soft); margin-top:14px; padding-top:10px;
  border-top:1px solid var(--zd-line); }

/* walkthrough states */
.zd-off{ opacity:0; transform:translateY(6px) scale(.96); pointer-events:none; }
.zd-pop{ animation:zdpop .35s ease; }
@keyframes zdpop{ 0%{ opacity:0; transform:translateY(8px) scale(.9);} 100%{ opacity:1; transform:none;} }
.zd-walking .zd-schema{ min-height:64px; }

@media (prefers-reduced-motion:reduce){
  .zd-root *{ transition:none!important; animation:none!important; }
  .zd-off{ transform:none; }
}

/* ---- унифициран вид на непреобразуваните примерни кутии (вместо синьото на Citizen) ---- */
.mw-parser-output pre:not(.zbt-diagram){ background:#f2efe9; border:1px solid #e7e0d8; border-radius:8px; padding:11px 16px; overflow-x:auto; color:#1b1b1b; }
/* ---- изравнени колонни таблици (от transformGrid) ---- */
.zbt-grid{ border-collapse:collapse; font-size:.95em; line-height:1.5; }
.zbt-grid td{ text-align:left; vertical-align:baseline; white-space:nowrap; padding:2px 20px 2px 0; }
.zbt-grid td:last-child{ padding-right:6px; }
.zbt-grid tr.zbt-g-zh td{ font-size:1.12em; color:#1b1b1b; }
.zbt-grid tr.zbt-g-py td{ color:#D04A2E; font-style:italic; font-size:.9em; }
.zbt-grid tr.zbt-g-bg td{ color:#3a3a3a; }

/* ---- скрий ВСИЧКИ бутони/връзки за редактиране за нерегистрирани (user-anon) ---- */
.user-anon .mw-editsection,
.user-anon #ca-edit, .user-anon #ca-ve-edit,
.user-anon #ca-edit-sticky-header, .user-anon #ca-ve-edit-sticky-header,
.user-anon a[href*="action=edit"],
.user-anon a[href*="veaction=edit"] { display: none !important; }

/* ---- широки таблици без хоризонтален скрол: пренасяне на текстовите колони + по-стегнат вид ---- */
.zbt-ex-wrap, .zbt-grid, .zbt-ex{ max-width:100%; }
.zbt-grid{ font-size:.9em; }
.zbt-grid td{ white-space:normal; overflow-wrap:break-word; padding:2px 12px 2px 0; vertical-align:top; }
.zbt-grid tr.zbt-g-zh td{ font-size:1.02em; }
.zbt-grid tr.zbt-g-py td{ font-size:.86em; }
/* в примерните таблици оставяме 汉字/пин-ин на един ред, но българският превод се пренася */
.zbt-ex tr.zbt-bg td{ white-space:normal; overflow-wrap:break-word; }

/* ---- пейджър: фиксирани стрелки на десния ръб (винаги видими) ---- */
.zbt-sidenav{ position:fixed; right:16px; top:50%; transform:translateY(-50%); display:flex; flex-direction:column; gap:12px; z-index:60; }
.zbt-snav{ width:46px; height:46px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:#fff; border:1px solid #e5d9d4; color:#D04A2E; text-decoration:none; box-shadow:0 2px 12px rgba(60,30,20,.16); transition:background .15s,color .15s,transform .12s,box-shadow .15s; }
.zbt-snav-g{ font-size:1.7rem; line-height:1; margin-top:-2px; }
.zbt-snav:hover{ background:#D04A2E; color:#fff; transform:scale(1.09); box-shadow:0 4px 16px rgba(208,74,46,.35); }
.zbt-snav-empty{ visibility:hidden; }
:root.skin-theme-clientpref-night .zbt-snav{ background:#241815; border-color:#3a2c27; color:#e8674a; }
:root.skin-theme-clientpref-night .zbt-snav:hover{ background:#e8674a; color:#1a1a1a; }
@media (max-width:820px){ .zbt-sidenav{ right:8px; gap:8px; } .zbt-snav{ width:40px; height:40px; } .zbt-snav-g{ font-size:1.5rem; } }

/* ---- нито една примерна кутия да не скролва хоризонтално: клетките се пренасят ---- */
.zbt-ex td, .zbt-ex th, .zbt-grid td{ white-space:normal; overflow-wrap:break-word; }
/* ---- превключвателят „пин-ин" да важи и за grid-таблиците ---- */
body.zbt-hide-py .zbt-grid tr.zbt-g-py{ display:none; }

/* ---- суровите (нетрансформирани) pre-кутии също да се пренасят, не да скролват ---- */
.mw-parser-output pre:not(.zbt-diagram){ white-space:pre-wrap !important; overflow-wrap:break-word !important; }