:root {
  --bg: #1e1f22;
  --bg-elevated: #2b2d31;
  --bg-input: #313338;
  --border: #3f4147;
  --text: #dbdee1;
  --text-muted: #949ba4;
  --text-bright: #f2f3f5;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #ed4245;
  --danger-hover: #c53537;
  --success: #23a55a;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: #00a8fc; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text-bright); font-size: 18px; }
.brand:hover { text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 16px; flex: 1; }
.topnav a { color: var(--text); }
.guild-name { color: var(--text-bright); font-weight: 600; margin-right: 8px; }
.logout-form { margin-left: auto; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

h1 { color: var(--text-bright); font-size: 24px; margin: 0 0 4px; }
h2 { color: var(--text-bright); font-size: 18px; margin: 0 0 12px; }
.subtitle { color: var(--text-muted); margin-bottom: 24px; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } }

label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .02em; }
label:first-child { margin-top: 0; }

input[type=text], input[type=password], input[type=url], input[type=number], textarea, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 80px; resize: vertical; }
select[multiple] { min-height: 110px; }
input[type=color] { width: 60px; height: 36px; padding: 2px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px; }
.hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-input); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; margin-top: 20px; }

.list { list-style: none; padding: 0; margin: 0; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-title { color: var(--text-bright); font-weight: 600; }
.list-item-meta { color: var(--text-muted); font-size: 13px; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { display: inline; }

.empty { color: var(--text-muted); padding: 16px 0; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-muted);
}
.badge-open { background: rgba(35,165,90,.15); color: var(--success); }
.badge-claimed { background: rgba(88,101,242,.15); color: var(--accent); }
.badge-closed { background: rgba(237,66,69,.15); color: var(--danger); }

.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.guild-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--text-bright);
}
.guild-card:hover { border-color: var(--accent); text-decoration: none; }
.guild-card img { width: 56px; height: 56px; border-radius: 50%; margin-bottom: 10px; background: var(--bg-input); }

.login-wrap { max-width: 340px; margin: 90px auto; }
.error { color: var(--danger); margin-bottom: 12px; font-size: 14px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.field-row select { min-height: unset; }

.embed-builder-layout { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .embed-builder-layout { grid-template-columns: 1fr; } }

.discord-embed-preview {
  background: #313338;
  border-radius: 8px;
  padding: 16px;
  border-left: 4px solid var(--accent);
}
.discord-embed-preview .author { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-bright); font-size: 14px; margin-bottom: 4px; }
.discord-embed-preview .author img { width: 20px; height: 20px; border-radius: 50%; }
.discord-embed-preview .title { color: #00a8fc; font-weight: 700; margin-bottom: 4px; }
.discord-embed-preview .desc { color: var(--text); white-space: pre-wrap; font-size: 14px; }
.discord-embed-preview .fields { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.discord-embed-preview .fields.has-inline { grid-template-columns: 1fr 1fr; }
.discord-embed-preview .field-name { font-weight: 700; color: var(--text-bright); font-size: 13px; }
.discord-embed-preview .field-value { font-size: 13px; color: var(--text); white-space: pre-wrap; }
.discord-embed-preview .thumb { float: right; width: 80px; height: 80px; border-radius: 4px; object-fit: cover; margin-left: 12px; }
.discord-embed-preview .image { width: 100%; border-radius: 4px; margin-top: 10px; }
.discord-embed-preview .footer { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--text-muted); font-size: 12px; }
.discord-embed-preview .footer img { width: 18px; height: 18px; border-radius: 50%; }
.sticky { position: sticky; top: 20px; }

/* Role picker */
.role-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 2px;
}
.role-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}
.role-chip:hover { border-color: var(--role-color, var(--accent)); }
.role-chip input { display: none; }
.role-chip .role-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--role-color, var(--text-muted));
  flex-shrink: 0;
}
.role-chip .role-icon { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; }
.role-chip:has(input:checked) {
  border-color: var(--role-color, var(--accent));
  background: color-mix(in srgb, var(--role-color, var(--accent)) 18%, var(--bg-input));
  color: var(--text-bright);
}

/* Panel display style choice */
.style-choice { display: flex; gap: 12px; }
.style-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
}
.style-option input { margin: 0; }
.style-option:has(input:checked) { border-color: var(--accent); background: rgba(88,101,242,.12); }
.style-option .style-title { color: var(--text-bright); font-weight: 600; font-size: 14px; }
.style-option .style-desc { color: var(--text-muted); font-size: 12px; }

/* Bot status badge */
.bot-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.bot-status .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bot-status.online .dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.bot-status.offline .dot { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
