/* K.I.T.T. Test-Client – Konsole nach dem Vorbild der Serie (1982) */
:root {
  --lit: #ff2a1a;
  --off: #2a0503;
  --amber: #ffb000;
  --fg: #e8e2dc;
  --muted: #8a7f78;
  --line: #2a1d1b;
  --panel: #0b0807;
  --beige-1: #f1ebb4;
  --beige-2: #d6cd88;
  --red-1: #f88e79;
  --red-2: #dc5c48;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--fg);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

button, input, select {
  font: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
button { padding: 10px 14px; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
input, select { padding: 10px 12px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row.end { justify-content: flex-end; }
.row.end > * { flex: 0 0 auto; }
.text-row input { flex: 3; }

/* ---------- Konsole ---------- */
.dash {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vmin;
}
/* Alle Maße relativ zur Konsolenbreite (cqw), damit sie auf jedem Bildschirm gleich aussieht. */
.kitt {
  container-type: inline-size;
  position: relative;
  display: grid;
  grid-template-columns: 25fr 50fr 25fr;
  width: min(96vw, 88vh * 1.08, 980px);
  aspect-ratio: 1.08;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.pod {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  margin: 4cqw 0 1cqw;
  padding: 3cqw 0;
  border-radius: 6cqw 6cqw 4cqw 4cqw;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(0, 0, 0, .35)),
    linear-gradient(90deg, #121214 0%, #2f2f33 30%, #3b3b40 55%, #232326 85%, #0d0d0e 100%);
  box-shadow: inset 0 0 1.2cqw rgba(0, 0, 0, .8), 0 0 0 .35cqw #070708;
}
.pod-left { align-items: flex-end; padding-right: 2.5cqw; }
.pod-right { align-items: flex-start; padding-left: 2.5cqw; }

.key {
  width: 14cqw;
  height: 8.6cqw;
  padding: 0;
  border: .45cqw solid #0d0d0d;
  border-radius: 1.7cqw;
  color: #232323;
  font-family: "Arial Narrow", "Roboto Condensed", "Liberation Sans Narrow", "Helvetica Neue", Arial, sans-serif;
  font-stretch: condensed;
  font-weight: 700;
  font-size: 3.5cqw;
  line-height: 1;
  letter-spacing: .02em;
  text-shadow: 0 .12cqw 0 rgba(255, 255, 255, .35);
  text-align: center;
  box-shadow: 0 0 0 .35cqw #050505, inset 0 .7cqw .4cqw rgba(255, 255, 255, .45), inset 0 -.8cqw .6cqw rgba(0, 0, 0, .22);
  transition: filter .08s, transform .08s, box-shadow .15s;
  touch-action: manipulation;
}
.key.two { font-size: 2.9cqw; }
.key.beige { background: linear-gradient(180deg, var(--beige-1), var(--beige-2)); }
.key.red { background: linear-gradient(180deg, var(--red-1), var(--red-2)); }
.key:hover { filter: brightness(1.06); }
.key:active, .key.pressed { transform: translateY(.3cqw); filter: brightness(.88); }
/* Leuchtende Taste (z. B. SPK im Gesprächsmodus) */
.key.lit { filter: brightness(1.18); box-shadow: 0 0 0 .35cqw #050505, 0 0 2.4cqw .6cqw rgba(255, 244, 170, .85), inset 0 .7cqw .4cqw rgba(255, 255, 255, .6); }
.key.red.lit { box-shadow: 0 0 0 .35cqw #050505, 0 0 2.4cqw .6cqw rgba(255, 120, 90, .85), inset 0 .7cqw .4cqw rgba(255, 255, 255, .5); }
/* SPK hört gerade Sprache */
.key.hearing { filter: brightness(1.4); box-shadow: 0 0 0 .35cqw #050505, 0 0 3.4cqw 1cqw rgba(255, 248, 190, .95), inset 0 .7cqw .4cqw rgba(255, 255, 255, .7); }
.key.blink { animation: key-blink .9s steps(1) infinite; }
.key.blink-fast { animation: key-blink .3s steps(1) infinite; }
/* FUEL als echte Tankanzeige: >50 % grün, 30–50 % gelb, darunter rot (unter 15 % blinkend) */
.key.fuel-green { background: linear-gradient(180deg, #8ef0a0, #2fbf55); box-shadow: 0 0 0 .35cqw #050505, 0 0 2cqw .4cqw rgba(60, 230, 100, .6), inset 0 .7cqw .4cqw rgba(255, 255, 255, .5); }
.key.fuel-yellow { background: linear-gradient(180deg, #fff08a, #f2c21e); box-shadow: 0 0 0 .35cqw #050505, 0 0 2cqw .4cqw rgba(255, 210, 40, .6), inset 0 .7cqw .4cqw rgba(255, 255, 255, .5); }
.key.fuel-red { background: linear-gradient(180deg, #ff8a74, #e8301c); box-shadow: 0 0 0 .35cqw #050505, 0 0 2cqw .4cqw rgba(255, 60, 40, .7), inset 0 .7cqw .4cqw rgba(255, 255, 255, .45); }
@keyframes key-blink { 50% { filter: brightness(.45); } }

.center {
  display: flex;
  flex-direction: column;
  gap: 2.4cqw;
  margin: 0 1.6cqw;
  padding: 2.6cqw 2.6cqw 3cqw;
  border-radius: 1.6cqw;
  background: #000;
  box-shadow: inset 0 0 0 .4cqw #121212, inset 0 0 2cqw rgba(0, 0, 0, .9);
}
.screen { flex: 1 1 60%; min-height: 0; background: #040000; border-radius: .8cqw; }
.screen canvas { display: block; width: 100%; height: 100%; }

.cruise { flex: 0 0 auto; display: grid; grid-template-columns: 5.2cqw 1fr; gap: 2.6cqw; }
.cruise-lights { display: grid; grid-template-rows: repeat(4, 1fr); gap: 1cqw; }
.cruise-lights i {
  border-radius: .5cqw;
  background: linear-gradient(180deg, #d9d9d6, #a9a9a5);
  box-shadow: inset 0 0 .6cqw rgba(0, 0, 0, .4);
  opacity: .55;
  transition: opacity .15s, background .15s, box-shadow .15s;
}
.cruise-labels { display: grid; grid-template-rows: repeat(4, 1fr); gap: 1cqw; }
.cruise-btn {
  height: 6.4cqw;
  padding: 0;
  border: .35cqw solid #1c1c1c;
  border-radius: .9cqw;
  background: linear-gradient(180deg, #9a9a98, #6f6f6d);
  color: #2a2a2a;
  /* breite, fette Schrift wie auf der Original-Cruise-Anzeige */
  font-family: "Eurostile Extended", "Microgramma", "Bahnschrift", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-stretch: expanded;
  font-weight: 800;
  font-size: 2.5cqw;
  line-height: 1.05;
  letter-spacing: .06em;
  text-shadow: 0 .1cqw 0 rgba(255, 255, 255, .25);
  transition: background .15s, box-shadow .15s, color .15s;
  touch-action: manipulation;
}
.cruise-btn:active { filter: brightness(.9); }
.cruise-btn.on { color: #101010; text-shadow: none; }
.cruise-btn.normal.on { background: linear-gradient(180deg, #7dff98, #2fc653); box-shadow: 0 0 2.6cqw rgba(60, 230, 100, .75); }
.cruise-btn.auto.on { background: linear-gradient(180deg, #fff08a, #f2c21e); box-shadow: 0 0 2.6cqw rgba(255, 210, 40, .75); }
.cruise-btn.pursuit.on { background: linear-gradient(180deg, #ff8a74, #e8301c); box-shadow: 0 0 2.6cqw rgba(255, 60, 40, .8); }
.cruise-btn.silent.on { background: linear-gradient(180deg, #9fd6ff, #1f7fe0); box-shadow: 0 0 2.6cqw rgba(40, 140, 255, .8); }
.cruise-lights i.on { opacity: 1; }
.cruise-lights i.normal.on { background: #5df07a; box-shadow: 0 0 1.6cqw rgba(60, 230, 100, .8); }
.cruise-lights i.auto.on { background: #ffe04a; box-shadow: 0 0 1.6cqw rgba(255, 210, 40, .8); }
.cruise-lights i.pursuit.on { background: #ff5a40; box-shadow: 0 0 1.6cqw rgba(255, 60, 40, .8); }
.cruise-lights i.silent.on { background: #4aa8ff; box-shadow: 0 0 1.6cqw rgba(40, 140, 255, .8); }

.sim label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.sim input { width: 100%; }

/* Mit eingeblendetem Text wird die Konsole kleiner, damit alles auf den Bildschirm passt */
body.text-open .kitt { width: min(96vw, 56vh * 1.08, 980px); }

/* ---------- Gesprächstext (TXT) ---------- */
.textpanel {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.textpanel[hidden] { display: none; }
#transcript {
  max-height: 24vh;
  overflow-y: auto;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
#transcript:empty::before { content: "Noch keine Nachrichten."; color: var(--muted); }
.line { margin: 4px 0; overflow-wrap: anywhere; }
.line b { margin-right: 6px; color: var(--muted); font-weight: 600; }
.line.kitt b { color: var(--lit); }

/* ---------- Einstellungen ---------- */
dialog {
  width: min(92vw, 460px);
  padding: 0;
  border: 1px solid #3a1510;
  border-radius: 12px;
  background: #0a0606;
  color: var(--fg);
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.dlg { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.dlg h2 { margin: 0 0 4px; color: var(--lit); font-size: 16px; letter-spacing: .2em; text-transform: uppercase; }
.dlg h3 { margin: 10px 0 0; color: var(--amber); font-size: 13px; letter-spacing: .15em; text-transform: uppercase; }
.dlg label { color: var(--muted); font-size: 13px; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
dialog { max-height: 92dvh; overflow-y: auto; }
.slider { display: grid; grid-template-columns: 11em 1fr 3em; align-items: center; gap: 10px; }
.slider input { width: 100%; accent-color: var(--lit); }
.slider output { color: var(--fg); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
#prompt-text, #pron-text {
  width: 100%;
  min-height: 12em;
  padding: 8px 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000;
  color: var(--fg);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Meldungen ---------- */
#toasts {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border: 1px solid #6b150c;
  border-radius: 8px;
  background: #1a0907;
  color: #ffd8d2;
  font-size: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .6);
  transition: opacity .5s, transform .5s;
}
.toast.info { border-color: #4d3a10; background: #140f05; color: #ffe6b0; }
.toast.out { opacity: 0; transform: translateY(-6px); }

/* ---------- Aktivitätsanzeige der Modelle (Lauflicht wie K.I.T.T.s Scanner) ---------- */
.activity {
  width: 100%;
  max-width: 560px;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
.lane {
  display: grid;
  grid-template-columns: 6.5em 1fr 10em;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--muted);
  opacity: .55;
  transition: opacity .2s;
}
.lane.on { opacity: 1; color: var(--fg); }
.lane-name { text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane-info { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane-track {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--off);
  overflow: hidden;
}
.lane-track::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 22%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--lit) 55%, #ffb3a6 70%, var(--lit) 80%, transparent);
  box-shadow: 0 0 8px var(--lit);
  opacity: 0;
}
.lane.on .lane-track::after {
  opacity: 1;
  animation: kitt-scan 1.1s ease-in-out infinite alternate;
}
@keyframes kitt-scan { from { left: 0; } to { left: 78%; } }
@media (prefers-reduced-motion: reduce) {
  .lane.on .lane-track::after { animation: none; left: 0; width: 100%; opacity: .7; }
}

/* Speicherstatus neben den Überschriften im Einstellungsdialog */
.dlg h3 { display: flex; align-items: center; gap: 10px; }
.save-state {
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: none;
  font-weight: 600;
  opacity: 0;
  transition: opacity .4s;
}
.save-state.show { opacity: 1; transition: none; }
.save-state.busy { color: var(--muted); }
.save-state.ok { color: #3ddc84; }
.save-state.err { color: var(--lit); }
#voice-select { width: 100%; }
.file-btn {
  position: relative;
  display: block;
  padding: 10px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--fg);
  text-align: center;
  cursor: pointer;
}
.file-btn:hover, .file-btn:focus-within { border-color: var(--lit); }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Speicherstatus neben den Überschriften im Einstellungsdialog */
.dlg h3 { display: flex; align-items: center; gap: 10px; }
.save-state { font-size: 11px; letter-spacing: .05em; text-transform: none; font-weight: 600; opacity: 0; transition: opacity .4s; }
.save-state.show { opacity: 1; transition: none; }
.save-state.busy { color: var(--muted); }
.save-state.ok { color: #3ddc84; }
.save-state.err { color: var(--lit); }
#voice-select { width: 100%; }
.file-btn { position: relative; display: block; padding: 10px 14px; border: 1px dashed var(--line); border-radius: 8px; color: var(--fg); text-align: center; cursor: pointer; }
.file-btn:hover, .file-btn:focus-within { border-color: var(--lit); }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
