:root {
  --bg:        #0f1419;
  --bg-2:      #161c26;
  --bg-3:      #1f2733;
  --border:    #2a3441;
  --text:      #e6e9ee;
  --text-dim:  #8a94a6;
  --accent:    #4f8cff;
  --accent-2:  #3b76e0;
  --ok:        #4ade80;
  --err:       #f87171;
  --warn:      #fbbf24;

  /* aus dem Dark-Theme der BSC-WebApp übernommen */
  --bsc-primary: #2566a6;
  --bsc-head:    #ccc;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

/* ---------- Kopfzeile ----------
   Farben und Maße stammen aus dem Dark-Theme der BSC-WebApp
   (--primary: #2566a6, --text-head: #ccc), damit die Leiste über dem iframe
   dieselbe ist wie die im iframe. */
.topbar {
  flex: 0 0 52px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 6px 14px;
  background: var(--bsc-primary);
  color: var(--bsc-head);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text strong { font-size: 16px; }
.brand-text small { font-size: 12px; margin-top: 3px; }

.topbar-title { font-size: 18px; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Auf der Leiste sind die Kontraste andere als auf dunklem Grund. */
.topbar .btn-ghost { color: var(--bsc-head); border-color: rgba(255, 255, 255, .35); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.topbar .mono { color: var(--bsc-head); }

@media (max-width: 640px) {
  .brand-text, .topbar .mono { display: none; }
  .topbar-title { font-size: 15px; }
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 13px; }
.dim { color: var(--text-dim); font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: 500 14px var(--sans);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 24px; padding: 12px; }

/* ---------- Anmelde-/Schlüsselschirm ---------- */
.screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, #1a2130, var(--bg) 70%);
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.card h1 { font-size: 21px; margin-bottom: 10px; }

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 22px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin: 16px 0 6px;
}

/* Erklaerung unter einem Eingabefeld, kleiner als .subtitle. */
.hint {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}

input[type=text], input[type=password], input[type=search] {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
input:focus { outline: none; border-color: var(--accent); }

.row { display: flex; gap: 10px; margin-top: 24px; }
.row .btn { flex: 1; }

.error { color: var(--err); font-size: 13px; margin-top: 14px; line-height: 1.5; }

/* ---------- Rahmen ---------- */
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.badge {
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-on  { background: rgba(74, 222, 128, .14); color: var(--ok); }
.badge-off { background: rgba(248, 113, 113, .14); color: var(--err); }

main { flex: 1; display: flex; min-height: 0; }

.panel { display: flex; flex-direction: column; min-width: 0; }
.panel-remote { flex: 1.25; }
.panel-logs { flex: 1; background: var(--bg-2); }

/* ---------- Trennlinie zwischen den Bereichen ---------- */
.splitter {
  flex: 0 0 5px;
  background: var(--border);
  cursor: col-resize;
  position: relative;
  transition: background .15s;
}

/* Der Greifbereich ist breiter als die sichtbare Linie — sonst muss man beim
   Ziehen zielen. */
.splitter::before {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

.splitter:hover,
.splitter:focus-visible,
.splitter.dragging { background: var(--accent); outline: none; }

/* Während des Ziehens darf der iframe die Maus nicht abfangen — sonst reißt die
   Bewegung ab, sobald der Zeiger die WebApp überstreicht. */
body.splitting { cursor: col-resize; user-select: none; }
body.splitting #frame { pointer-events: none; }

.panel-head {
  flex: 0 0 auto;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-head h2 { font-size: 14px; font-weight: 600; }

#frame { flex: 1; width: 100%; border: 0; background: #fff; }

.panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
}

/* ---------- Log-Werkzeugleiste ---------- */
.notice {
  background: rgba(79, 140, 255, .1);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.notice .row { margin: 0; }
.notice .btn { flex: 0 0 auto; }

.toolbar { display: flex; align-items: center; gap: 14px; }
.toolbar input[type=search] { flex: 1; }

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.check input { cursor: pointer; }

/* ---------- Log-Anzeige ---------- */
.viewer {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.placeholder { color: var(--text-dim); text-align: center; padding: 32px 0; font-family: var(--sans); }

.line { white-space: pre-wrap; word-break: break-word; padding: 1px 3px; border-radius: 3px; }
.line.fresh { animation: fresh .5s ease; }
@keyframes fresh {
  from { background: rgba(74, 222, 128, .18); }
  to   { background: transparent; }
}

mark { background: rgba(251, 191, 36, .28); color: inherit; border-radius: 2px; }

.file-head {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 4px 4px;
  margin-top: 6px;
  cursor: pointer;
  border-radius: 4px;
}

.file-head:hover,
.file-head:focus-visible {
  background: rgba(79, 140, 255, .12);
  text-decoration: underline;
  outline: none;
}

/* Kurzes Aufblinken der Zeile, zu der gesprungen wurde — sonst muss man erst
   suchen, wo man gelandet ist. */
.line.jump {
  background: rgba(79, 140, 255, .22);
  box-shadow: inset 2px 0 0 var(--accent);
  transition: background 1.2s ease, box-shadow 1.2s ease;
}

/* ---------- Trennlinie zwischen Log-Anzeige und Dateiliste ---------- */
.hsplitter {
  flex: 0 0 5px;
  background: var(--border);
  border-radius: 3px;
  cursor: row-resize;
  position: relative;
  transition: background .15s;
}

.hsplitter::before {
  content: "";
  position: absolute;
  inset: -4px 0;
}

.hsplitter:hover,
.hsplitter:focus-visible,
.hsplitter.dragging { background: var(--accent); outline: none; }

body.splitting-v { cursor: row-resize; user-select: none; }

/* ---------- Dateiliste ---------- */
.files { flex: 0 0 168px; min-height: 0; display: flex; flex-direction: column; }

.files h3 {
  flex: 0 0 auto;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.files ul { flex: 1; min-height: 0; list-style: none; overflow-y: auto; }

.files li {
  padding: 6px 9px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.files li:hover { background: var(--bg-3); color: var(--text); }
.files li.active { background: rgba(79, 140, 255, .14); color: var(--accent); }

@media (max-width: 900px) {
  main { flex-direction: column; }
  .panel-remote { border-bottom: 1px solid var(--border); }
  .splitter { display: none; }
}
