/* Funk — Gestaltung.
   Farben nur als Tokens hier oben; hell und dunkel folgen der Einstellung des Geräts. */

:root {
  color-scheme: light dark;

  --grund: #f6f5f2;
  --flaeche: #ffffff;
  --flaeche-2: #efede8;
  --text: #1c1c1e;
  --leise: #6a6a70;
  --linie: #e2dfd8;
  --akzent: #e05a10;
  --akzent-text: #ffffff;
  --senden: #d32f2f;
  --empfang: #12804a;
  --fehler: #b3261e;
  --ok: #12804a;
  --schatten: 0 10px 30px rgba(40, 30, 10, 0.12);

  --rund: 14px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #121316;
    --flaeche: #1c1d21;
    --flaeche-2: #26272c;
    --text: #ececef;
    --leise: #9b9ba3;
    --linie: #2e2f35;
    --akzent: #ff7a2e;
    --akzent-text: #1a0d04;
    --senden: #ff5a52;
    --empfang: #3ddc84;
    --fehler: #ff8a80;
    --ok: #3ddc84;
    --schatten: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 16px/1.45 var(--schrift);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

h1, h2 { margin: 0; line-height: 1.15; }

.hinweis-ohne-js { padding: 24px; text-align: center; }

/* ---- Start ------------------------------------------------------------------------- */

.start {
  min-height: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: max(48px, env(safe-area-inset-top)) 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.start-zeichen { border-radius: 18px; margin-bottom: 18px; }

.start h1 { font-size: 34px; letter-spacing: -0.02em; }

.start-text { color: var(--leise); margin: 8px 0 32px; max-width: 30ch; }

.start-form { width: 100%; display: grid; gap: 16px; text-align: left; }

/* ---- Felder und Knöpfe ------------------------------------------------------------- */

.feld { display: grid; gap: 6px; }

.feld > span:first-child { font-size: 14px; color: var(--leise); }

.feld input {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--linie);
  border-radius: 12px;
  background: var(--flaeche);
  font-size: 17px; /* ab 16 px zoomt iOS beim Antippen nicht hinein */
}

.zeile { display: flex; gap: 8px; }

.knopf {
  padding: 12px 16px;
  border: 1px solid var(--linie);
  border-radius: 12px;
  background: var(--flaeche);
  font-weight: 600;
  white-space: nowrap;
}

.knopf-haupt {
  border-color: transparent;
  background: var(--akzent);
  color: var(--akzent-text);
  padding: 14px 18px;
  font-size: 17px;
}

.knopf-gefahr { color: var(--fehler); }

.fehler { margin: 0; color: var(--fehler); font-size: 15px; }

.ok { margin: 8px 0 0; color: var(--ok); font-size: 15px; }

/* ---- Funkgerät --------------------------------------------------------------------- */

.funk {
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.marke { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }

.marke img { border-radius: 7px; }

.verbindung {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--leise);
  margin-left: 2px;
}

.verbindung.an { background: var(--empfang); }

.ich {
  max-width: 50%;
  padding: 6px 12px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  background: var(--flaeche);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Kanal-Leiste: auf dem Handy seitlich wischbar, damit die Taste oben bleibt. */
.kanalleiste {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.kanalleiste::-webkit-scrollbar { display: none; }

.kanaele { display: contents; list-style: none; margin: 0; padding: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 9px 14px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  background: var(--flaeche);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.chip[aria-current="true"] {
  border-color: var(--akzent);
  background: var(--akzent);
  color: var(--akzent-text);
}

.chip-leise { font-weight: 500; color: var(--leise); background: transparent; }

.chip-zahl { font-weight: 500; opacity: 0.7; font-variant-numeric: tabular-nums; }

/* Im Kanal spricht gerade jemand. */
.chip-funkt::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--empfang);
  animation: blinken 1s ease-in-out infinite;
}

.chip[aria-current="true"].chip-funkt::before { background: currentColor; }

.geraet {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px 28px;
  text-align: center;
}

.kanalkopf { margin-top: 8px; width: 100%; }

.kanaltitel { display: flex; align-items: center; justify-content: center; gap: 6px; }

.kanalkopf h2 {
  font-size: 30px;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

/* Glocke: Rufe für diese Gruppe an oder aus. Aus = durchgestrichen. */
.glocke {
  flex: none;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--leise);
  display: grid;
  place-items: center;
}

.glocke svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glocke-strich { display: none; }
.glocke[aria-pressed="false"] .glocke-strich { display: inline; }
.glocke[aria-pressed="false"] { color: var(--fehler); }

.leute { margin: 6px 0 0; color: var(--leise); font-size: 15px; }

.leute:empty { display: none; }

/* Wer zur Gruppe gehört. Antippen: privat funken. */
.personen {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.personen:empty { display: none; }

.person {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  background: var(--flaeche);
  font-size: 14px;
  color: var(--leise);
}

.person-hier { color: var(--text); font-weight: 600; }

.person::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--leise);
}

.person-hier::before { background: var(--empfang); border-color: var(--empfang); }
.person-online::before { border-color: var(--empfang); }

.karte {
  width: 100%;
  max-width: 380px;
  margin: 18px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--linie);
  border-radius: var(--rund);
  background: var(--flaeche);
  text-align: left;
  font-size: 15px;
}

.karte p { margin: 0 0 12px; }

.karte-knoepfe { display: flex; gap: 8px; flex-wrap: wrap; }

.karte .knopf, .ruf .knopf { padding: 10px 14px; font-size: 15px; }

/* Ein Ruf von aussen: oben eingeblendet, gut zu treffen. */
.ruf {
  position: fixed;
  z-index: 10;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(488px, calc(100vw - 24px));
  padding: 14px 16px;
  border: 1px solid var(--akzent);
  border-radius: var(--rund);
  background: var(--flaeche);
  box-shadow: var(--schatten);
}

.ruf-text { margin: 0 0 12px; font-weight: 600; }

.ruf-knoepfe { display: flex; gap: 8px; }

.status {
  margin: auto 0 18px;
  padding-top: 24px;
  min-height: 1.45em;
  font-weight: 600;
  font-size: 17px;
}

/* Auf dem Handy sitzt die Taste unten beim Daumen. Am Computer gäbe das eine leere Wüste
   zwischen Kanalname und Taste — dort rückt sie nach oben. */
@media (min-width: 700px) and (min-height: 700px) {
  .status { margin-top: 64px; }
}

.status.sendet { color: var(--senden); }

.status.empfaengt { color: var(--empfang); }

/* ---- Die Sprechtaste --------------------------------------------------------------- */

.taste {
  position: relative;
  width: min(62vw, 240px);
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  background: var(--akzent);
  color: var(--akzent-text);
  box-shadow: var(--schatten);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  /* Langes Drücken darf weder Text markieren noch ein Menü oder die Lupe öffnen. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 120ms ease, background-color 160ms ease;
}

.taste-zeichen {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.taste-text { font-weight: 700; font-size: 16px; max-width: 80%; }

/* Allein im Kanal wird aus der Sprechtaste die Ruftaste — mit Glocke statt Mikrofon. */
.zeichen-ruf { display: none; }
.taste.rufen .zeichen-ruf, .taste.gerufen .zeichen-ruf { display: block; }
.taste.rufen .zeichen-mikro, .taste.gerufen .zeichen-mikro { display: none; }

.taste.gerufen { background: var(--flaeche-2); color: var(--text); box-shadow: none; }

.taste.gerufen .taste-ring { border-color: var(--akzent); animation: pulsieren 2s ease-out infinite; }

.taste-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 3px solid transparent;
  pointer-events: none;
}

.taste.sendet { background: var(--senden); transform: scale(0.97); }

.taste.sendet .taste-ring { border-color: var(--senden); animation: pulsieren 1.2s ease-out infinite; }

.taste.empfaengt { background: var(--flaeche-2); color: var(--text); box-shadow: none; }

.taste.empfaengt .taste-ring { border-color: var(--empfang); animation: pulsieren 1.2s ease-out infinite; }

.taste:disabled { background: var(--flaeche-2); color: var(--leise); box-shadow: none; cursor: default; }

.hilfe { margin: 22px 0 0; color: var(--leise); font-size: 14px; max-width: 32ch; }

.hinweis {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--flaeche-2);
  font-size: 15px;
}

@keyframes pulsieren {
  from { transform: scale(0.96); opacity: 1; }
  to { transform: scale(1.12); opacity: 0; }
}

@keyframes blinken {
  50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .taste-ring, .chip-funkt::before { animation: none !important; }
  .taste { transition: none; }
}

/* ---- Dialoge ----------------------------------------------------------------------- */

.dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 18px 18px 22px;
  border: 1px solid var(--linie);
  border-radius: 18px;
  background: var(--flaeche);
  color: var(--text);
  box-shadow: var(--schatten);
}

.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }

.dialog-kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }

.dialog-kopf h2 { font-size: 21px; }

.dialog-kopf form { margin: 0; }

.schliessen {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--flaeche-2);
  font-size: 15px;
}

.dialog-text { margin: 0 0 14px; color: var(--leise); font-size: 15px; }

.dialog-text.klein { margin: 20px 0 0; font-size: 13px; }

.kanalliste { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }

.kanalliste li { display: flex; gap: 8px; }

.kanalliste input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--linie);
  border-radius: 10px;
  background: var(--grund);
  font-size: 17px;
}

.kanalliste .knopf { padding: 10px 12px; }

.neuerkanal { margin: 0 0 8px; }

.abschnitt { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--linie); }

.abschnitt h3 { margin: 0 0 6px; font-size: 16px; }

.knopf-breit { width: 100%; margin: 4px 0 0; }
