:root {
  --bg: #f6f5f1; --card: #ffffff; --text: #1d1d1b; --muted: #77756e; --line: #e6e3db;
  --accent: #2f5d50; --accent-soft: #e3ece8; --warn: #8a5a12; --warn-soft: #fbf1df;
  --danger: #a1332c; --danger-soft: #f8e5e3; --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161615; --card: #22221f; --text: #ecebe6; --muted: #9c9a92; --line: #34332f;
    --accent: #7fb3a2; --accent-soft: #24342f; --warn: #e2b46b; --warn-soft: #3a2f1c;
    --danger: #e58a82; --danger-soft: #3d2422; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; }
.hidden { display: none !important; }
h1 { font-size: 28px; margin: 0; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 14px; } .center { text-align: center; }
.error { color: var(--danger); min-height: 1.2em; font-size: 14px; margin: 6px 0; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

main { padding: calc(var(--safe-t) + 8px) 16px calc(84px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
.top { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 0 14px; }
.top.sticky { position: sticky; top: 0; background: var(--bg); z-index: 3; padding-top: calc(var(--safe-t) + 10px); align-items: center; }
.section-title { margin: 26px 0 10px; }
.row { display: flex; align-items: center; } .between { justify-content: space-between; } .gap { gap: 10px; margin: 12px 0; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; padding: 11px 16px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; flex: 1; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; width: 100%; }
@media (prefers-color-scheme: dark) { button.primary { color: #10201b; } }
button.link { background: none; border: none; color: var(--accent); padding: 6px 0; flex: 0 0 auto; font-weight: 500; white-space: nowrap; }
.btn.danger { color: var(--danger); }
button:disabled { opacity: .55; }

input, select, textarea { font: inherit; width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); -webkit-appearance: none; }
textarea { resize: vertical; }
input[type="search"] { margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.banner { border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 6px 0; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

/* Anmeldung */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-card input { margin: 18px 0 4px; }
.logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: #fff; font-size: 32px;
  font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }

/* Erfassen */
.capture-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.big-btn { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.big-btn svg { width: 30px; height: 30px; color: var(--accent); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.thumb { position: relative; width: 72px; height: 92px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line);
  background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); text-align: center; padding: 4px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.thumb .x { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 11px; padding: 0; flex: 0;
  background: rgba(0,0,0,.6); color: #fff; border: none; font-size: 14px; line-height: 1; z-index: 2; }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 10px; font-size: 15px; }
.check input { width: 20px; height: 20px; -webkit-appearance: checkbox; }

/* Liste */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border-radius: 999px; padding: 6px 12px; font-size: 14px; border: 1px solid var(--line); background: var(--card); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; cursor: pointer; }
.item .ic { width: 48px; height: 60px; flex: 0 0 48px; border-radius: 8px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 11px; font-weight: 600; }
.item .ic img { width: 100%; height: 100%; object-fit: cover; }
.item .body { min-width: 0; flex: 1; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-size: 14px; font-weight: 600; white-space: nowrap; }
.badge { font-size: 12px; border-radius: 6px; padding: 2px 7px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.wait { background: var(--warn-soft); color: var(--warn); } .badge.err { background: var(--danger-soft); color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
#expiring h2 { margin-bottom: 8px; } #expiring .e { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; font-size: 15px; }

/* Chat */
.chat-log { display: flex; flex-direction: column; gap: 10px; padding-bottom: 76px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
@media (prefers-color-scheme: dark) { .msg.user { color: #10201b; } }
.msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot.typing { color: var(--muted); }
.refs { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; white-space: normal; }
.ref { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 8px 10px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); cursor: pointer; }
.chat-form { position: fixed; left: 0; right: 0; bottom: calc(64px + var(--safe-b)); display: flex; gap: 8px;
  padding: 10px 16px; background: var(--bg); max-width: 720px; margin: 0 auto; }
.chat-form button { width: 52px; flex: 0 0 52px; padding: 0; }

/* Detail */
.detail { position: fixed; inset: 0; background: var(--bg); overflow-y: auto; z-index: 10; padding: 0 16px calc(30px + var(--safe-b)); }
.detail > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.preview { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-height: 120px;
  display: flex; align-items: center; justify-content: center; }
.preview img { width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.preview iframe { width: 100%; height: 60vh; border: 0; background: #fff; }
.form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.form label input, .form label select, .form label textarea { margin-top: 4px; color: var(--text); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
pre { white-space: pre-wrap; font-size: 13px; max-height: 50vh; overflow: auto; }
summary { cursor: pointer; font-weight: 600; }

/* Tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-b)); z-index: 5; }
.tabs button { border: none; background: none; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); padding: 6px 0; border-radius: 10px; }
.tabs button.active { color: var(--accent); font-weight: 600; }

#detail-meta { white-space: pre-line; }
.ref small { font-size: 12px; word-break: break-word; }

.btn.wide { width: 100%; margin-top: 12px; padding: 14px; font-weight: 500; }
.btn.wide svg { color: var(--accent); }
.big-count { font-size: 20px; font-weight: 600; margin: 8px 0 14px; }
.primary-label { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--accent); color: #fff;
  border-radius: 12px; padding: 18px; font-size: 18px; font-weight: 600; cursor: pointer; }
@media (prefers-color-scheme: dark) { .primary-label { color: #10201b; } }

table.costs { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.costs td { padding: 4px 4px; border-bottom: 1px solid var(--line); }
table.costs td.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.costs tr.sum td { font-weight: 600; border-bottom: none; }
#costs summary { cursor: pointer; }

.pair-code { font-size: 40px; font-weight: 700; letter-spacing: 4px; text-align: center; margin: 18px 0; font-variant-numeric: tabular-nums; }
.dev { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dev:last-child { border-bottom: none; }
.dev form { margin: 0; gap: 6px; }
.link.danger { color: #c0392b; }
.dev form button.primary { width: auto; }
button.secondary { width: 100%; margin: 4px 0 10px; }
