/* Funkkreis Web-Client: das Telefon als Handfunkgerät.
   Gehäuse graugrün, ein hinterleuchtetes LCD als Mittelpunkt,
   Rot nur für Senden und Notruf, Grün nur für Empfang. */

:root {
  --body: #2b3a34;        /* Gehäuse */
  --body-edge: #1d2824;
  --rubber: #39463f;      /* PTT-Gummi */
  --lcd: #c9dccb;         /* hinterleuchtetes LCD */
  --lcd-ink: #1a2e22;
  --lcd-dim: #5d7464;
  --text: #e6ece7;
  --muted: #a3b2a8;
  --tx: #e2432a;          /* Senden, Notruf */
  --rx: #41b36a;          /* Empfang */
  --line: #42524a;
  --accent: #c9dccb;      /* Markierungen außerhalb des LCD */
  --field: #22302a;
  --radius: 14px;
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--body);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

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

button { cursor: pointer; }

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

/* ---- Einrichtung und Entsperren ---- */

.panel {
  max-width: 30rem;
  margin: 0 auto;
  padding: max(2rem, env(safe-area-inset-top)) 16px 2rem;
}

.panel h1 { font-size: 1.6rem; margin: 0 0 1rem; letter-spacing: -0.01em; }

.panel form { display: grid; gap: 1rem; margin-bottom: 1.5rem; }

label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }

input, select {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  color: var(--text);
  min-width: 0;
}

input[type="file"] { padding: 0.55rem; }

.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }

.error { color: #ff9c87; margin: 0; min-height: 1.2em; }

.primary {
  background: var(--lcd);
  color: var(--lcd-ink);
  border: 0;
  border-radius: 10px;
  padding: 0.85rem;
  font-weight: 650;
}

.quiet {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  padding: 0.5rem 0;
}

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

.radio {
  max-width: 30rem;
  margin: 0 auto;
  padding: max(0.75rem, env(safe-area-inset-top)) 16px max(1rem, env(safe-area-inset-bottom));
  display: grid;
  gap: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
}

.topbar #who { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link { color: var(--muted); font-size: 0.85rem; }
.link.up { color: var(--rx); }

/* Status-LED wie am Handgerät: aus, grün (Empfang), rot (Senden). */
.led {
  width: 12px; height: 12px; border-radius: 50%;
  background: #18211d;
  box-shadow: inset 0 1px 2px #000;
  flex: none;
}
.led.rx { background: var(--rx); box-shadow: 0 0 10px var(--rx); }
.led.tx { background: var(--tx); box-shadow: 0 0 10px var(--tx); }

.lcd {
  background: var(--lcd);
  color: var(--lcd-ink);
  border-radius: 8px;
  padding: 0.75rem 0.9rem 0.8rem;
  border: 3px solid var(--body-edge);
  box-shadow: inset 0 2px 6px rgb(0 0 0 / 0.25);
  min-height: 8.5rem;
  display: grid;
  align-content: space-between;
}

.lcd-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--lcd-dim);
}

.lcd-main {
  font-size: clamp(1.6rem, 8vw, 2.1rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.lcd-sub { font-size: 0.95rem; min-height: 1.4em; }
.lcd.tx .lcd-main { color: #8a1d0e; }

.target {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
}

/* Die PTT-Taste: groß, griffig, gerippt wie Gummi. */
.ptt {
  height: clamp(9rem, 32vh, 14rem);
  border-radius: 22px;
  border: 2px solid var(--body-edge);
  background:
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.04) 0 2px, transparent 2px 9px),
    var(--rubber);
  box-shadow: 0 6px 0 var(--body-edge), inset 0 1px 0 rgb(255 255 255 / 0.08);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 60ms, box-shadow 60ms;
}
.ptt.down { transform: translateY(4px); box-shadow: 0 2px 0 var(--body-edge); }
.ptt.tx { background: var(--tx); color: #fff; border-color: #8a1d0e; }
.ptt.busy { background: #6b5b2a; }

.sos {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem;
  border-radius: 12px;
  border: 2px solid var(--tx);
  background: transparent;
  color: #ffb3a5;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  position: relative;
  overflow: hidden;
}
.sos small { font-weight: 400; color: var(--muted); }
/* Füllt sich beim Halten. */
.sos::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--tx);
  opacity: 0.35;
  transform: scaleX(0);
  transform-origin: left;
}
.sos.holding::before { transform: scaleX(1); transition: transform 2s linear; }
.sos.active { background: var(--tx); color: #fff; }
.sos.active small { color: #ffe1db; }

.alarm {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--tx);
  color: #fff;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-weight: 600;
}
.alarm span { flex: 1; }
.alarm button { background: #fff; color: #8a1d0e; border: 0; border-radius: 8px; padding: 0.5rem 0.8rem; font-weight: 700; }

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  margin-top: 0.4rem;
}
.tabs button {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 0.6rem 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button.unread { color: var(--accent); font-weight: 700; }

.tab { display: grid; gap: 0.75rem; }

.messages, .log, .people { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.messages { max-height: 40vh; overflow-y: auto; align-content: start; }

.messages:empty::before { content: "Noch keine Nachrichten."; color: var(--muted); }
.messages li { background: var(--field); border-radius: 10px; padding: 0.55rem 0.75rem; max-width: 88%; }
.messages li.out { justify-self: end; background: #34463d; }
.messages .from { font-size: 0.8rem; color: var(--muted); display: block; }
.messages .state { font-size: 0.8rem; color: var(--muted); }

.compose { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }
.compose button, .status-grid button, .people button {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
}

.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.5rem; }
.status-grid button { text-align: left; padding: 0.8rem; }
.status-grid b { display: block; color: var(--muted); font-weight: 500; font-size: 0.8rem; }

.people:empty::before { content: "Noch niemand online gesehen."; color: var(--muted); }
.people li { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.people .name { flex: 1; min-width: 0; }
.people .name small { display: block; color: var(--muted); }

.log { font-size: 0.85rem; color: var(--muted); max-height: 40vh; overflow-y: auto; }
.log time { color: var(--text); margin-right: 0.5rem; }

@media (prefers-reduced-motion: reduce) {
  .ptt, .sos.holding::before { transition: none; }
}

@media (prefers-color-scheme: light) {
  :root {
    --body: #d6ddd7;
    --body-edge: #9faca4;
    --rubber: #5d6b63;
    --text: #18241e;
    --muted: #4c5c53;
    --line: #aab7af;
    --field: #e8ede9;
    --accent: #1f6b3d;
    color-scheme: light;
  }
  .ptt { color: #fff; }
  .messages li.out { background: #c7d4cb; }
  .led { background: #b4beb8; box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.4); }
  .sos { color: #a3220f; }
  .error { color: #a3220f; }
  .link.up { color: var(--accent); }
}

.panel h2 { font-size: 1.15rem; margin: 0; }
.import { margin-top: 1.5rem; color: var(--muted); }
.import summary { cursor: pointer; padding: 0.5rem 0; }
.import form { margin-top: 0.75rem; }
