:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #ececf0;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --sep: rgba(0, 0, 0, .1);
  --accent: #0071e3;          /* Links, Fokus */
  --accent-fill: #0071e3;     /* Buttons mit weißer Schrift (4.6:1) */
  --accent-press: #005bb8;
  --accent-soft: rgba(0, 113, 227, .1);
  --ok: #248a3d;
  --warn: #b25000;
  --bad: #d70015;
  --glass: rgba(245, 245, 247, .72);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .07);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .18);
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --ease: cubic-bezier(.32, .72, 0, 1);  /* iOS-Sheet-Kurve, kein Überschwingen */
  --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Roboto Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #98989d;
    --sep: rgba(255, 255, 255, .12);
    --accent: #0a84ff;
    --accent-press: #0062cc;
    --accent-soft: rgba(10, 132, 255, .16);
    --ok: #30d158;
    --warn: #ff9f0a;
    --bad: #ff453a;
    --glass: rgba(0, 0, 0, .62);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .06);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.47 var(--font);
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: 0 max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile (Glas) ---------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-left)));
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 7px; }
h1 { margin: 0; font-size: 1.375rem; font-weight: 700; letter-spacing: -.025em; }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 14px;
  border: 0; border-radius: 999px;
  background: var(--surface-2);
  font-size: .875rem; font-weight: 500;
  transition: transform .1s ease-out, background-color .2s;
}
.status:active { transform: scale(.96); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); transition: background-color .3s; }
.status[data-state="ok"] .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status[data-state="wait"] .dot { background: var(--warn); }
.status[data-state="bad"] .dot { background: var(--bad); }

main { max-width: 640px; margin: 0 auto; padding-top: 8px; display: grid; gap: 16px; }

/* ---------- Geräte ---------- */
.devices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips { display: contents; list-style: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 0;
  background: var(--surface); box-shadow: var(--shadow);
  font-size: .875rem; font-weight: 500;
  max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .dot { flex: none; background: var(--ok); }
.chip.me { background: transparent; box-shadow: inset 0 0 0 1px var(--sep); color: var(--text-2); }
.chip.add { color: var(--accent); transition: transform .1s ease-out; }
.chip.add:active { transform: scale(.96); }
.chips li { transition: opacity .3s var(--ease), transform .4s var(--ease); }
@starting-style { .chips li { opacity: 0; transform: scale(.9); } }

/* ---------- Ablagefläche ---------- */
.drop {
  display: grid; justify-items: center; gap: 4px;
  padding: 36px 20px 30px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  text-align: center;
  outline: 2px dashed transparent; outline-offset: -10px;
  transition: outline-color .2s, background-color .2s;
}
.drop-icon { color: var(--accent); margin-bottom: 6px; }
.drop-title { margin: 0; font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; }
.drop-sub { margin: 0; color: var(--text-2); font-size: .9375rem; }
kbd { font: 500 .8125rem var(--font); padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
@media (pointer: coarse) {
  .hint-desktop { display: none; }
  .drop-title { font-size: 1.125rem; }
  .status, .chip, .item-actions .btn { min-height: 44px; }
  :root .link { padding: 12px 8px; }
  :root .send { width: 44px; height: 44px; }
  .composer textarea { min-height: 44px; padding: 11px 0; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 0; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text);
  font-size: 1rem; font-weight: 600;
  transition: transform .1s ease-out, background-color .15s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent-fill); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.wide { width: 100%; min-height: 50px; }
.btn:disabled, .send:disabled { opacity: .4; cursor: default; transform: none; }
.link { border: 0; background: none; padding: 4px 2px; color: var(--accent); font-weight: 500; }
.link:active { opacity: .6; }
@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover { filter: brightness(.96); }
  .btn.primary:not(:disabled):hover { filter: brightness(1.08); }
  .link:hover { text-decoration: underline; }
}

/* ---------- Eingabe ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 6px 6px 16px;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
}
.composer:focus-within { box-shadow: var(--shadow), 0 0 0 3px var(--accent-soft); }
.composer textarea {
  flex: 1; min-width: 0; max-height: 40dvh;
  padding: 8px 0; border: 0; outline: 0; resize: none;
  background: transparent; font-size: 1rem; line-height: 1.4;
}
.composer textarea::placeholder { color: var(--text-2); }
.send {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-fill); color: #fff;
  transition: transform .1s ease-out, opacity .2s;
}
.send:not(:disabled):active { transform: scale(.95); }

/* ---------- Verlauf ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 4px 8px; }
h2 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--text-2); font-size: .9375rem; }

.item {
  display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start;
  padding: 14px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
  transition: opacity .2s var(--ease), transform .26s var(--ease);
}
@starting-style { .item { opacity: 0; transform: translateY(-10px) scale(.98); } }
.item-icon {
  width: 44px; height: 44px; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.item.in .item-icon { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.item-icon img { width: 100%; height: 100%; object-fit: cover; }
.item-body { min-width: 0; display: grid; gap: 4px; }
.item-meta { font-size: .8125rem; color: var(--text-2); }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-text { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 9.5em; overflow: auto; }
.item-text.code { font: .8125rem/1.5 var(--mono); padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-sm); white-space: pre; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.item-actions .btn { min-height: 36px; padding: 0 14px; font-size: .875rem; border-radius: 999px; text-decoration: none; }
.item.failed .item-meta { color: var(--bad); }

.progress { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.progress i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform .15s linear; }
.item.in .progress i { background: var(--ok); }
.item.done .progress { opacity: 0; height: 0; margin: 0; transition: opacity .3s, height .3s .2s, margin .3s .2s; }

/* ---------- Drag-Overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease-out;
}
.overlay.show { opacity: 1; }
.overlay-card {
  display: grid; justify-items: center; gap: 12px;
  width: min(420px, 100%); padding: 48px 24px;
  border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-lg);
  outline: 2px dashed var(--accent); outline-offset: -12px;
  color: var(--accent); font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em;
  transform: scale(.94); transition: transform .4s var(--ease);
}
.overlay-card p { margin: 0; color: var(--text); }
.overlay.show .overlay-card { transform: scale(1); }

/* ---------- Sheet (Dialog) ---------- */
dialog {
  border: 0; padding: 0; background: transparent; color: inherit;
  width: 100%; max-width: 100%; max-height: 92dvh;
  margin: auto auto 0;
  opacity: 0; transform: translateY(40px);
  transition: opacity .3s var(--ease), transform .45s var(--ease), overlay .45s allow-discrete, display .45s allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: translateY(40px); } }
dialog::backdrop {
  background: rgba(0, 0, 0, 0);
  transition: background-color .35s var(--ease), overlay .45s allow-discrete, display .45s allow-discrete;
}
dialog[open]::backdrop { background: rgba(0, 0, 0, .35); }
@starting-style { dialog[open]::backdrop { background: rgba(0, 0, 0, 0); } }

.sheet {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px;
  padding: 8px 20px max(20px, env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-lg);
  max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
}
.grabber { justify-self: center; width: 36px; height: 5px; border-radius: 3px; background: var(--sep); margin-bottom: 4px; }
.sheet h2 { font-size: 1.375rem; }
.muted { margin: -6px 0 0; color: var(--text-2); font-size: .9375rem; }
.qr { justify-self: center; width: 188px; aspect-ratio: 1; padding: 12px; border-radius: 18px; background: #fff; }
.qr svg { display: block; width: 100%; height: 100%; }
.code { margin: 0; text-align: center; font: 600 1.75rem/1 var(--mono); letter-spacing: .2em; }
.group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding-top: 14px; border-top: 1px solid var(--sep); }
.group label { font-size: .875rem; font-weight: 600; color: var(--text-2); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; text-transform: uppercase; font-family: var(--mono); letter-spacing: .12em; }
.sheet input:not([type="checkbox"]) {
  min-height: 44px; padding: 0 14px; font-size: 1rem;
  border: 1px solid var(--sep); border-radius: var(--r-md); background: var(--bg);
}
.sheet input:not([type="checkbox"]):focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sheet input[aria-invalid="true"] { border-color: var(--bad); }
.field-error { margin: 0; color: var(--bad); font-size: .8125rem; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-top: 14px; border-top: 1px solid var(--sep); font-size: .9375rem; cursor: pointer;
}
input[role="switch"] {
  appearance: none; flex: none; position: relative; margin: 0;
  width: 51px; height: 31px; border-radius: 999px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--sep);
  transition: background-color .25s var(--ease); cursor: pointer;
}
input[role="switch"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16);
  transition: transform .35s var(--ease);
}
input[role="switch"]:checked { background: var(--ok); box-shadow: none; }
input[role="switch"]:checked::after { transform: translateX(20px); }

@media (min-width: 640px) {
  dialog { width: 420px; margin: auto; transform: translateY(16px) scale(.97); }
  @starting-style { dialog[open] { transform: translateY(16px) scale(.97); } }
  .sheet { border-radius: 28px; padding-top: 24px; }
  .grabber { display: none; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 60;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px;
  background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-lg); font-size: .9375rem; font-weight: 500;
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
  transition: opacity .25s ease-out, transform .4s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Barrierefreiheit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; transition-delay: 0s !important; }
  dialog, dialog[open] { transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .bar, .toast { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .overlay { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- Hop-Ergänzungen ---------- */
.brand { color: inherit; text-decoration: none; border-radius: 8px; min-height: 44px; }
.bar-actions { display: flex; gap: 8px; align-items: center; }
.chip.pending .dot { background: var(--warn); }
.chip .tag { font-size: .75rem; font-weight: 600; color: var(--text-2); padding: 2px 6px; border-radius: 6px; background: var(--surface-2); }
.pair-box { display: grid; gap: 10px; justify-items: center; }
.center { text-align: center; margin: 0; }
.link.danger { color: var(--bad); justify-self: center; }

/* ---------- Native App (Tauri) ---------- */
html.native .bar { -webkit-user-select: none; user-select: none; }
html.os-macos .bar { padding-left: 84px; padding-top: 14px; padding-bottom: 14px; } /* Platz für die Ampel-Knöpfe */
html.glass, html.glass body { background: transparent; }
html.glass .bar { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
html.glass .empty { color: var(--text); opacity: .7; }
