:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #182033;
  --muted: #667085;
  --line: #d8dee9;
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --danger: #b42318;
  --in: #047857;
  --out: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

.topbar {
  min-height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
}

.brand {
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.server-context {
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}

nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

nav a {
  color: var(--muted);
  text-decoration: none;
}

nav form {
  margin: 0;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.hero,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hero {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.hero h1 {
  font-size: 40px;
  line-height: 1;
  margin: 0;
}

.balance-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.refresh-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: #fff;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.refresh-button:hover {
  border-color: var(--primary);
  background: #eff6ff;
}

.eyebrow,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.player-label {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  vertical-align: middle;
}

.server-badges {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.server-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.server-login {
  margin: -4px 0 12px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 18px;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 22px;
}

.panel h1,
.panel h2 {
  margin-top: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.narrow {
  max-width: 520px;
  margin: 48px auto;
}

.center {
  text-align: center;
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.checkbox-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

button,
.button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.history {
  display: grid;
  gap: 10px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.history-row span,
.history-row small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.admin-table {
  margin-top: 18px;
}

.in {
  color: var(--in);
}

.out {
  color: var(--out);
}

.summary {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
}

.summary dt {
  color: var(--muted);
}

.summary dd {
  margin: 0;
  font-weight: 700;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}

.tabs a,
.thread-link {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  text-decoration: none;
  font-weight: 700;
}

.tabs a.active,
.thread-link.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

.thread-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 18px;
}

.thread-link {
  display: block;
}

.neutral {
  color: var(--muted);
}

.inline-form {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--primary);
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--primary-dark);
}

.qr {
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
}

.copy-field {
  margin-top: 18px;
  text-align: left;
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.copy-row input {
  font-size: 14px;
}

.copy-status {
  min-height: 24px;
  margin: 10px 0 0;
  text-align: left;
}

.danger-zone {
  margin-top: 18px;
}

code {
  background: #eef2ff;
  padding: 2px 5px;
  border-radius: 4px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
    gap: 12px;
  }

  nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .grid,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .thread-layout,
  .inline-form,
  .copy-row {
    grid-template-columns: 1fr;
  }

  .history-row {
    flex-direction: column;
  }
}
