/* Server-Werkbank: Farben aus Deepslate, Calcit, oxidiertem Kupfer, Redstone und Gold */
:root {
  --bg: #23262c;          /* Deepslate */
  --surface: #2d3138;     /* Tuff */
  --raised: #383d46;
  --line: #454b56;
  --text: #e8eaec;        /* Calcit */
  --muted: #9ba1aa;       /* Andesit */
  --copper: #55a898;      /* oxidiertes Kupfer: aktiv, primaer */
  --copper-ink: #0f2723;
  --redstone: #dc4a3f;
  --gold: #e9b93a;
  --slot: #2a2e35;
  --slot-dark: #1a1c21;
  --slot-light: #4a505b;
  --focus: #e9b93a;
  --radius: 4px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #e3e5e8;
    --surface: #f3f4f5;
    --raised: #ffffff;
    --line: #c7cbd1;
    --text: #23262c;
    --muted: #5d636c;
    --copper: #2e7a6c;
    --copper-ink: #ffffff;
    --redstone: #b8352b;
    --gold: #8d6a0c;
    --slot: #c9cdd3;
    --slot-dark: #9ea4ad;
    --slot-light: #eef0f2;
    --focus: #2e7a6c;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 "Rubik", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 18px; }
p { margin: 0; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wordmark {
  font-family: "Pixelify Sans", "Rubik", sans-serif;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.01em;
}

.hint { color: var(--muted); font-size: 13px; }
.count { color: var(--muted); font-weight: 400; }

/* ---------- Buttons & Felder */
.btn {
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn--primary { background: var(--copper); border-color: var(--copper); color: var(--copper-ink); }
.btn--primary:hover { filter: brightness(1.08); border-color: var(--copper); }
.btn--danger { background: var(--redstone); border-color: var(--redstone); color: #fff; }
.btn--quiet { background: transparent; }
.btn--small { padding: 4px 10px; font-size: 13px; }

input[type="password"], input[type="search"], input:not([type]), textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--slot);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  width: 100%;
}
label { font-size: 14px; color: var(--muted); }
.form-error { color: var(--redstone); font-size: 14px; min-height: 1.5em; white-space: pre-line; }

/* ---------- Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login__card {
  width: min(380px, 100%);
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.login__lead { color: var(--muted); margin-bottom: 12px; }

/* ---------- Kopf */
#app { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.top { display: grid; gap: 12px; }
.top__row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.top__actions { display: flex; gap: 8px; }

.status { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 14px; }
.status__state { color: var(--text); font-weight: 500; }

/* Redstone-Lampe: aus = grau, an = Gold mit Schein, offline = Redstone */
.lamp {
  width: 18px; height: 18px;
  background: #5a4a3a;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.12), inset -2px -2px 0 rgba(0,0,0,.35);
}
.lamp--on {
  background: var(--gold);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.45), inset -2px -2px 0 rgba(120,70,0,.45), 0 0 14px 2px rgba(233,185,58,.45);
}
.lamp--off { background: var(--redstone); }
.lamp--busy { animation: blink 1s steps(2, end) infinite; }
@keyframes blink { 50% { background: #5a4a3a; box-shadow: none; } }

/* ---------- Tabs */
.tabs { display: flex; gap: 4px; margin: 22px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--copper); font-weight: 500; }

.pending {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--gold);
  border-left-width: 6px;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 18px;
}

/* ---------- Abschnitte */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 26px 0 10px; }
.tab > .section-head:first-child { margin-top: 0; }
.section-head__side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Slots (Plugin-Zeilen) */
.slots { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.slots:empty { display: none; }
.slot {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 14px;
}
.slot + .slot { border-top: 1px solid var(--line); }

.tile {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--slot);
  box-shadow: inset 3px 3px 0 var(--slot-dark), inset -3px -3px 0 var(--slot-light);
  font-family: "Pixelify Sans", sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--copper);
  overflow: hidden;
}
.tile img { width: 32px; height: 32px; image-rendering: pixelated; }
.slot--disabled .tile { color: var(--muted); }
.slot--disabled .slot__name { color: var(--muted); }

.slot__main { min-width: 0; }
.slot__title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.slot__name { font-weight: 600; }
.slot__version { color: var(--muted); font-size: 13px; }
.slot__desc { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot__meta { display: flex; gap: 6px 10px; flex-wrap: wrap; margin-top: 4px; font-size: 13px; }

.chip { font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip--active { border-color: var(--copper); color: var(--copper); }
.chip--pending { border-color: var(--gold); color: var(--gold); }
.chip--update { background: var(--gold); border-color: var(--gold); color: #2a2205; }
.chip--essential { border-style: dashed; }

.slot__actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }

/* Schalter wie ein Hebel */
.switch {
  position: relative;
  width: 44px; height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--slot);
  cursor: pointer;
  padding: 0;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s ease, background .15s ease;
}
.switch[aria-checked="true"] { background: var(--copper); border-color: var(--copper); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--copper-ink); }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 5;
  min-width: 180px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  display: grid;
}
.menu__panel button, .menu__panel a {
  font: inherit; font-size: 14px; text-align: left; text-decoration: none;
  color: var(--text); background: none; border: 0; padding: 8px 10px; border-radius: 3px; cursor: pointer;
}
.menu__panel button:hover, .menu__panel a:hover { background: var(--surface); }
.menu__panel .danger { color: var(--redstone); }

/* ---------- Spieler */
.player-add {
  display: grid; gap: 10px;
  max-width: 560px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.player-add__row { display: flex; gap: 8px; }
.segmented { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.segmented label {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}
.segmented label:has(input:checked) { border-color: var(--copper); background: color-mix(in srgb, var(--copper) 16%, transparent); }
.segmented input { accent-color: var(--copper); margin: 0; }
.chip--op { border-color: var(--gold); color: var(--gold); }
.tile--bedrock { color: var(--gold); }

/* ---------- Hinzufuegen */
.add { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; }
.add__search, .add__upload { display: grid; gap: 10px; }
.results { list-style: none; margin: 6px 0 0; padding: 0; }
.results .slot { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 8px; }
.results .slot + .slot { border-top: 1px solid var(--line); }

.drop {
  display: grid; place-items: center; text-align: center;
  min-height: 140px; padding: 16px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.drop:hover, .drop--over { border-color: var(--copper); color: var(--text); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Editor */
.editor { display: grid; gap: 10px; }
.editor__bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.editor__bar select { width: auto; min-width: 220px; }
.editor textarea {
  min-height: 52vh;
  font: 13px/1.55 ui-monospace, "SF Mono", Menlo, monospace;
  tab-size: 2;
  resize: vertical;
  white-space: pre;
}

/* ---------- Log */
.log {
  margin: 0;
  height: 62vh;
  overflow: auto;
  background: var(--slot);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: 12.5px/1.55 ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.log .warn { color: var(--gold); }
.log .error { color: var(--redstone); }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }

/* ---------- Dialoge & Meldungen */
.dialog {
  width: min(460px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.dialog--wide { width: min(900px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10, 12, 15, .6); }
.dialog form, .dialog { display: grid; gap: 12px; }
.dialog:not([open]) { display: none; }
.dialog p { color: var(--muted); }
.dialog__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.choices { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.choices legend { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.choices label { color: var(--text); font-size: 15px; display: flex; gap: 8px; align-items: center; }

.toasts { position: fixed; left: 16px; right: 16px; bottom: 16px; display: grid; justify-items: end; gap: 8px; pointer-events: none; z-index: 20; }
.toast {
  max-width: 440px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-left: 6px solid var(--copper);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  pointer-events: auto;
  white-space: pre-line;
}
.toast--error { border-left-color: var(--redstone); }

.empty { color: var(--muted); padding: 14px; }

@media (max-width: 760px) {
  .add { grid-template-columns: 1fr; }
  .slot { grid-template-columns: 44px minmax(0, 1fr); }
  .slot__actions { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .slot__desc { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .switch::after { transition: none; }
  .lamp--busy { animation: none; }
}
