:root {
  --bg-0: #0e0f12;
  --bg-1: #1a1b1f;
  --bg-2: #232529;
  --bg-3: #2d2f35;
  --border: #383a40;
  --border-strong: #4a4d54;
  --text: #f2f3f5;
  --text-dim: #b5bac1;
  --text-faint: #80848e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --accent-soft: rgba(88, 101, 242, 0.12);
  --danger: #ed4245;
  --success: #23a559;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font: 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 120ms;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---- Header ---- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(26, 27, 31, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  text-decoration: none;
}
header .brand:hover { text-decoration: none; color: var(--text); }
header .brand::before {
  content: "";
  display: inline-block;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #5865f2 0%, #7983f5 100%);
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.4);
}
header nav {
  display: flex;
  gap: 18px;
  align-items: center;
  color: var(--text-dim);
  font-size: 13px;
}
header nav a { color: var(--text-dim); }
header nav a:hover { color: var(--text); }

/* ---- Main ---- */
main {
  max-width: 980px;
  margin: 36px auto 96px;
  padding: 0 24px;
}
.narrow { max-width: 520px; }

h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text);
}
.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 28px;
}

/* ---- Flash ---- */
.flash {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
}
.card + .card { margin-top: 18px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.card-header h2 { margin: 0; }

/* ---- Login card ---- */
.center-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
}
.login-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 360px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { margin-bottom: 8px; }
.login-card p { color: var(--text-dim); margin: 0 0 24px; }

/* ---- Server grid ---- */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.server-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 140ms, border-color 140ms, background 140ms;
  cursor: pointer;
}
.server-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-2);
  transform: translateY(-2px);
  text-decoration: none;
}
.server-card .icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text);
  font-size: 16px;
  overflow: hidden;
  object-fit: cover;
}
img.icon { padding: 0; }
.server-card .name {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty-state {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-1);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
}

/* ---- Form layout ---- */
.config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
}
@media (max-width: 880px) {
  .config-grid { grid-template-columns: 1fr; }
  .preview-sticky { position: static !important; }
}

.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-faint);
}

input[type="text"],
input:not([type]),
textarea,
select {
  display: block;
  width: 100%;
  background: var(--bg-0);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  transition: border-color 120ms, box-shadow 120ms;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b5bac1' d='M3 4.5l3 3 3-3z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms, border-color 120ms, transform 80ms;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.full { width: 100%; }
.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

/* ---- Discord embed preview ---- */
.preview-sticky { position: sticky; top: 84px; }
.preview-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.discord-frame {
  background: #313338;
  border: 1px solid #1e1f22;
  border-radius: 8px;
  padding: 16px;
}
.discord-msg-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.discord-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5865f2, #7983f5);
  flex-shrink: 0;
}
.discord-content { flex: 1; min-width: 0; }
.discord-author {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 600; font-size: 14px;
}
.discord-badge {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.discord-timestamp {
  color: #949ba4;
  font-size: 11px;
  margin-left: 6px;
}
.discord-embed {
  display: flex;
  margin-top: 6px;
  background: #2b2d31;
  border-radius: 4px;
  overflow: hidden;
  max-width: 440px;
}
.discord-embed .bar {
  width: 4px;
  background: var(--accent);
  flex-shrink: 0;
}
.discord-embed .body {
  padding: 10px 14px 14px;
  flex: 1;
  min-width: 0;
}
.discord-embed-title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  margin: 4px 0 4px;
  word-wrap: break-word;
}
.discord-embed-desc {
  color: #dbdee1;
  font-size: 13px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.discord-button {
  display: inline-block;
  margin-top: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 3px;
  border: none;
}

/* ---- Color input ---- */
.color-input {
  width: 56px;
  height: 36px;
  padding: 2px;
  background: var(--bg-0);
  cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 1px solid var(--border); border-radius: 4px; }

/* ---- Switch (toggle) ---- */
.switch-row { display: flex; align-items: center; gap: 14px; margin: 0; }
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-3);
  border-radius: 24px;
  transition: background 140ms;
}
.switch .slider::before {
  content: "";
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 140ms;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---- Divider ---- */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* ---- Two-column row inside the same fieldset ---- */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }
