:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1b1f2e;
  --muted: #6b7186;
  --line: #e3e5f0;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #d13c3c;
  --ok: #17a34a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 46, .05), 0 8px 24px rgba(20, 24, 46, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141d;
    --card: #1b1e2b;
    --text: #eceef6;
    --muted: #9aa0b4;
    --line: #2a2e40;
    --accent: #7c75ff;
    --accent-soft: #23264a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.brand-name b { color: var(--accent); font-weight: 800; }
.brand-name { font-weight: 300; letter-spacing: .3px; }
.topbar-info { color: var(--muted); font-size: 13px; }

main { flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: 26px 18px 60px; }

.hero { text-align: center; margin: 18px 0 26px; }
.hero h1 { font-size: 28px; margin: 0 0 10px; }
.hero .sub { color: var(--muted); max-width: 620px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .home-grid, .composer-grid { grid-template-columns: 1fr !important; } }

button {
  font: inherit; cursor: pointer; border-radius: 10px;
  border: 1px solid transparent; padding: 9px 16px;
  transition: filter .15s, background .15s;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.primary:not(:disabled):hover { filter: brightness(1.1); }
button.ghost {
  background: transparent; color: var(--text); border-color: var(--line);
}
button.ghost:not(:disabled):hover { background: var(--accent-soft); }
button.danger { color: var(--danger); }
button.icon { padding: 6px 10px; }

input[type="text"], textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; width: 100%;
}
input[type="text"]:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
#join-form { display: flex; gap: 8px; }
#join-form input { flex: 1; font-family: Consolas, monospace; }

.optin { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; cursor: pointer; }
.optin input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.optin span { font-size: 14px; color: var(--muted); }
.optin b { color: var(--text); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 22px; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; }
.fact b { display: block; margin-bottom: 3px; font-size: 13.5px; }
.fact span { color: var(--muted); }

/* Raum */
.key-card { margin-bottom: 16px; }
.key-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 4px; }
.key-value { font-family: Consolas, "Cascadia Mono", monospace; font-size: 24px; font-weight: 700; letter-spacing: 1px; user-select: all; }
.key-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.off { background: var(--danger); }
.sep { opacity: .5; }

.pw-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 14px; color: var(--muted);
}
.pw-ico { font-size: 16px; }
#pw-input { width: 230px; flex: none; }

.ttl-bar {
  height: 4px; margin-top: 10px; border-radius: 999px;
  background: var(--line); overflow: hidden;
}
.ttl-bar > div {
  height: 100%; border-radius: 999px; background: var(--accent);
  transition: width 1s linear;
}
.ttl-bar > div.low { background: var(--danger); }

.composer-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-bottom: 22px; }
textarea { resize: vertical; min-height: 88px; }
.row-right { display: flex; justify-content: flex-end; margin-top: 10px; }

.dropzone { display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; border-style: dashed; border-width: 2px; border-color: var(--line); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 26px; margin-bottom: 6px; }
.drop-inner .muted { margin-top: 6px; font-size: 12.5px; }

.items-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin: 6px 0 10px; }
.items-head h2 { margin: 0; font-size: 18px; }
.items-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 10px; font-size: 13px; vertical-align: 2px; }

.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 16px;
}
.item-top { display: flex; align-items: center; gap: 12px; }
.item-ico { font-size: 22px; flex: none; }
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.item-main { flex: 1; min-width: 0; }
.item-buttons { display: flex; gap: 6px; flex: none; }
.item-text {
  margin: 10px 0 2px; padding: 10px 12px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow-y: auto;
}
.expiring { color: var(--danger); }

.progress { position: relative; height: 26px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
#progress-bar { position: absolute; inset: 0; width: 0%; background: var(--accent-soft); transition: width .2s; }
#progress-text { position: relative; display: block; text-align: center; font-size: 12.5px; line-height: 26px; color: var(--muted); }

.muted { color: var(--muted); }
.center { text-align: center; }

footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px; border-top: 1px solid var(--line); }

.qr-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 12, 24, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.qr-overlay[hidden] { display: none; }
.qr-card {
  /* QR immer dunkel auf weiß, unabhängig vom Theme (Scanner-Kontrast) */
  background: #fff; color: #1b1f2e;
  border-radius: 16px; padding: 22px 24px 20px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  max-width: min(92vw, 420px);
}
.qr-card svg { width: min(70vw, 320px); height: auto; display: block; }
.qr-link {
  font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px;
  overflow-wrap: anywhere; text-align: center; color: #444a63;
}
.qr-hint { font-size: 12.5px; color: #6b7186; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px;
  border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); z-index: 50;
  max-width: 90vw;
}
