:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8b93a3;
  --accent: #f5a524;
  --accent-ink: #1a1203;
  --ok: #3ccf8e;
  --warn: #f5c542;
  --err: #ef5b5b;
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1rem; font-weight: 600; }
.mt { margin-top: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code { font-family: var(--mono); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: .9rem; }
.error { color: var(--err); min-height: 1.2em; margin: 0; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem; background: rgba(15, 17, 21, .92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; white-space: nowrap; }
.brand img { width: 26px; height: 26px; }
.brand.big { font-size: 1.25rem; justify-content: center; margin-bottom: .4rem; }
.brand.big img { width: 34px; height: 34px; }
.topbar { flex-wrap: wrap; row-gap: .45rem; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; order: 3; flex: 1 0 100%; scrollbar-width: none; }
.game-switch { display: flex; gap: 3px; padding: 3px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; }
.game-switch button {
  display: flex; align-items: center; gap: .45rem; border: 0; background: none; color: var(--muted);
  font: inherit; font-weight: 600; padding: .32rem .8rem; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.game-switch button:hover { color: var(--text); }
.game-switch button.active { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.game-switch .dot { width: 8px; height: 8px; box-shadow: none; }
.game-switch .abbr { display: none; }
.who { margin-left: auto; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 0; color: var(--muted); font: inherit;
  padding: .45rem .75rem; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); background: var(--panel-2); }
.tabs button.active { color: var(--accent-ink); background: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: .6rem; color: var(--muted); white-space: nowrap; }

main { max-width: 1240px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }

/* Karten & Layout */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .4rem; }
.card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stack { display: grid; gap: 1rem; align-content: start; }
.tab { display: grid; gap: 1rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > input { flex: 1; min-width: 0; }
form.card { display: grid; gap: .7rem; align-content: start; }
form.card h3 { margin: 0; }

/* Eingaben */
label { display: grid; gap: .3rem; color: var(--muted); font-size: .9rem; }
label.check { display: flex; align-items: center; gap: .45rem; color: var(--text); cursor: pointer; }
input, select {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); padding: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
select { width: auto; }

/* Buttons */
.btn {
  font: inherit; font-weight: 500; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .9rem; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { border-color: #3a4150; background: #252a35; }
.btn:disabled { opacity: .35; filter: grayscale(1); cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #ffb53d; }
.btn.success { background: rgba(60, 207, 142, .14); border-color: rgba(60, 207, 142, .45); color: var(--ok); }
.btn.danger { background: rgba(239, 91, 91, .12); border-color: rgba(239, 91, 91, .45); color: var(--err); }
.btn.ghost { background: none; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 .5rem; }

/* Status */
.status-head { display: flex; align-items: center; gap: .6rem; }
.status-head h2 { margin: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(60, 207, 142, .18); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(245, 197, 66, .18); }
.dot.err { background: var(--err); box-shadow: 0 0 0 4px rgba(239, 91, 91, .18); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); vertical-align: middle; }
.badge.ok { color: var(--ok); border-color: rgba(60, 207, 142, .45); }
.badge.err { color: var(--err); border-color: rgba(239, 91, 91, .45); }
.badge.accent { color: var(--accent); border-color: rgba(245, 165, 36, .5); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.meters { display: grid; gap: .8rem; }
.meter-label { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: .3rem; }
.meter-label span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.bar > div.hot { background: var(--err); }

.address { display: flex; gap: .5rem; align-items: center; }
.address code { flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.list li { display: flex; justify-content: space-between; gap: 1rem; }
.list li span:last-child { color: var(--muted); font-size: .88rem; white-space: nowrap; }

/* Banner */
#banner:empty { display: none; }
.banner { border-color: rgba(245, 165, 36, .55); background: linear-gradient(180deg, rgba(245, 165, 36, .1), var(--panel)); }
.banner p { margin: 0 0 .7rem; }
.banner .row { flex-wrap: wrap; }
.banner input { flex: 1 1 180px; }

/* Log / Konsole */
.log {
  font: 12.5px/1.5 var(--mono); background: #0a0c10; border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .7rem; margin: 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
#log { height: min(62vh, 640px); }
.log.small { max-height: 260px; font-size: 12px; }
.log .t { color: #596173; margin-right: .6rem; user-select: none; }
.log .l-err { color: #ff8a8a; }
.log .l-warn { color: #ffd479; }
.log .l-sys { color: #7fb4ff; }
.log .l-join { color: var(--ok); }
.log .l-cmd { color: var(--accent); font-weight: 600; }
.log .l-res { color: var(--text); background: rgba(245, 165, 36, .07); border-left: 2px solid var(--accent); padding-left: .5rem; }
.log.only-warn > div:not(.l-err):not(.l-warn):not(.l-cmd):not(.l-res) { display: none; }
.console { display: grid; gap: .7rem; }
.console-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.console-head h3 { margin: 0; margin-right: auto; }
.console-input { display: flex; gap: .5rem; }
.console-input input { font-family: var(--mono); }

/* Job */
.job { border-color: rgba(245, 165, 36, .5); }
.job-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.job-head h3 { margin: 0; }
.job-head .btn { margin-left: auto; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.btns { text-align: right; white-space: nowrap; }
.table td.btns .btn { margin-left: .3rem; }
.table tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); padding: .6rem 0; }

.session { display: grid; gap: .6rem; }
.session .card-head { flex-wrap: wrap; }
.session .card-head h3 { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* Optionen */
.option { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.option:last-child { border-bottom: 0; }
.option .name { display: grid; }
.option .name small { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.option input:not([type=checkbox]) { width: 110px; text-align: right; }

.option .name small.hint { font-family: inherit; font-size: .8rem; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 2rem; }
.server-name { margin: .35rem 0 0; font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.current-name { color: var(--text); }
.badge.warn { color: var(--warn); border-color: rgba(245, 197, 66, .45); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
details summary { cursor: pointer; }

/* Mods */
.mods-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.mods-bar h3 { margin: 0 0 .2rem; }
.mods-bar p { margin: 0; }
.mods-bar .actions { margin: 0; }
.mod-list { display: grid; gap: .5rem; }
#mods-results, #vh-mod-results { max-height: 680px; overflow-y: auto; padding-right: .2rem; }
.mod {
  display: grid; grid-template-columns: 44px 1fr auto; gap: .75rem; align-items: center;
  padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2);
}
.mod img, .mod .ph { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #0a0c10; }
.mod .body { min-width: 0; }
.mod .title { display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap; font-weight: 600; }
.mod .title a { color: var(--text); }
.mod .desc { color: var(--muted); font-size: .85rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.mod .meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .25rem; font-size: .78rem; color: var(--muted); align-items: center; }
.mod.pending-add { border-color: rgba(245, 165, 36, .6); }
.mod.pending-remove { border-style: dashed; opacity: .75; }

/* Project Zomboid */
.update-line { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0; }
.update-line > span:first-child { color: var(--muted); }
#pz-mod-updates.has-updates { color: var(--warn); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chips .btn { font-family: var(--mono); }
.mod-toggles { display: grid; gap: .2rem; margin-top: .45rem; }
.mod-toggles label { display: block; font-size: .85rem; color: var(--text); overflow-wrap: anywhere; }
.mod-toggles label input { vertical-align: -2px; margin-right: .35rem; }
.mod-toggles code { color: var(--muted); font-size: .78rem; }
.mod.pz-item { align-items: start; grid-template-columns: 64px 1fr auto; }
.mod.pz-item img, .mod.pz-item .ph { width: 64px; height: 64px; }
.order-list { margin: 0; padding-left: 1.7rem; display: grid; gap: .15rem; max-height: 560px; overflow-y: auto; font-size: .9rem; }
.order-list li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.order-list li > div { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .15rem .3rem; border-radius: 6px; }
.order-list li > div:hover { background: var(--panel-2); }
.order-list li code { color: var(--muted); font-size: .75rem; margin-left: .3rem; }
.order-list li > div > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.mod .title a, .mod .desc { overflow-wrap: anywhere; }
.order-list .btns { display: flex; gap: .2rem; flex: none; }
.order-list .btn { padding: .05rem .45rem; font-size: .8rem; }
.card.warn-card { border-color: rgba(245, 197, 66, .5); background: linear-gradient(180deg, rgba(245, 197, 66, .08), var(--panel)); }
.card.warn-card h3 { color: var(--warn); }
.card.warn-card p { margin: 0 0 .6rem; }
.card.warn-card .actions { margin: 0; }
details.card > summary { list-style-position: inside; }

/* Profile & Spielregeln */
.profile-bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .7rem 1.1rem; }
.profile-pick { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 600; }
.profile-pick select { min-width: 220px; }
.profile-list { display: grid; gap: .6rem; }
.profile { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.profile.active { border-color: rgba(60, 207, 142, .55); }
.profile h4 { margin: 0 0 .2rem; font-size: 1rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.profile .meta { color: var(--muted); font-size: .85rem; }
.profile .actions { margin: 0; }
details.rules { padding: 0; }
details.rules > summary { padding: .9rem 1.1rem; font-weight: 600; display: flex; justify-content: space-between; gap: 1rem; cursor: pointer; list-style: none; }
details.rules > summary::-webkit-details-marker { display: none; }
details.rules > summary::after { content: "▸"; color: var(--muted); }
details.rules[open] > summary::after { content: "▾"; }
details.rules > .option-grid { padding: 0 1.1rem 1rem; }
#pz-rules { display: grid; gap: .7rem; }
.option .name .desc { color: var(--muted); font-size: .8rem; font-weight: 400; }
.option select { max-width: 220px; }
.option input[type=text], .option input:not([type]) { width: 180px; text-align: left; }
.option.changed { background: rgba(245, 165, 36, .07); border-radius: 6px; }
#pz-rules-search { width: 200px; }
.code-edit { width: 100%; min-height: 360px; margin-top: .7rem; font: 12.5px/1.5 var(--mono); color: var(--text);
  background: #0a0c10; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; resize: vertical; }

.config-section { margin-top: .6rem; padding-left: .7rem; border-left: 2px solid var(--border); }
.config-section h4 { margin: .4rem 0 .2rem; font-size: .92rem; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: .5rem; z-index: 50; max-width: calc(100vw - 32px); }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: .65rem .9rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: slide .2s ease-out; }
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 720px) {
  .topbar { gap: .5rem; padding: .5rem 16px; }
  .topbar > .brand span { display: none; }
  .game-switch button { padding: .3rem .6rem; }
  .game-switch .full { display: none; }
  .game-switch .abbr { display: inline; }
  .who span { display: none; }
  main { padding: 16px; }
  .grid, .grid.two { grid-template-columns: 1fr; }
  .table td.btns .btn { margin: .15rem 0 .15rem .3rem; }
  .mod { grid-template-columns: 36px 1fr; }
  .mod img, .mod .ph { width: 36px; height: 36px; }
  .mod > .btn { grid-column: 2; justify-self: start; }
  .mod.pz-item { grid-template-columns: 48px 1fr; }
  .mod.pz-item img, .mod.pz-item .ph { width: 48px; height: 48px; }
  .option-grid { grid-template-columns: 1fr; }
}

/* Workshop-Suche */
#pz-workshop .card-head { align-items: flex-start; }
#pz-workshop .row.wrap > input { flex: 1 1 16rem; }
#pz-workshop .row.wrap { margin-bottom: .5rem; }
.ws-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: .5rem; max-height: 720px; overflow-y: auto; padding-right: .2rem; margin: .4rem 0 .6rem; }
.mod-toggles label a { color: var(--text); }
.btn.attention { box-shadow: 0 0 0 3px rgba(245, 165, 36, .35); animation: attention 1.6s ease-in-out infinite; }
@keyframes attention { 50% { box-shadow: 0 0 0 6px rgba(245, 165, 36, .12); } }
@media (prefers-reduced-motion: reduce) { .btn.attention { animation: none; } }

/* Valheim */
.mt-s { margin-top: .5rem; }
.stack-s { display: grid; gap: .35rem; padding: .55rem 0; }
.option input.wide { width: min(260px, 100%); text-align: left; }
.list-edit { width: 100%; font: 12.5px/1.5 var(--mono); color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; resize: vertical; }
.list-edit:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
#vh-lists-form { display: grid; gap: .7rem; }
.list li code { color: var(--muted); font-size: .78rem; }
#vh-mod-search > input { flex: 1 1 14rem; }
#vh-mod-search { margin-bottom: .5rem; }

/* Assistent */
.ai-grid { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
.ai-log { display: grid; gap: .6rem; max-height: min(62vh, 640px); min-height: 220px; overflow-y: auto; padding: .2rem .2rem .6rem; }
.ai-msg { padding: .6rem .8rem; border-radius: 10px; max-width: 92%; overflow-wrap: anywhere; line-height: 1.5; }
.ai-msg p { margin: 0 0 .5rem; }
.ai-msg p:last-child, .ai-msg ul:last-child, .ai-msg ol:last-child { margin-bottom: 0; }
.ai-msg ul, .ai-msg ol { margin: 0 0 .5rem; padding-left: 1.3rem; }
.ai-msg pre { margin: .4rem 0; max-height: 260px; }
.ai-user { justify-self: end; background: rgba(245, 165, 36, .14); border: 1px solid rgba(245, 165, 36, .35); white-space: normal; }
.ai-user .who { font-size: .75rem; color: var(--muted); margin-bottom: .15rem; }
.ai-bot { justify-self: start; background: var(--panel-2); border: 1px solid var(--border); }
.ai-tool { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: .4rem; }
.ai-action { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .55rem .7rem; border: 1px solid rgba(245, 165, 36, .5); border-radius: 10px; }
.ai-error { color: var(--err); font-size: .88rem; }
.ai-input { display: flex; gap: .5rem; align-items: flex-end; margin-top: .6rem; }
.ai-input textarea { flex: 1; min-width: 0; resize: vertical; font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; }
.ai-input textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.ai-examples { display: flex; flex-wrap: wrap; gap: .4rem; }
.steps { padding-left: 1.2rem; display: grid; gap: .3rem; }
@media (max-width: 900px) { .ai-grid { grid-template-columns: 1fr; } }
