:root {
  --sumi:      #11121a;
  --sumi-2:    #191b26;
  --sumi-3:    #232634;
  --line:      #2c3040;
  --kurenai:   #e23e52;  /* live */
  --kurenai-d: #8e1f2e;
  --ai:        #6d8cb8;  /* ruhend */
  --kin:       #d8a44b;  /* Störung */
  --text:      #e9e7ef;
  --muted:     #878ca1;
  --faint:     #5d6377;

  --display: "Zen Kaku Gothic New", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --r: 3px;
  --pad: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }

/*
  Wichtig: Eigene display-Regeln schlagen das hidden-Attribut, weil dieses
  nur ueber das Standardstylesheet des Browsers wirkt. Ohne diese Zeile
  bleiben Anmeldemaske und Kontofenster dauerhaft sichtbar.
*/
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--sumi);
  color: var(--text);
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.55;
  padding: 0 var(--pad) calc(64px + env(safe-area-inset-bottom));
  max-width: 900px;
  margin-inline: auto;
  overflow-x: hidden;
}

/* Feine Textur, damit die Fläche nicht wie flaches Schwarz wirkt */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .35;
  background:
    radial-gradient(1100px 500px at 82% -8%, rgba(226, 62, 82, .09), transparent 70%),
    radial-gradient(700px 400px at 8% 4%, rgba(109, 140, 184, .07), transparent 70%);
}
main, .top { position: relative; z-index: 1; }

/* ---------- Kopf ---------- */
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: calc(28px + env(safe-area-inset-top)) 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.kanji {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: .06em;
  color: var(--kurenai);
  line-height: 1;
  padding-right: 14px;
  border-right: 1px solid var(--line);
}
.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  margin: 0;
}
.brand p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}

.watch {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.watch-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 0 rgba(226, 62, 82, .5);
}
.watch.on .watch-dot { background: var(--ai); }
.watch.beat .watch-dot { animation: beat .6s ease-out; }
@keyframes beat {
  0%   { box-shadow: 0 0 0 0 rgba(109, 140, 184, .55); }
  100% { box-shadow: 0 0 0 11px rgba(109, 140, 184, 0); }
}

/* ---------- Bausteine ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 12px;
}

input, button, a.ghost {
  font-family: inherit;
  font-size: 15px;
  border-radius: var(--r);
}

input {
  background: var(--sumi);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  width: 100%;
  transition: border-color .15s, background .15s;
}
input::placeholder { color: var(--faint); }
input:focus-visible {
  outline: none;
  border-color: var(--kurenai);
  background: #0d0e15;
}

button, a.ghost {
  cursor: pointer;
  border: 1px solid transparent;
  padding: 12px 20px;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--kurenai); outline-offset: 2px; }

.primary {
  background: var(--kurenai);
  color: #fff;
  font-weight: 700;
  letter-spacing: .04em;
}
.primary:hover { background: #f04a5e; }
.primary:disabled { background: var(--sumi-3); color: var(--faint); cursor: not-allowed; }

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.ghost:hover { border-color: var(--muted); color: var(--text); }
.ghost.sm {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 7px 11px;
}
.ghost.danger:hover { border-color: var(--kurenai-d); color: var(--kurenai); }

.mono { font-family: var(--mono); }

/* ---------- Eingabe ---------- */
.add { margin-bottom: 34px; }
.add-row { display: flex; gap: 10px; }
.add-row input { flex: 1; min-width: 0; }

.add-extra {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.add-extra label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 8px;
}
.add-extra input { width: 150px; padding: 7px 10px; font-size: 13px; }
.add-extra input[type=number] { width: 78px; }

.note {
  margin: 12px 0 0;
  padding: 11px 13px;
  border-left: 2px solid var(--ai);
  background: var(--sumi-2);
  font-size: 13.5px;
  color: var(--muted);
}
.note.warn { border-color: var(--kin); }

/* ---------- Benachrichtigungen ---------- */
.push {
  background: var(--sumi-2);
  border: 1px solid var(--line);
  padding: 20px;
  margin-bottom: 38px;
}
.push-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.push-head .eyebrow { margin: 0; }
.pill {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 4px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.on { border-color: var(--kurenai-d); color: var(--kurenai); }
.pill.off { border-color: var(--line); color: var(--faint); }
.push-text { margin: 12px 0 16px; font-size: 14px; color: var(--muted); }
.push-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Liste ---------- */
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--faint);
}
.list { display: flex; flex-direction: column; gap: 10px; }

.card {
  display: flex;
  background: var(--sumi-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.card-edge {
  width: 3px;
  flex: 0 0 3px;
  background: var(--sumi-3);
}
.card.live { border-color: #3a2530; }
.card.live .card-edge {
  background: var(--kurenai);
  animation: breathe 2.6s ease-in-out infinite;
}
.card.down .card-edge { background: var(--kin); }
.card.paused { opacity: .55; }
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}

.card-main { flex: 1; min-width: 0; padding: 15px 17px; }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-id { min-width: 0; }
.card-label {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-platform {
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}
.status {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--faint);
}
.status.live { color: var(--kurenai); }
.status.down { color: var(--kin); }

.card-title {
  margin: 7px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Signatur: der Wachpuls */
.pulse {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
  margin: 13px 0 12px;
}
.pulse i {
  flex: 1;
  min-width: 1px;
  border-radius: 1px;
  background: var(--sumi-3);
  height: 4px;
  transition: height .2s ease, background .2s ease;
}
.pulse i.on  { height: 100%; background: var(--kurenai); }
.pulse i.off { height: 5px;  background: #313648; }
.pulse i.err { height: 11px; background: var(--kin); }
.pulse i.gap { background: transparent; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--faint);
}
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty {
  border: 1px dashed var(--line);
  padding: 42px 20px;
  text-align: center;
  color: var(--faint);
}
.empty-mark {
  display: block;
  font-size: 34px;
  font-weight: 900;
  color: var(--sumi-3);
  margin-bottom: 10px;
}
.empty p { margin: 0; font-size: 14px; }

/* ---------- Protokoll ---------- */
.log-section { margin-top: 44px; }
.log {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.log li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--sumi-2);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.log time { color: var(--faint); flex: 0 0 auto; }
.log .kind { flex: 0 0 68px; letter-spacing: .1em; text-transform: uppercase; font-size: 10.5px; }
.log .kind.online { color: var(--kurenai); }
.log .kind.offline { color: var(--ai); }
.log .kind.error { color: var(--kin); }
.log .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 130%);
  background: var(--sumi-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--kurenai);
  color: var(--text);
  padding: 12px 18px;
  font-size: 13.5px;
  max-width: min(460px, calc(100vw - 32px));
  z-index: 50;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.toast.show { transform: translate(-50%, 0); }
.toast.bad { border-left-color: var(--kin); }

/* ---------- Handy ---------- */
@media (max-width: 620px) {
  .add-row { flex-direction: column; }
  .add-row button { width: 100%; padding: 13px; }
  .kanji { font-size: 24px; }
  .brand h1 { font-size: 17px; }
  .watch { width: 100%; justify-content: flex-start; }
  .push-actions button { flex: 1; }
  .card-foot { align-items: flex-start; }
  .log .kind { flex-basis: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: .01ms !important; }
}

/* ---------- Anmeldung ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--sumi);
  overflow-y: auto;
}
.gate-box {
  width: min(400px, 100%);
  background: var(--sumi-2);
  border: 1px solid var(--line);
  padding: clamp(22px, 5vw, 34px);
}
.gate-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.gate-brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.gate-brand p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}
.gate-fehler {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 2px solid var(--kurenai);
  background: rgba(226, 62, 82, .07);
  color: var(--text);
  font-size: 13.5px;
}
.gate-fuss {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}
.gate code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--sumi);
  padding: 2px 5px;
}

.feld {
  display: block;
  margin-bottom: 14px;
}
.feld span {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 14px;
}
.check input { width: auto; }

.block { width: 100%; }
.abstand { margin-top: 28px; }

/* ---------- Kopfzeile mit Konto ---------- */
.top-rechts {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.konto {
  display: flex;
  align-items: center;
  gap: 10px;
}
.konto-name {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Fenster ---------- */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 8, 12, .82);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.dialog-box {
  width: min(480px, 100%);
  background: var(--sumi-2);
  border: 1px solid var(--line);
  padding: clamp(20px, 4vw, 28px);
  margin: auto;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.dialog-head .eyebrow { margin: 0; }
.konto-info {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.dialog h3.eyebrow { margin-bottom: 12px; }

.user-liste {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.user-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  background: var(--sumi);
  border: 1px solid var(--line);
  font-size: 13px;
}
.user-zeile .wer { min-width: 0; }
.user-zeile .mail {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-zeile .rolle {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}
.user-zeile .rolle.admin { color: var(--kurenai); }
.user-zeile .tasten { display: flex; gap: 5px; flex-shrink: 0; }

.card.muted { opacity: .6; }
.card.muted .card-edge { background: var(--sumi-3) !important; animation: none; }

@media (max-width: 620px) {
  .top-rechts { width: 100%; justify-content: space-between; }
}
