/* RagnaIDE Fernsteuerung — dieselbe Sprache wie die Desktop-App:
   kaltes Eisen, eine Glut als Akzent, Schienen statt Flächen. */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Muss vor allen display-Regeln stehen und sie schlagen: eine eigene
   display-Angabe (etwa .app { display: flex }) haette sonst Vorrang vor dem
   hidden-Attribut, und verborgene Bereiche blieben sichtbar. */
[hidden] { display: none !important; }

:root {
  --bg-0: #0b0e10;
  --bg: #12171a;
  --bg-panel: #1a2126;
  --bg-hover: #222b31;
  --border: #212a30;
  --line-strong: #33404a;
  --fg: #dce4e8;
  --fg-dim: #8c9aa4;
  --fg-faint: #6e7c86;
  --accent: #f0803c;
  --accent-wash: rgba(240, 128, 60, 0.12);
  --ember-ink: #1b0d05;
  --run: #56b6d8;
  --ok: #8fbf6a;
  --err: #ef5a5f;
  --warn: #d9a441;
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  --font-display: Bahnschrift, "Segoe UI Semibold", var(--font-ui);
}

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #2b363d;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 6px;
}
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

button {
  font-family: inherit;
  font-size: 13px;
  color: var(--fg);
  background: #2b363d;
  border: none;
  border-radius: 3px;
  padding: 7px 13px;
  cursor: pointer;
  transition: background-color 90ms cubic-bezier(.2,.8,.2,1);
}
button:hover { background: var(--line-strong); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--ember-ink); font-weight: 600; }
button.primary:hover { background: #ff9450; }
button.danger { background: rgba(239,90,95,.16); color: var(--err); }
button.ghost { background: none; color: var(--fg-faint); }
button.ghost:hover { background: none; color: var(--accent); }

input, textarea, select {
  font-family: inherit;
  color: var(--fg);
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 7px 9px;
  font-size: 13px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

/* ---------------------------------------------------------------- Anmeldung */

.login {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
.mark { color: var(--accent); line-height: 1; }
.mark.big { font-size: 56px; }
.login h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.login p { color: var(--fg-dim); max-width: 34ch; line-height: 1.6; }
.error { color: var(--err); }

/* ------------------------------------------------------------------ Gerüst */

.app { height: 100%; display: flex; flex-direction: column; }

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 12px;
  background: var(--bg-0);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bar .mark { font-size: 20px; }
.title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 13px;
}
.spacer { flex: 1; }
.who { font-family: var(--font-mono); font-size: 12px; color: var(--fg-dim); }
.devices { max-width: 40vw; font-size: 12px; padding: 4px 7px; }

.link {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 2px;
  border: 1px solid var(--border);
}
.link.on { color: var(--ok); border-color: var(--ok); }
.link.off { color: var(--err); border-color: var(--err); }
.link.wait { color: var(--warn); border-color: var(--warn); }

.main { flex: 1; display: grid; grid-template-columns: 300px 1fr; min-height: 0; }

/* ---------------------------------------------------------------- Seitenteil */

.side {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
}

.panel { border-bottom: 1px solid var(--border); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  padding: 0 12px;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0 6px;
}

.plan { padding: 2px 12px 10px; }
.plan-step {
  display: flex;
  gap: 8px;
  padding: 3px 0 3px 8px;
  font-size: 13px;
  color: var(--fg-dim);
  border-left: 2px solid transparent;
  line-height: 1.45;
}
.plan-step.in_progress { color: var(--fg); border-left-color: var(--run); }
.plan-step.done { color: var(--fg-faint); text-decoration: line-through; }
.plan-step.blocked { border-left-color: var(--err); }
.plan-icon { flex-shrink: 0; }
.plan-step span:last-child { overflow-wrap: anywhere; }
.plan-step.in_progress .plan-icon { color: var(--run); }
.plan-step.done .plan-icon { color: var(--ok); }

.agents { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 5px; }
.agent {
  border: 1px solid var(--border);
  border-left: 2px solid var(--line-strong);
  border-radius: 2px;
  padding: 6px 9px;
  background: var(--bg);
}
.agent.running { border-left-color: var(--run); }
.agent.done { border-left-color: var(--ok); }
.agent.error { border-left-color: var(--err); }
.agent.stopped { border-left-color: var(--warn); }
.agent-head { display: flex; align-items: center; gap: 7px; }
.agent-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.agent-model { font-family: var(--font-mono); font-size: 10px; color: var(--fg-faint); }
.agent-activity {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-faint);
  margin-top: 3px;
  overflow-wrap: anywhere;
  /* Zwei Zeilen reichen; danach ist es Rauschen. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-faint); flex-shrink: 0; }
.dot.running { background: var(--run); animation: pulse 1.6s ease-in-out infinite; }
.dot.done { background: var(--ok); }
.dot.error { background: var(--err); }
.dot.stopped { background: var(--warn); }
@keyframes pulse { 50% { opacity: .45; } }

.controls { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.workspace {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-faint);
  word-break: break-all;
}

/* --------------------------------------------------------------------- Chat */

.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.empty { color: var(--fg-faint); text-align: center; margin-top: 18vh; }

.role {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 4px;
}
.msg.user {
  background: var(--bg-hover);
  border-left: 2px solid var(--accent);
  padding: 8px 11px;
  border-radius: 0 3px 3px 0;
}
.msg.user .role { color: var(--accent); }
.body { line-height: 1.6; overflow-wrap: anywhere; }
.body code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-0);
  border-radius: 2px;
  padding: 1px 4px;
  color: var(--accent);
}
.body pre {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 10px;
  overflow-x: auto;
  margin: 8px 0;
}
.body pre code { background: none; padding: 0; color: var(--fg); }

.tool {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-faint);
  border-left: 2px solid var(--border);
  box-shadow: inset 0 -1px 0 var(--border);
}
.tool.ok { border-left-color: var(--ok); }
.tool.error { border-left-color: var(--err); }
.tool.running { border-left-color: var(--run); }

.tool-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 4px 10px;
}
.tool-icon, .tool-toggle { flex-shrink: 0; }
.tool.ok .tool-icon { color: var(--ok); }
.tool.error .tool-icon { color: var(--err); }
.tool.running .tool-icon { color: var(--run); }

/* Lange Befehle und Pfade umbrechen statt abschneiden — auf dem Handy ist
   sonst schon nach "ls -la" Schluss. */
.tool-label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.tool-output {
  margin: 0;
  padding: 8px 10px;
  background: var(--bg-0);
  border-top: 1px solid var(--border);
  max-height: 40vh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11.5px;
  color: var(--fg-dim);
}

.confirm, .question {
  border: 1px solid var(--accent);
  background: var(--accent-wash);
  border-radius: 3px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.confirm.allowed, .confirm.denied { border-color: var(--border); background: none; }
.confirm-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.confirm-cmd {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-0);
  border-radius: 2px;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.confirm-actions, .question-row { display: flex; gap: 8px; }
.question-row input { flex: 1; }
.confirm-state { font-family: var(--font-mono); font-size: 11px; color: var(--fg-faint); }

.composer {
  border-top: 1px solid var(--border);
  background: var(--bg-0);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.composer textarea { resize: none; line-height: 1.5; }
.composer-row { display: flex; gap: 8px; }
.pending { font-family: var(--font-mono); font-size: 11px; color: var(--warn); }

/* Auf dem Handy hat die Seitenspalte keinen Platz — Chat zuerst. */
@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { max-height: 34vh; border-right: none; border-bottom: 1px solid var(--border); }
  .devices { max-width: 32vw; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
