/* editor.css – Oberfläche des Seiteneditors (hb-editor.js).
   Aufbau: .hbx  →  .hbx-top (Register, Menüband, Suchleiste; bleibt beim Scrollen oben)
                    .hbx-stage (Schreibansicht)  |  .hbx-src (Quelltext)
                    .hbx-status (Elementpfad, Wortzahl)
   Farben kommen aus den --hb-Variablen (app.css) – Hell und Dunkel funktionieren ohne Sonderregeln.
   Die Gestaltung des Seiteninhalts selbst (Tabellenstile, Kästen …) steht in app.css unter „.doc-body“. */

.hbx { display: flex; flex-direction: column; min-width: 0; }
.hbx-ico { flex: none; display: block; }
.hbx [hidden] { display: none !important; }

/* ---------- Kopf: Register + Menüband ---------- */
.hbx-top {
  position: sticky; top: var(--hb-top-h); z-index: 20;
  background: var(--hb-surface-2);
  border-top: 1px solid var(--hb-border); border-bottom: 1px solid var(--hb-border-strong);
  box-shadow: 0 2px 6px rgba(16, 24, 40, .06);
}
.hbx-tabs { display: flex; align-items: flex-end; gap: .1rem; padding: .3rem .6rem 0; overflow-x: auto; scrollbar-width: none; }
.hbx-tabs::-webkit-scrollbar { display: none; }
.hbx-tabs__fill { flex: 1; }
.hbx-tab {
  flex: none; border: 1px solid transparent; border-bottom: 0; background: none; color: var(--hb-fg-muted);
  font-size: .86rem; font-weight: 600; padding: .38rem .85rem .42rem; border-radius: 8px 8px 0 0; position: relative; top: 1px;
}
.hbx-tab:hover { color: var(--hb-fg); background: color-mix(in srgb, var(--hb-surface) 60%, transparent); }
.hbx-tab.is-active { background: var(--hb-surface); color: var(--hb-accent); border-color: var(--hb-border); }
.hbx-tab--ctx { color: var(--hb-accent); }
.hbx-tab--ctx::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--hb-accent); margin-right: .4rem; vertical-align: 1px; }
.hbx-tabtool {
  flex: none; display: inline-flex; align-items: center; gap: .35rem; height: 30px; margin-bottom: .25rem; padding: 0 .6rem;
  border: 1px solid transparent; border-radius: 7px; background: none; color: var(--hb-fg-muted); font-size: .84rem; font-weight: 600;
}
.hbx-tabtool:hover { background: var(--hb-surface); color: var(--hb-fg); border-color: var(--hb-border); }
.hbx-tabtool.is-on { background: var(--hb-accent); color: var(--hb-on-accent); }

.hbx-ribbon { background: var(--hb-surface); border-top: 1px solid var(--hb-border); }
.hbx-panel { display: flex; flex-wrap: wrap; align-items: stretch; padding: .3rem .35rem .2rem; row-gap: .25rem; }
.hbx-group { display: flex; flex-direction: column; justify-content: space-between; padding: 0 .55rem; border-right: 1px solid var(--hb-border); min-height: 66px; }
.hbx-group:last-child { border-right: 0; }
.hbx-group__items { display: flex; flex-wrap: nowrap; align-items: center; gap: .1rem; flex: 1; }
.hbx-group__label { text-align: center; font-size: .66rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--hb-fg-muted); padding: .15rem 0 .05rem; white-space: nowrap; }

.hbx-btn {
  min-width: 30px; height: 30px; padding: 0 .4rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid transparent; border-radius: 6px; background: none; color: var(--hb-fg);
  font-size: .84rem; font-weight: 600; line-height: 1; white-space: nowrap;
}
.hbx-btn:hover, .hbx-btn.is-open { background: var(--hb-surface-2); border-color: var(--hb-border); }
.hbx-btn.is-on { background: var(--hb-accent-soft); border-color: color-mix(in srgb, var(--hb-accent) 45%, transparent); color: var(--hb-accent); }
.hbx-btn[disabled] { opacity: .35; pointer-events: none; }
.hbx-btn--text { padding: 0 .55rem; font-weight: 550; }
.hbx-btn--lg { flex-direction: column; gap: .2rem; height: 46px; min-width: 46px; padding: .25rem .35rem; font-size: .74rem; font-weight: 550; }
.hbx-glyph { font-size: .85rem; font-weight: 700; }
.hbx-glyph sup, .hbx-glyph sub { font-size: .65em; }
.hbx-caret { display: inline-block; width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0; vertical-align: middle; opacity: .7; }
.hbx-btn--color { gap: .2rem; padding: 0 .3rem; }
.hbx-colorglyph { font-weight: 800; font-size: .9rem; border-bottom: 3px solid #b42318; line-height: 1.05; padding: 0 .12rem; }
.hbx-btn--color.is-marker .hbx-colorglyph { border-bottom: 0; background: #fff3a3; color: #17212f; border-radius: 3px; padding: .08rem .22rem; font-size: .78rem; }
.hbx-sep { width: 1px; height: 20px; background: var(--hb-border-strong); margin: 0 .25rem; }
.hbx-sel {
  height: 30px; max-width: 11rem; border-radius: 6px; border: 1px solid var(--hb-border-strong);
  background: var(--hb-surface); color: var(--hb-fg); padding: 0 .35rem; font-size: .84rem;
}
.hbx-sel--style { min-width: 9.5rem; font-weight: 600; }
.hbx-num { display: inline-flex; align-items: center; height: 30px; margin: 0; border: 1px solid var(--hb-border-strong); border-radius: 6px; background: var(--hb-surface); overflow: hidden; font-size: .84rem; }
.hbx-num:focus-within { border-color: var(--hb-accent); box-shadow: 0 0 0 2px var(--hb-accent-soft); }
.hbx-num__in { width: 3.1rem; height: 100%; border: 0; background: none; color: var(--hb-fg); text-align: right; padding: 0 .2rem 0 .3rem; font-variant-numeric: tabular-nums; }
.hbx-num__in:focus { outline: none; }
.hbx-num span { padding: 0 .4rem 0 .1rem; color: var(--hb-fg-muted); }
@media (pointer: coarse) { .hbx-btn { min-width: 40px; height: 40px; } .hbx-btn--lg { height: 54px; } .hbx-sel, .hbx-num { height: 40px; } }

/* ---------- Aufklappmenüs (hängen an <body>) ---------- */
.hbx-pop {
  position: fixed; z-index: 1075; min-width: 11rem; max-width: min(22rem, calc(100vw - 16px)); padding: .4rem;
  background: var(--hb-surface); color: var(--hb-fg); border: 1px solid var(--hb-border-strong); border-radius: 10px; box-shadow: var(--hb-shadow-lg);
}
.hbx-menuitem { display: flex; align-items: center; gap: .55rem; width: 100%; border: 0; background: none; color: var(--hb-fg); text-align: left; padding: .45rem .6rem; border-radius: 6px; font-size: .88rem; }
.hbx-menuitem:hover { background: var(--hb-accent-soft); color: var(--hb-accent); }
.hbx-swatches { display: grid; grid-template-columns: repeat(5, 28px); gap: 5px; padding: .25rem .25rem .45rem; }
.hbx-swatch { width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .18); padding: 0; }
.hbx-swatch:hover { transform: scale(1.12); box-shadow: 0 0 0 2px var(--hb-accent); }
.hbx-pop--tpick { min-width: 0; }
.hbx-tpick__grid { display: grid; grid-template-columns: repeat(8, 20px); gap: 3px; padding: .2rem; cursor: pointer; }
.hbx-tpick__grid i { width: 20px; height: 20px; border: 1px solid var(--hb-border-strong); border-radius: 3px; background: var(--hb-surface-2); }
.hbx-tpick__grid i.is-on { background: var(--hb-accent); border-color: var(--hb-accent); }
.hbx-tpick__info { text-align: center; font-size: .8rem; color: var(--hb-fg-muted); padding: .3rem 0 .35rem; }
.hbx-check { display: flex; align-items: center; gap: .45rem; font-size: .86rem; padding: .15rem .25rem; margin: 0; cursor: pointer; }
.hbx-check .form-check-input { margin: 0; flex: none; }
.hbx-chars { display: grid; grid-template-columns: repeat(10, 28px); gap: 2px; padding: .15rem .15rem .4rem; }
.hbx-char { width: 28px; height: 28px; border: 0; border-radius: 5px; background: none; color: var(--hb-fg); font-size: 1rem; padding: 0; }
.hbx-char:hover { background: var(--hb-accent-soft); color: var(--hb-accent); }

/* ---------- Suchleiste ---------- */
.hbx-find { border-top: 1px solid var(--hb-border); background: var(--hb-surface-2); padding: .35rem .6rem; }
.hbx-find__row { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.hbx-find__row + .hbx-find__row { margin-top: .3rem; padding-left: 1.55rem; }
.hbx-find__ico { color: var(--hb-fg-muted); display: grid; place-items: center; width: 1.25rem; }
.hbx-find__in {
  flex: 0 1 18rem; min-width: 8rem; height: 30px; padding: 0 .55rem; font-size: .88rem;
  border: 1px solid var(--hb-border-strong); border-radius: 6px; background: var(--hb-surface); color: var(--hb-fg);
}
.hbx-find__in:focus { outline: none; border-color: var(--hb-accent); box-shadow: 0 0 0 2px var(--hb-accent-soft); }
.hbx-find__in.is-invalid { border-color: var(--hb-danger); }
.hbx-find__count { min-width: 5.5rem; font-size: .8rem; color: var(--hb-fg-muted); font-variant-numeric: tabular-nums; padding: 0 .25rem; }
.hbx-find__count.is-none { color: var(--hb-danger); font-weight: 600; }
.hbx-find__nav, .hbx-find__opt, .hbx-find__btn {
  height: 30px; min-width: 30px; padding: 0 .45rem; display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 6px; background: none; color: var(--hb-fg); font-size: .82rem; font-weight: 600;
}
.hbx-find__nav:hover, .hbx-find__opt:hover { background: var(--hb-surface); border-color: var(--hb-border); }
.hbx-find__opt { font-family: ui-monospace, Consolas, monospace; color: var(--hb-fg-muted); }
.hbx-find__opt.is-on { background: var(--hb-accent); color: var(--hb-on-accent); }
.hbx-find__btn { border-color: var(--hb-border-strong); background: var(--hb-surface); padding: 0 .7rem; }
.hbx-find__btn:hover { border-color: var(--hb-accent); color: var(--hb-accent); }
::highlight(hbx-find) { background-color: #ffe58a; color: #17212f; }
::highlight(hbx-find-cur) { background-color: #ff9632; color: #17212f; }

/* ---------- Schreibansicht ---------- */
.hbx-stage { position: relative; }
.hbx-stage .hb-editable { min-height: 50vh; }
.hb-editable.is-colresize, .hb-editable.is-colresize * { cursor: col-resize !important; user-select: none; }
.hb-editable table { outline: 1px dashed transparent; }
.hb-editable td:hover, .hb-editable th:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hb-accent) 35%, transparent); }
.hb-editable table.hb-t-plain td, .hb-editable table.hb-t-plain th, .hb-editable table.hb-layout td { outline: 1px dashed var(--hb-border-strong); outline-offset: -1px; }
.hb-editable caption:empty::before, .hb-editable figcaption:empty::before { content: "Beschriftung …"; color: var(--hb-fg-muted); }
.hb-editable .hb-pagebreak { height: auto; margin: 1.25rem 0; border-top: 2px dashed var(--hb-border-strong); text-align: center; user-select: all; }
.hb-editable .hb-pagebreak::after { content: "Seitenumbruch (PDF)"; position: relative; top: -.75em; padding: 0 .6rem; background: var(--hb-surface); font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--hb-fg-muted); }
.hb-editable details { outline: 1px dashed var(--hb-border-strong); outline-offset: 2px; }
.hb-editable summary { cursor: text; }

.hbx-resizetip {
  position: absolute; z-index: 5; pointer-events: none; white-space: nowrap;
  background: #111a27; color: #fff; font-size: .78rem; font-weight: 600; padding: .25rem .55rem; border-radius: 6px; box-shadow: var(--hb-shadow-lg);
}
.hbx-linkbar {
  position: absolute; z-index: 5; display: flex; align-items: center; gap: .25rem; max-width: min(30rem, calc(100% - 16px));
  padding: .25rem .3rem .25rem .55rem; background: var(--hb-surface); border: 1px solid var(--hb-border-strong); border-radius: 8px; box-shadow: var(--hb-shadow-lg); font-size: .82rem;
}
.hbx-linkbar__ico { color: var(--hb-accent); display: grid; }
.hbx-linkbar__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--hb-fg-muted); padding-right: .35rem; }
.hbx-linkbar button { flex: none; display: inline-flex; align-items: center; gap: .3rem; height: 26px; padding: 0 .45rem; border: 0; border-radius: 5px; background: none; color: var(--hb-fg); font-size: .8rem; font-weight: 600; }
.hbx-linkbar button:hover { background: var(--hb-accent-soft); color: var(--hb-accent); }

/* „Struktur anzeigen“: Blöcke umranden und benennen, Sprungmarken zeigen */
.hbx-show-blocks :is(p, h1, h2, h3, h4, h5, h6, ul, ol, pre, blockquote, table, div, figure, details) { outline: 1px dashed color-mix(in srgb, var(--hb-accent) 50%, transparent); outline-offset: 1px; position: relative; }
.hbx-show-blocks :is(p, h1, h2, h3, h4, ul, ol, pre, blockquote, div, figure, details)::before {
  position: absolute; right: 0; top: -.62rem; z-index: 1; padding: 0 .3rem; border-radius: 3px; pointer-events: none;
  font: 600 .6rem/1.5 ui-monospace, Consolas, monospace; background: var(--hb-accent); color: var(--hb-on-accent); opacity: .85;
}
.hbx-show-blocks p::before { content: "p"; } .hbx-show-blocks h1::before { content: "h1"; } .hbx-show-blocks h2::before { content: "h2"; }
.hbx-show-blocks h3::before { content: "h3"; } .hbx-show-blocks h4::before { content: "h4"; } .hbx-show-blocks ul::before { content: "ul"; }
.hbx-show-blocks ol::before { content: "ol"; } .hbx-show-blocks pre::before { content: "pre"; } .hbx-show-blocks blockquote::before { content: "zitat"; }
.hbx-show-blocks div::before { content: "div"; } .hbx-show-blocks figure::before { content: "figure"; } .hbx-show-blocks details::before { content: "details"; }
.hbx-show-blocks p.hb-lead::before { content: "einleitung"; } .hbx-show-blocks .hb-note::before { content: "hinweis"; } .hbx-show-blocks .hb-tip::before { content: "tipp"; }
.hbx-show-blocks .hb-warn::before { content: "achtung"; } .hbx-show-blocks .hb-danger::before { content: "warnung"; } .hbx-show-blocks .hb-seealso::before { content: "siehe auch"; }
.hbx-show-blocks .hb-pagebreak::before { content: none; }
.hbx-show-blocks [id]::after {
  content: "⚓ #" attr(id); margin-left: .5rem; padding: 0 .35rem; border-radius: 3px; vertical-align: middle; pointer-events: none;
  font: 600 .68rem/1.5 ui-monospace, Consolas, monospace; background: var(--hb-warn-soft); color: var(--hb-warn); letter-spacing: 0; text-transform: none;
}
.hbx-show-blocks .hb-uploading::after, .hbx-show-blocks .hb-pagebreak[id]::after { content: none; }
.hbx-show-blocks a[data-topic-id] { box-shadow: 0 0 0 1px var(--hb-accent); border-radius: 2px; }

/* ---------- Quelltextansicht ---------- */
.hbx-src {
  --src-font: .86rem/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; --src-gutter: 3.6em;
  position: relative; overflow: auto; min-height: 50vh; max-height: 74vh; background: #111a27; color: #e6edf3; tab-size: 2;
}
.hbx-src__inner { position: relative; min-width: 100%; min-height: 50vh; }
.hbx-src.is-nowrap .hbx-src__inner { width: max-content; }
.hbx-src__mirror, .hbx-src__ta { margin: 0; border: 0; font: var(--src-font); letter-spacing: 0; padding: .75rem 1rem 3rem 0; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.hbx-src.is-nowrap .hbx-src__mirror, .hbx-src.is-nowrap .hbx-src__ta { white-space: pre; overflow-wrap: normal; }
.hbx-src__mirror { position: relative; pointer-events: none; counter-reset: ln; }
.hbx-src__mirror .l { position: relative; counter-increment: ln; padding-left: calc(var(--src-gutter) + .9rem); min-height: 1.55em; }
.hbx-src__mirror .l::before {
  content: counter(ln); position: absolute; left: 0; top: 0; bottom: 0; width: var(--src-gutter); padding-right: .6em;
  text-align: right; color: #5d6b80; background: #0c131d; border-right: 1px solid #1f2c3f; user-select: none;
}
.hbx-src__ta {
  position: absolute; inset: 0; width: 100%; height: 100%; padding-left: calc(var(--src-gutter) + .9rem);
  background: transparent; color: transparent; caret-color: #fff; resize: none; overflow: hidden; outline: none;
}
.hbx-src__ta::selection { background: rgba(88, 166, 255, .4); color: transparent; }
.hbx-src .k-t { color: #7ee0d2; } .hbx-src .k-a { color: #f2c572; } .hbx-src .k-s { color: #a8d8ff; }
.hbx-src .k-c { color: #7d8b9d; font-style: italic; } .hbx-src .k-p { color: #ffb86b; font-weight: 700; } .hbx-src .k-e { color: #d2a8ff; }
.hbx-src .m { background: #6b5a00; border-radius: 2px; box-shadow: 0 0 0 1px #a88f00; }
.hbx-src .m-cur { background: #d9730d; box-shadow: 0 0 0 1px #ffb86b; color: #fff; }

/* ---------- Statuszeile ---------- */
.hbx-status { display: flex; align-items: center; gap: 1rem; min-height: 30px; padding: .2rem .9rem; border-top: 1px solid var(--hb-border); background: var(--hb-surface-2); font-size: .76rem; color: var(--hb-fg-muted); }
.hbx-status__path { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: .1rem; }
.hbx-status__sep { opacity: .6; padding: 0 .1rem; }
.hbx-status__count { flex: none; font-variant-numeric: tabular-nums; }
.hbx-crumb { border: 0; background: none; color: var(--hb-fg-muted); padding: .05rem .3rem; border-radius: 4px; font: 600 .74rem/1.4 ui-monospace, Consolas, monospace; }
.hbx-crumb:hover { background: var(--hb-accent-soft); color: var(--hb-accent); }

/* ---------- Dialoge des Editors ---------- */
.hbx-field { margin-bottom: .9rem; }
.hbx-cw__bar { display: flex; height: 26px; border: 1px solid var(--hb-border-strong); border-radius: 6px; overflow: hidden; margin-bottom: .75rem; }
.hbx-cw__bar i { min-width: 0; display: grid; place-items: center; overflow: hidden; white-space: nowrap; font-style: normal; font-size: .7rem; font-weight: 700; background: var(--hb-accent-soft); color: var(--hb-accent); border-right: 1px solid var(--hb-border-strong); }
.hbx-cw__bar i:last-child { border-right: 0; }
.hbx-cw__bar i.is-auto { background: var(--hb-surface-2); color: var(--hb-fg-muted); font-weight: 500; }
.hbx-cw__list { display: grid; gap: .35rem; max-height: 38vh; overflow-y: auto; padding-right: .25rem; }
.hbx-cw__row { display: flex; align-items: center; gap: .75rem; }
.hbx-cw__name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: .5rem; font-size: .9rem; }
.hbx-cw__name b { flex: none; font-weight: 600; }
.hbx-cw__name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--hb-fg-muted); }
.hbx-cw__in { flex: none; display: flex; align-items: center; gap: .35rem; color: var(--hb-fg-muted); }
.hbx-cw__in input { width: 5.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.hbx-cw__sum { margin: .6rem 0; font-size: .84rem; color: var(--hb-fg-muted); }
.hbx-cw__sum.is-warn { color: var(--hb-warn); font-weight: 600; }
.hbx-cw__tools { display: flex; flex-wrap: wrap; gap: .4rem; padding-bottom: .9rem; margin-bottom: .9rem; border-bottom: 1px solid var(--hb-border); }
.hbx-anchorlist { max-height: 50vh; overflow-y: auto; }
.hbx-anchor { display: flex; align-items: center; gap: .55rem; }
.hbx-anchor code { margin-left: auto; font-size: .74rem; color: var(--hb-fg-muted); background: none; }
.hbx-anchor__ico { color: var(--hb-fg-muted); display: grid; }
.hbx-anchor--l3 { padding-left: 2rem; } .hbx-anchor--l4 { padding-left: 3rem; }
.hbx-anchor--l1, .hbx-anchor--l2 { font-weight: 600; }

/* ---------- Vollbild ---------- */
.hbx-noscroll { overflow: hidden; }
.hb-editor.is-full { position: fixed; inset: 0; z-index: 1060; overflow: auto; border-radius: 0; border: 0; display: flex; flex-direction: column; }
.hb-editor.is-full .hbx { flex: 1; }
.hb-editor.is-full .hbx-top { top: 0; }
.hb-editor.is-full .hbx-stage { flex: 1; }
.hb-editor.is-full .hbx-stage .hb-editable { max-width: 62rem; margin: 0 auto; min-height: 100%; }
.hb-editor.is-full .hbx-src { flex: 1; max-height: none; }
.hb-editor.is-full .hb-editor__props { display: none; }
.hb-editor.is-full .hbx-status { position: sticky; bottom: 61px; }
