:root {
  --bg: #0d1220;
  --bar: #121a2e;
  --surface: #172036;
  --line: #27314d;
  --text: #e8ecf6;
  --muted: #94a0bd;
  --accent: #4d86ff;
  --accent-2: #6d3df2;
  --danger: #ff6b6b;
  --ok: #4cd9a0;
  --input: #0f1629;
  --hover: #1d2845;
  --hover2: #24325a;
  --tabhover: #18213a;
  color-scheme: dark;
  --radius: 10px;
  --bar-h: 46px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg: #eef1f8;
  --bar: #e2e7f2;
  --surface: #ffffff;
  --line: #cdd5e6;
  --text: #172036;
  --muted: #5a6683;
  --accent: #3b74f0;
  --danger: #d63b3b;
  --ok: #17935f;
  --input: #f4f6fb;
  --hover: #e6ebf6;
  --hover2: #d8e0f0;
  --tabhover: #d9e0ef;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; }
#root { height: 100%; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Anmeldung ---------- */
.auth {
  position: relative;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(77, 134, 255, .16), transparent 60%),
    radial-gradient(800px 500px at 90% 95%, rgba(109, 61, 242, .18), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 28px 26px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand b { font-size: 22px; letter-spacing: .2px; }
.auth-card h1 { font-size: 17px; margin: 0 0 4px; font-weight: 600; }
.auth-card p.lead { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; }
input[type=text], input[type=password], select {
  width: 100%;
  padding: 10px 12px;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--hover);
  cursor: pointer;
}
.btn:hover { background: var(--hover2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #6797ff; }
.btn.danger { border-color: rgba(255, 107, 107, .5); color: var(--danger); background: transparent; }
.btn.danger:hover { background: rgba(255, 107, 107, .12); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }

.msg { min-height: 20px; margin: 0 0 10px; font-size: 13.5px; color: var(--danger); }
.msg.ok { color: var(--ok); }

/* ---------- App ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.chrome { flex: none; background: var(--bar); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }

.tabrow { display: flex; align-items: center; gap: 10px; padding: 6px 10px 0 10px; min-height: 40px; }
.logo { width: 24px; height: 24px; border-radius: 6px; flex: none; margin-bottom: 4px; }
.tabs { flex: 0 1 auto; min-width: 0; display: flex; align-items: flex-end; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 1 200px; min-width: 70px; height: 34px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px 0 12px;
  border: 1px solid transparent; border-bottom: 0;
  border-radius: 9px 9px 0 0;
  color: var(--muted); cursor: pointer; user-select: none;
}
.tab:hover { background: var(--tabhover); }
.tab.active { background: var(--surface); border-color: var(--line); color: var(--text); margin-bottom: -1px; height: 35px; }
.tab .ttl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.tab .x {
  flex: none; width: 20px; height: 20px; display: grid; place-items: center;
  border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
}
.tab .x:hover { background: var(--hover2); color: var(--text); }
.spacer { flex: 1 1 0; min-width: 0; }
.newtab { flex: none; width: 30px; height: 30px; margin-left: 4px; font-size: 18px; }

.toolrow { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--surface); border-top: 1px solid var(--line); }
.icon-btn {
  flex: none; width: 34px; height: 34px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; color: var(--text);
}
.icon-btn:hover:not([disabled]) { background: var(--hover); }
.icon-btn[disabled] { opacity: .35; cursor: default; }
.urlbar {
  flex: 1; min-width: 0; height: 34px;
  padding: 0 14px;
  background: var(--input); border: 1px solid var(--line); border-radius: 999px;
}
.urlbar:focus { border-color: var(--accent); outline: none; }
.loadbar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; }
.loadbar[hidden] { display: none; }
.loadbar i { position: absolute; top: 0; bottom: 0; width: 30%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { left: -30%; } to { left: 100%; } }

.user { position: relative; flex: none; }
.user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 5px; margin-bottom: 4px;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer;
}
.user-btn:hover, .user-btn[aria-expanded=true] { background: var(--hover); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 12.5px; font-weight: 700; color: #fff;
}
.user-btn .name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.caret { width: 10px; height: 10px; color: var(--muted); transition: transform .15s; }
.user-btn[aria-expanded=true] .caret { transform: rotate(180deg); }

.menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  min-width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  z-index: 50;
}
.menu[hidden] { display: none; }
.menu .who { padding: 8px 10px 9px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu button {
  display: block; width: 100%; text-align: left;
  padding: 9px 10px;
  background: none; border: 0; border-radius: 7px;
  color: var(--text); cursor: pointer;
}
.menu button:hover { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

.stage { position: relative; flex: 1; min-height: 0; background: var(--bg); overflow: hidden; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.newpage {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center; padding: 20px;
  background: var(--bg); color: var(--muted);
}
.newpage img { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 14px; }
.newpage b { display: block; margin-bottom: 4px; color: var(--text); font-size: 20px; }
.newpage[hidden] { display: none; }
.tab .fav { width: 16px; height: 16px; flex: none; border-radius: 3px; }

.histpanel {
  position: absolute; right: 10px; top: 100%;
  width: min(440px, calc(100vw - 20px)); max-height: 60vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  z-index: 60;
}
.histhead { padding: 10px; border-bottom: 1px solid var(--line); }
.histhead input {
  width: 100%; padding: 8px 12px;
  background: var(--input); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.histhead input:focus { border-color: var(--accent); outline: none; }
.histlist { overflow: auto; padding: 4px 6px 8px; }
.histday { padding: 10px 8px 4px; color: var(--muted); font-size: 12.5px; }
.histrow { display: flex; align-items: center; border-radius: 7px; }
.histrow:hover { background: var(--hover); }
.histitem {
  display: block; flex: 1; min-width: 0; text-align: left;
  padding: 7px 8px; background: none; border: 0; border-radius: 7px; cursor: pointer; color: var(--text);
}
.histitem .ht, .histitem .hu { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.histitem .hu { color: var(--muted); font-size: 12.5px; }
.histempty { margin: 14px 8px; color: var(--muted); }

.section .row select, .section .row input { flex: 1 1 160px; width: auto; min-width: 0; }

.urlwrap { position: relative; flex: 1; min-width: 0; }
.urlwrap .urlbar { width: 100%; padding-right: 42px; }
.starbtn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer;
}
.starbtn:hover:not([disabled]) { background: var(--hover); color: var(--text); }
.starbtn.on { color: #f5b301; }
.starbtn[disabled] { opacity: .35; cursor: default; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35); z-index: 70; padding: 4px; max-height: 50vh; overflow: auto;
}
.suggest[hidden] { display: none; }
.sugrow { display: flex; align-items: center; border-radius: 7px; }
.sugrow:hover, .sugrow.sel { background: var(--hover); }
.sugitem { display: block; flex: 1; min-width: 0; text-align: left; padding: 7px 10px; background: none; border: 0; border-radius: 7px; cursor: pointer; color: var(--text); }
.sugitem .st, .sugitem .su { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugitem .su { color: var(--muted); font-size: 12.5px; }

.bmrow { position: relative; background: var(--surface); border-top: 1px solid var(--line); }
.bmrow[hidden] { display: none; }
.bmbar {
  display: flex; align-items: center; gap: 4px; padding: 4px 10px; min-height: 34px;
  overflow-x: auto; scrollbar-width: none;
}
.bmbar::-webkit-scrollbar { display: none; }
.bmarrow {
  position: absolute; top: 0; bottom: 0; width: 32px; z-index: 3;
  display: grid; place-items: center; border: 0; color: var(--text); cursor: pointer;
}
.bmarrow[hidden] { display: none; }
.bmarrow.l { left: 0; background: linear-gradient(90deg, var(--surface) 60%, transparent); justify-items: start; padding-left: 6px; }
.bmarrow.r { right: 0; background: linear-gradient(270deg, var(--surface) 60%, transparent); justify-items: end; padding-right: 6px; }
.bmarrow:hover { color: var(--accent); }
.bm.dragover { outline: 2px solid var(--accent); outline-offset: -2px; }
.bmfold { display: inline-flex; color: var(--muted); }
.bmicon.img { background: none; }
.bmicon img { width: 16px; height: 16px; border-radius: 3px; display: block; }
.bmdrop {
  position: fixed; z-index: 110; min-width: 220px; max-width: 320px; max-height: 60vh; overflow: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .4);
}
.bmkid {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 9px;
  background: none; border: 0; border-radius: 7px; color: var(--text); cursor: pointer; font-size: 13.5px;
}
.bmkid:hover { background: var(--hover); }
.cachelist { max-height: 240px; overflow: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); }
.cacherow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.cacherow:last-child { border-bottom: 0; }
.cacherow .ch { flex: 1; min-width: 0; }
.cacherow .ch b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cacherow .cm { color: var(--muted); font-size: 12.5px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.bm {
  flex: none; max-width: 190px; display: flex; align-items: center; gap: 6px; padding: 4px 9px;
  background: none; border: 0; border-radius: 7px; color: var(--text); cursor: pointer; font-size: 13.5px;
}
.bm:hover { background: var(--hover); }
.bmicon {
  width: 18px; height: 18px; flex: none; display: grid; place-items: center; border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 11px; font-weight: 700;
}
.bmt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bmempty { color: var(--muted); font-size: 13px; }
.ctxmenu {
  position: fixed; z-index: 120; min-width: 160px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.ctxmenu button { display: block; width: 100%; text-align: left; padding: 8px 10px; background: none; border: 0; border-radius: 7px; color: var(--text); cursor: pointer; }
.ctxmenu button:hover { background: var(--hover); }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; cursor: pointer; }

.rowdel {
  flex: none; width: 26px; height: 26px; margin-right: 4px; border: 0; border-radius: 6px;
  background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; opacity: 0;
}
.sugrow:hover .rowdel, .sugrow.sel .rowdel, .histrow:hover .rowdel, .rowdel:focus-visible { opacity: 1; }
.rowdel:hover { background: var(--hover2); color: var(--text); }

.icon-btn[hidden] { display: none; }
.icon-btn.err { position: relative; color: #f5b301; }
.icon-btn.err .badge {
  position: absolute; top: 1px; right: 1px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; line-height: 15px; text-align: center;
}
.errhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.erritem { padding: 6px 8px; border-bottom: 1px solid var(--line); font: 12px ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

.foot {
  flex: none; height: 26px; display: flex; align-items: center; justify-content: center;
  background: var(--bar); border-top: 1px solid var(--line); font-size: 12px;
}
.foot a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--text); }
.auth .foot { position: absolute; left: 0; right: 0; bottom: 0; background: none; border-top: 0; }

/* ---------- Dialoge ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(3, 5, 12, .66);
}
.dialog {
  width: 100%; max-width: 460px; max-height: 92vh; overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
}
.dialog.wide { max-width: 780px; }
.dialog h2 { margin: 0 0 16px; font-size: 18px; }
.stabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
.stab {
  padding: 9px 14px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer; white-space: nowrap; margin-bottom: -1px;
}
.stab:hover { color: var(--text); }
.stab.active { color: var(--text); border-bottom-color: var(--accent); }
.sbody { min-height: 330px; }
.spanel[hidden], .sbody form[hidden] { display: none; }
.spanel p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .two { grid-template-columns: 1fr; } }
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.section h3 { margin: 0 0 4px; font-size: 14.5px; }
.section p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }
.section .row { display: flex; flex-wrap: wrap; gap: 10px; }
.hint { margin: -6px 0 14px; color: var(--muted); font-size: 12.5px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 200;
  padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
}

.dialog .msgtext { margin: 0 0 14px; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 560px) {
  .user-btn .name { display: none; }
  .tab { flex-basis: 130px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .loadbar i { animation-duration: 2.4s; }
  .caret { transition: none; }
}
