/* app.css — OrbitalAgent. Dunkel, cyan, im Stil des Panels.
   Mobil zuerst: volle Hoehe, Eingabe unten, Verlauf scrollt dazwischen. */

:root {
  --bg: #070a12;
  --surface: #0d1626;
  --surface-2: #111d31;
  --accent: #34d7e8;
  --accent-deep: #22b6c6;
  --text: #e2ebfa;
  --muted: #8a9cbd;
  --faint: #56688f;
  --line: rgba(120, 175, 255, 0.12);
  --err: #ff8a8a;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------- Anmelde-/Setup-Karte */

body.centered {
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(52,215,232,.07), transparent 60%),
    var(--bg);
}
.card {
  width: min(24rem, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem 1.6rem;
  text-align: center;
  box-shadow: 0 20px 50px -24px rgba(0,0,0,.7);
}
.brandmark {
  font-family: var(--mono);
  letter-spacing: .22em;
  text-transform: uppercase;
  font-size: .82rem;
  color: var(--accent);
  margin-bottom: 1rem;
}
.card h1 { font-size: 1.25rem; margin: .2rem 0 .4rem; }
.muted { color: var(--muted); }
.msg.err, .msg[role="status"] { min-height: 1.4em; }

/* ---------------------------------------------- Knoepfe */

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; }
.primary {
  background: var(--accent);
  color: #041016;
  font-weight: 650;
  padding: .7rem 1.1rem;
  margin-top: 1rem;
}
.primary:hover { background: var(--accent-deep); }
.primary:disabled { opacity: .5; cursor: default; }
/* Eigenständig, damit <a class="ghost"> und <button class="ghost"> identisch
   aussehen — der <a> erbt Rahmen/Rundung/Schrift NICHT von der button-Regel. */
.ghost {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .35rem .7rem;
  font: inherit;
  font-size: .85rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.ghost:hover { color: var(--text); }

/* Statuszeile auf den Karten */
p.msg { margin: .8rem 0 0; font-size: .9rem; color: var(--muted); }
p.msg.err { color: var(--err); }

/* ---------------------------------------------- Chat */

body.chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(.7rem, env(safe-area-inset-top)) 1rem .7rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.top .brand {
  font-family: var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: .8rem;
  color: var(--accent);
}
.top-actions { display: flex; gap: .4rem; }

.stream {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  -webkit-overflow-scrolling: touch;
}
.hello {
  color: var(--muted);
  max-width: 34rem;
  margin: auto 0;
}
.hello p { margin: .4rem 0; }

.msg {
  max-width: min(80%, 42rem);
  padding: .6rem .85rem;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #041016;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.pending { color: var(--faint); font-family: var(--mono); }
.msg.error { border-color: rgba(255,138,138,.4); color: var(--err); }

/* Notiz im Verlauf: was passiert ist. Bewusst keine Blase — es hat niemand
   gesagt, es ist geschehen. */
.notiz {
  align-self: center;
  max-width: min(90%, 42rem);
  text-align: center;
  color: var(--faint);
  font-size: .82rem;
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------- Aktionskarte
   Der Vorschlag des Agenten. Steht bewusst neben den Blasen und nicht darin:
   das hier ist keine Rede, sondern ein Knopf, der etwas am Server tut. */
.aktion {
  align-self: flex-start;
  max-width: min(90%, 42rem);
  width: min(90%, 30rem);
  background: var(--surface);
  border: 1px solid rgba(52,215,232,.35);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: .7rem .85rem;
}
.aktion-kopf {
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
}
.aktion-cmd {
  display: block;
  margin: .45rem 0;
  padding: .4rem .55rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: .85rem;
  overflow-wrap: anywhere;
}
.aktion-grund { margin: .35rem 0 .6rem; color: var(--muted); font-size: .9rem; }
.aktion-knoepfe { display: flex; gap: .5rem; }
.aktion-knoepfe .primary { padding: .4rem .9rem; }
.aktion-msg {
  margin: .5rem 0 0;
  color: var(--muted);
  font-size: .85rem;
  overflow-wrap: anywhere;
}
.aktion-msg:empty { display: none; }
.aktion.fertig    { border-color: rgba(52,215,232,.25); border-left-color: var(--accent-deep); }
.aktion.schief    { border-color: rgba(255,138,138,.4); border-left-color: var(--err); }
.aktion.schief .aktion-msg { color: var(--err); }
.aktion.verworfen { border-color: var(--line); border-left-color: var(--faint); opacity: .6; }

.composer {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  padding: .6rem 1rem max(.6rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer textarea {
  flex: 1;
  resize: none;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .6rem .8rem;
  max-height: 160px;
  line-height: 1.4;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--accent-deep);
}
.composer .primary {
  margin: 0;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  flex: none;
}

@media (prefers-reduced-motion: no-preference) {
  .msg.pending::after { content: ""; }
}

/* ---------------------------------------------- Cockpit */

body.cockpit {
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(52,215,232,.05), transparent 60%),
    var(--bg);
}
.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1rem max(1.5rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
}
.panel h2 {
  margin: 0 0 .7rem;
  font-size: .8rem;
  font-family: var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}
.panel .big {
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-family: var(--mono);
  margin: 0 0 .6rem;
  color: var(--text);
}
.small { font-size: .8rem; }

/* Deckel-Balken */
.bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--line);
}
.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width .3s ease;
}

/* Token-Aufstellung */
.tokens {
  margin: 1rem 0 .4rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .3rem 1rem;
  font-size: .9rem;
}
.tokens dt { color: var(--muted); }
.tokens dd { margin: 0; font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }

/* Zeilen (Gespräche, Gedächtnis) */
.row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .92rem;
}
.row:last-child { border-bottom: none; }
.row-main { color: var(--text); overflow-wrap: anywhere; }
.row-main code { font-family: var(--mono); font-size: .85rem; }

/* "selbst" — der Assistent hat ohne Rueckfrage gehandelt. Muss im Protokoll
   auf einen Blick zu finden sein, deshalb warm statt cyan. */
.marke {
  display: inline-block;
  padding: .05rem .4rem;
  margin-right: .3rem;
  border-radius: 6px;
  background: rgba(255,176,90,.16);
  border: 1px solid rgba(255,176,90,.4);
  color: #ffb05a;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: .05em;
}

/* ---------------------------------------------- Not-Aus */

.notaus {
  display: flex;
  gap: .9rem;
  align-items: center;
  justify-content: space-between;
  padding: .7rem .9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--faint);
  background: var(--bg);
}
.notaus.an { border-color: rgba(255,176,90,.45); border-left-color: #ffb05a; }
.notaus strong {
  font-family: var(--mono);
  letter-spacing: .12em;
  font-size: 1.35rem;
  color: var(--faint);
}
.notaus.an strong { color: #ffb05a; }
.notaus button { flex: none; }

/* Etwas ist still kaputt und niemand wuerde es merken — das darf nicht
   aussehen wie eine beilaeufige Randnotiz. */
.warnung {
  margin: 0 0 .6rem;
  padding: .6rem .75rem;
  border: 1px solid rgba(255,138,138,.4);
  border-left: 3px solid var(--err);
  border-radius: 10px;
  background: rgba(255,138,138,.07);
  color: var(--text);
  font-size: .88rem;
}

/* ---------------------------------------------- Dienst-Kacheln
   Angetippt wird die ganze Kachel, nicht ein 16-Pixel-Kaestchen: auf dem Handy
   ist das der Unterschied zwischen treffen und danebentippen. */
.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: .5rem;
  margin: .6rem 0;
}
.kachel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background .12s;
}
.kachel:hover { border-color: rgba(120,175,255,.3); }
/* Das Kaestchen bleibt bedienbar (Tastatur, Vorleser), nur unsichtbar. */
.kachel input {
  position: absolute;
  opacity: 0;
  width: 100%; height: 100%;
  top: 0; left: 0;
  margin: 0;
  cursor: pointer;
}
.kachel input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.kachel-name {
  font-weight: 600;
  font-size: .9rem;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.kachel-zustand { color: var(--faint); font-size: .78rem; }
.kachel.frei {
  border-color: var(--accent);
  background: rgba(52,215,232,.08);
}
.kachel.frei .kachel-name { color: var(--accent); }
.kachel.frei::after {
  content: "✓";
  position: absolute;
  top: .4rem; right: .55rem;
  color: var(--accent);
  font-size: .8rem;
}

/* ---------------------------------------------- Protokolleintrag
   Drei eigene Zeilen statt zwei Spalten. Als zweispaltige Zeile wurde ein
   langes Kommando neben dem Zeitstempel zu einer vier Zeilen hohen Nudel —
   deshalb bekommt das Kommando die volle Breite und scrollt seitwaerts,
   statt umzubrechen. */
.eintrag {
  padding: .6rem 0;
  border-bottom: 1px solid var(--line);
}
.eintrag:last-of-type { border-bottom: none; }
.eintrag-kopf {
  display: flex;
  gap: .45rem;
  align-items: center;
  margin-bottom: .35rem;
}
.eintrag-status {
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.eintrag.gut      .eintrag-status { color: var(--accent); }
.eintrag.schlecht .eintrag-status { color: var(--err); }
.eintrag.aktiv    .eintrag-status { color: #ffb05a; }
.eintrag time {
  margin-left: auto;
  color: var(--faint);
  font-size: .78rem;
  font-family: var(--mono);
  white-space: nowrap;
}
.eintrag-cmd {
  display: block;
  padding: .35rem .5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: .8rem;
  /* Nicht umbrechen — seitwaerts scrollen. Ein Kommando ist eine Zeile. */
  white-space: pre;
  overflow-x: auto;
}
.eintrag-text {
  margin: .35rem 0 0;
  color: var(--muted);
  font-size: .85rem;
  overflow-wrap: anywhere;
}
.row-side { color: var(--faint); white-space: nowrap; font-family: var(--mono); font-size: .8rem; align-self: center; }
