:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2026;
  --muted: #646a76;
  --border: #dde0e6;
  --accent: #5865f2;
  --accent-text: #ffffff;
  --ok-bg: #e7f6ec;  --ok-border: #9fd8b1;
  --warn-bg: #fff6e0; --warn-border: #f0d08a;
  --err-bg: #fdecec;  --err-border: #f0a8a8;
  --danger: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --surface: #1e2128;
    --text: #e6e8ec;
    --muted: #9aa0ab;
    --border: #2f343e;
    --accent: #7983f5;
    --ok-bg: #16301f;  --ok-border: #2f6b44;
    --warn-bg: #33290f; --warn-border: #7a5f1e;
    --err-bg: #3a1a1a;  --err-border: #7d3333;
    --danger: #ff7b6b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
code { font-size: 0.92em; }
main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { margin: 0 0 16px; font-size: 1.6rem; }
h2 { margin: 0 0 4px; font-size: 1.2rem; }
h3 { margin: 24px 0 4px; font-size: 1rem; }
.muted { color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.who { display: flex; align-items: center; gap: 8px; }
.who form { margin: 0; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; margin-bottom: 16px;
}
.narrow { max-width: 460px; margin: 48px auto; }
.center { text-align: center; }

.button {
  display: inline-block; padding: 9px 18px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
button.link.danger { color: var(--danger); }

.guilds { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.guild { display: flex; align-items: center; gap: 12px; margin: 0; text-decoration: none; color: var(--text); }
.guild:hover { border-color: var(--accent); }
.guild img, .icon-fallback { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.icon-fallback { display: grid; place-items: center; background: var(--border); font-weight: 700; }
.guild .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--text); }

.guild-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.guild-head img { width: 56px; height: 56px; border-radius: 50%; }
.guild-head h1 { margin: 0; }
.crumb { margin: 0; color: var(--muted); }

.notice { border: 1px solid; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice.ok { background: var(--ok-bg); border-color: var(--ok-border); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.notice.error { background: var(--err-bg); border-color: var(--err-border); }

.settings label { display: block; margin-top: 14px; font-weight: 600; }
.settings label .muted { font-weight: 400; }
.settings input, .settings select, .settings textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit;
}
.settings select[multiple] { min-height: 140px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

table.rows { width: 100%; border-collapse: collapse; margin: 6px 0 8px; }
table.rows th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.85rem; padding: 4px 6px; }
table.rows td { padding: 4px 6px; vertical-align: middle; }
table.rows td input, table.rows td select { margin-top: 0; }
table.rows td:last-child { width: 1%; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

.actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  table.rows.wide { display: block; overflow-x: auto; }
  table.rows.wide td select { min-width: 120px; }
}
