:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --line: #e4e4e0;
  --line-soft: #efefeb;
  --text: #141414;
  --text-2: #3d3d3d;
  --muted: #5c5c5c;
  --faint: #8e8e8a;
  --accent: #c8102e;
  --accent-soft: #fbe9eb;
  --ok: #1c6b34;
  --ok-soft: #e7f3ea;
  --mark: #ffe69a;
  --mark-text: #141414;
  --tab-bg: rgba(255, 255, 255, 0.92);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --text-size: 18px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --surface: #1b1b1b;
    --surface-2: #262626;
    --line: #2e2e2e;
    --line-soft: #252525;
    --text: #f2f2f0;
    --text-2: #d6d6d2;
    --muted: #a8a8a4;
    --faint: #7a7a76;
    --accent: #ff5a6e;
    --accent-soft: #3a1a1f;
    --ok: #6fd08c;
    --ok-soft: #16301f;
    --mark: #6b5600;
    --mark-text: #fff6d6;
    --tab-bg: rgba(27, 27, 27, 0.92);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { max-width: 720px; margin: 0 auto; padding-bottom: calc(84px + var(--safe-bottom)); }
.page { padding: calc(16px + var(--safe-top)) 16px 24px; display: flex; flex-direction: column; gap: 20px; }

/* Kopfzeilen */
.brand { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.brand .logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: -0.2px; }
.brand .mark { width: 30px; height: 30px; color: var(--accent); flex-shrink: 0; }
.brand .lex { color: var(--accent); }
h1.big { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: -0.6px; }
h2.sec { margin: 0; font-size: 15px; font-weight: 600; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; }
.link { color: var(--accent); font-weight: 500; font-size: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 600; min-height: 32px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--accent-soft); color: var(--accent); }
.badge svg.i { width: 14px; height: 14px; stroke-width: 2.4; }

.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); padding: calc(4px + var(--safe-top)) 8px 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.topbar .back { display: flex; align-items: center; gap: 2px; min-height: 44px; padding-right: 8px; color: var(--accent); font-size: 16px; }
.topbar .title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .actions { display: flex; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--accent); border-radius: 10px; }
.icon-btn svg.i { width: 22px; height: 22px; }
.icon-btn[aria-pressed="true"] svg.i { fill: currentColor; }

/* Suchfeld */
.search { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.search svg.i { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 17px; height: 100%; }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button, .search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search-row .cancel { white-space: nowrap; display: flex; align-items: center; }
.search .clear { color: var(--faint); width: 32px; height: 32px; display: grid; place-items: center; }
.search-row { display: flex; align-items: center; gap: 12px; }
.search-row .search { flex: 1; min-width: 0; height: 46px; background: var(--surface-2); border-color: transparent; box-shadow: none; }
.search-row .cancel { color: var(--accent); font-size: 16px; min-height: 44px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 12px; min-height: 34px; font-size: 14px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip svg.i { width: 14px; height: 14px; }

/* Karten und Listen */
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.card.pad { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px; border-top: 1px solid var(--line-soft); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row .t { font-size: 15px; font-weight: 600; }
.row .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.row .chev { color: var(--faint); width: 16px; height: 16px; }
.row .ico { color: var(--muted); width: 18px; height: 18px; }
.empty { color: var(--muted); font-size: 14px; padding: 16px; text-align: center; }

.law-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.law-tile { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; min-height: 76px; }
.law-tile b { font-size: 17px; letter-spacing: -0.2px; }
.law-tile span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Resultate */
.meta-line { font-size: 13px; color: var(--muted); }
.direct { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1.5px solid var(--accent); border-radius: var(--radius); padding: 14px; }
.direct .k { font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--accent); }
.direct .t { font-size: 17px; font-weight: 700; }
.direct .s { font-size: 14px; color: var(--text-2); }
.pill-ico { width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.group-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; font-weight: 600; margin: 0 2px 6px; }
.group-h span:last-child { font-weight: 500; color: var(--muted); white-space: nowrap; }
.hit { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-top: 1px solid var(--line-soft); }
.hit:first-child { border-top: 0; }
.hit .h { display: flex; gap: 8px; align-items: baseline; font-size: 15px; }
.hit .h b { color: var(--accent); white-space: nowrap; }
.hit .h span { font-weight: 600; }
.hit .x { font-size: 14px; line-height: 1.45; color: var(--text-2); }
mark { background: var(--mark); color: var(--mark-text); border-radius: 3px; padding: 0 2px; }

/* Artikel */
.article { padding: 18px 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.crumbs { font-size: 13px; line-height: 1.5; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 6px; }
.crumbs a:hover { text-decoration: underline; }
.marginal { font-size: 14px; color: var(--muted); }
.article h1 { margin: 0; font-size: 32px; letter-spacing: -0.6px; line-height: 1.1; }
.article .heading { font-size: 18px; font-weight: 600; margin-top: -8px; }
.law-text { font-family: var(--serif); font-size: var(--text-size); line-height: 1.6; display: flex; flex-direction: column; gap: 12px; }
.law-text p { margin: 0; }
.law-text .para { display: block; scroll-margin-top: 80px; }
.law-text .para > p, .law-text .para > ul { display: block; }
.law-text .para .abs { font-family: var(--sans); font-size: 12px; color: var(--accent); font-weight: 700; margin-right: 6px; vertical-align: 0.4em; }
.law-text .para > sup.abs + p { display: inline; }
.law-text .para.hl { background: color-mix(in srgb, var(--mark) 45%, transparent); border-radius: 8px; box-shadow: 0 0 0 6px color-mix(in srgb, var(--mark) 45%, transparent); }
.law-text ul { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; }
.law-text li { display: flex; gap: 8px; }
.law-text li .lbl { font-family: var(--sans); font-weight: 600; font-size: 0.85em; min-width: 1.6em; padding-top: 0.15em; }
.law-text li > p { flex: 1; }
.law-text li > ul { margin-left: 0; }
.law-text sup.fn { font-family: var(--sans); font-size: 11px; color: var(--accent); font-weight: 600; }
.law-text .tbl { overflow-x: auto; font-family: var(--sans); font-size: 14px; }
.law-text table { border-collapse: collapse; }
.law-text td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; }
.repealed { font-family: var(--sans); font-size: 15px; color: var(--muted); font-style: italic; }
.notes { font-size: 12.5px; line-height: 1.5; color: var(--muted); padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.notes ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.source { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px 16px; }
.source a { color: var(--accent); }
.artnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--tab-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 12px calc(6px + var(--safe-bottom)); }
.artnav .in { max-width: 720px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.artnav a, .artnav button { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 6px; font-size: 15px; font-weight: 500; color: var(--text-2); }
.artnav .ph { min-width: 90px; }

/* Inhaltsverzeichnis */
.toc details { border-top: 1px solid var(--line-soft); scroll-margin-top: 64px; }
.toc > details:first-child, .toc > a:first-child { border-top: 0; }
.toc summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 12px; cursor: pointer; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary .tw { width: 14px; height: 14px; color: var(--faint); transition: transform 0.15s; stroke-width: 2.6; }
.toc details[open] > summary .tw { transform: rotate(90deg); }
.toc summary .lab { flex: 1; min-width: 0; font-size: 15px; line-height: 1.3; }
.toc summary .lab small { display: block; font-size: 12px; color: var(--muted); }
.toc .kids { padding-left: 14px; }
.toc a.art { display: flex; gap: 8px; align-items: baseline; padding: 10px 12px; min-height: 44px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.toc a.art b { white-space: nowrap; font-weight: 600; }
.toc a.art span { color: var(--text-2); }
.toc a.art.rep { color: var(--faint); }
.toc a.art.rep span { color: var(--faint); }
.law-head { display: flex; flex-direction: column; gap: 4px; }
.law-head .k { font-size: 13px; font-weight: 600; color: var(--muted); }
.law-head h1 { margin: 0; font-size: 22px; letter-spacing: -0.3px; line-height: 1.25; }
.preamble { font-family: var(--serif); font-size: 15px; color: var(--text-2); line-height: 1.5; }

/* Offline */
.status { display: flex; align-items: center; gap: 12px; }
.status .dot { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; flex-shrink: 0; }
.status .dot.ok { background: var(--ok-soft); color: var(--ok); }
.status .dot.no { background: var(--accent-soft); color: var(--accent); }
.status .t { font-size: 16px; font-weight: 600; }
.status .s { font-size: 13px; color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--accent); }
.small { font-size: 13px; color: var(--muted); line-height: 1.5; }
.small a { color: var(--accent); }
.err { color: var(--accent); font-size: 14px; }

/* Tab-Leiste */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--tab-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + var(--safe-bottom)); }
.tabs .in { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--muted); min-height: 48px; justify-content: center; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabs svg.i { width: 24px; height: 24px; }
body.reading .tabs { display: none; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-bottom)); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); }
.loading { color: var(--muted); font-size: 14px; padding: 24px 0; text-align: center; }

/* Kantone und Pakete */
.jur { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 20px; padding: 0 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: 0.3px; vertical-align: 2px; }
.crumbs .jur { margin-right: 2px; }
.pkgs .pkg { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line-soft); }
.pkgs .pkg:first-child { border-top: 0; }
.btn.small-btn { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 10px; }
.btn.small-btn svg.i { width: 18px; height: 18px; }
.ok-label { display: inline-flex; align-items: center; gap: 4px; color: var(--ok); font-size: 14px; font-weight: 600; white-space: nowrap; }
.ok-label svg.i { width: 16px; height: 16px; stroke-width: 2.4; }
.linkbtn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; color: var(--muted); font-size: 14px; }
.linkbtn svg.i { width: 16px; height: 16px; }
a.card.pad { text-decoration: none; }
