:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #15181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2f6df6;
  --accent-text: #ffffff;
  --me: #e8f0ff;
  --peer: #ffffff;
  --danger: #d33a3a;
  --ok: #1f9d55;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 20px rgba(0, 0, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b22;
    --text: #eef1f5;
    --muted: #8b93a1;
    --line: #262b35;
    --accent: #4f86ff;
    --me: #1d2b4a;
    --peer: #181b22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: .2px; }

main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.narrow { max-width: 480px; margin: 0 auto; padding: 24px 16px 40px; }
.center { text-align: center; }
h1 { font-size: 22px; margin: 8px 0 12px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; margin: 10px 0 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field input, .field select {
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 42px; width: 100%;
}
.field.inline select { width: auto; min-height: 36px; padding: 6px 10px; font-size: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-center { display: flex; justify-content: center; margin-top: 10px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 12px; border: 1px solid transparent; padding: 12px 16px; width: 100%;
  min-height: 46px; transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); width: auto; }
.btn.small { padding: 8px 14px; min-height: 36px; font-size: 14px; font-weight: 500; color: var(--muted); }
.btn-block { width: 100%; margin-top: 10px; font-weight: 500; }
pre.log { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.4; margin: 14px 0 0; color: var(--text); }
.card .hint { margin-bottom: 14px; }
.btn[disabled] { opacity: .5; cursor: default; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 500;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .7; }
.pill-muted { color: var(--muted); }
.pill-ok { color: var(--ok); }
.pill-warn { color: #c47d00; }
.pill-bad { color: var(--danger); }
.pill-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 2px; color: var(--text); }
.pill-code::before, .pill-btn::before { display: none; }
.pill-btn { cursor: pointer; font: inherit; font-size: 13px; color: var(--accent); }

/* Gespräch */
.talk { max-width: 720px; margin: 0 auto; padding: 12px 12px 24px; }
.statusbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.qr { margin-bottom: 12px; text-align: center; }
.qr summary { cursor: pointer; font-weight: 600; text-align: left; }
.qr img { display: block; margin: 12px auto 8px; width: min(70vw, 300px); height: auto; border-radius: 12px; background: #fff; padding: 8px; image-rendering: pixelated; }
.bigcode { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 30px; letter-spacing: 6px; font-weight: 700; }
.link-text { color: var(--muted); font-size: 13px; word-break: break-all; margin-top: 4px; }

.bubbles { display: flex; flex-direction: column; gap: 10px; }
.bubble {
  max-width: 88%; border-radius: var(--radius); padding: 10px 14px;
  background: var(--peer); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.bubble.me { align-self: flex-end; background: var(--me); }
.bubble.peer { align-self: flex-start; }
.bubble .who { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }
.bubble .src { font-size: 15px; }
.bubble .tgt { font-size: 17px; font-weight: 500; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.bubble i { font-style: normal; opacity: .55; }
.bubble.live { border-color: var(--accent); }
.bubble.error .tgt { color: var(--danger); font-weight: 400; }
.bubble .tag { font-size: 11px; color: var(--muted); margin-left: 6px; }

/* Fußbereich mit Sprechtaste */
.footer {
  position: sticky; bottom: 0; z-index: 5;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: center; }
.ptt {
  width: 150px; height: 150px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 700; font-size: 15px; line-height: 1.2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 10px 30px rgba(47, 109, 246, .35);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .08s ease, background .12s ease, box-shadow .12s ease;
}
.ptt-icon { width: 26px; height: 26px; border-radius: 8px 8px 12px 12px; background: currentColor; opacity: .95; position: relative; }
.ptt-icon::after { content: ""; position: absolute; left: 50%; bottom: -9px; width: 12px; height: 4px; background: currentColor; transform: translateX(-50%); border-radius: 2px; }
.ptt.on { background: var(--danger); transform: scale(1.06); box-shadow: 0 0 0 10px rgba(211, 58, 58, .18), 0 10px 30px rgba(211, 58, 58, .35); }
.ptt.on .ptt-icon { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.ptt[disabled] { opacity: .45; cursor: default; }
.footer-row { display: flex; gap: 12px; }

.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 20;
}
.overlay .card { max-width: 360px; width: 100%; }
.overlay .btn { margin-top: 12px; }

@media (max-width: 400px) {
  .row2 { grid-template-columns: 1fr; }
  .ptt { width: 132px; height: 132px; }
}
