/* Minixley Dashboard — weiss, minimalistisch, klinisch klar.
   Vorbild: ChatGPT-App. Monochrome Flaechen, Farbakzente nur fuer
   Zustaende (laeuft/fertig/fehlgeschlagen), Icons als Strichzeichnung. */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --bg-hover: #ececec;
  --line: #e4e4e7;
  --txt: #0d0d0d;
  --txt-dim: #6b6b70;
  --txt-faint: #a1a1aa;
  --ink: #0d0d0d;           /* Buttons/Marke: schwarz auf weiss */
  --ok: #059669;
  --run: #d97706;
  --err: #dc2626;
  --radius: 14px;
  --sidebar-w: 288px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor;
      stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Marke ---------- */
.brand-mark {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--ink); color: #fff;
  font: 600 24px/52px -apple-system, sans-serif;
  text-align: center; margin: 0 auto;
}
.brand-mark.small {
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 13px; line-height: 24px; display: inline-block;
  vertical-align: -5px; margin-right: 6px;
}
.brand-mark.big { width: 60px; height: 60px; font-size: 28px; line-height: 60px; }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; display: flex; align-items: center;
  justify-content: center; background: var(--bg); padding: 24px;
}
.login-card { width: 100%; max-width: 330px; text-align: center; }
.login-card h1 { font-size: 26px; font-weight: 700; margin: 14px 0 6px; letter-spacing: -.3px; }
.login-card p { color: var(--txt-dim); margin-bottom: 18px; }
.login-card input {
  width: 100%; padding: 13px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg); color: var(--txt);
  font: inherit; margin-bottom: 12px; outline: none; text-align: center;
}
.login-card input:focus { border-color: var(--ink); }
.btn.primary {
  width: 100%; padding: 13px; border-radius: var(--radius);
  background: var(--ink); color: #fff; font-weight: 600;
}
.login-error { color: var(--err); margin-top: 14px; }

/* ---------- Shell ---------- */
.shell { display: flex; height: 100dvh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px 10px;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
#sidebar-close { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 10px; padding: 10px 12px; text-align: left;
  border-radius: 10px; font-weight: 500;
}
.nav-item:hover, .nav-item.active { background: var(--bg-hover); }
.nav-item .ic { width: 18px; height: 18px; }

.section-label {
  padding: 16px 20px 6px; font-size: 11px; font-weight: 600;
  letter-spacing: .7px; text-transform: uppercase; color: var(--txt-faint);
}
.task-list { flex: 1; overflow-y: auto; padding: 0 10px; }
.task-item {
  width: 100%; text-align: left; padding: 9px 10px;
  border-radius: 10px; display: flex; gap: 10px; align-items: center;
}
.task-item:hover, .task-item.active { background: var(--bg-hover); }
.task-item-title {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 13.5px;
}
.task-item-time { flex: none; font-size: 11px; color: var(--txt-faint); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none;
       display: inline-block; background: var(--txt-faint); }
.dot.running   { background: var(--run); animation: pulse 1.6s ease-in-out infinite; }
.dot.completed { background: var(--ok); }
.dot.failed    { background: var(--err); }
.dot.ok        { background: var(--ok); }
@keyframes pulse { 50% { opacity: .3; } }

.sidebar-foot {
  padding: 12px 20px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--txt-dim);
}
.link-btn { margin-left: auto; color: var(--txt-faint); font-size: 12px; }
.link-btn:hover { color: var(--txt); }

/* ---------- Hauptbereich ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid var(--line);
}
.icon-btn { color: var(--txt-dim); padding: 8px; border-radius: 10px;
            display: inline-flex; }
.icon-btn:hover { background: var(--bg-hover); color: var(--txt); }
#menu-btn { display: none; }
.title { font-weight: 600; font-size: 15px;
         white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-state { margin-left: auto; font-size: 12px; color: var(--txt-dim); flex: none; }

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- Startseite / Bedienfeld ---------- */
.home-pane {
  flex: 1; overflow-y: auto; width: 100%; max-width: 920px;
  margin: 0 auto; padding: 42px 24px calc(36px + env(safe-area-inset-bottom));
}
.home-intro { margin-bottom: 32px; }
.home-kicker {
  color: var(--txt-faint); font-size: 11px; font-weight: 650;
  letter-spacing: 1.1px; text-transform: uppercase;
}
.home-intro h1 {
  margin-top: 7px; font-size: clamp(28px, 5vw, 40px); line-height: 1.15;
  letter-spacing: -.8px;
}
.home-intro p { margin-top: 8px; color: var(--txt-dim); font-size: 15px; }
.home-status {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 38px;
}
.home-status-card {
  min-height: 116px; padding: 16px; border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column;
  gap: 7px; background: var(--bg);
}
.home-status-card strong { display: flex; align-items: center; gap: 7px; font-size: 15px; }
.home-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.home-section-head h2 { font-size: 17px; letter-spacing: -.2px; }
.home-section-head span { color: var(--txt-faint); font-size: 12px; }
.home-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.home-action {
  min-height: 76px; width: 100%; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; align-items: center; gap: 13px; text-align: left;
  background: var(--bg); transition: background .15s ease, border-color .15s ease;
}
.home-action:hover { background: var(--bg-soft); border-color: #d4d4d8; }
.home-action > .ic:first-child { width: 22px; height: 22px; color: var(--txt-dim); flex: none; }
.home-action > span { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.home-action strong { font-size: 15px; }
.home-action small { margin-top: 2px; color: var(--txt-dim); font-size: 12.5px; }
.home-action .chevron { width: 17px; height: 17px; color: var(--txt-faint); flex: none; }
@media (max-width: 780px) {
  .home-status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .home-pane { padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); }
  .home-intro { margin-bottom: 24px; }
  .home-status { gap: 9px; margin-bottom: 30px; }
  .home-status-card { min-height: 108px; padding: 14px; }
  .home-actions { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Chat ---------- */
.chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat-empty { text-align: center; padding: 72px 32px 24px; }
.chat-empty h2 { font-size: 22px; font-weight: 700; margin-top: 18px; letter-spacing: -.3px; }

.chat-log { max-width: 720px; margin: 0 auto; padding: 20px 16px 8px; }
.msg { margin-bottom: 16px; display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 18px;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .bubble { background: var(--bg-soft); border-bottom-right-radius: 6px; }
.msg.ai .bubble { padding-left: 0; }   /* KI-Antworten wie ChatGPT: frei stehend */

/* Denk-Animation: weicher, atmender Punkt wie in der ChatGPT-App */
.thinking {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink); display: inline-block;
  animation: breathe 1.1s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(.65); opacity: .35; }
  50%       { transform: scale(1);   opacity: 1; }
}

.task-chip {
  display: inline-block; margin-top: 8px; padding: 5px 12px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--txt);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.task-chip:hover { border-color: var(--ink); }

/* ---------- Eingabezeile ---------- */
.composer-wrap {
  max-width: 720px; width: 100%; margin: 0 auto;
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom));
}
.speech-status { font-size: 12.5px; color: var(--txt-dim); padding: 0 8px 6px; }
.speech-status.error { color: var(--err); }
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  border: 1px solid var(--line); border-radius: 26px;
  padding: 8px 8px 8px 16px; background: var(--bg);
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
}
.composer:focus-within { border-color: #c8c8cd; }
.composer textarea {
  flex: 1; resize: none; max-height: 140px; border: none; outline: none;
  background: none; color: var(--txt); font: inherit; padding: 8px 0;
}
.round-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--txt-dim); border: 1px solid transparent;
}
.round-btn:hover { background: var(--bg-hover); color: var(--txt); }
.round-btn.solid { background: var(--ink); color: #fff; }
.round-btn.solid:hover { background: #2d2d2d; color: #fff; }
.round-btn.solid:disabled { opacity: .25; }
.round-btn.recording { background: var(--ink); color: #fff; animation: pulse 1.4s infinite; }
label.round-btn { cursor: pointer; }

/* Aufnahme-Wellenform: fuenf Balken, live vom Mikrofonpegel getrieben */
.wave { display: flex; align-items: center; gap: 3px; height: 40px; padding: 0 4px; }
.wave span {
  width: 4px; height: 8px; border-radius: 2px; background: var(--ink);
  transition: height .08s linear;
}

/* ---------- Aufgaben-Detail ---------- */
.task-detail {
  flex: 1; overflow-y: auto; max-width: 720px; width: 100%;
  margin: 0 auto; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.detail-state {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.detail-title { font-size: 21px; font-weight: 700; letter-spacing: -.3px; margin: 14px 0 6px; }
.detail-meta { color: var(--txt-faint); font-size: 13px; margin-bottom: 20px; }
.detail-block { margin-bottom: 20px; }
.detail-block h3 {
  font-size: 11px; font-weight: 600; letter-spacing: .7px;
  text-transform: uppercase; color: var(--txt-faint); margin-bottom: 8px;
}
.detail-block .card {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  white-space: pre-wrap; word-wrap: break-word;
}
.detail-block .card.error { border-color: #fecaca; color: var(--err); background: #fef2f2; }
.detail-actions { display: flex; gap: 10px; margin-top: 26px; }
.btn.secondary {
  padding: 11px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg); font-weight: 600;
}
.btn.secondary:hover { border-color: var(--ink); }
.btn.primary.inline { width: auto; padding: 11px 18px; }

/* ---------- Dateien ---------- */
.files-pane {
  flex: 1; overflow-y: auto; max-width: 720px; width: 100%;
  margin: 0 auto; padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.files-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.crumbs { flex: 1; display: flex; align-items: center; flex-wrap: wrap;
          gap: 2px; font-size: 13.5px; color: var(--txt-dim); min-width: 0; }
.crumbs button { padding: 4px 6px; border-radius: 8px; font-weight: 500; }
.crumbs button:hover { background: var(--bg-hover); color: var(--txt); }
.crumbs .ic { width: 14px; height: 14px; color: var(--txt-faint); }
.files-list { flex: none; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 10px; border-radius: 12px; cursor: default;
}
.file-row:hover { background: var(--bg-soft); }
.file-row .ic { width: 19px; height: 19px; color: var(--txt-dim); flex: none; }
.file-row.is-dir { cursor: pointer; }
.file-name { flex: 1; min-width: 0; white-space: nowrap;
             overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.file-size { flex: none; font-size: 12px; color: var(--txt-faint); }
.file-act { flex: none; display: flex; gap: 2px; }
.file-act button { padding: 7px; border-radius: 9px; color: var(--txt-faint);
                   display: inline-flex; }
.file-act button:hover { background: var(--bg-hover); color: var(--txt); }
.file-act .del:hover { color: var(--err); }
.files-hint { font-size: 12px; color: var(--txt-faint); margin-top: 14px; }
.files-empty { color: var(--txt-faint); text-align: center; padding: 36px 0; }

/* ---------- Mobil ---------- */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 8; }
@media (max-width: 760px) {
  .sidebar {
    position: fixed; z-index: 9; inset: 0 auto 0 0; height: 100dvh;
    transform: translateX(-105%); transition: transform .22s ease;
    width: min(84vw, var(--sidebar-w));
    box-shadow: 8px 0 28px rgba(0,0,0,.12);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; }
  #menu-btn, #sidebar-close { display: inline-flex; }
}

/* ---------- Marke: echtes K-Logo ---------- */
.brand-logo {
  display: block; margin: 0 auto; border-radius: 22%;
  object-fit: contain;
}
.brand-logo.small {
  display: inline-block; width: 24px; height: 24px;
  vertical-align: -6px; margin: 0 7px 0 0; border-radius: 6px;
}
.brand-logo.big { width: 72px; height: 72px; border-radius: 20px; }
.tagline {
  font-size: 11px; letter-spacing: 2.4px; text-transform: uppercase;
  color: var(--txt-faint); margin: 4px 0 16px !important;
}

/* ---------- iPhone: kein Auto-Zoom, kein seitliches Wandern ----------
   iOS Safari zoomt beim Antippen automatisch hinein, sobald ein
   Eingabefeld eine Schrift KLEINER als 16px hat — und zoomt danach nicht
   zurueck. Deshalb hier ausdruecklich 16px auf allen Eingaben; das ist
   der eigentliche Fix, nicht user-scalable=no (das wuerde auch das
   absichtliche Vergroessern verbieten).
   Dazu waagerecht dichtmachen, damit sich die Seite wie eine App anfuehlt
   und nicht seitlich verschieben laesst. */
textarea, input, select { font-size: 16px !important; }
html, body { max-width: 100%; overflow-x: hidden; }
.shell, .main, .view, .chat-log, .composer-wrap, .files-pane, .task-detail {
  max-width: 100%;
}
.bubble, .file-name, .detail-block .card { overflow-wrap: anywhere; }

/* Aufraeum-Knopf neben der Abschnittsueberschrift */
.section-label { display: flex; align-items: center; justify-content: space-between; }
.label-btn { color: var(--txt-faint); padding: 2px 4px; border-radius: 6px;
             display: inline-flex; }
.label-btn:hover { color: var(--err); background: var(--bg-hover); }
.label-btn .ic { width: 15px; height: 15px; }
.btn.secondary.danger:hover { border-color: var(--err); color: var(--err); }
.btn.secondary:disabled { opacity: .35; }

/* ---------- Live-Verlauf einer laufenden Aufgabe ---------- */
.live-list {
  max-height: 300px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-soft); padding: 8px 4px;
}
.live-row { display: flex; gap: 10px; align-items: baseline; padding: 5px 10px; }
.live-dot {
  flex: none; width: 6px; height: 6px; border-radius: 50%;
  background: var(--run); margin-top: 6px;
}
.live-row.thought .live-dot { background: var(--txt-faint); }
.live-text { font-size: 13.5px; color: var(--txt); overflow-wrap: anywhere; }
.live-row.thought .live-text { color: var(--txt-dim); font-style: italic; }
.live-row:last-child .live-dot { animation: pulse 1.4s infinite; }

/* ---------- M5 Einstellungen ----------
   Vorher stand alles gleich laut in einer langen Liste. Jetzt: benannte
   Abschnitte, ruhige Abstaende, und was selten gebraucht wird (eigenes
   Sprachmodell, Server-Zugang) liegt eingeklappt darunter. */
.automation-pane { flex: 1; overflow-y: auto; max-width: 860px; width: 100%; margin: 0 auto; padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); }
.automation-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.status-card { display: flex; flex-direction: column; gap: 5px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.status-card strong { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.status-label { color: var(--txt-faint); font-size: 11px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase; }
.status-meta { color: var(--txt-dim); font-size: 12.5px; }
.status-meta.dirty { color: var(--run); font-weight: 600; }

/* Abschnitte: eine Ueberschrift, ein Satz dazu, dann die Felder. */
.m5-block { margin: 0 0 30px; }
.m5-block > h3, .klapp-titel {
  font-size: 15.5px; font-weight: 650; letter-spacing: -.2px;
  color: var(--txt); margin: 0 0 4px;
}
.m5-erklaerung {
  color: var(--txt-dim); font-size: 12.5px; line-height: 1.5;
  margin: 0 0 12px; max-width: 64ch;
}
.m5-block .card {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
/* Eingeklappt: das selten Gebrauchte bleibt erreichbar, ohne mitzuschreien. */
details.m5-block { border: 1px solid var(--line); border-radius: var(--radius);
                   padding: 14px 16px; background: var(--bg); }
details.m5-block > summary {
  cursor: pointer; list-style: none; display: flex; flex-wrap: wrap;
  align-items: baseline; gap: 4px 10px; min-height: 30px;
}
details.m5-block > summary::-webkit-details-marker { display: none; }
details.m5-block > summary::after {
  content: "einblenden"; margin-left: auto; color: var(--txt-faint);
  font-size: 12px; font-weight: 600;
}
details.m5-block[open] > summary::after { content: "ausblenden"; }
details.m5-block[open] > summary { margin-bottom: 12px; }
details.m5-block .card { background: var(--bg-soft); }
.klapp-hinweis { color: var(--txt-faint); font-size: 12px; }
.klapp-hinweis.warnung { color: #92400e; font-weight: 600; }
details.m5-block.heikel { border-color: #fde68a; background: #fffdf6; }
details.m5-block.heikel .card { background: #fff; border-color: #fde68a; }
.m5-block details.m5-block { margin-top: 18px; margin-bottom: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; white-space: normal !important; }
/* Seitliches Scrollen: ein Rasterfeld ist von Haus aus min-width:auto, also
   mindestens so breit wie sein laengstes untrennbares Wort. Am 10.08.2026
   liess sich "M5 Einstellungen" und "Launcher" darum seitlich schieben,
   "Dateien" nicht — dort ist die Spalte flex mit min-width:0 und die
   Dateinamen kuerzen mit Ellipse. Drei Regeln halten das zusammen:
   minmax(0, 1fr) statt 1fr, min-width:0 auf den Flex-Spalten, und lange
   Werte brechen um. Das overflow-x unten ist nur noch der Fangzaun. */
.feld-hilfe, .feld-jetzt, .m5-erklaerung { overflow-wrap: anywhere; }
.automation-pane, .launcher-pane, .home-pane, .files-pane { overflow-x: hidden; }
.form-grid label { display: flex; flex-direction: column; min-width: 0; gap: 6px; color: var(--txt-dim); font-size: 12.5px; font-weight: 500; }
.form-grid input:not([type="checkbox"]), .form-grid select, .form-grid textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: var(--bg); color: var(--txt); font: inherit; outline: none; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--ink); }
.form-grid textarea { resize: vertical; min-height: 100px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .toggle-row { flex-direction: row; align-items: center; gap: 9px; min-height: 42px; color: var(--txt); font-size: 14px; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--ink); }
/* Ein Satz unter jedem Feld, das sich nicht von selbst erklaert. */
.feld-hilfe { color: var(--txt-faint); font-size: 11.5px; font-weight: 400;
              line-height: 1.5; margin-top: -1px; }
/* Was gerade gilt — damit sichtbar ist, was man ueberschreibt. */
.feld-jetzt { color: var(--txt-dim); font-size: 11.5px; font-weight: 600; }
.feld-jetzt:empty { display: none; }
.automation-actions { position: sticky; bottom: -1px; display: flex; align-items: center; gap: 10px; padding: 14px 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
.automation-actions .status-meta { margin-right: auto; }
.automation-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.automation-actions .btn .ic { width: 17px; height: 17px; }
.automation-notice { margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: var(--bg-soft); border: 1px solid var(--line); font-size: 13px; }
.automation-notice.success { color: var(--ok); border-color: #a7f3d0; background: #ecfdf5; }
.automation-notice.warning { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.automation-notice.error { color: var(--err); border-color: #fecaca; background: #fef2f2; }
@media (max-width: 620px) {
  .automation-status-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .wide { grid-column: auto; }
  details.m5-block > summary::after { content: ""; }
  .automation-actions { flex-wrap: wrap; }
  .automation-actions .status-meta { flex-basis: 100%; }
}

/* ---------- Launcher-Reiter: Vorschau + Editor ----------
   Am Rechner nebeneinander, am Handy untereinander — die Vorschau oben,
   die Einstellungen darunter, damit man beim Tippen sieht, was passiert. */
.launcher-pane {
  flex: 1; overflow-y: auto; width: 100%;
  max-width: 980px; margin: 0 auto;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr);
  align-content: start;
}
@media (min-width: 900px) {
  .launcher-pane { grid-template-columns: 360px minmax(0, 1fr); align-items: start; }
  .preview-wrap { position: sticky; top: 12px; }
}

.preview-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.preview-titel { font-weight: 600; font-size: 13px; }
.preview-tools { margin-left: auto; display: flex; gap: 6px; }
.chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--txt);
}
.chip:hover { border-color: var(--ink); }
.chip.ghost { color: var(--txt-faint); pointer-events: none; }

/* Das Geraet
   ----------------------------------------------------------------
   WARUM ECHTE PIXEL: Die erste Fassung rechnete in Prozent und cqw.
   Damit verschob sich das Layout mit jeder Fensterbreite — auf dem
   iPhone sah die Vorschau nicht mehr aus wie der M5. Jetzt ist der
   Bildschirm exakt 320x240 CSS-Pixel gross, mit denselben Abstaenden
   wie device/main.py, und wird als Ganzes skaliert. Was hier steht,
   kann sich damit gar nicht mehr anders verhalten als das Geraet. */
.geraet { display: flex; flex-direction: column; align-items: center; }
.geraet-rand {
  background: #2b2b2e; padding: 10px 10px 14px; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.09);
  max-width: 100%;
}
.geraet-fuss {
  width: 62%; height: 9px; background: #17171a;
  border-radius: 0 0 9px 9px; display: flex; justify-content: center;
}
.geraet-fuss span { width: 34%; height: 3px; margin-top: 3px;
  background: #4a4a50; border-radius: 2px; }

.screen-scale {
  width: calc(320px * var(--z, 1)); height: calc(240px * var(--z, 1));
  max-width: 100%;
}
.screen {
  width: 320px; height: 240px; flex: none;
  transform: scale(var(--z, 1)); transform-origin: top left;
  position: relative; overflow: hidden; border-radius: 3px;
  background: #E8DCBE; color: #2A2519;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.screen.dark { background: #1E1B15; color: #EDE2C8; }

/* Kopfzeile: HEAD_H = 26 */
.screen-bar {
  position: absolute; inset: 0 0 auto 0; height: 26px;
  display: flex; align-items: center; gap: 6px; padding: 0 6px;
  background: #F2E6C9; border-bottom: 1px solid #9A8E72; font-size: 12px;
}
.screen.dark .screen-bar { background: #272319; border-color: #574F3F; }
.cube { width: 12px; height: 9px; border: 2px solid #2A2519;
        border-radius: 1px; flex: none; }
.screen.dark .cube { border-color: #4E4A40; }
.bar-titel { font-weight: 700; letter-spacing: .3px; }
.bar-mitte { margin: 0 auto; opacity: .7; }
.batt { width: 20px; height: 10px; border: 1.5px solid currentColor;
        border-radius: 2px; padding: 1px; flex: none; }
.batt i { display: block; height: 100%; width: 70%; background: #839B4B; }

/* Kacheln: GAP 6, TILE_W 151, TILE_H 77, ab y = 32 */
.tiles { position: absolute; inset: 26px 0 42px 0; }
.tile {
  position: absolute; width: 151px; height: 77px;
  background: #F7EDD6; border: 1px solid #9A8E72; border-radius: 6px;
  box-shadow: 2px 2px 0 #C0B08C;
}
.screen.dark .tile { background: #2B2720; border-color: #574F3F;
                     box-shadow: 2px 2px 0 #100E0A; }
.tile.leer { background: none; border: 1px dashed #C0B08C; box-shadow: none; }
/* Icon sitzt auf (x+10, y+16) und ist 44 Pixel breit — wie im Launcher */
.tile .ic { position: absolute; left: 4px; top: 10px; width: 52px; height: 54px; }
.tile span {
  position: absolute; left: 56px; top: 20px; right: 4px;
  font-size: 12px; font-weight: 700; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden;
}
.tile .balken { position: absolute; right: 6px; bottom: 6px;
                display: flex; align-items: flex-end; gap: 2px; height: 10px; }
.tile .balken i { width: 4px; border-radius: 1px; display: block; }

/* Fusszeile: FOOT_Y = 198, drei Drittel */
.screen-foot {
  position: absolute; left: 0; right: 0; top: 198px; height: 36px;
  display: flex; gap: 12px; padding: 0 6px;
}
.fkey {
  flex: 1; background: #DCCFB0; border: 1px solid #9A8E72; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; box-shadow: 2px 2px 0 #C0B08C;
}
.fkey.mid { color: #8A7F66; }
.fkey.aus { visibility: hidden; }
.screen.dark .fkey { background: #231F19; border-color: #574F3F;
                     box-shadow: 2px 2px 0 #100E0A; }

/* Editor */
.editor-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.editor-head h3 { font-size: 15px; }
.editor-status { font-size: 12px; color: var(--txt-faint); margin-left: auto; }
.app-list { display: flex; flex-direction: column; gap: 8px; }
.app-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.app-row.aus { opacity: .45; }
.app-row .griff { display: flex; flex-direction: column; gap: 2px; flex: none; }
.app-row .griff button {
  width: 26px; height: 20px; border: 1px solid var(--line); border-radius: 5px;
  font-size: 11px; line-height: 1; color: var(--txt-dim);
}
.app-row .griff button:hover { border-color: var(--ink); color: var(--txt); }
.app-row input[type="text"] {
  flex: 1; min-width: 0; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--txt);
  font: inherit; outline: none;
}
.app-row input:focus { border-color: var(--ink); }
.app-row .datei { font-size: 11px; color: var(--txt-faint); flex: none; }
.icon-pick { position: relative; flex: none; }
.icon-pick > button {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-pick > button:hover { border-color: var(--ink); }
.icon-menu {
  position: absolute; right: 0; top: 44px; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 40px); gap: 4px; padding: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.14);
}
.icon-menu button {
  width: 40px; height: 40px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-menu button:hover, .icon-menu button.aktiv { background: var(--bg-hover); }
.augen { flex: none; padding: 8px; border-radius: 8px; color: var(--txt-faint); }
.augen:hover { background: var(--bg-hover); color: var(--txt); }
.editor-actions { display: flex; gap: 10px; margin-top: 14px; }

/* ---------- Ball-Spuren ----------
   Eigene Seiten statt einer langen: jede Seite fuellt den Bereich, die
   Adresse sagt welche. Die Zeilenregel ist dieselbe wie am Geraet — die
   Nebenangabe steht RECHTS, nicht darunter; darum min-width:0 auf dem
   Titel, sonst schiebt ein langer Name die Angabe aus dem Bild. */
.spiel-pane {
  flex: 1; overflow-y: auto; overflow-x: hidden; width: 100%;
  max-width: 720px; margin: 0 auto;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
}

.spiel-leiste { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.spiel-abschnitt { margin: 16px 0 6px; font-size: 12.5px; font-weight: 600;
  color: var(--txt-dim); }
.spiel-koordinate { padding: 10px 13px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 13px; overflow-wrap: anywhere; }
.spiel-meldung { padding: 10px 13px; border-radius: 12px; font-size: 13px;
  border: 1px solid var(--line); overflow-wrap: anywhere; }
.spiel-meldung.schlecht { border-color: var(--warn, #d4795f);
  color: var(--warn, #d4795f); }
.spiel-leer { color: var(--txt-dim); font-size: 13.5px; line-height: 1.5; }
.spiel-fussnote { margin-top: 6px; font-size: 11.5px; color: var(--txt-faint);
  overflow-wrap: anywhere; }
.spiel-stand:empty { display: none; }

/* ---------- Ball-Spuren: eigene Optik, weil es ein Spiel ist ----------
   Der Rest des Dashboards ist Werkzeug: schwarz auf weiss, sachlich. Ein
   Spiel darf anders aussehen — Kacheln statt Zeilen, Farbe je Typ, eine
   Karte. Die Farben stehen HIER als Variablen und nicht in spiel.js: eine
   Anzeige, die sich ihre eigenen Farben ausdenkt, ist der Anfang einer
   zweiten Optik (dieselbe Regel wie am Geraet in theme.py). */
:root {
  --typ-wald: #2f7d55;
  --typ-licht: #c98a17;
  --typ-klang: #7c5cd6;
  --typ-wasser: #2b6fb5;
  --typ-stein: #7a6a58;
  --typ-wind: #2a9aa5;
  --spiel-flaeche: #fbfaf8;
}
.spiel-pane { background: var(--spiel-flaeche); }

/* Kopf einer Seite: Titel links, Menue rechts — dieselbe Regel wie am
   Geraet, die Nebenangabe steht neben der Sache, nicht darunter. */
.spiel-topbar { display: flex; align-items: center; gap: 10px;
  margin: 2px 0 16px; }
.spiel-kopf { font-size: 21px; margin: 0; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spiel-zurueck { flex: none; width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--txt);
  font-size: 17px; line-height: 1; cursor: pointer; }
.spiel-zurueck:hover { border-color: var(--ink); }

/* --- Kacheln --- */
.spiel-kacheln { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px; }
.spiel-kachel-gross {
  position: relative; overflow: hidden; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 18px; background: var(--bg);
  padding: 16px 15px 15px; min-height: 118px; color: var(--txt);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 3px;
  font: inherit; transition: transform .12s ease, border-color .12s ease;
}
.spiel-kachel-gross:hover { border-color: var(--ink); transform: translateY(-2px); }
.spiel-kachel-gross .zahl { font-size: 30px; font-weight: 600; line-height: 1; }
.spiel-kachel-gross .was { font-size: 13.5px; font-weight: 500; }
.spiel-kachel-gross .dazu { font-size: 11.5px; color: var(--txt-dim); }
.spiel-kachel-gross .band { position: absolute; inset: 0 0 auto 0; height: 5px;
  background: var(--akzent, var(--ink)); }

/* --- Ballkacheln --- */
.spiel-raster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; margin-top: 4px; }
.spiel-ball {
  position: relative; overflow: hidden; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 16px; background: var(--bg);
  padding: 14px 13px 12px; color: var(--txt); font: inherit;
  display: flex; flex-direction: column; gap: 4px;
  transition: transform .12s ease, border-color .12s ease;
}
.spiel-ball:hover { border-color: var(--ink); transform: translateY(-2px); }
.spiel-ball .marke { width: 30px; height: 30px; border-radius: 50%;
  background: var(--akzent); opacity: .18; position: absolute;
  top: 11px; right: 11px; }
.spiel-ball .punkt { width: 9px; height: 9px; border-radius: 50%;
  background: var(--akzent); position: absolute; top: 21px; right: 21px; }
.spiel-ball .name { font-weight: 600; font-size: 14.5px; padding-right: 34px;
  overflow-wrap: anywhere; }
.spiel-ball .art { font-size: 11.5px; color: var(--akzent); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; }
.spiel-ball .ort { font-size: 11.5px; color: var(--txt-dim);
  overflow-wrap: anywhere; }
.sterne { display: flex; gap: 3px; margin-top: 2px; }
.sterne i { width: 7px; height: 7px; border-radius: 50%;
  background: var(--line); }
.sterne i.an { background: var(--akzent); }

/* --- Steckbrief --- */
.spiel-held { border-radius: 18px; padding: 20px 18px; color: #fff;
  background: var(--akzent); margin-bottom: 14px; }
.spiel-held h3 { margin: 0 0 4px; font-size: 22px; overflow-wrap: anywhere; }
.spiel-held .unter { font-size: 13px; opacity: .9; }
.spiel-held .sterne i { background: rgba(255,255,255,.35); }
.spiel-held .sterne i.an { background: #fff; }
.spiel-werte { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px; margin-bottom: 14px; }
.spiel-wert { border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 12px; background: var(--bg); }
.spiel-wert strong { display: block; font-size: 15px; overflow-wrap: anywhere; }
.spiel-wert span { font-size: 11px; color: var(--txt-dim); }

/* --- Menue im Menue --- */
.spiel-menue { position: relative; flex: none; }
.spiel-menue-liste { position: absolute; right: 0; top: 38px; z-index: 30;
  min-width: 194px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.13); }
.spiel-menue-liste button { display: block; width: 100%; text-align: left;
  padding: 10px 12px; border: 0; border-radius: 10px; background: none;
  color: var(--txt); font: inherit; cursor: pointer; }
.spiel-menue-liste button:hover { background: var(--bg-soft); }
.spiel-menue-liste button.gefahr { color: var(--err); }
.spiel-menue-liste hr { border: 0; border-top: 1px solid var(--line);
  margin: 5px 4px; }

/* --- Karte --- */
.spiel-karte { border: 1px solid var(--line); border-radius: 18px;
  background: var(--bg); overflow: hidden; }
.spiel-karte svg { display: block; width: 100%; height: auto; }
.spiel-karte-fuss { display: flex; gap: 14px; flex-wrap: wrap;
  padding: 11px 14px; border-top: 1px solid var(--line); font-size: 12px;
  color: var(--txt-dim); }

/* Die Farbe kommt aus data-typ, nicht aus dem Skript. */
[data-typ="wald"]   { --akzent: var(--typ-wald); }
[data-typ="licht"]  { --akzent: var(--typ-licht); }
[data-typ="klang"]  { --akzent: var(--typ-klang); }
[data-typ="wasser"] { --akzent: var(--typ-wasser); }
[data-typ="stein"]  { --akzent: var(--typ-stein); }
[data-typ="wind"]   { --akzent: var(--typ-wind); }
