:root {
  color-scheme: dark;
  --bg: #0d1117;
  --leiste: #11161d;
  --flaeche: #161b22;
  --flaeche-2: #1c222b;
  --hover: #1f2630;
  --aktiv: #1f2d42;
  --rand: #262d37;
  --text: #d7dde6;
  --leise: #8590a0;
  --akzent: #4c8dff;
  --akzent-dunkel: #2f6fe0;
  --gut: #3fb950;
  --warn: #d29922;
  --schlecht: #f2564b;
  --term-bg: #0b0e13;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --hoehe: 100dvh;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  background: var(--flaeche-2);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--hover); border-color: #343c48; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--akzent);
  outline-offset: 1px;
}
button.haupt { background: var(--akzent-dunkel); border-color: var(--akzent-dunkel); color: #fff; font-weight: 600; }
button.haupt:hover { background: var(--akzent); }
button.haupt:disabled { opacity: .55; cursor: wait; }
button.gefahr:hover { border-color: var(--schlecht); color: #ffb3ad; }
button.klein { padding: 3px 10px; font-size: 13px; }
button.link { background: none; border: 0; padding: 0; color: var(--leise); text-decoration: underline; }
button.link:hover { color: var(--text); }
button.symbol { padding: 4px 9px; font-size: 16px; line-height: 1; }
button.symbol[aria-pressed="true"] { background: var(--aktiv); border-color: var(--akzent-dunkel); }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 7px 9px;
}
input::placeholder, textarea::placeholder { color: #5d6776; }

label { display: block; margin: 10px 0 0; color: var(--leise); font-size: 13px; }
label > input, label > select { margin-top: 4px; color: var(--text); font-size: 14px; }

.leise { color: var(--leise); }
.klein { font-size: 12px; }
.fehler { color: var(--schlecht); min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }

.marke { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.logo {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: linear-gradient(135deg, #1f3a66, #18263d);
  color: #7fb0ff; font: 700 12px/1 var(--mono);
}
.logo.gross { width: 64px; height: 64px; font-size: 26px; border-radius: 14px; }

/* ---------- Anmeldung ---------- */

#login { height: var(--hoehe); display: grid; place-items: center; padding: 16px; }
.karte {
  width: min(360px, 100%);
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 24px;
}
.karte .leise { margin: 4px 0 8px; }
.karte button.haupt { width: 100%; margin-top: 10px; padding: 9px; }

/* ---------- Grundaufbau ---------- */

#app { display: grid; grid-template-columns: 280px minmax(0, 1fr); height: var(--hoehe); }

#leiste {
  background: var(--leiste);
  border-right: 1px solid var(--rand);
  display: flex; flex-direction: column;
  min-height: 0;
}
.leiste-kopf { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 10px; border-bottom: 1px solid var(--rand); }
#liste { flex: 1; overflow-y: auto; padding: 6px 6px 12px; }
.leiste-fuss {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--rand); font-size: 12px;
}

.gruppe { margin-top: 10px; }
.gruppe-kopf {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; color: var(--leise);
}
.gruppe-kopf .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gruppe-kopf .info { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11px; opacity: .8; }
.gruppe-leer { padding: 2px 8px 4px 22px; font-size: 12px; color: #5d6776; }

.punkt { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #4a525e; }
.punkt.gut { background: var(--gut); }
.punkt.warn { background: var(--warn); }
.punkt.schlecht { background: var(--schlecht); }

.eintrag {
  display: flex; align-items: flex-start; gap: 9px;
  width: 100%; text-align: left;
  background: none; border: 1px solid transparent; border-radius: var(--radius);
  padding: 7px 8px; margin: 1px 0;
}
.eintrag:hover { background: var(--hover); border-color: transparent; }
.eintrag.gewaehlt { background: var(--aktiv); border-color: #2b4266; }
.eintrag .punkt { margin-top: 6px; }
.eintrag .text { flex: 1; min-width: 0; }
.eintrag .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eintrag .meta { font-size: 12px; color: var(--leise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.eintrag.neu .name { font-weight: 700; color: #fff; }
.eintrag .neu-punkt { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--akzent); margin-top: 7px; flex: none; }
.eintrag.neu .neu-punkt { display: block; }
.eintrag.beendet .name { color: var(--leise); }

/* ---------- Mitte ---------- */

#mitte { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--term-bg); }

#kopf {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; min-height: 52px;
  background: var(--flaeche); border-bottom: 1px solid var(--rand);
}
#menue { display: none; }
.titel { flex: 1; min-width: 0; }
#titel-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#titel-info { font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marke-status {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: #1d2a1f; color: #7ee087; border: 1px solid #2a4a2f; white-space: nowrap;
}
.marke-status.warn { background: #2e2614; color: #f0c15a; border-color: #4d3f1c; }
.marke-status.aus { background: #1d2128; color: var(--leise); border-color: var(--rand); }
.aktionen { display: flex; gap: 6px; flex-wrap: nowrap; }
.aktionen button { font-size: 13px; padding: 4px 10px; }

#banner {
  background: #3a2a10; color: #f6d38b; border-bottom: 1px solid #5a4218;
  padding: 6px 12px; font-size: 13px; text-align: center;
}

#termrahmen { position: relative; flex: 1; min-height: 0; }
#term { position: absolute; inset: 8px 4px 4px 12px; }
#term .xterm-viewport { scrollbar-width: thin; scrollbar-color: #2c333d transparent; }
#leer {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--leise); text-align: center; padding: 24px; background: var(--term-bg);
}

#eingabe { border-top: 1px solid var(--rand); background: var(--flaeche); padding: 8px 10px; }
#tasten { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
#tasten button { font: 12px/1 var(--mono); padding: 7px 10px; flex: none; }
#schreiben { display: flex; gap: 8px; align-items: flex-end; }
#schreiben textarea { resize: none; max-height: 160px; min-height: 38px; line-height: 1.4; font-size: 15px; }
#schreiben button { height: 38px; }

/* ---------- Dialog & Meldung ---------- */

dialog {
  width: min(460px, calc(100vw - 32px));
  background: var(--flaeche); color: var(--text);
  border: 1px solid var(--rand); border-radius: 12px; padding: 20px;
}
dialog::backdrop { background: rgba(3, 6, 10, .65); }
dialog h2 { margin: 0 0 6px; font-size: 17px; }
fieldset { border: 0; padding: 0; margin: 12px 0 0; }
legend { color: var(--leise); font-size: 13px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chips button { border-radius: 99px; padding: 4px 12px; font-size: 13px; }
.chips button[aria-pressed="true"] { background: var(--aktiv); border-color: var(--akzent); color: #fff; }
.knoepfe { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#rechner-hinweis { margin: 4px 0 0; min-height: 1em; }

#meldung {
  position: fixed; right: 16px; bottom: 16px; max-width: min(420px, calc(100vw - 32px));
  background: #2b1616; color: #ffc9c4; border: 1px solid #5a2622;
  padding: 10px 14px; border-radius: var(--radius); z-index: 50; font-size: 13px;
}

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #leiste {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0;
    width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform .18s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, .4);
  }
  body.leiste-offen #leiste { transform: none; }
  #vorhang { position: fixed; inset: 0; z-index: 25; background: rgba(3, 6, 10, .55); }
  #menue { display: inline-block; }
  #kopf { padding: 8px; gap: 8px; }
  .aktionen button:not(.symbol) { padding: 4px 8px; font-size: 12px; }
  .aktionen [data-aktion="rename"] { display: none; }
  #term { inset: 6px 2px 2px 6px; }
}

/* ---------- Zugangsfreigabe ---------- */

button.breit { width: 100%; padding: 8px; }
.oder { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; color: var(--leise); font-size: 12px; }
.oder::before, .oder::after { content: ""; flex: 1; border-top: 1px solid var(--rand); }
.code {
  margin: 14px 0; padding: 14px; text-align: center;
  font: 700 30px/1 var(--mono); letter-spacing: 4px; color: #fff;
  background: var(--bg); border: 1px solid var(--rand); border-radius: var(--radius);
}
#freigabe-karte p { margin: 8px 0; }
#freigabe-karte button { margin-top: 8px; }

#anfragen { background: #14233b; border-bottom: 1px solid #2b4266; }
.anfrage { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; font-size: 13px; }
.anfrage + .anfrage { border-top: 1px solid #2b4266; }
.anfrage .text { flex: 1; min-width: 200px; }
.anfrage b { font-family: var(--mono); letter-spacing: 1px; color: #fff; }

.freigabe { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--rand); }
.freigabe .text { flex: 1; min-width: 0; }
#freigaben-liste:empty::after { content: "Keine aktiven Freigaben."; display: block; color: var(--leise); padding: 8px 0; }
.anfrage input { width: 150px; padding: 4px 8px; font-size: 13px; }

/* ---------- Vorschau ---------- */

a.knopf {
  display: inline-block; border-radius: 6px; padding: 5px 12px; text-decoration: none;
  background: var(--akzent-dunkel); border: 1px solid var(--akzent-dunkel); color: #fff; font-weight: 600;
}
a.knopf:hover { background: var(--akzent); }
#vorschau-link { font-family: var(--mono); font-size: 13px; margin-top: 10px; }
#vorschau-dialog code { font-size: 12px; }
@media (max-width: 820px) { .aktionen [data-aktion="vorschau"] { padding: 4px 8px; } }
