:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #efefea;
  --text: #1c1e1b;
  --muted: #61655e;
  --border: #dadbd4;
  --border-strong: #c3c5bc;
  --accent: #2c6a46;
  --accent-hover: #24583a;
  --accent-text: #ffffff;
  --focus: #3a7bd5;

  --green: #2b9450;
  --yellow: #c08f00;
  --grey: #979a93;
  --red: #c23d2c;
  --orange: #c56f12;
  --blue: #3466a8;
  --violet: #7a4fb0;

  --danger-bg: #c23d2c;
  --danger-text: #ffffff;

  --attn-bg: #fff3cf;
  --attn-border: #e2b440;
  --attn-text: #3d2e00;

  --log-bg: #1b1d1a;
  --log-text: #d6d9d0;
  --log-time: #7f8579;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141513;
    --surface: #1c1e1b;
    --surface-2: #262824;
    --text: #e6e7e2;
    --muted: #9b9f96;
    --border: #30332d;
    --border-strong: #454940;
    --accent: #5db683;
    --accent-hover: #74c897;
    --accent-text: #0d1a12;
    --focus: #6ea4f0;

    --green: #4cc278;
    --yellow: #e0b42a;
    --grey: #7d8179;
    --red: #ec6a58;
    --orange: #e8913a;
    --blue: #6b9be0;
    --violet: #a785d8;

    --danger-bg: #d9503e;
    --danger-text: #ffffff;

    --attn-bg: #3a2f0c;
    --attn-border: #9c7a1c;
    --attn-text: #fbeab8;

    --log-bg: #0e0f0d;
    --log-text: #d6d9d0;
    --log-time: #6c7167;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: anywhere;
  min-height: 100vh;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px 0; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Kopfleiste ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 17px;
}
.brand:hover { color: var(--text); }
.brand img { border-radius: 5px; }
.summary {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.conn {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 5px 16px;
  border-top: 1px solid var(--border);
}

/* ---------- Banner ---------- */

.banner {
  background: var(--attn-bg);
  color: var(--attn-text);
  border-bottom: 1px solid var(--attn-border);
}
.banner-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  gap: 8px;
}
.banner-title { font-weight: 600; }
.banner-title a { color: inherit; }
.banner-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.login-code {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 2px 12px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--attn-border);
  user-select: all;
}
.banner-note { font-size: 13px; opacity: .85; }
.banner + .banner .banner-inner { padding-top: 10px; }

/* ---------- Grundgerüst ---------- */

.main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}
.page-title { font-size: 22px; margin: 4px 0 16px; }

.group + .group { margin-top: 28px; }
.group-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count {
  font-size: 12px;
  background: var(--surface-2);
  border-radius: 99px;
  padding: 0 7px;
  letter-spacing: 0;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
}

.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Bot-Kachel ---------- */

.bot-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color .15s;
}
.bot-card:hover { border-color: var(--border-strong); }
.bot-card.is-stopped { background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
.bot-card .actions { margin-top: auto; }

.bot-head { display: grid; gap: 4px; min-width: 0; }
.bot-head-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bot-title { font-size: 20px; font-weight: 650; }
.bot-name {
  color: var(--text);
  text-decoration: none;
  font-size: 20px;
  font-weight: 650;
}
h1.bot-name { font-size: 24px; }
a.bot-name:hover { text-decoration: underline; color: var(--text); }
.bot-meta { color: var(--muted); font-size: 13px; }
.account { font-family: var(--mono); font-size: 12.5px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 550;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--grey); flex: none; }
.st-online .dot { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }
.st-online { color: var(--green); }
.st-connecting .dot { background: var(--yellow); animation: pulse 1.4s ease-in-out infinite; }
.st-connecting { color: var(--yellow); }
.st-offline .dot { background: var(--grey); }
.st-offline { color: var(--muted); }
.st-stopped .dot { background: transparent; border: 2px solid var(--red); }
.st-stopped { color: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .st-connecting .dot { animation: none; } }

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge-java { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 40%, transparent); }
.badge-bedrock { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }

.last-event {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: 13.5px;
}
.last-text { flex: 1 1 140px; min-width: 0; }

.ev-tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 0 7px;
  border-radius: 5px;
  white-space: nowrap;
  color: var(--c, var(--muted));
  background: color-mix(in srgb, var(--c, var(--muted)) 13%, transparent);
}
.ev-good { --c: var(--green); }
.ev-warn { --c: var(--orange); }
.ev-bad { --c: var(--red); }
.ev-info { --c: var(--blue); }
.ev-attn { --c: var(--violet); }
.ev-neutral { --c: var(--muted); }

.conflict {
  font-size: 13px;
  color: var(--orange);
  border-left: 3px solid var(--orange);
  padding: 2px 0 2px 8px;
}
.conflict a { color: inherit; font-weight: 600; }

/* ---------- Knöpfe & Felder ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary:disabled { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-danger, .btn-danger:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger-bg); color: var(--danger-text); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.actions .btn { padding: 0 6px; white-space: normal; line-height: 1.15; font-size: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:disabled { opacity: .5; }
.input.mono { font-family: var(--mono); font-size: 15px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field { display: grid; gap: 6px; }
.stack { display: grid; gap: 12px; }
.form-error { color: var(--red); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.chip {
  appearance: none;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chip.mono { font-family: var(--mono); font-size: 13.5px; }
.chip:hover:not(:disabled) { border-color: var(--accent); }
.chip:disabled { opacity: .42; cursor: not-allowed; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 32px;
  padding: 4px 0;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.checks { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }

/* ---------- Detailansicht ---------- */

.back {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: 8px;
  text-decoration: none;
  font-weight: 550;
}

.detail-head {
  padding: 16px;
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.detail-head-main { display: grid; gap: 10px; }

.detail-grid { display: grid; gap: 14px; }
.col-main, .col-side { display: grid; gap: 14px; align-content: start; min-width: 0; }

.panel { padding: 14px; min-width: 0; }
.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.panel-title h2 { font-size: 15px; font-weight: 650; }

.log-wrap { position: relative; }
.log {
  background: var(--log-bg);
  color: var(--log-text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: 8px;
  padding: 8px 10px;
  height: min(52vh, 460px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.ll { white-space: pre-wrap; word-break: break-word; }
.lt { color: var(--log-time); user-select: none; }
.log .muted { color: var(--log-time); }
.log .form-error { font-family: inherit; }
.log-down {
  position: absolute;
  right: 12px;
  bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

.send-row { display: flex; gap: 8px; }
.send-row .input { flex: 1; min-width: 0; }
.counter { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.full { color: var(--red); font-weight: 600; }
.panel > p.small { margin-top: 8px; }

.events { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.event {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}
.event:first-child { border-top: 0; }
.event-time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Einstellungen ---------- */

.settings-grid { display: grid; gap: 14px; }
code.wrap { word-break: break-all; }

/* ---------- Login ---------- */

.login-wrap { display: grid; place-items: center; min-height: 70vh; }
.login {
  width: 100%;
  max-width: 360px;
  padding: 22px;
  display: grid;
  gap: 10px;
}
.login-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.login-head h1 { font-size: 20px; }
.login-head img { border-radius: 7px; }
.login .btn { margin-top: 6px; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 440px);
  display: grid;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
  animation: toast-in .18s ease-out;
  transition: opacity .25s;
}
.toast-error { background: var(--danger-bg); color: var(--danger-text); }
.toast.out { opacity: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Breitere Bildschirme ---------- */

@media (min-width: 720px) {
  .detail-head { grid-template-columns: 1fr minmax(300px, 360px); align-items: start; }
  .settings-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .settings-grid > :nth-child(2) { grid-row: span 2; }
}
@media (min-width: 1000px) {
  .detail-grid { grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); align-items: start; }
  .log { height: min(62vh, 620px); }
}
@media (max-width: 400px) {
  .summary { font-size: 12px; }
  .login-code { font-size: 22px; }
}

/* ---------- Labels ---------- */
.badge-label {
  color: var(--violet);
  border-color: color-mix(in srgb, var(--violet) 40%, transparent);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}
.chip {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.label-form { display: grid; gap: 10px; }
.label-form input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.label-form .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Markt ---------- */
.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 550;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  flex: none;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.market-intro { max-width: 70ch; margin: -8px 0 14px; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.chip-count {
  margin-left: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  opacity: .7;
}
.chip-small { min-height: 30px; padding: 0 11px; font-size: 13px; }
.market-controls { display: grid; gap: 10px; margin-bottom: 12px; }
.market-controls .filters { margin: 0; gap: 6px; }
.market-panel { padding: 0 14px; }

.finds, .chatlog { list-style: none; margin: 0; padding: 0; }
.finds > li, .chatlog > li { border-top: 1px solid var(--border); }
.finds > li:first-child, .chatlog > li:first-child { border-top: 0; }
.finds .empty, .chatlog .empty { padding: 18px 0; }

.find { padding: 11px 0; display: grid; gap: 4px; }
.find-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.find-what { font-size: 15px; }
.price {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
}
.repeat { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.find-text { font-size: 13.5px; color: var(--muted); }
.find-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12.5px; color: var(--muted); }
.who { font-weight: 600; color: var(--text); }
.cb {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
}

.chatlog { max-height: min(70vh, 720px); overflow-y: auto; overscroll-behavior: contain; }
.chat-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  font-size: 13.5px;
}
.chat-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chat-body .cb { margin-right: 6px; }

@media (min-width: 720px) {
  .market-controls { grid-template-columns: 1fr minmax(220px, 300px); align-items: center; }
}
