:root {
  color-scheme: dark;
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1c1f28;
  --panel-hover: #23262f;
  --surface-sunken: #0b0c10;
  --input-bg: rgba(255,255,255,0.03);
  --border: #262a35;
  --text: #e7e9ee;
  --muted: #8a8f9c;
  --accent: #4f8cff;
  --green: #35c98f;
  --red: #ef5563;
  --yellow: #f0b429;
  --shadow-color: rgba(0,0,0,0.4);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f1f4;
  --panel-hover: #e6e8ec;
  --surface-sunken: #eceef2;
  --input-bg: #ffffff;
  --border: #dde0e6;
  --text: #1b1d22;
  --muted: #6b7280;
  --accent: #3568d4;
  --green: #1f9d6e;
  --red: #d63b4a;
  --yellow: #b8860b;
  --shadow-color: rgba(20,22,30,0.10);
}

* { box-sizing: border-box; }

/* Garantiert, dass das hidden-Attribut IMMER greift, egal welche display-Regel
   eine Komponente sonst für sich definiert (z. B. .notif-panel { display: flex }
   würde das Browser-Standardverhalten für [hidden] sonst überschreiben). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-feature-settings: "tnum";
}

.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 14px;
}
.brand-icon { font-size: 19px; }
.brand-title { font-weight: 700; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  color: var(--muted);
  cursor: default;
  font-size: 13px;
}
.nav-item.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.nav-item.disabled { opacity: 0.45; }

.engine-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  margin-top: 10px;
  flex-shrink: 0;
}
.engine-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 9px;
}
.engine-version-block { margin-bottom: 9px; }
.engine-version-block:last-child { margin-bottom: 0; }
.engine-version-label { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; margin-bottom: 5px; }
.engine-version-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.pill-on { background: rgba(53,201,143,0.15); color: var(--green); }
.pill-off { background: rgba(138,143,156,0.15); color: var(--muted); }
.pill-warn { background: rgba(240,180,41,0.15); color: var(--yellow); }
.version-status-group { display: flex; align-items: center; gap: 6px; }
.icon-btn-tiny {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 2px; line-height: 1; border-radius: 4px;
  transition: color .15s, transform .15s;
}
.icon-btn-tiny:hover { color: var(--text); }
.icon-btn-tiny.spinning { animation: icon-btn-spin 0.6s linear; }
@keyframes icon-btn-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.sidebar-footer-version { font-size: 10px; color: var(--muted); margin-bottom: 8px; }

.btn {
  display: block;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { filter: brightness(1.1); }

.accounts-list { flex: 1; overflow-y: auto; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 6px 4px;
  margin-top: 8px;
}
.sidebar-footer-text {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 8px;
}
.sidebar-footer-text a { color: var(--muted); text-decoration: underline; }
.sidebar-footer-text a:hover { color: var(--text); }
.sidebar-footer-kofi {
  display: block;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #ff5f5f;
  border-radius: var(--radius-md);
  padding: 7px 10px;
  text-decoration: none;
}
.sidebar-footer-kofi:hover { filter: brightness(1.08); }
.sidebar-footer-github {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #24292e;
  border: 1px solid #3d4247;
  border-radius: var(--radius-md);
  padding: 7px 10px;
  text-decoration: none;
  margin-top: 6px;
}
.sidebar-footer-github svg { width: 14px; height: 14px; fill: #fff; flex-shrink: 0; }
.sidebar-footer-github:hover { filter: brightness(1.25); }
.accounts-list-title {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 6px 8px;
}
.account-item {
  padding: 7px 9px;
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  cursor: pointer;
}
.account-item:hover { background: var(--panel-2); }
.account-item.selected { background: var(--panel-2); }
.account-item-name-row { display: flex; align-items: center; gap: 6px; }
.account-item-name { font-weight: 600; font-size: 13px; }
.account-item-sub { font-size: 11px; color: var(--muted); margin-left: 14px; }
.account-item-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.account-item-dot.active { background: var(--green); box-shadow: 0 0 5px var(--green); }

.account-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  cursor: pointer;
}
.account-group-header:hover { background: var(--panel-2); }
.account-group-chevron {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.account-group-header.expanded .account-group-chevron { transform: rotate(90deg); }
.account-group-name { font-weight: 600; font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-group-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}
.account-group-badge.active { color: var(--green); background: color-mix(in srgb, var(--green) 16%, transparent); }
.account-group-body {
  padding-left: 14px;
  border-left: 1px solid var(--border);
  margin: 0 0 4px 12px;
}
.account-group-body .account-item { padding: 6px 9px; }

.content {
  flex: 1;
  padding: 16px 20px;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  box-sizing: border-box;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.account-select { position: relative; }
.account-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  min-width: 180px;
  text-align: left;
}
.account-dropdown-btn:hover { background: var(--panel-hover); }
.account-dropdown-caret { margin-left: auto; color: var(--muted); font-size: 11px; }
.account-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  z-index: 20;
  box-shadow: 0 8px 24px var(--shadow-color);
}
.account-dropdown-option {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}
.account-dropdown-option:hover { background: var(--panel); }
.account-dropdown-option.selected { background: var(--panel); font-weight: 600; }
.status-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12px;
  color: var(--muted);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--panel-hover); }
.topbar-icon { width: 16px; height: 16px; flex-shrink: 0; }
.lang-toggle-btn {
  width: auto;
  padding: 0 8px;
  font-weight: 700;
  font-size: 11px;
}

.page-title { font-size: 18px; margin: 0 0 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-bottom: 10px;
  min-width: 0;
  box-shadow: 0 1px 2px var(--shadow-color);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  margin-bottom: 10px;
}
.muted { color: var(--muted); font-weight: 400; font-size: 12px; }

.accounts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.accounts-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.03em;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.accounts-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}
.accounts-table tr:last-child td { border-bottom: none; }
.acc-name { font-weight: 600; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.stat-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}
.stat-value { font-size: 19px; font-weight: 700; }

.activity-log {
  font-family: "Consolas", "SF Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.6;
}
.activity-log .line { color: var(--text); opacity: 0.85; border-bottom: 1px solid var(--border); padding: 4px 0; }

.sidebar-toggle-btn { display: none; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.settings-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.settings-panel-backdrop.visible { opacity: 1; pointer-events: auto; }

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 100;
  transform: translateX(100%);
  transition: transform .2s ease;
  box-shadow: -10px 0 30px var(--shadow-color);
  display: flex;
  flex-direction: column;
}
.settings-panel.open { transform: translateX(0); }

.settings-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 0 16px; border-bottom: 1px solid var(--border);
}
.settings-panel-tabs { display: flex; gap: 4px; }
.settings-panel-tab {
  background: none; border: none; padding: 10px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600;
}
.settings-panel-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.settings-panel-close-btn {
  background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer;
  line-height: 1; padding: 6px 10px;
}
.settings-panel-close-btn:hover { color: var(--text); }

.settings-panel-body { flex: 1; overflow-y: auto; padding: 16px; }
.settings-panel-content { display: none; }
.settings-panel-content.active { display: block; }

@media (max-width: 900px) {
  .settings-panel { width: 100%; max-width: 100%; }
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 82vw;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 10px 0 30px var(--shadow-color);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
  }
  .sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }

  .sidebar-toggle-btn { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

  .content { padding: 12px 12px 24px; }

  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .account-select { order: 3; flex: 1 1 100%; }
  .account-dropdown-btn { width: 100%; min-width: 0; }
  .status-chip { order: 4; flex: 1 1 100%; text-align: center; }
  .topbar-right { flex: 1 1 auto; }

  .icon-btn, .sidebar-toggle-btn { width: 38px; height: 38px; }

  .notif-panel, .account-dropdown-panel {
    max-width: calc(100vw - 24px);
  }
  .notif-panel { width: min(340px, calc(100vw - 24px)); }

  .toast-stack { left: 12px; right: 12px; max-width: none; bottom: 12px; }

  .accounts-table { min-width: 760px; }
  .actions-table { min-width: 620px; }
  .daily-earnings-table { min-width: 480px; }
}

@media (max-width: 480px) {
  .page-title { font-size: 17px; }
  .stat-grid { gap: 6px; }
}

.nav-item {
  text-decoration: none;
}

.anon-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.switch { display: inline-flex; }
.switch input { display: none; }
.switch-track {
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  position: relative;
  transition: background .15s;
  display: inline-block;
}
.switch-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s, background .15s;
}
.switch input:checked + .switch-track {
  background: rgba(79,140,255,0.25);
  border-color: var(--accent);
}
.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(16px);
  background: var(--accent);
}

/* Anonym-Modus: verpixelt/verwischt Charakternamen (z. B. für Screenshots/Streaming).
   Hover deckt den Namen kurzzeitig wieder auf, damit man selbst noch lesen kann. */
body.anon-mode .char-name {
  filter: blur(5px);
  transition: filter .12s;
}
body.anon-mode .char-name:hover {
  filter: blur(0);
}

/* Benachrichtigungen (Fehler & Warnungen) */
.notif-dropdown { position: relative; }
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  max-height: 420px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px var(--shadow-color);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
}
.notif-clear-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  font-weight: 500;
}
.notif-panel-list { overflow-y: auto; }
.notif-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  border-left: 3px solid transparent;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.level-error { border-left-color: var(--red); }
.notif-item.level-warn { border-left-color: var(--yellow); }
.notif-item-char { font-weight: 700; font-size: 12.5px; color: var(--text); margin-bottom: 3px; }
.notif-item-meta-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.notif-item-level-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.03em; }
.notif-item.level-error .notif-item-level-badge { color: var(--red); }
.notif-item.level-warn .notif-item-level-badge { color: var(--yellow); }
.notif-item-time { font-size: 10.5px; color: var(--muted); }
.notif-item-message { color: var(--text); word-break: break-word; line-height: 1.4; opacity: 0.9; }
.notif-panel-empty { padding: 20px 12px; text-align: center; color: var(--muted); font-size: 12px; }

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  max-width: 320px;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 12.5px;
  box-shadow: 0 8px 20px var(--shadow-color);
  animation: toast-in .15s ease-out;
}
.toast.level-error { border-left-color: var(--red); }
.toast.level-warn { border-left-color: var(--yellow); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.update-popup {
  position: fixed; bottom: 20px; right: 20px; z-index: 1000;
  background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius-lg);
  padding: 14px 16px; max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.update-popup .update-popup-close {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1; padding: 0;
}
.update-popup .update-popup-close:hover { color: var(--text); }
.update-popup .update-popup-title { font-weight: 600; font-size: 13.5px; margin: 0 0 6px; padding-right: 16px; }
.update-popup .update-popup-body { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.update-popup .update-popup-btn { width: auto; padding: 6px 14px; font-size: 12px; }
