:root {
  --bg: #0f1115;
  --bg-alt: #171a21;
  --bg-card: #1c1f27;
  --border: #2a2e38;
  --text: #e6e8ec;
  --text-dim: #9aa0ac;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #57f287;
  --danger: #ed4245;
  --warning: #fee75c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  text-align: center;
  padding: 20px;
}

.brand {
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.btn.secondary:hover { background: #23262f; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #c53537; }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .guild-name {
  font-weight: 700;
  font-size: 16px;
  padding: 0 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  word-break: break-word;
}
.sidebar a.nav-link {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar a.nav-link:hover { background: var(--bg-card); color: var(--text); }
.sidebar a.nav-link.active { background: var(--accent); color: white; }
.sidebar .back-link { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 13px; }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1100px;
}

.page-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.page-subtitle { color: var(--text-dim); margin-bottom: 28px; font-size: 14px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
input[type=text], input[type=number], input[type=color], input[type=url], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 14px;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.field-row { display: flex; gap: 10px; align-items: center; }

.guild-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.guild-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.guild-tile img.icon, .guild-tile .icon-fallback {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px;
}
.guild-tile .name { font-weight: 600; font-size: 15px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 700; }
.badge.on { background: rgba(87,242,135,0.15); color: var(--success); }
.badge.off { background: rgba(154,160,172,0.15); color: var(--text-dim); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.panel-item { border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 12px; background: var(--bg); }
.binding-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.binding-row:last-child { border-bottom: none; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; max-height: 160px; overflow-y: auto; padding: 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; background: var(--bg); }
.emoji-picker img { width: 24px; height: 24px; }
.emoji-btn { padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; background: transparent; font-size: 18px; }
.emoji-btn:hover { background: var(--bg-card); border-color: var(--border); }
.emoji-btn.selected { background: var(--accent); }

.embed-preview {
  border-left: 4px solid var(--accent);
  background: #2b2d31;
  border-radius: 6px;
  padding: 14px 16px;
  max-width: 480px;
}
.embed-preview .title { font-weight: 700; margin-bottom: 6px; }
.embed-preview .desc { font-size: 14px; white-space: pre-wrap; color: #dbdee1; }
.embed-preview img.thumb { float: right; width: 70px; height: 70px; border-radius: 6px; object-fit: cover; margin-left: 10px; }
.embed-preview img.full { width: 100%; border-radius: 6px; margin-top: 10px; }
.embed-preview .field { margin-top: 8px; }
.embed-preview .field .fname { font-weight: 700; font-size: 13px; }
.embed-preview .field .fvalue { font-size: 13px; color: #dbdee1; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--bg-card); border: 1px solid var(--border); padding: 12px 18px; border-radius: 8px; font-size: 14px; z-index: 999; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }

.muted { color: var(--text-dim); font-size: 13px; }
.hint { color: var(--text-dim); font-size: 12px; margin-top: -8px; margin-bottom: 12px; }
