:root {
  color-scheme: dark;
  --bg: #0a0f1d;
  --surface: #121a2d;
  --surface-2: #18223a;
  --border: #243152;
  --text: #e7eaf3;
  --muted: #8e99b5;
  --primary: #3b6ff6;
  --primary-hover: #5a86ff;
  --discord: #5865f2;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 14px;
  --shadow: 0 12px 32px rgb(0 0 0 / 35%);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 0% -10%, rgb(59 111 246 / 18%), transparent 60%),
    radial-gradient(900px 480px at 110% 0%, rgb(155 89 182 / 12%), transparent 60%),
    var(--bg);
}

a {
  color: var(--primary-hover);
  text-decoration: none;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: 1.7rem;
}

h2 {
  font-size: 1.1rem;
}

.muted {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgb(10 15 29 / 85%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-badge {
  padding: 3px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1f4e8c, var(--primary));
  font-size: 0.8rem;
  letter-spacing: 0.1em;
}

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

.user-name {
  font-weight: 600;
}

.avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.loading,
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-discord {
  padding: 12px 22px;
  background: var(--discord);
  font-size: 1rem;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.82rem;
}

.btn-discord:hover {
  background: #6d78f5;
}

.hero {
  max-width: 520px;
  margin: 64px auto;
  padding: 48px 32px;
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.hero-logo {
  width: 112px;
  height: 112px;
  border-radius: 24px;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgb(0 0 0 / 40%));
}

.alert {
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
}

.alert-error {
  background: rgb(239 68 68 / 12%);
  border: 1px solid rgb(239 68 68 / 40%);
  color: #fca5a5;
}

.page-header {
  display: grid;
  gap: 4px;
  margin-bottom: 24px;
}

.page-header p {
  margin: 0;
}

.guild-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back {
  display: inline-block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.guild-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.guild-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 16px;
  color: var(--text);
  text-align: center;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.guild-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.guild-card-invite {
  opacity: 0.7;
}

.guild-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: cover;
}

.guild-icon-fallback {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 700;
  color: var(--muted);
}

.guild-name {
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-success {
  background: rgb(34 197 94 / 12%);
  border-color: rgb(34 197 94 / 40%);
  color: #86efac;
}

.badge-bot {
  background: var(--discord);
  border-color: var(--discord);
  color: #fff;
  font-size: 0.68rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tab {
  padding: 8px 14px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

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

.tab.active {
  background: var(--primary);
  color: #fff;
}

.tab-content {
  display: grid;
  gap: 20px;
}

.section {
  padding: 22px 24px;
}

.section-description {
  margin: 6px 0 0;
  font-size: 0.92rem;
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-label {
  font-weight: 600;
  font-size: 0.92rem;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

input[type='text'],
input[type='number'],
input[type='time'],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgb(59 111 246 / 55%);
  outline-offset: 1px;
  border-color: var(--primary);
}

.color-input {
  width: 64px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.15s ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle-text {
  display: grid;
}

.multi {
  display: grid;
  gap: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.86rem;
}

.chip-remove {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}

.chip-remove:hover {
  background: rgb(239 68 68 / 20%);
  color: #fca5a5;
}

.emoji-picker {
  max-width: 320px;
}

.multi-bulk {
  display: flex;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.save-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1052px, calc(100% - 32px));
  padding: 12px 16px 12px 20px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.save-bar.dirty {
  border-color: rgb(245 158 11 / 60%);
}

.save-bar.dirty .save-status {
  color: #fcd34d;
}

.save-status {
  color: var(--muted);
  font-weight: 600;
}

.save-actions {
  display: flex;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr.clickable {
  cursor: pointer;
}

.table-form td {
  padding: 8px 10px;
  white-space: normal;
  vertical-align: middle;
}

.table-form input {
  min-width: 150px;
}

.row-label {
  width: 44px;
  font-size: 1.3rem;
  text-align: center;
}

.group-list {
  display: grid;
  gap: 10px;
}

.group-items {
  display: grid;
  gap: 14px;
}

.group-item {
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}

.group-item.collapsed {
  gap: 0;
}

.group-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.group-item-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.group-item-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-item-toggle {
  flex-shrink: 0;
  color: var(--muted);
  width: 12px;
}

.group-item .fields {
  margin-top: 4px;
}

.group-add {
  justify-self: start;
}

.module-pages {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.page-intro {
  margin: 0;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.module-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.15s ease;
  opacity: 0.75;
}

.module-card.enabled {
  border-color: var(--primary);
  opacity: 1;
}

.module-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 1.5rem;
}

.module-text {
  display: grid;
  gap: 2px;
  flex: 1;
}

.switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch input:checked + .toggle-track {
  background: var(--primary);
  border-color: var(--primary);
}

.switch input:checked + .toggle-track::after {
  transform: translateX(20px);
  background: #fff;
}

.switch input:focus-visible + .toggle-track {
  outline: 2px solid rgb(59 111 246 / 55%);
  outline-offset: 2px;
}

.table tr.clickable:hover td {
  background: var(--surface-2);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.transcript-header {
  margin: 8px 0 20px;
  padding: 22px 24px;
}

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 24px;
  margin: 18px 0 0;
}

.meta-item dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta-item dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.messages {
  display: grid;
  gap: 2px;
  padding: 12px;
}

.message {
  display: flex;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 10px;
}

.message:hover {
  background: var(--surface-2);
}

.message-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.message-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.message-header time {
  font-size: 0.8rem;
}

.message-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.embed {
  display: grid;
  gap: 6px;
  max-width: 560px;
  padding: 10px 14px;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  background: var(--surface-2);
}

.embed-field-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.attachment-image {
  max-width: 320px;
  max-height: 240px;
  border-radius: 8px;
}

.toasts {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 30;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100% - 40px));
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}

.toast ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.toast-success {
  border-color: rgb(34 197 94 / 50%);
}

.toast-error {
  border-color: rgb(239 68 68 / 60%);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (max-width: 720px) {
  .container {
    padding: 20px 14px 140px;
  }

  .fields {
    grid-template-columns: 1fr;
  }

  .user-name {
    display: none;
  }

  .save-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .save-actions {
    justify-content: flex-end;
  }
}

.alert-warning {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  background: rgb(245 158 11 / 12%);
  border: 1px solid rgb(245 158 11 / 40%);
  color: #fcd34d;
}

.alert-warning ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  font-size: 0.9rem;
}

.tab-badge {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgb(245 158 11 / 20%);
  color: #fcd34d;
  font-size: 0.75rem;
}

.audit-entry {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 18px 22px;
}

.audit-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.audit-header strong {
  font-size: 1rem;
}

.audit-header .muted {
  font-size: 0.86rem;
}

.audit-badge {
  padding: 1px 9px;
  border-radius: 999px;
  background: rgb(59 111 246 / 20%);
  color: var(--primary-hover);
  font-size: 0.75rem;
  font-weight: 600;
}

.audit-changes {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-changes li {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.audit-changes summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  border-radius: 10px;
}

.audit-changes summary:hover {
  background: var(--surface-2);
}

.audit-scope {
  color: var(--muted);
  font-size: 0.86rem;
}

.audit-key {
  font-weight: 600;
}

.audit-diffs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 4px 14px 14px;
}

.audit-diff {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.audit-diff-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.audit-diff.before .audit-diff-label {
  color: #fca5a5;
}

.audit-diff.after .audit-diff-label {
  color: #86efac;
}

.audit-diff pre {
  margin: 0;
  padding: 8px 10px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.82rem;
}

@media (max-width: 700px) {
  .audit-diffs {
    grid-template-columns: 1fr;
  }
}

.backup-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.embed-preview {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.embed-preview-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.embed-preview-inner {
  flex: 1;
  min-width: 0;
  padding: 2px 0 2px 12px;
  border-left: 4px solid #1f4e8c;
  display: grid;
  gap: 8px;
}

.embed-preview-author {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.88rem;
}

.embed-preview-author img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

.embed-preview-title {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

a.embed-preview-title:hover {
  text-decoration: underline;
}

.embed-preview-description {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  color: var(--text);
}

.embed-preview-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.embed-preview-field {
  flex: 1 1 100%;
  min-width: 0;
}

.embed-preview-field.inline {
  flex: 1 1 calc(33.33% - 8px);
  min-width: 120px;
}

.embed-preview-field-name {
  font-weight: 600;
  font-size: 0.86rem;
}

.embed-preview-field-value {
  font-size: 0.86rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.embed-preview-image {
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 6px;
}

.embed-preview-thumbnail {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.embed-preview-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.embed-preview-footer img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
}

.log-action {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
}

.log-action.success {
  background: rgb(34 197 94 / 12%);
  border-color: rgb(34 197 94 / 40%);
  color: #86efac;
}

.log-action.info {
  background: rgb(59 111 246 / 15%);
  border-color: rgb(59 111 246 / 40%);
  color: var(--primary-hover);
}

.log-action.danger {
  background: rgb(239 68 68 / 12%);
  border-color: rgb(239 68 68 / 40%);
  color: #fca5a5;
}
