/* SAMARITAN — weiss + Vignette, zentrale unterstrichene Direktive, rotes Dreieck */

:root {
  --bg: #f6f6f4;
  --ink: #1a1b1e;
  --ink-soft: #8b8f96;
  --red: #d4141c;
  --mono: "Share Tech Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
}

/* Vignette: Raender sanft abgedunkelt */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(
    ellipse 85% 80% at 50% 45%,
    rgba(0, 0, 0, 0) 45%,
    rgba(0, 0, 0, 0.10) 78%,
    rgba(0, 0, 0, 0.26) 100%
  );
}

/* immer sichtbare Versionsnummer, dezent oben links */
.version {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  z-index: 3;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  opacity: 0.7;
  pointer-events: none;
  user-select: none;
}
.version::before { content: "▲ "; color: var(--red); }

/* Update-Hinweis oben */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  border: 0;
  padding: calc(9px + env(safe-area-inset-top)) 14px 9px;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
  animation: appearDown 0.25s ease-out;
}
.update-banner:hover { background: var(--red-dark, #a3141a); }
@keyframes appearDown { from { transform: translateY(-100%); } to { transform: none; } }

/* Versionsnummer antippbar machen (oeffnet Diagnose) */
.version { pointer-events: auto; cursor: pointer; }

/* Diagnose-Panel */
.diag {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #fff;
  color: var(--ink);
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  padding:
    calc(14px + env(safe-area-inset-top))
    calc(14px + env(safe-area-inset-right))
    calc(14px + env(safe-area-inset-bottom))
    calc(14px + env(safe-area-inset-left));
  overflow: hidden;
}
.diag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--red);
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.diag-head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.22em;
  color: var(--red);
  font-weight: 400;
}
.diag-close {
  width: 28px; height: 28px;
  border: 1px solid rgba(0,0,0,0.2);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
}
.diag-close:hover { background: var(--red); color: #fff; border-color: var(--red); }
.diag-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.diag-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 12px; }
.diag-table td { padding: 4px 6px; border-bottom: 1px solid #eee; vertical-align: top; }
.diag-table td:first-child { color: var(--ink-soft); white-space: nowrap; width: 42%; }
.diag-table td:last-child { word-break: break-word; }
.diag-yes { color: #1a8f3c; }
.diag-no { color: var(--red); font-weight: 700; }
.diag-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.diag-btn {
  flex: 1 1 auto;
  min-width: 130px;
  padding: 11px 10px;
  border: 1px solid var(--red);
  background: #fff;
  color: var(--red);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.diag-btn:hover { background: var(--red); color: #fff; }
.diag-log {
  background: #0e0f12;
  color: #e8e8e8;
  font-size: 11.5px;
  line-height: 1.5;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 120px;
  max-height: 40vh;
  overflow-y: auto;
}
.diag-log .ok { color: #59d98a; }
.diag-log .err { color: #ff6b6b; }

/* dezenter Schriftzug oben */
.wordmark {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: calc(22px + env(safe-area-inset-top)) 0 0;
  font-size: 13px;
  letter-spacing: 0.55em;
  color: var(--ink-soft);
  text-indent: 0.55em;
}

/* Buehne: alles vertikal zentriert */
.stage {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px max(20px, env(safe-area-inset-right)) 24px max(20px, env(safe-area-inset-left));
  gap: 30px;
  text-align: center;
  width: 100%;
}

/* aktuelle Frage — klein, dezent darueber */
.query {
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  text-transform: uppercase;
  max-width: min(80ch, 100%);
  overflow-wrap: break-word;
}
.query::before { content: "> "; color: var(--red); }

/* zentrale Direktive: unterstrichene Computerschrift */
.directive {
  font-size: clamp(19px, 5vw, 40px);
  line-height: 1.8;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  max-width: min(26ch, 100%);
  min-height: 1.8em;
  overflow-wrap: break-word;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 10px;
  word-break: break-word;
}

/* Tipp-Cursor */
.caret {
  display: inline-block;
  width: 0.62ch;
  height: 1.05em;
  margin-left: 2px;
  background: var(--red);
  vertical-align: -0.18em;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* rotes Dreieck, Spitze nach oben */
.triangle {
  width: 0; height: 0;
  border-left: 30px solid transparent;
  border-right: 30px solid transparent;
  border-bottom: 50px solid var(--red);
  filter: drop-shadow(0 3px 10px rgba(212, 20, 28, 0.35));
  transition: transform 0.25s ease;
}
.triangle.active { animation: hum 2.4s ease-in-out infinite; }
@keyframes hum {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 3px 10px rgba(212,20,28,0.35)); }
  50%      { transform: scale(1.06); filter: drop-shadow(0 4px 16px rgba(212,20,28,0.55)); }
}

/* Eingabeleiste — dezent unten */
.composer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(30px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.composer-form { width: min(520px, 100%); flex: 1; max-width: 520px; }

.input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.1em;
  text-align: center;
  padding: 10px 6px;
  outline: none;
  transition: border-color 0.2s;
}
.input::placeholder { color: var(--ink-soft); letter-spacing: 0.12em; }
.input:focus { border-bottom-color: var(--red); }

.mic, .tts-toggle {
  width: 42px; height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.18s;
}
.mic:hover, .tts-toggle:hover { color: var(--red); border-color: var(--red); }

.mic.listening {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  animation: pulse 1.2s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(212, 20, 28, 0.5); }
  100% { box-shadow: 0 0 0 12px rgba(212, 20, 28, 0); }
}

.tts-toggle.is-on { color: var(--red); border-color: var(--red); }
.tts-toggle:not(.is-on) { opacity: 0.55; }

/* ---- verschiebbare Fenster (Bild/Video/Stream/Text) ---- */
.win {
  position: fixed;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-top: 3px solid var(--red);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.22);
  min-width: 200px;
  min-height: 130px;
  max-width: 94vw;
  max-height: 86vh;
  resize: both;
  overflow: hidden;
  font-family: var(--mono);
  animation: winIn 0.18s ease-out;
}
@keyframes winIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

.win-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #faf9f8;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  cursor: move;
  user-select: none;
  touch-action: none;
}
.win-title {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.win-close {
  flex: none;
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}
.win-close:hover { background: var(--red); border-color: var(--red); color: #fff; }

.win-body {
  flex: 1;
  overflow: auto;
  background: #fff;
  min-height: 0;
}
.win-body img,
.win-body video,
.win-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: #000;
}
.win-text {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 560px) {
  .wordmark { letter-spacing: 0.4em; font-size: 12px; }
  .directive { letter-spacing: 0.02em; text-underline-offset: 7px; }
  .stage { gap: 24px; }
  .triangle {
    border-left-width: 24px;
    border-right-width: 24px;
    border-bottom-width: 40px;
  }
}
