:root {
  --bg: #0f1116;
  --panel: #191c24;
  --panel-2: #20242e;
  --line: #2b2f3a;
  --ink: #e7e9ee;
  --muted: #9aa0ad;
  --accent: #5865f2;
  --accent-2: #4954d6;
  --green: #3ba55d;
  --red: #ed4245;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; min-width: 0; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.userbox img { width: 30px; height: 30px; border-radius: 50%; }

main { max-width: 900px; margin: 0 auto; padding: 24px 20px 80px; }
h2 { margin: 8px 0 18px; }
h3 { margin: 0 0 12px; font-size: 15px; }

.center { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.login-card { max-width: 420px; text-align: center; }
.login-card h1 { margin-top: 0; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; margin-bottom: 16px;
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-wide { grid-column: 1 / -1; }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; } }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
select, textarea, input[type="text"] {
  width: 100%; margin-top: 6px; padding: 9px 10px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  font-size: 14px; font-family: inherit;
}
input[type="number"], input[type="search"], input:not([type]) { font-size: 16px; }
@media (max-width: 680px) { select, textarea, input { font-size: 16px !important; } }
select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { resize: vertical; }
.row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; margin: 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: none; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  text-decoration: none; color: #fff; font-family: inherit;
}
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.guild-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 12px; cursor: pointer; color: var(--ink); font-size: 14px; font-family: inherit;
  transition: border-color .15s, transform .1s;
}
.guild-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.guild-card img, .guild-fallback {
  width: 60px; height: 60px; border-radius: 50%; object-fit: cover;
}
.guild-fallback {
  display: grid; place-items: center; background: var(--accent); font-size: 26px; font-weight: 700;
}
.guild-card span { text-align: center; word-break: break-word; }

.actions { margin-top: 8px; }
.notice {
  background: rgba(237,66,69,.12); border: 1px solid rgba(237,66,69,.35);
  color: #ffb3b5; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px;
}

.spinner {
  width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; color: #fff; z-index: 20;
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
