:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --text: #1e1f24;
  --muted: #5d6070;
  --border: #e3e5ec;
  --accent: #5865f2;
  --accent-text: #ffffff;
  --ok: #1f9d55;
  --error: #d93b3b;
  --quote: #f0f1f7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111216;
    --surface: #1b1c22;
    --text: #ecedf1;
    --muted: #9ea1b0;
    --border: #2b2d36;
    --accent: #6d78f7;
    --quote: #23252d;
    --ok: #3ccf7d;
    --error: #ff6b6b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.06);
}
.avatar { border-radius: 50%; display: block; margin: 0 auto 12px; }
.badge {
  width: 64px; height: 64px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 28px; font-weight: 700;
  background: var(--quote); color: var(--accent);
}
.tone-ok .badge { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tone-error .badge { background: color-mix(in srgb, var(--error) 15%, transparent); color: var(--error); }
h1 { font-size: 1.35rem; margin: 0 0 8px; overflow-wrap: anywhere; }
.msg { color: var(--muted); margin: 0 0 16px; }
.tone-ok h1 { color: var(--ok); }
.tone-error h1 { color: var(--error); }
.custom {
  margin: 0 0 16px; padding: 12px 14px; text-align: left;
  background: var(--quote); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.who { font-size: 0.9rem; color: var(--muted); margin: 0 0 16px; overflow-wrap: anywhere; }
.btn {
  width: 100%; padding: 12px 16px;
  border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 12px 0 0; min-height: 1.3em; }
.foot { text-align: center; font-size: 0.8rem; color: var(--muted); padding: 16px; }

/* ------------------------------------------------------------------ dashboard */
.btn { display: inline-block; text-align: center; text-decoration: none; }
.card .btn { margin-top: 4px; }
body.dash { display: block; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.brand span { color: var(--muted); font-weight: 500; }
.me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me img { border-radius: 50%; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.me form { margin: 0; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 4px; }
.dash-main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
.dash-main h1 { font-size: 1.5rem; margin: 0; }
.dash-main h2 { font-size: 1.1rem; margin: 0 0 12px; }
.dash-main section { margin-top: 28px; }
.muted { color: var(--muted); }
a { color: var(--accent); }

.guilds { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.guilds a {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.guilds a:hover, .guilds a:focus-visible { border-color: var(--accent); }
.guilds img, .guild-head img { border-radius: 12px; flex: none; }
.gicon {
  width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: var(--quote); color: var(--accent); font-weight: 700;
}
.guild-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-width: 0; }
.guild-head h1 { overflow-wrap: anywhere; }
.guild-head .gicon { width: 48px; height: 48px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 16px; }
.flash-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.flash-error { background: color-mix(in srgb, var(--error) 14%, transparent); color: var(--error); }

.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.tile-v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-l { color: var(--muted); font-size: 0.85rem; }
.tile.warn .tile-v { color: var(--error); }

.problems { margin: 0; padding-left: 20px; color: var(--error); }
.problems li { margin: 4px 0; }
.ok-line { color: var(--ok); margin: 0; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.filter { display: flex; align-items: center; gap: 8px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td, tr:last-child th { border-bottom: 0; }
thead th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.nowrap { white-space: nowrap; }
.details { min-width: 220px; overflow-wrap: anywhere; }
.details .k { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--quote); white-space: nowrap; font-size: 0.8rem; }
.b-alt, .b-ban { background: color-mix(in srgb, var(--error) 16%, transparent); color: var(--error); }
.b-success, .b-manual { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
table.kv th { width: 34%; color: var(--muted); font-weight: 500; }

form.settings fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 8px 16px 16px; margin: 0 0 16px; background: var(--surface); }
form.settings legend { font-weight: 600; padding: 0 6px; }
.field { display: grid; gap: 6px; margin-top: 14px; }
.field-boolean { grid-template-columns: auto 1fr; align-items: center; }
.field-boolean label { order: 2; }
.field-boolean input { order: 1; width: 18px; height: 18px; }
.field-boolean .field-error { order: 3; grid-column: 1 / -1; }
.field label { font-weight: 500; }
select, input[type="number"], input[type="text"], input:not([type]), input[inputmode], textarea {
  width: 100%; max-width: 520px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
.filter select { width: auto; }
.has-error select, .has-error input, .has-error textarea { border-color: var(--error); }
.field-error { color: var(--error); margin: 0; font-size: 0.85rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.actions form { margin: 0; }
.actions .btn, .settings .btn { width: auto; padding: 10px 18px; }
.btn-small { width: auto; padding: 7px 12px; font-size: 0.9rem; }
.lookup { display: grid; gap: 6px; max-width: 560px; }
.lookup .row { display: flex; gap: 8px; }
.lookup .btn { width: auto; }
.member { margin-top: 20px; }
.member-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.member-head img { border-radius: 50%; }
.member-head h2 { margin: 0; }
