:root {
  --bg: #1e2125;
  --card: #2a2d32;
  --panel: #2b2f34;
  --line: #41464d;
  --text: #dee2e6;
  --muted: #a7adb6;
  --soft: #b6bce8;
  --blue: #0d6efd;
  --blue-h: #0b5ed7;
  --green: #198754;
  --green-h: #157347;
  --orange: #f7931e;
  --red: #e5534b;
  --ok: #3fb950;
  --field: #212428;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 24px 16px 32px; }

/* ---------- Kopf ---------- */
.brand { text-align: center; margin-bottom: 28px; }
.logo { display: inline-flex; align-items: center; gap: 22px; color: #fff; text-decoration: none; }
.logo-mark { width: 72px; height: 72px; border-radius: 12px; background: var(--orange); display: grid; place-items: center; color: #fff; }
.logo-mark svg { width: 46px; height: 46px; stroke-width: 1.8; }
.logo-text { font-size: 42px; font-weight: 800; letter-spacing: -.02em; }
.tagline { color: var(--soft); font-size: 21px; margin: 18px 0 0; }

/* ---------- Karten ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.muted { color: var(--soft); margin: 0 0 16px; }
.error { color: var(--red); min-height: 1.5em; margin: 8px 0 0; font-size: 15px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 999px; padding: 12px 26px;
  font: inherit; font-size: 18px; font-weight: 500; color: #fff; cursor: pointer;
  transition: background .15s, transform .05s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--soft); outline-offset: 2px; }
.btn-primary { background: var(--blue); }
.btn-primary:hover { background: var(--blue-h); }
.btn-green { background: var(--green); }
.btn-green:hover { background: var(--green-h); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(255, 255, 255, .05); }
.btn-lg { width: 100%; padding: 14px 26px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 50px; align-self: stretch;
  background: transparent; border: 0; border-left: 1px solid var(--line); color: var(--muted); cursor: pointer; font-size: 20px;
}
.icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .04); }

.link-btn {
  display: inline-flex; align-items: center; gap: 7px; justify-self: end;
  background: none; border: 0; color: var(--text); font: inherit; font-size: 15px; cursor: pointer; padding: 4px 2px;
}
.link-btn:hover:not(:disabled) { color: #fff; text-decoration: underline; }
.link-btn:disabled { opacity: .45; cursor: default; }
.link-btn.danger { color: var(--muted); }
.link-btn.danger:hover { color: var(--red); }

/* ---------- Startseite ---------- */
.home { display: grid; grid-template-columns: 1fr auto 1fr; gap: 28px; align-items: start; max-width: 820px; margin: 0 auto; }
.home h2 { margin: 0 0 6px; font-size: 22px; }
.home-sep { align-self: stretch; display: grid; place-items: center; position: relative; color: var(--muted); font-size: 14px; }
.home-sep::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px solid var(--line); }
.home-sep span { background: var(--card); padding: 8px 0; position: relative; }
.code-input {
  width: 100%; margin-bottom: 14px; padding: 12px 14px;
  background: var(--field); border: 1px solid var(--line); border-radius: 10px;
  color: #fff; font: 600 30px/1.2 var(--mono); letter-spacing: .25em; text-align: center;
}
.code-input:focus { outline: none; border-color: var(--blue); }

/* ---------- Geräte in der Nähe ---------- */
.nearby { max-width: 820px; margin: 18px auto 0; padding: 22px 28px; }
.nearby-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.nearby-head h2 { margin: 0; font-size: 20px; }
.nearby-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.nearby-empty { margin: 0; font-size: 15px; }
.nearby-dev {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer;
  background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: inherit;
  transition: border-color .15s, background .15s;
}
.nearby-dev:hover:not(:disabled) { border-color: var(--blue); background: rgba(13, 110, 253, .08); }
.nearby-dev:disabled { cursor: default; opacity: .75; }
.nd-icon { font-size: 26px; color: var(--soft); display: grid; }
.nd-text { flex: 1; min-width: 0; display: grid; }
.nd-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-sys { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-act { font-size: 13px; color: #8fb4ff; white-space: nowrap; }
.nearby-dev:disabled .nd-act { color: var(--muted); }
.nearby-room { border-top: 1px solid var(--line); padding: 12px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nearby-label { color: var(--muted); font-size: 14px; }
.nearby-list.compact { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.nearby-list.compact .nearby-dev { padding: 6px 12px; border-radius: 999px; gap: 8px; width: auto; }
.nearby-list.compact .nd-icon { font-size: 18px; }
.nearby-list.compact .nd-sys { display: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 11px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track .knob { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--soft); outline-offset: 2px; }

/* ---------- Raum ---------- */
.room-top { display: grid; grid-template-columns: 220px 1fr; gap: 48px; align-items: center; margin-bottom: 28px; }
.qr { width: 220px; height: 220px; color: var(--soft); }
.qr svg { width: 100%; height: 100%; stroke: none; fill: currentColor; }
.room-info { min-width: 0; }

.status { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 17px; margin-bottom: 14px; color: var(--text); }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--blue); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(63, 185, 80, .18); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 4px rgba(229, 83, 75, .18); }
@keyframes spin { to { transform: rotate(360deg); } }

.code-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 12px;
  background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding-left: 14px; overflow: hidden;
}
.code-label { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.room-code { flex: 1; font: 700 32px/1.6 var(--mono); letter-spacing: .14em; color: #fff; }
.link-field { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--field); margin-bottom: 22px; }
.link-field input { flex: 1; min-width: 0; background: transparent; border: 0; color: #8fb4ff; font: 16px var(--mono); padding: 12px 14px; }
.link-field input:focus { outline: none; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- Listen ---------- */
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-top: 18px; overflow: hidden; }
.panel-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 20px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list .empty { text-align: center; color: var(--text); padding: 12px; }

.user { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }
.user .star { color: var(--orange); fill: var(--orange); stroke: none; }
.user .you { color: var(--muted); }
.user .device { color: var(--muted); font-size: 18px; display: inline-grid; }
.user .sys { color: var(--muted); font-size: 12px; }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.direct { color: var(--ok); border-color: rgba(63, 185, 80, .4); }
.badge.turn { color: #58a6ff; border-color: rgba(88, 166, 255, .4); }
.badge.relay { color: #d29922; border-color: rgba(210, 153, 34, .4); }
.safety { font: 12px var(--mono); color: var(--muted); cursor: help; }

.file-main { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.file .dir { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: rgba(255, 255, 255, .05); font-size: 18px; }
.file .dir.in { color: var(--ok); }
.file .dir.out { color: #8fb4ff; }
.file .meta { min-width: 0; }
.file .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.file .sub { color: var(--muted); font-size: 13px; }
.file .sub .fail { color: var(--red); }
.bar { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .08); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .2s; }
.bar.done > i { background: var(--ok); }
.acts { display: flex; gap: 8px; align-items: center; }
.act {
  color: var(--text); font: inherit; font-size: 14px; background: none; border: 1px solid var(--line); border-radius: 8px;
  min-width: 38px; height: 36px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
.act svg { font-size: 18px; }
.act:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.act.ok { background: var(--green); border-color: var(--green); color: #fff; padding: 0 12px; }
.act.ok:hover { background: var(--green-h); }
.expand { background: none; border: 0; color: var(--muted); padding: 0; width: 22px; height: 22px; display: grid; place-items: center; cursor: pointer; flex: none; }
.expand .chev { transition: transform .15s; }
.file.open .expand .chev { transform: rotate(90deg); }
.detail { list-style: none; margin: 10px 0 0 48px; padding: 8px 12px; border-left: 2px solid var(--line); max-height: 260px; overflow: auto; font-size: 13px; }
.detail li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; color: var(--muted); }
.detail .dpath { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.detail .dstate { flex: none; }
.detail .more { justify-content: center; }

.accept-mode { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); justify-self: start; }
.accept-mode select {
  background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 13px;
}

.share-banner { max-width: 820px; margin: 0 auto 16px; padding: 12px 16px; border-radius: 10px; background: rgba(13, 110, 253, .15); border: 1px solid rgba(13, 110, 253, .5); text-align: center; }
.share-targets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.share-targets:empty { display: none; }
.share-targets .btn { font-size: 15px; padding: 7px 16px; gap: 8px; }

/* ---------- Text/Links ---------- */
.text-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.text-form textarea {
  flex: 1; min-width: 0; resize: none; max-height: 160px; padding: 7px 11px; background: var(--field); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 15px; line-height: 1.4;
}
.text-form textarea:focus { outline: none; border-color: var(--blue); }
.text-form .btn { flex: none; }
.file.text .text-body { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9.5em; overflow: auto; font-size: 15px; }
.file.text .text-body a { color: #8fb4ff; }
.file .dir.thumb { padding: 0; overflow: hidden; cursor: zoom-in; background: #000; border: 0; }
.file .dir.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
dialog.preview { width: auto; max-width: calc(100vw - 32px); text-align: center; }
dialog.preview img { display: block; margin: 0 auto; width: min(480px, 80vw); max-height: 60vh; object-fit: contain; border-radius: 8px; background: #000; image-rendering: auto; }
dialog.preview p { margin: 10px 0 0; overflow-wrap: anywhere; }
.nearby-dev.offline { opacity: .75; }
.nearby-dev.offline .nd-icon { color: var(--muted); }

.room-foot { text-align: center; margin-top: 16px; }

/* ---------- Konto: Meine Geräte ---------- */
.mine-acts { display: inline-flex; gap: 14px; flex-wrap: wrap; }
.mine-acts .link-btn { color: var(--soft); font-size: 14px; }
.mine-acts .link-btn.on { color: var(--ok); }
.login-hint { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.login-hint .link-btn { color: var(--soft); font-size: 14px; padding: 0; text-decoration: underline; }
.pair-box { display: flex; gap: 18px; align-items: center; margin: 6px 0 10px; flex-wrap: wrap; }
.pair-box .qr { width: 150px; height: 150px; flex: none; }
.pair-box .room-code { font-size: 28px; letter-spacing: .12em; }
.account-devices { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.account-devices li { display: flex; align-items: center; gap: 10px; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.account-devices .ad-text { flex: 1; min-width: 0; display: grid; }
.account-devices .ad-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-devices .ad-sys { font-size: 12px; color: var(--muted); }
.account-devices .ad-this { font-size: 12px; color: var(--ok); }
.account-devices .act { flex: none; }
.nd-own { color: var(--orange); }

/* ---------- Windows-App: Update-Hinweis ---------- */
.app-update {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 16px;
  padding: 8px 16px; background: var(--blue); color: #fff; font-size: 15px; box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.app-update-acts { display: inline-flex; align-items: center; gap: 8px; }
.btn-sm { font-size: 14px; padding: 5px 14px; }
.app-update .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .6); }
.app-update .btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.btn-light { background: #fff; color: var(--blue); text-decoration: none; }
.btn-light:hover { background: #e7efff; }
.app-update-x { display: inline-grid; place-items: center; background: none; border: 0; color: #fff; font-size: 18px; padding: 4px; cursor: pointer; opacity: .8; }
.app-update-x:hover { opacity: 1; }
.app-version { display: inline-flex; align-items: center; gap: 8px; }
.app-version .link-btn { color: var(--muted); font-size: 14px; padding: 0; }

dialog.notes { width: min(520px, calc(100vw - 32px)); }
.notes-body { max-height: 60vh; overflow: auto; margin: 10px 0; }
.notes-body h4 { margin: 14px 0 4px; color: var(--soft); font-size: 15px; }
.notes-body h4:first-child { margin-top: 0; }
.notes-body ul { margin: 0; padding-left: 20px; }
.notes-body li { margin: 4px 0; }

/* ---------- Fuß ---------- */
.foot a { color: var(--muted); }
.foot a:hover { color: var(--text); }
.foot { flex-wrap: wrap; display: flex; justify-content: center; align-items: center; gap: 8px; color: #80868f; font-size: 14px; margin-top: 30px; text-align: center; }

/* ---------- Drag & Drop ---------- */
.drop { position: fixed; inset: 0; background: rgba(13, 110, 253, .15); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; pointer-events: none; }
.drop div { border: 3px dashed var(--blue); border-radius: 20px; padding: 40px 60px; font-size: 24px; font-weight: 600; background: rgba(30, 33, 37, .85); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(420px, calc(100vw - 32px)); }
.toast { background: #353a40; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); animation: pop .2s ease-out; }
.toast.err { border-color: rgba(229, 83, 75, .6); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Dialog ---------- */
dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h3 { margin: 0 0 6px; }
dialog input { width: 100%; padding: 11px 13px; background: var(--field); border: 1px solid var(--line); border-radius: 8px; color: #fff; font: inherit; }
dialog input:focus { outline: none; border-color: var(--blue); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.dlg-actions .btn { font-size: 16px; padding: 9px 20px; }

/* ---------- Mobil ---------- */
@media (max-width: 760px) {
  .wrap { padding-top: 18px; }
  .logo { gap: 14px; }
  .logo-mark { width: 52px; height: 52px; }
  .logo-mark svg { width: 34px; height: 34px; }
  .logo-text { font-size: 32px; }
  .tagline { font-size: 17px; margin-top: 12px; }
  .card { padding: 18px; }
  .home { grid-template-columns: 1fr; gap: 12px; }
  .home-sep { height: 30px; }
  .home-sep::before { top: 50%; bottom: auto; left: 0; right: 0; border-left: 0; border-top: 1px solid var(--line); }
  .home-sep span { padding: 0 10px; }
  .nearby { padding: 18px; }
  .nearby-room { padding: 10px 14px; }
  .room-top { grid-template-columns: 1fr; gap: 20px; justify-items: center; }
  .qr { width: 180px; height: 180px; }
  .room-info { width: 100%; }
  .room-code { font-size: 26px; }
  .actions .btn { flex: 1 1 100%; }
  .panel-head { grid-template-columns: 1fr auto; padding: 10px 14px; row-gap: 8px; }
  .panel-head > span:first-child { display: none; }
  .panel-head .accept-mode { grid-column: 1 / -1; grid-row: 2; }
  .file-main { grid-template-columns: auto 1fr; }
  .acts { grid-column: 1 / -1; justify-content: flex-end; }
  .acts:empty { display: none; }
  .detail { margin-left: 0; }
  .user .sys { display: none; }
  .list > li { padding: 10px 14px; }
}
