: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; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
#lang-select {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 6px; cursor: pointer;
}
@media (max-width: 700px) { .topbar-info { display: none; } }
#btn-header-upgrade { white-space: nowrap; }
.prem-badge {
  font-size: 13px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 5px 12px;
  white-space: nowrap; cursor: default;
}

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; position: relative; transition: padding .15s; }
.header-toggle {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.header-toggle:hover { background: var(--accent-soft); color: var(--accent); }
/* Eingeklappt: dezent – nur Share-Key + Session-Status */
.key-card.collapsed { padding: 12px 18px; }
.key-card.collapsed .key-actions,
.key-card.collapsed .pw-row { display: none; }
.key-card.collapsed .key-value { font-size: 18px; }
.key-card.collapsed .label { margin-bottom: 1px; }
.key-card.collapsed .status-row { margin-top: 8px; padding-top: 8px; }
.key-card.collapsed .key-row { padding-right: 26px; }
.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; }
#lic-input { width: 230px; flex: none; font-family: Consolas, monospace; }
#recover-input { width: 220px; flex: none; }
button.small { padding: 6px 12px; font-size: 13.5px; }
.recover-link { color: var(--muted); font-size: 12.5px; text-decoration: underline; }
.recover-link:hover { color: var(--accent); }
.claim-actions { display: flex; gap: 10px; }
#claim-key { user-select: all; }
.sharefile-name { font-weight: 600; font-size: 14px; text-align: center; overflow-wrap: anywhere; }
.sharefile-qr svg { width: min(60vw, 220px); height: auto; display: block; margin: 0 auto; }

.buy-card { align-items: stretch; text-align: left; max-width: min(92vw, 460px); }
.buy-card h2 { margin: 0; text-align: center; }
.buy-info { font-size: 14px; color: #444a63; }
.buy-optin { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.buy-optin input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.buy-optin span { font-size: 13px; color: #444a63; }
.qr-hint.left { text-align: left; }
.buy-card .claim-actions { justify-content: flex-end; }
button.danger-btn { background: var(--danger); }
button.danger-btn:not(:disabled):hover { filter: brightness(1.1); }

.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; }
.composer-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 10px; flex-wrap: wrap;
}
.clip-sync {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 12.5px; color: var(--muted);
}
.clip-sync input { width: 15px; height: 15px; accent-color: var(--accent); flex: none; }

button.linkish {
  background: none; border: none; padding: 0; color: var(--muted);
  font: inherit; font-size: 14px; text-decoration: underline dotted;
  cursor: pointer;
}
button.linkish:hover { color: var(--accent); }

.device-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.device-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 14px;
  color: var(--text); flex-wrap: wrap;
}
.device-row .muted { font-size: 12.5px; }
.device-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.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; }

.faq { margin-top: 30px; }
.faq h2 { font-size: 18px; margin-bottom: 10px; }
.faq details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px;
}
.faq summary { cursor: pointer; font-weight: 600; font-size: 14.5px; }
.faq p { margin: 10px 0 2px; color: var(--muted); font-size: 14px; }

footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px; border-top: 1px solid var(--line); }
.footer-links { margin-top: 8px; }
.footer-links a { color: var(--muted); text-decoration: underline; }
.footer-links a:hover { color: var(--accent); }

/* Rechtsseite (legal.html) */
.legal-wrap { max-width: 760px; margin: 0 auto; padding: 26px 18px 60px; }
.legal-wrap h1 { font-size: 24px; }
.legal-wrap h2 { font-size: 18px; margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line); }
.legal-wrap h3 { font-size: 15px; margin-top: 20px; }
.legal-wrap p, .legal-wrap li { font-size: 14px; color: var(--text); }
.legal-wrap .muted { font-size: 13px; }
.legal-lang-note { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--accent); text-decoration: none; }

.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;
}

/* Live-Direkt-Transfer (Gerät → Gerät) */
.device-row > div:first-child { margin-right: auto; }
.device-row.drop-target { cursor: copy; }
.device-row.drag-over { border-color: var(--accent); background: var(--accent-soft); }

.xfer-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.xfer-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px;
}
.xfer-label { flex: 1; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xfer-bar { flex: 0 0 120px; height: 6px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.xfer-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .2s; }
.xfer-row button { padding: 2px 9px; }

.direct-xfer { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; display: flex; flex-direction: column; gap: 9px; text-align: left; }
.direct-xfer .dx-title { font-weight: 600; font-size: 14px; }
.dir-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.small { font-size: 12px; color: var(--muted); }
.xfer-offer-file { font-size: 15px; }

/* Rechner-Chips unter der Statuszeile (Drag&Drop-Ziele) */
.device-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 13px; color: var(--text); max-width: 220px;
}
.chip.drop-target { cursor: copy; }
.chip.drop-target:hover { border-color: var(--accent); }
.chip.self { border-style: dashed; color: var(--muted); }
.chip.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.chip-ico { font-size: 15px; line-height: 1; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rename-wrap { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; max-width: 320px; }
.rename-wrap input { flex: 1; min-width: 0; padding: 6px 10px; }
