:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #14213d;
  --muted: #6b7280;
  --line: #e5e1d8;
  --accent: #e76f2c;
  --accent-ink: #ffffff;
  --ok: #2a9d8f;
  --warn: #c2410c;
  --chip: #efe9de;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 16px rgba(20, 33, 61, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1626; --card: #182238; --ink: #eef1f7; --muted: #9aa4b8; --line: #26324d;
    --chip: #223052; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--warn); min-height: 1.2em; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 24px 0 8px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); padding: 28px; border-radius: 20px; box-shadow: var(--shadow); display: grid; gap: 12px; text-align: center; }
.logo { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-size: 28px; font-weight: 700; }

/* Layout */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 16px 8px; max-width: 760px; margin: 0 auto; }
#content { padding: 0 16px 24px; max-width: 760px; margin: 0 auto; }
.banner { margin: 0 16px 8px; padding: 8px 12px; border-radius: 10px; background: #fff4d6; color: #7a5300; font-size: 13px; max-width: 728px; }
@media (min-width: 792px) { .banner { margin: 0 auto 8px; } }

/* Inputs & Buttons */
input, textarea, select { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
textarea { resize: vertical; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 11px 16px; border-radius: 10px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; }
.icon-btn { font-size: 22px; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

/* Karten */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; border-left: 4px solid transparent; }
.card.p-high { border-left-color: var(--accent); }
.card.p-mid { border-left-color: #e9c46a; }
.card-title { font-weight: 600; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 12px; background: var(--chip); padding: 2px 8px; border-radius: 999px; color: var(--ink); }
.chip.warn { background: #fde2d3; color: #9a3412; }
.chip.draft { background: #d8f0ec; color: #155e55; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { font-size: 28px; display: block; letter-spacing: -.02em; }
.event { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 92px; font-size: 14px; }

/* Tabbar & FAB */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabbar button { font: inherit; font-size: 11px; border: 0; background: none; color: var(--muted); padding: 8px 0 10px; display: grid; gap: 2px; justify-items: center; cursor: pointer; }
.tabbar button span { font-size: 20px; }
.tabbar button.active { color: var(--accent); font-weight: 600; }
.fab { position: fixed; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 30px; box-shadow: 0 6px 18px rgba(231, 111, 44, .4); cursor: pointer; z-index: 6; }

/* Sheets */
dialog.sheet { width: min(640px, 100%); max-height: 92vh; border: 0; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); margin: auto auto 0; background: var(--card); color: var(--ink); }
@media (min-width: 700px) { dialog.sheet { border-radius: 20px; margin: auto; } }
dialog::backdrop { background: rgba(10, 15, 30, .45); }
dialog form, #detail { display: grid; gap: 12px; }
.detail-section { display: grid; gap: 6px; }
.detail-section label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.missing { margin: 0; padding-left: 20px; }
.excerpt { white-space: pre-wrap; font-size: 14px; background: var(--bg); border-radius: 10px; padding: 10px 12px; max-height: 180px; overflow: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.testtools { border-top: 1px dashed var(--line); padding-top: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100% - 32px); z-index: 20; font-size: 14px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
