:root {
  --bg: #15161b;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(88, 101, 242, 0.12), transparent),
    radial-gradient(900px 500px at -10% 110%, rgba(88, 101, 242, 0.08), transparent);
  --panel: #1e2027;
  --panel-2: #262832;
  --panel-3: #2d303b;
  --border: #34363f;
  --border-soft: #2a2c35;
  --text: #eef0f5;
  --muted: #8b8e9c;
  --muted-2: #6a6d7a;
  --accent: #5865f2;
  --accent-2: #7983f5;
  --accent-hover: #4752c4;
  --danger: #f2495c;
  --success: #57f287;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, system-ui, sans-serif;
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 40px;
  text-align: center;
  width: 340px;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(88, 101, 242, 0.35);
}

.login-card h1 {
  font-size: 1.35rem;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.login-card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 26px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(88, 101, 242, 0.32);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(88, 101, 242, 0.4); }
.btn:active { transform: translateY(0); }
.btn.secondary {
  background: var(--panel-3);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:hover { background: var(--panel-2); box-shadow: none; }
.btn.icon-only { padding: 9px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 14px; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(30, 32, 39, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(88, 101, 242, 0.35);
}

.brand-text h1 {
  font-size: 0.98rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--muted);
}

header.topbar .user { display: flex; align-items: center; gap: 14px; }

.guild-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.guild-select-wrap svg {
  position: absolute;
  left: 10px;
  pointer-events: none;
  color: var(--muted);
}

.guild-select {
  appearance: none;
  width: auto;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 30px 7px 30px;
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
}

.guild-select-wrap::after {
  content: '';
  position: absolute;
  right: 11px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 22px;
  padding: 28px;
  max-width: 1220px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.panel-head svg { color: var(--accent-2); flex-shrink: 0; }
.panel-head h2 { font-size: 0.95rem; margin: 0; font-weight: 700; letter-spacing: -0.01em; }

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
  margin: 22px 0 12px;
}
.section-label:first-of-type { margin-top: 0; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }

input[type="text"], input[type="url"], select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
}

input[type="text"]:focus, input[type="url"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-3);
}

input::placeholder, textarea::placeholder { color: var(--muted-2); }

textarea { min-height: 110px; resize: vertical; line-height: 1.5; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.combo { position: relative; }

.combo-input { cursor: text; }

.combo-list {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 30;
  padding: 4px;
}

.combo-list.open { display: block; }

.combo-item {
  padding: 8px 10px;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combo-item:hover, .combo-item.active { background: var(--accent); color: white; }

.combo-empty {
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--muted-2);
}

.mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 6px;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.mode-btn:hover { color: var(--text); }

.mode-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.submit-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

.raw-preview {
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 0.88rem;
  white-space: pre-wrap;
  color: #dcdde0;
  line-height: 1.5;
}

.discord-mock {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.discord-mock .dm-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.discord-mock .dm-bot-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex-shrink: 0;
}

.discord-mock .dm-name { font-size: 0.82rem; font-weight: 600; }
.discord-mock .dm-tag {
  font-size: 0.62rem;
  background: var(--accent);
  color: white;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
}

.embed-preview {
  border-left: 4px solid var(--accent);
  background: var(--panel-3);
  border-radius: 4px;
  padding: 12px 14px;
}

.embed-preview .e-title { font-weight: 700; margin-bottom: 6px; font-size: 0.92rem; }
.embed-preview .e-desc { font-size: 0.86rem; white-space: pre-wrap; color: #dcdde0; line-height: 1.5; }
.embed-preview .e-footer { font-size: 0.72rem; color: var(--muted); margin-top: 12px; }
.embed-preview img { max-width: 100%; border-radius: 6px; margin-top: 10px; display: block; }

.history-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.history-item:last-child { border-bottom: none; padding-bottom: 0; }
.history-item:first-child { padding-top: 0; }

.history-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--panel-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-2);
}

.history-body { min-width: 0; flex: 1; }
.history-item .h-title {
  font-weight: 600;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item .h-meta { color: var(--muted); font-size: 0.75rem; margin-top: 3px; }

.empty-state {
  color: var(--muted-2);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px 0;
}

.status-msg {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-msg.ok { color: var(--success); }
.status-msg.err { color: var(--danger); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  header.topbar { padding: 12px 16px; }
}
