:root {
  --bg: #0b1220;
  --bg2: #0f182a;
  --panel: #141f31;
  --panel2: #1a2740;
  --line: #2a3a54;
  --text: #eaf0f8;
  --muted: #9cabc1;
  --dim: #6f8099;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --ok: #34d399;
  --warn: #fbbf24;
  --hyp: #c4a7ff;
  --danger: #f87171;
  --radius: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(circle at 70% -10%, #1d2d4a, var(--bg) 60%) fixed; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent2); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 26px 22px; }
.login-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.5px; }
.login-card p { color: var(--muted); margin: 0 0 18px; font-size: 14px; line-height: 1.5; }

/* ---------- App-Gerüst ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 14px 8px; }
.brand { font-weight: 700; font-size: 19px; letter-spacing: -.4px; flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.status-dot.busy { background: var(--warn); animation: pulse 1.2s infinite; }
.status-dot.err { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
.iconbtn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; font-size: 18px; flex: none; }
.views { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; overflow-y: auto; padding: 4px 14px calc(var(--nav-h) + var(--safe-b) + 90px); -webkit-overflow-scrolling: touch; }
.view.graph-view { padding: 0; overflow: hidden; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: #0d1626f2; border-top: 1px solid var(--line); backdrop-filter: blur(10px); z-index: 20; }
.nav button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--dim); position: relative; }
.nav button .ic { font-size: 20px; line-height: 1; }
.nav button[aria-current="page"] { color: var(--text); }
.nav button[aria-current="page"] .ic { filter: drop-shadow(0 0 6px #3b82f6aa); }
.badge { position: absolute; top: 7px; left: calc(50% + 6px); background: var(--warn); color: #1a1300; border-radius: 10px; font-size: 10px; font-weight: 700; padding: 1px 5px; min-width: 16px; text-align: center; }
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 8px 24px #0008; z-index: 21; }
.fab:active { transform: scale(.95); }

/* ---------- Graph ---------- */
.graph-wrap { position: absolute; inset: 0; bottom: calc(var(--nav-h) + var(--safe-b)); }
#graph { width: 100%; height: 100%; display: block; touch-action: none; }
.graph-filters { position: absolute; top: 6px; left: 10px; right: 10px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; z-index: 2; }
.graph-filters::-webkit-scrollbar { display: none; }
.fchip { flex: none; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #101a2cd9; border-radius: 20px; padding: 8px 11px; font-size: 12px; color: var(--muted); }
.fchip[aria-pressed="true"] { color: var(--text); border-color: #4b6286; background: #1b2a45e6; }
.fchip .sw { width: 18px; height: 0; border-top: 2px solid; }
.sw.confirmed { border-color: #9fb3cf; }
.sw.suggested { border-color: var(--warn); border-top-style: dashed; }
.sw.hypothesis { border-color: var(--hyp); border-top-style: dotted; border-top-width: 3px; }
.graph-tools { position: absolute; right: 10px; top: 54px; display: flex; flex-direction: column; gap: 8px; z-index: 2; }
.graph-tools .iconbtn { background: #101a2cd9; }
.graph-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; color: var(--muted); pointer-events: none; }
.graph-empty > div { pointer-events: auto; }
.sheet { position: absolute; left: 10px; right: 10px; bottom: 12px; background: #141f31f2; border: 1px solid var(--line); border-radius: 18px; padding: 14px 15px; z-index: 3; box-shadow: 0 10px 30px #0009; backdrop-filter: blur(8px); max-height: 46%; overflow-y: auto; }
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.sheet .muted { font-size: 13px; }

/* ---------- Allgemeine Bausteine ---------- */
h2.vt { font-size: 21px; margin: 8px 2px 12px; letter-spacing: -.3px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px; margin-bottom: 10px; }
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--panel2); }
.card h3 { margin: 0 0 5px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 10px 14px; font-size: 14px; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ok { border-color: #2a6a55; color: #8ff0c9; }
.btn.no { border-color: #6b3434; color: #ffb4b4; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn:active:not(:disabled) { transform: scale(.98); }
label { display: block; color: var(--muted); font-size: 12px; margin: 12px 0 5px; }
input[type=text], input[type=password], input[type=search], textarea, select { width: 100%; background: #0c1626; border: 1px solid #344963; padding: 12px; border-radius: 12px; font-size: 16px; }
input:focus, textarea:focus, select:focus { outline: 2px solid #3b82f680; border-color: var(--accent); }
textarea { min-height: 42vh; resize: vertical; line-height: 1.5; font-family: ui-monospace, "Roboto Mono", monospace; font-size: 15px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { background: #24344b; border-radius: 30px; padding: 4px 10px; font-size: 12px; color: #c4d4e8; border: 0; }
.chip.cat { color: #0b1220; font-weight: 600; }
.kind { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; text-transform: none; }
.kind.confirmed { background: #1f3346; color: #b8cde6; }
.kind.suggested { background: #3b2f10; color: #fcd34d; }
.kind.hypothesis { background: #2c2445; color: #d6c6ff; }
.conf { font-size: 11px; color: var(--dim); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; line-height: 1.6; }
.notice { background: #2a2312; border: 1px solid #5c4a1c; color: #f6dca0; border-radius: 12px; padding: 11px 13px; font-size: 13px; line-height: 1.45; margin-bottom: 10px; }
.notice.err { background: #2c1518; border-color: #6b2e35; color: #ffc2c2; }
.searchbar { position: sticky; top: 0; z-index: 2; background: linear-gradient(var(--bg) 70%, transparent); padding: 4px 0 10px; display: flex; gap: 8px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 86px); background: #1f2d47; border: 1px solid #3a4f72; color: var(--text); padding: 11px 16px; border-radius: 14px; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 8px 24px #0009; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.progress { height: 6px; background: #0c1626; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.progress > i { display: block; height: 100%; background: var(--accent); }

/* ---------- Notiz-Ansicht ---------- */
.page { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; }
.page-head { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 8px; border-bottom: 1px solid var(--line); }
.page-head .title { flex: 1; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(30px + var(--safe-b)); }
.note-title { font-size: 25px; margin: 2px 0 6px; letter-spacing: -.4px; line-height: 1.2; word-break: break-word; }
.md { line-height: 1.65; font-size: 16px; word-wrap: break-word; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.25; margin: 1.1em 0 .4em; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 17px; }
.md p { margin: .6em 0; }
.md ul, .md ol { padding-left: 1.3em; margin: .5em 0; }
.md blockquote { margin: .6em 0; padding: .2em .9em; border-left: 3px solid #3b5375; color: #c3d0e0; }
.md code { background: #1b2840; padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.md pre { background: #0c1626; border: 1px solid var(--line); padding: 10px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md .wl { color: #8ec5ff; text-decoration: none; border-bottom: 1px dashed #4f7cb3; }
.md .wl.missing { color: var(--dim); border-bottom-color: var(--dim); }
.md .tag { color: #8ff0c9; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .7px; color: var(--dim); margin: 22px 0 8px; }
.conn { border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; margin-bottom: 8px; background: var(--panel); }
.conn .who { font-weight: 600; font-size: 15px; background: none; border: 0; padding: 0; text-align: left; color: #cfe2ff; }
.conn .why { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 5px 0 0; }
.conn .actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.conn .actions .btn { min-height: 36px; padding: 6px 11px; font-size: 13px; }
.pair { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.pair .arrow { color: var(--dim); font-weight: 400; }
.pair button { background: none; border: 0; padding: 0; color: #cfe2ff; font-weight: 600; font-size: 15px; text-align: left; }
.editor-hint { font-size: 12px; color: var(--dim); margin-top: 6px; line-height: 1.5; }
.suggest-list { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; margin-top: 6px; overflow: hidden; }
.suggest-list button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; font-size: 14px; }
.answer { white-space: pre-wrap; line-height: 1.6; font-size: 15px; }

@media (min-width: 760px) {
  .view { padding-left: max(14px, calc(50% - 380px)); padding-right: max(14px, calc(50% - 380px)); }
  .page-body { padding-left: max(16px, calc(50% - 380px)); padding-right: max(16px, calc(50% - 380px)); }
  .sheet { left: auto; width: 420px; }
}
.mt16 { margin-top: 16px; }
.mt8 { margin-top: 8px; }
.center { justify-content: center; }
