@font-face { font-family: "Jost"; src: url("/static/fonts/jost.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
/* NormenPool – Farben kommen als CSS-Variablen aus den Einstellungen (app.js: applyDesign) */
:root {
  --accent: #4f7cff; --accent2: #b04fff; --radius: 18px; --fs: 1;
  --pad: 1; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f7f8fb; --surface: #ffffff; --surface2: #f0f2f7; --border: #e2e5ee;
  --text: #1a1d24; --muted: #646b7a; --mark: #ffe066; --danger: #d64545; --ok: #2f9e66; --warn: #d9911a;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(20,30,60,.08);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #181b22; --surface2: #20242d; --border: #2c313c;
  --text: #e8eaf0; --muted: #9aa1b0; --mark: #8a6d00; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { font-size: calc(16px * var(--fs)); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.hidden { display: none !important; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { flex: 1; }

/* --------- Topbar --------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.2rem; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand img { width: 26px; height: 26px; }
.nav { display: flex; gap: .2rem; }
.nav a { padding: .4rem .8rem; border-radius: 999px; color: var(--muted); font-weight: 500; }
.nav a.active, .nav a:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.badge-dot { display: inline-block; min-width: 1.2rem; padding: 0 .35rem; margin-left: .3rem; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .72rem; text-align: center; line-height: 1.2rem; }

main { max-width: 1180px; margin: 0 auto; padding: calc(1.4rem * var(--pad)) 1.2rem 4rem; }
main.wide { max-width: none; }

/* --------- Buttons / Inputs --------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border); background: var(--surface);
  padding: .5rem .95rem; border-radius: 999px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface2); }
.btn.sm { padding: .3rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 2.4rem; height: 2.4rem; padding: 0; justify-content: center; border-radius: 50%; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * .55);
  padding: .55rem .75rem; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea { min-height: 6rem; resize: vertical; }
input[type=color] { width: 3rem; height: 2.2rem; border: 1px solid var(--border); border-radius: 8px; background: none; padding: 2px; }
label.field { display: block; margin-bottom: .8rem; }
label.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .25rem; font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; user-select: none; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: calc(1.1rem * var(--pad)) calc(1.25rem * var(--pad)); box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .65rem; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--border); font-size: .8rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: color-mix(in srgb, var(--accent) 15%, var(--surface)); border-color: var(--accent); color: var(--accent); }
.chip.static { cursor: default; }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 6px; font-size: .75rem; font-weight: 600;
  background: var(--surface2); color: var(--muted); }
.tag.gueltig { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tag.ersetzt, .tag.zurueckgezogen { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tag.entwurf { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.tag.num { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

/* --------- Startseite / Suchbalken --------- */
.hero { display: flex; flex-direction: column; align-items: center; padding-top: 12vh; }
.hero.compact { padding-top: 0; }
.greeting { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 650; letter-spacing: -.02em; margin-bottom: 1.6rem; text-align: center; }
.greeting.gradient { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.searchbar { width: 100%; max-width: 780px; background: var(--surface); border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.6); box-shadow: var(--shadow); padding: .55rem .55rem .55rem 1.2rem;
  display: flex; align-items: center; gap: .4rem; position: relative; transition: border-color .15s; }
.searchbar:focus-within { border-color: var(--accent); }
.searchbar input { border: 0; box-shadow: none !important; background: transparent; font-size: 1.1rem; padding: .6rem 0; }
.searchbar .mode { display: flex; background: var(--surface2); border-radius: 999px; padding: 3px; }
.searchbar .mode button { white-space: nowrap; border: 0; background: transparent; border-radius: 999px; padding: .32rem .75rem; cursor: pointer; font-size: .85rem; color: var(--muted); }
.searchbar .mode button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.searchbar .go { width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); display: grid; place-items: center; flex-shrink: 0; }
.catbtn { border: 1px solid var(--border); background: var(--surface2); border-radius: 999px; padding: .42rem .85rem;
  cursor: pointer; font-size: .9rem; display: flex; gap: .35rem; align-items: center; white-space: nowrap; max-width: 15rem; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; }
.catbtn.on { border-color: var(--accent); color: var(--accent); }
.popover { position: absolute; top: calc(100% + .5rem); right: 0; z-index: 30; width: min(560px, 92vw); max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.popover h4 { margin: .2rem 0 .5rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.popover .chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .9rem; }
.below-bar { width: 100%; max-width: 780px; margin-top: .8rem; }
.adv-toggle { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .88rem; padding: .3rem .4rem; }
.adv-toggle:hover { color: var(--text); }
.adv { margin-top: .6rem; }
.adv .chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.adv .group { margin-bottom: .8rem; }
.adv .group > span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; font-weight: 600; }
.suggest { display: flex; gap: .45rem; flex-wrap: wrap; justify-content: center; margin-top: 1.2rem; }
.home-widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; width: 100%; margin-top: 3rem; }
.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li { padding: .35rem 0; border-bottom: 1px dashed var(--border); display: flex; gap: .5rem; align-items: baseline; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.stat b { display: block; font-size: 1.5rem; }

/* --------- Ergebnisse --------- */
.results-head { display: flex; align-items: baseline; gap: 1rem; margin: 1.2rem 0 .8rem; }
.result { display: grid; grid-template-columns: 74px 1fr; gap: 1rem; }
.result + .result { margin-top: .9rem; }
.result .thumb { width: 74px; height: 100px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.result .title { font-weight: 650; font-size: 1.05rem; color: var(--text); }
.result .meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin: .2rem 0 .4rem; }
.hit { display: flex; gap: .7rem; padding: .35rem .5rem; margin: 0 -.5rem; border-radius: 8px; cursor: pointer; color: var(--text); }
.hit:hover { background: var(--surface2); text-decoration: none; }
.hit .pg { flex-shrink: 0; font-size: .78rem; font-weight: 700; color: var(--accent); min-width: 3.2rem; padding-top: .1rem; }
.hit .sn { font-size: .92rem; }
.more-pages { font-size: .8rem; margin-top: .3rem; }
.more-pages a { margin-right: .35rem; }
.answer { border-left: 4px solid var(--accent); }
.answer .md p { margin: .4rem 0; }
.answer .md ul { margin: .3rem 0; padding-left: 1.3rem; }
.cite { display: inline-block; font-size: .72rem; font-weight: 700; padding: 0 .35rem; border-radius: 5px; margin: 0 1px;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); cursor: pointer; vertical-align: 1px; }
.sources { margin-top: .8rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.pager { display: flex; gap: .4rem; justify-content: center; margin-top: 1.4rem; }

/* --------- Viewer --------- */
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 1rem; align-items: start; }
.viewer .pagebox { background: var(--surface2); border-radius: var(--radius); padding: .8rem; border: 1px solid var(--border); }
.viewer .pagetools { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.viewer .pagetools input { width: 4.5rem; text-align: center; }
.viewer .pageimg { display: block; width: 100%; height: auto; background: #fff; border-radius: 6px; box-shadow: var(--shadow); min-height: 400px; }
.viewer .side { position: sticky; top: 4.2rem; max-height: calc(100vh - 5rem); overflow: auto; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: .9rem; }
.tabs button { border: 0; background: none; padding: .5rem .75rem; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.hitnav { display: flex; flex-wrap: wrap; gap: .3rem; }
.outline a { display: block; padding: .15rem 0; color: var(--text); font-size: .9rem; }
.locked { color: var(--accent); font-size: .72rem; margin-left: .3rem; cursor: pointer; }
.pagetext { white-space: pre-wrap; font-size: .85rem; background: var(--surface2); padding: .8rem; border-radius: 8px; max-height: 60vh; overflow: auto; }

/* --------- Bibliothek --------- */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.6rem; text-align: center; cursor: pointer; transition: .15s; }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
table.lib { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.lib th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .5rem; border-bottom: 1px solid var(--border); }
table.lib td { padding: .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.lib tr:hover td { background: var(--surface2); }
table.lib td.t a { color: var(--text); font-weight: 550; }
.state { font-size: .75rem; }
.state.err { color: var(--danger); } .state.busy { color: var(--warn); } .state.ok { color: var(--ok); }
.bulkbar { position: sticky; bottom: 1rem; margin-top: 1rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 999px; padding: .5rem .8rem; box-shadow: var(--shadow); }

/* --------- Einstellungen --------- */
.settings { display: grid; grid-template-columns: 210px 1fr; gap: 1.4rem; align-items: start; }
.settings nav { position: sticky; top: 4.5rem; display: flex; flex-direction: column; gap: .15rem; }
.settings nav a { padding: .45rem .8rem; border-radius: 10px; color: var(--muted); }
.settings nav a.on, .settings nav a:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.catrow { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.catrow input[type=text] { flex: 1; padding: .3rem .55rem; }
.catrow code { font-size: .75rem; color: var(--muted); min-width: 7rem; }
.log { font-family: ui-monospace, monospace; font-size: .78rem; max-height: 320px; overflow: auto; }
.log div { padding: .12rem 0; border-bottom: 1px dashed var(--border); }
.log .error { color: var(--danger); } .log .warn { color: var(--warn); }
.codes { font-family: ui-monospace, monospace; display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem 1rem; background: var(--surface2); padding: .8rem; border-radius: 8px; }
.qr { background: #fff; padding: .6rem; border-radius: 12px; width: 220px; }
.qr svg { width: 100%; height: auto; display: block; }

/* --------- Login --------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth { width: 100%; max-width: 420px; }
.auth .brand { justify-content: center; font-size: 1.4rem; margin-bottom: 1.2rem; }
.auth .brand img { width: 40px; height: 40px; }
.otp { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-family: ui-monospace, monospace; }
.err-msg { color: var(--danger); font-size: .9rem; min-height: 1.3rem; margin: .3rem 0; }
.pw-meter { height: 5px; border-radius: 3px; background: var(--surface2); overflow: hidden; margin: -.4rem 0 .8rem; }
.pw-meter div { height: 100%; transition: .2s; }

#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; align-items: center; }
#toast div { background: var(--text); color: var(--bg); padding: .55rem 1rem; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow); }
#toast div.error { background: var(--danger); color: #fff; }
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .viewer { grid-template-columns: 1fr; }
  .viewer .side { position: static; max-height: none; }
  .settings { grid-template-columns: 1fr; }
  .settings nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .hide-m { display: none !important; }
  main { padding: 1rem 1rem 4rem; }
  #logoutBtn { padding: .3rem .5rem; font-size: .8rem; }
  .searchbar .go { margin-left: auto; }
  .topbar { padding: .5rem 1rem; gap: .5rem; }
  .brand span { display: none; }
  .nav a { padding: .3rem .5rem; font-size: .88rem; }
  .badge-dot { margin-left: .15rem; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .searchbar { flex-wrap: wrap; padding: .5rem .6rem; border-radius: var(--radius); }
  .searchbar input { flex-basis: 100%; order: -1; padding: .4rem .3rem; }
  .hero { padding-top: 6vh; }
  table.lib .hide-m { display: none; }
  .result { grid-template-columns: 1fr; }
  .result > a:first-child { display: none; }
}

/* --------- Dokument-Viewer (pdf.js) --------- */
body.no-scroll { overflow: hidden; }
body.no-scroll #app { height: 100vh; display: flex; flex-direction: column; }
body.no-scroll main { flex: 1; min-height: 0; padding: 0; max-width: none; width: 100%; margin: 0; }
.dv { height: 100%; display: flex; flex-direction: column; }
.dv-head { display: flex; align-items: center; gap: .5rem; padding: .4rem .8rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.dv-title { min-width: 0; flex: 0 1 auto; }
.dv-title > b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dv-title .tag { font-size: .68rem; }
.docnav { display: flex; align-items: center; gap: .1rem; border-right: 1px solid var(--border); padding-right: .4rem; }
.dv-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.dv-body.with-panel { grid-template-columns: 300px minmax(0, 1fr) 400px; }
.dv-body:not(.with-panel) .dv-panel { display: none; }
.dv-side { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.dv-side .tabs { margin: 0; padding: 0 .5rem; }
.side-scroll { overflow: auto; flex: 1; padding: .3rem; }
.shit { display: block; padding: .45rem .55rem; border-radius: 8px; color: var(--text); border-left: 3px solid transparent; }
.shit:hover { background: var(--surface2); text-decoration: none; }
.shit.on, .dv-side .outline a.on { background: color-mix(in srgb, var(--accent) 11%, transparent); border-left-color: var(--accent); }
.shit .pg { color: var(--accent); font-size: .78rem; white-space: nowrap; }
.shit .sn { font-size: .8rem; line-height: 1.35; margin-top: .15rem; }
.sec { font-size: .72rem; color: var(--muted); font-weight: 600; }
.hit .sn .sec { display: block; }
.dv-side .outline a { display: flex; justify-content: space-between; gap: .5rem; padding: .25rem .4rem; border-radius: 6px; border-left: 3px solid transparent; color: var(--text); font-size: .85rem; }
.dv-side .outline a:hover { background: var(--surface2); text-decoration: none; }
.dv-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dv-tools { display: flex; align-items: center; gap: .6rem; padding: .35rem .7rem; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.findbox { display: flex; align-items: center; gap: .15rem; background: var(--surface2); border-radius: 999px; padding: .05rem .25rem .05rem .85rem; flex: 1 1 260px; max-width: 480px; border: 1px solid transparent; }
.findbox:focus-within { border-color: var(--accent); }
.findbox input { border: 0; background: transparent; box-shadow: none !important; padding: .35rem 0; }
.findbox #findCount { min-width: 2.6rem; text-align: right; }
#pno { width: 4rem; text-align: center; padding: .3rem; }
#zsel { width: auto; padding: .3rem .5rem; }
.dv-wrap { position: relative; flex: 1; min-height: 0; background: var(--surface2); }
.pdfc { position: absolute; inset: 0; overflow: auto; }
.pdfViewer .page { box-shadow: var(--shadow); border: 0 !important; margin: 14px auto !important; }
.pdfViewer .textLayer .highlight { background-color: rgba(255, 196, 0, .45); }
.pdfViewer .textLayer .highlight.selected { background-color: rgba(255, 120, 0, .65); }
.dv-panel { border-left: 1px solid var(--border); overflow: auto; background: var(--surface); padding: .9rem; min-width: 0; }
.selpop { position: absolute; z-index: 10; display: flex; gap: .3rem; background: var(--surface); padding: .3rem; border-radius: 999px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.pdf-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.ctx-item { border: 1px solid var(--border); border-radius: 10px; padding: .35rem .6rem; margin-bottom: .4rem; }
.ctx-text { color: var(--muted); }
.answer-box { margin-top: .8rem; border-left: 3px solid var(--accent); padding-left: .8rem; }
@media (max-width: 900px) {
  .dv-body, .dv-body.with-panel { grid-template-columns: minmax(0, 1fr); }
  .dv-side { display: none; }
  .dv-panel { position: fixed; left: 0; right: 0; bottom: 0; height: 62vh; z-index: 40; box-shadow: var(--shadow); border-top: 1px solid var(--border); }
  .dv-title .row { display: none; }
  .dv-head { flex-wrap: wrap; padding: .35rem .5rem; }
  .dv-title { flex: 1 1 60%; }
  .dv-head .spacer { display: none; }
  .dv-tools { gap: .4rem; }
}

.ctx-box { border: 1px solid var(--border); border-radius: 12px; padding: .5rem .7rem; margin-bottom: .6rem; }
.ctx-box summary { cursor: pointer; }
.ctx-opt { margin: .5rem 0 .4rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--border); }
.qa { margin-top: .9rem; }
.qa .q { font-weight: 600; background: var(--surface2); border-radius: 10px; padding: .4rem .7rem; margin-bottom: .4rem; white-space: pre-wrap; }

/* --------- Bereiche (Ueberkategorien) --------- */
.area-tabs { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin: .9rem 0 .2rem; }
.area-tabs button { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: .35rem .95rem; cursor: pointer; font-size: .9rem; font-weight: 500; }
.area-tabs button:hover { color: var(--text); border-color: var(--accent); }
.area-tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.area-tabs .cnt { font-size: .72rem; opacity: .65; margin-left: .15rem; }
.pop-head { display: flex; align-items: center; margin-bottom: .6rem; }
.pop-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pop-cols h4 { margin-top: 0; }
@media (max-width: 600px) { .pop-cols { grid-template-columns: 1fr; } }
.tag.area { background: color-mix(in srgb, var(--accent2) 15%, transparent); color: var(--accent2); }
.area-chips { display: flex; gap: .2rem; flex-wrap: wrap; }
.chip.tiny { font-size: .7rem; padding: .1rem .45rem; }

/* --------- Karte / Regional --------- */
.mapview { height: 100%; display: grid; grid-template-columns: 380px minmax(0, 1fr); }
.map-side { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.map-search { position: relative; padding: .8rem; border-bottom: 1px solid var(--border); }
.geo-sug { position: absolute; left: .8rem; right: .8rem; top: calc(100% - .4rem); z-index: 1000; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
.geo-sug a { display: flex; justify-content: space-between; gap: .5rem; padding: .5rem .8rem; color: var(--text); border-bottom: 1px solid var(--border); }
.geo-sug a:hover { background: var(--surface2); text-decoration: none; }
.place-box { padding: .9rem; overflow: auto; flex: 1; }
.place-box h3 { font-size: .95rem; margin: .4rem 0; }
.map { min-height: 300px; background: var(--surface2); }
.oereb-item { display: flex; align-items: flex-start; gap: .5rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.oereb-item > span { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.oereb-item input { margin-top: .2rem; }
.leaflet-container { font: inherit; }
@media (max-width: 900px) {
  .mapview { grid-template-columns: 1fr; grid-template-rows: 45vh minmax(0, 1fr); }
  .map { order: -1; }
}

/* =====================================================================
   Smartphone (nur unter 600px – Desktop bleibt unveraendert)
   ===================================================================== */
.nav .ni, .show-m { display: none; }
@media (max-width: 600px) {
  :root { --navh: 58px; }
  body { padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom)); }
  /* Kopfzeile: nur Logo + Status + Abmelden; Navigation unten als Tab-Leiste */
  /* backdrop-filter wuerde die fixierte Tab-Leiste in der Kopfzeile "einsperren" */
  .topbar { padding: .5rem .9rem; gap: .5rem; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .brand span { display: inline; font-size: 1rem; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; gap: 0; justify-content: space-around;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: .25rem .2rem calc(.25rem + env(safe-area-inset-bottom)); }
  .nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .3rem 0 .2rem;
    font-size: .68rem; font-weight: 500; border-radius: 12px; position: relative; min-height: 48px; justify-content: center; }
  .nav a.active, .nav a:hover { background: transparent; color: var(--accent); }
  .nav .ni { display: block; }
  .nav #libBadge .badge-dot { position: absolute; top: .1rem; left: calc(50% + .45rem); margin: 0; min-width: 1.05rem; line-height: 1.05rem; font-size: .62rem; }
  #logoutBtn { font-size: .78rem; padding: .3rem .55rem; }
  #toast { bottom: calc(var(--navh) + 1rem + env(safe-area-inset-bottom)); width: calc(100% - 2rem); }
  #toast div { text-align: center; }
  .show-m { display: inline-flex; }

  /* Startseite / Suche */
  .hero { padding-top: 7vh; }
  .greeting { font-size: 1.75rem; margin-bottom: 1.1rem; }
  .searchbar { gap: .35rem; }
  .searchbar .mode button { padding: .3rem .6rem; }
  .catbtn { padding: .38rem .7rem; font-size: .85rem; }
  .area-tabs { gap: .3rem; margin-top: .75rem; }
  .area-tabs button { padding: .32rem .7rem; font-size: .84rem; }
  .popover { position: fixed; left: .6rem; right: .6rem; top: auto; bottom: calc(var(--navh) + .6rem); width: auto; max-height: 65vh; }
  .adv .grid4 { grid-template-columns: 1fr 1fr; }
  .results-head { flex-wrap: wrap; gap: .3rem .8rem; }
  .card { padding: .9rem 1rem; }
  .hit { gap: .5rem; }
  .hit .pg { min-width: 2.6rem; }

  /* Dokument-Viewer: Platz fuer das PDF, Treffer & Panels als Blatt von unten */
  body.no-scroll { padding-bottom: 0; }
  body.no-scroll #app { height: 100dvh; }
  body.no-scroll main { padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom)); }
  .dv-head { gap: .3rem; }
  .dv-head .docnav { border: 0; padding: 0; }
  .dv-title > b { font-size: .95rem; }
  .dv-tools { gap: .35rem; padding: .35rem .5rem; }
  .findbox { flex: 1 1 100%; max-width: none; order: -1; }
  #pno { width: 3.2rem; }
  #zsel { max-width: 7.5rem; }
  .dv-body.side-open .dv-side, .dv-panel {
    display: flex; position: fixed; left: 0; right: 0; bottom: calc(var(--navh) + env(safe-area-inset-bottom)); height: 58vh; z-index: 45;
    border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.18); }
  .dv-panel { display: block; }
  .dv-body:not(.with-panel) .dv-panel { display: none; }
  .selpop { left: .5rem !important; right: .5rem; justify-content: center; }

  /* Bibliothek: Zeilen als Karten */
  .lib-filters > * { flex: 1 1 45% !important; max-width: none !important; }
  .lib-filters .spacer { display: none; }
  table.lib-cards thead { display: none; }
  table.lib-cards, table.lib-cards tbody { display: block; }
  table.lib-cards tr { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .7rem; padding: .7rem .8rem; border-bottom: 1px solid var(--border); }
  table.lib-cards td { padding: 0; border: 0; font-size: .82rem; }
  table.lib-cards td.t { flex: 1 1 calc(100% - 2.2rem); font-size: .95rem; }
  table.lib-cards td:nth-child(3) { margin-left: 2rem; font-weight: 600; }
  table.lib-cards td:nth-child(3):empty { display: none; }
  table.lib-cards tr:hover td { background: transparent; }
  .bulkbar { bottom: calc(var(--navh) + .6rem + env(safe-area-inset-bottom)); border-radius: 16px; }
  .dropzone { padding: 1.1rem; }

  /* Einstellungen */
  .settings { gap: .8rem; }
  .settings nav { flex-wrap: nowrap; overflow-x: auto; margin: 0 -1rem; padding: 0 1rem .2rem; scrollbar-width: none; }
  .settings nav::-webkit-scrollbar { display: none; }
  .settings nav a { white-space: nowrap; flex-shrink: 0; }
  .catrow { flex-wrap: wrap; gap: .3rem .4rem; padding: .5rem 0; }
  .catrow input[type=text] { flex: 1 1 55%; min-width: 0; }
  .catrow code { display: none; }
  .catrow .btn.sm { padding: .25rem .45rem; }
  .catrow .area-chips { order: 10; flex-basis: 100%; padding-left: 1.7rem; }
  .codes { grid-template-columns: 1fr; }

  /* Karte */
  .mapview { grid-template-rows: 42vh minmax(0, 1fr); }
  .map-side { border-right: 0; }

  /* Login */
  .auth-wrap { padding-bottom: 1rem; }
}

/* --------- Regional-Filter (Suche) & Bibliothek-Bereiche --------- */
.reg-filter { width: 100%; max-width: 780px; }
.reg-filter:empty { display: none; }
.reg-row { margin-top: .7rem; align-items: flex-start; flex-wrap: nowrap; }
.rf-canton { width: auto; min-width: 11rem; padding: .35rem .6rem; border-radius: 999px; }
.rf-munis { display: flex; flex-wrap: wrap; gap: .35rem; flex: 1; padding-top: .15rem; }
.rf-missing { margin-top: .5rem; }
.lib-areas { justify-content: flex-start; margin: 0 0 .8rem; }
.reg-lib { padding: .8rem 1rem; }
@media (max-width: 600px) {
  .reg-row { flex-wrap: wrap; }
  .rf-canton { width: 100%; }
  .lib-areas { justify-content: center; }
}

/* --------- Filter-Popover Stufe 2 --------- */
.pop-more { border-top: 1px solid var(--border); margin: .4rem 0 .8rem; padding-top: .6rem; }
.pop-more summary { cursor: pointer; font-weight: 600; font-size: .9rem; list-style: none; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.pop-more summary::before { content: "▸"; color: var(--muted); }
.pop-more[open] summary::before { content: "▾"; }
.pop-more .adv { margin-top: .7rem; }
.popover { width: min(640px, 94vw); }

.pop-reg { border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem; margin-bottom: .9rem; background: var(--surface2); }
.pop-reg h4 { margin-top: 0; }

/* --------- Split View, Norm-Links, Bürolizenz --------- */
.dv-body.with-split { grid-template-columns: 260px minmax(0, 1fr) minmax(0, 1fr); }
.dv-body.with-split .dv-panel { display: none; }
.dv-split { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--border); }
.dv-split.hidden { display: none; }
.sp-head { display: flex; align-items: center; gap: .35rem; padding: .35rem .6rem; border-bottom: 1px solid var(--border); background: var(--surface); min-height: 2.9rem; }
.sp-title { color: var(--text); font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sp-head input { width: 3.6rem; padding: .25rem; text-align: center; }
.split-pop { position: fixed; width: min(420px, 92vw); padding: .7rem; z-index: 50; }
.split-pop input { margin-bottom: .5rem; }
.sp-list { max-height: 55vh; overflow: auto; }
.sp-list a { display: block; padding: .45rem .5rem; border-radius: 8px; color: var(--text); font-size: .9rem; }
.sp-list a:hover { background: var(--surface2); text-decoration: none; }
.textLayer a.normlink { color: transparent; cursor: pointer; background: color-mix(in srgb, var(--accent) 22%, transparent); border-bottom: 2px solid var(--accent); border-radius: 2px; pointer-events: auto; }
.textLayer a.normlink:hover { background: color-mix(in srgb, var(--accent) 38%, transparent); }
.lic-lock { border-color: var(--warn); }
.tag.loc { font-weight: 700; }
@media (max-width: 900px) { .dv-body.with-split { grid-template-columns: minmax(0, 1fr); } .dv-split { display: none; } }

.map-toggle { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: .35rem .7rem; font: inherit; font-size: .82rem; cursor: pointer; box-shadow: var(--shadow); }
.map-toggle.on { border-color: var(--accent); color: var(--accent); }
.map-hint { background: color-mix(in srgb, var(--surface) 90%, transparent); padding: .2rem .55rem; border-radius: 8px; font-size: .75rem; color: var(--muted); }

/* --------- Favoriten-Markierungen --------- */
/* Leuchtstift: Rechtecke deckend, Transparenz auf der ganzen Ebene -> Überlappungen werden nicht dunkler, Farbe bleibt einheitlich */
.hl-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; opacity: .3; mix-blend-mode: multiply; }
.hl-rect { position: absolute; }
.hl-red { background: #ff5a5a; }
.hl-yellow { background: #ffd200; }
.hl-green { background: #3cc878; }
.hl-blue { background: #5a96ff; }
.hl-layer.flash { animation: hlflash 1.6s ease-out; }
@keyframes hlflash { 0%, 40% { opacity: .65; } 100% { opacity: .3; } }
.hl-btn { border-color: #e5484d; color: #e5484d; }
.hl-sn { border-left: 3px solid rgba(255, 45, 45, .6); padding-left: .4rem; }
.fav-doc .title { font-weight: 650; font-size: 1.05rem; color: var(--text); display: block; margin-bottom: .4rem; }
.fav-item { padding: .55rem 0; border-top: 1px dashed var(--border); }
.fav-item .pg { font-size: .78rem; font-weight: 700; color: var(--accent); }
.fav-text { display: block; margin-top: .25rem; color: var(--text); font-size: .9rem; border-left: 3px solid rgba(255, 45, 45, .6); padding-left: .6rem;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.fav-text:hover { text-decoration: none; background: var(--surface2); }
.fav-edit { max-width: 20rem; padding: .25rem .5rem; }
@media (max-width: 600px) { .nav a { font-size: .62rem; } #selBtns .btn { padding: .3rem .5rem; } }
.vcard { padding: .65rem .9rem; margin-bottom: .9rem; }
.vcard .row { gap: .5rem; }
.vcard.v-neuer, .vcard.v-zurueckgezogen { border-color: var(--danger); }
.vcard.v-aktuell { border-color: color-mix(in srgb, var(--ok, #2f9e66) 55%, transparent); }
.vchg { margin-top: .2rem; color: var(--text); }

/* =====================================================================
   Entdecken
   ===================================================================== */
.disc { max-width: 920px; margin: 0 auto; }
.disc-head h2 { margin: 0 0 .2rem; }
.disc-head p { margin: 0 0 1rem; }
.disc-tabs { display: flex; gap: .25rem; padding: .25rem; background: var(--surface2); border-radius: 999px; width: max-content; max-width: 100%; overflow-x: auto; margin-bottom: 1.2rem; }
.disc-tabs a { padding: .4rem 1rem; border-radius: 999px; color: var(--muted); font-size: .9rem; font-weight: 500; white-space: nowrap; }
.disc-tabs a:hover { color: var(--text); }
.disc-tabs a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.map-tabs { padding: .7rem .8rem 0; }
.map-tabs .disc-tabs { margin: 0; font-size: .85rem; }
.map-tabs .disc-tabs a { padding: .35rem .7rem; font-size: .8rem; }
.disc-bar { display: flex; gap: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .35rem .35rem .35rem 1.1rem; box-shadow: var(--shadow); }
.disc-bar input { border: 0; background: transparent; box-shadow: none; padding: .45rem 0; flex: 1; min-width: 0; font-size: 1.02rem; }
.disc-bar input:focus { outline: none; box-shadow: none; }
.disc-bar .btn { border-radius: 999px; }
.disc-ex { gap: .35rem; margin: .8rem 0 .2rem; }
.disc-hint { margin: .5rem .2rem 1.2rem; }
.disc-count { margin: .2rem 0 .6rem; }
.dres { display: flex; gap: 1rem; align-items: flex-start; padding: .85rem 1rem; margin-bottom: .55rem; }
.dres.have { opacity: .75; }
.dres-main { flex: 1; min-width: 0; }
.dres-title { font-weight: 600; overflow-wrap: anywhere; }
.dres-note { margin-top: .3rem; color: var(--muted); }
.dres-act { display: flex; gap: .35rem; align-items: center; flex-shrink: 0; }
.plink { display: flex; gap: .8rem; align-items: center; padding: .55rem .9rem; border-bottom: 1px solid var(--border); }
.plink:last-child { border-bottom: 0; }
.plink-t { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .92rem; }
.plink.have { opacity: .7; }

/* Vorschau-Dialog */
.dlg-back { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 18, 25, .55); display: flex; align-items: center; justify-content: center; padding: 2vh 2vw; }
.dlg { background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden; }
.dpv { width: min(1300px, 96vw); height: 94vh; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.dpv-load { grid-column: 1 / -1; align-self: center; text-align: center; padding: 2rem; overflow-wrap: anywhere; }
.dpv-view { position: relative; background: var(--surface2); min-height: 0; }
.dpv-view .pdfc { position: absolute; inset: 0; overflow: auto; }
.dpv-side { border-left: 1px solid var(--border); padding: 1rem; overflow: auto; display: flex; flex-direction: column; gap: .6rem; }
.dpv-dup { padding: .7rem .8rem; border-color: var(--warn); display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }

/* KI im Hintergrund */
.bg-pause { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: calc(var(--radius) * .7); background: var(--surface2); margin-bottom: .8rem; cursor: pointer; }
.bg-pause input { margin-top: .25rem; width: 1.1rem; height: 1.1rem; }
.bg-opts { display: flex; flex-direction: column; gap: .5rem; transition: opacity .2s; }
.bg-opts.dim { opacity: .45; }
.tag.ai-paused { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); text-decoration: none; }

@media (max-width: 900px) {
  .dpv { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; height: 96vh; }
  .dpv-side { border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; }
}
@media (max-width: 600px) {
  .dres { flex-direction: column; gap: .5rem; }
  .dres-act { flex-wrap: wrap; }
  .dlg-back { padding: 0; }
  .dpv { width: 100vw; height: 100dvh; border-radius: 0; }
}
@media (max-width: 600px) {
  .disc-tabs { width: 100%; }
  .disc-tabs a { flex: 1; text-align: center; padding: .4rem .4rem; font-size: .78rem; }
  .disc-head p { font-size: .85rem; }
}
