/* Grundgestaltung der Basis. Farben und Schriften einer Instanz stehen in
   deren branding.css und uebersteuern die Variablen in :root.
   Schwarz als Grund, warmes Beige fuer Ueberschriften, Rot als Aktionsfarbe.
   Schriften bewusst systemseitig: Google Fonts wuerde bei jedem Aufruf die
   IP-Adresse an Google uebertragen, was bei einer App mit Kundendaten nicht
   vertretbar ist. Echte Schriftdateien koennen spaeter lokal eingebunden
   werden. */

:root {
  --bg: #000000;
  --surface: #0d0d0d;
  --surface-2: #161616;
  --line: #262626;
  --accent: #af9c83;
  --text: #f2f2f2;
  --muted: #8b8b8b;
  --action: #ff0000;
  --action-dim: #c40000;
  --ok: #6d9a5f;
  --radius: 3px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* Muss vor allen Layout-Regeln stehen und sich durchsetzen: eine eigene
   display-Angabe (etwa display:flex) schlaegt sonst das hidden-Attribut,
   und ausgeblendete Bereiche bleiben sichtbar. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body {
  padding: 0 1rem env(safe-area-inset-bottom) 1rem;
  max-width: 720px;
  margin: 0 auto;
}

h1, h2 { font-weight: 400; margin: 0; }

/* --- Kopf --------------------------------------------------------------- */

.top { text-align: center; padding: 2rem 0 1.5rem; }

.wordmark {
  font-family: var(--serif);
  font-size: 2rem;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.claim {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.intro {
  margin: 1.2rem auto 0;
  max-width: 30rem;
  font-size: 0.92rem;
  color: #c9c9c9;
  line-height: 1.6;
}

/* Absenderzeile ueber einem Eintrag: bei Antworten der Name des
   Ansprechpartners, bei eingehenden Nachrichten der Zugang, von dem sie kam.
   Stand frueher als fester Name hier in der CSS-Datei, also an der
   Stelle, an der niemand nach einem Kundennamen sucht. */
.h-item .h-von {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

/* --- Sperrbildschirm ---------------------------------------------------- */

.gate {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
}
.gate-text { color: var(--text); margin: 1rem 0 0; }
.gate-hint { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* --- Aufnahme ----------------------------------------------------------- */

.recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 2rem;
}

.rec {
  width: 100%;
  max-width: 340px;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  background: var(--action);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  /* Auf Beruehrung sofort sichtbar reagieren. */
  transition: transform 0.08s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.rec:active { transform: scale(0.985); background: var(--action-dim); }
.rec[disabled] { opacity: 0.5; cursor: default; }

.rec-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  flex: none;
}
.rec.is-recording .rec-dot { animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

@media (prefers-reduced-motion: reduce) {
  .rec.is-recording .rec-dot { animation: none; }
  * { transition: none !important; }
}

/* Laufende Aufnahme: Zeit und Pegel, damit sichtbar ist, dass die Stimme
   ankommt. Ohne das spricht man unsicher oder bricht ab. */
.rec-live {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.meter {
  width: 100%;
  height: 5px;
  background: var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.08s linear;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  color: var(--accent);
}
.timer.near-limit { color: var(--action); }

.btn-stop {
  width: 100%;
  padding: 0.85rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--sans);
  cursor: pointer;
}
.btn-plain {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* --- Alternativen ------------------------------------------------------- */

.alt {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 340px;
}
.alt-item {
  flex: 1 1 auto;
  text-align: center;
  padding: 0.65rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.alt-item:hover, .alt-item:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.hint {
  max-width: 340px;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--surface);
  border-left: 2px solid var(--accent);
  padding: 0.6rem 0.75rem;
}

/* --- Textformular ------------------------------------------------------- */

.text-form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 0.6rem; }
.text-form textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-family: var(--sans);
  font-size: 1rem;
  resize: vertical;
}
.text-form textarea:focus { outline: none; border-color: var(--accent); }

.btn-send {
  padding: 0.8rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

/* --- Upload-Fortschritt ------------------------------------------------- */

.upload {
  position: relative;
  width: 100%;
  max-width: 340px;
  height: 30px;
  background: var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}
.upload-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--accent);
  opacity: 0.28;
  transition: width 0.2s ease;
}
.upload-text {
  position: relative;
  display: block;
  text-align: center;
  line-height: 30px;
  font-size: 0.82rem;
  color: var(--text);
}

.error {
  max-width: 340px;
  background: #1a0505;
  border-left: 2px solid var(--action);
  padding: 0.75rem;
  font-size: 0.88rem;
  color: #ffd7d7;
}
.error a { color: var(--accent); }

/* --- Fragen ------------------------------------------------------------- */

.questions, .history { padding: 1.5rem 0; border-top: 1px solid var(--line); }

.questions h2, .history h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.q-intro, .h-empty { color: var(--muted); font-size: 0.88rem; margin: 0 0 1rem; }

.q-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }

.q-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.q-text { margin: 0 0 0.75rem; }
.q-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.q-actions button {
  flex: 1 1 auto;
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.82rem;
  cursor: pointer;
}
/* Beige statt Rot: Rot bleibt allein dem Aufnahmeknopf vorbehalten, sonst
   verliert die wichtigste Aktion der Seite ihre Wirkung. */
.q-actions .primary { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }
.q-done { color: var(--ok); font-size: 0.9rem; }

/* --- Verlauf ------------------------------------------------------------ */

.h-list { display: flex; flex-direction: column; gap: 0.75rem; }

.h-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 0.85rem;
  animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.h-item.is-answer { border-left-color: var(--accent); background: var(--surface-2); }
.h-item.is-pending { border-left-color: var(--muted); }
.h-item.is-processed { border-left-color: var(--ok); }
.h-item.is-problem { border-left-color: var(--action); }

.h-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.h-body { margin: 0; white-space: pre-wrap; word-break: break-word; }

.h-transcript {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
  font-size: 0.92rem;
  color: #d8d8d8;
}
/* Stellen, bei denen die Erkennung unsicher war. Nur diese werden markiert,
   statt pauschal um Pruefung zu bitten. */
.low-conf {
  background: rgba(175, 156, 131, 0.22);
  border-bottom: 1px dotted var(--accent);
}
.h-actions { margin-top: 0.6rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.h-actions button {
  padding: 0.4rem 0.7rem;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.78rem;
  cursor: pointer;
}
.h-actions button:hover { color: var(--accent); border-color: var(--accent); }

/* Der Rueckfallweg, auf den die Mikrofon-Fehlermeldung zeigt. Die Klasse
   wurde vom Skript gesetzt, war aber nie definiert: der Knopf blieb ein
   grauer Kasten zwischen zwei gleich aussehenden Kaesten. */
.alt-highlight {
  border-color: var(--action) !important;
  color: var(--text) !important;
  animation: puls 1.4s ease-in-out 3;
}
@keyframes puls {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.28); }
}
@media (prefers-reduced-motion: reduce) {
  .alt-highlight { animation: none; }
}

/* Wiederholknopf in der Fehlerbox: die Aufnahme ist noch da. */
.btn-retry {
  margin-left: 0.5rem;
  padding: 0.5rem 0.9rem;
  min-height: 44px;
  background: var(--action);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

/* Trefferflaechen auf das Mindestmass. "Zrušit" sass mit 23 Pixeln direkt
   unter dem 44 Pixel hohen "Hotovo": der gefaehrlichere Knopf war der
   kleinere. */
.btn-plain, .h-actions button, .btn-ack, .alt-item, .q-actions button {
  min-height: 44px;
}
.h-actions button, .btn-ack, .q-actions button { padding-inline: 0.9rem; }

/* Im Standalone-Modus reicht der Inhalt bis unter die Statusleiste. Ohne
   diesen Abstand sitzt der Schriftzug hinter der Uhr. */
.top { padding-top: calc(2rem + env(safe-area-inset-top)); }
body {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

/* Lange Adressen und Namen im Transkript sprengen sonst die Karte. */
.h-transcript, .h-done-note, .q-text { word-break: break-word; }

/* iOS zoomt bei Feldern unter 16 Pixeln hinein und nicht wieder heraus.
   Ausgerechnet die Korrekturfunktion verstellte damit die Ansicht. */
.edit-area { font-size: 1rem; }

/* Erledigt: der Haken traegt die Botschaft, der Rest bleibt ruhig. */
.h-item.is-resolved { border-left: 2px solid var(--ok); }

.h-done {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}

.h-done-note {
  flex: 1 1 12rem;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.45;
}
.h-done-note::before {
  content: "✓";
  margin-right: 0.45rem;
  color: var(--ok);
  font-weight: 700;
}
.h-done-note:empty::before { content: "✓ Vyřízeno"; }

.btn-ack {
  flex: 0 0 auto;
  padding: 0.45rem 0.8rem;
  background: none;
  border: 1px solid var(--ok);
  border-radius: var(--radius);
  color: var(--ok);
  font-family: var(--sans);
  font-size: 0.78rem;
  cursor: pointer;
}
.btn-ack:hover { background: var(--ok); color: var(--bg); }

.btn-older {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.6rem;
  background: none;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-older:hover { color: var(--accent); border-color: var(--accent); }

/* Abgehaktes tritt zurueck, bleibt aber lesbar. */
.h-older { margin-top: 0.8rem; opacity: 0.72; }

.edit-area {
  width: 100%;
  margin-top: 0.5rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem;
  font-family: var(--sans);
  font-size: 0.92rem;
}

/* --- Fuss --------------------------------------------------------------- */

.foot {
  padding: 2rem 0 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}
.foot p { margin: 0.3rem 0; }

/* Der Hinweis, dass Rueckmeldung zur Oberflaeche ueber denselben Kanal geht.
   Absichtlich staerker als der Rest der Fusszeile. */
.foot-feedback {
  color: var(--accent);
  font-size: 0.85rem;
  max-width: 26rem;
  margin: 0 auto 1rem !important;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

/* --- Groessere Bildschirme ---------------------------------------------- */

@media (min-width: 640px) {
  body { padding: 0 2rem 2rem; }
  .wordmark { font-size: 2.6rem; }
  .rec { max-width: 420px; min-height: 96px; }
  .rec-live, .alt, .text-form, .upload, .error, .hint { max-width: 420px; }
}

/* Angehaengte Bilder im Verlauf */
.h-image {
  display: block;
  max-width: 100%;
  margin-top: 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
