:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5b6370;
  --border: #d9dce1;
  --accent: #5865f2;
  --accent-text: #ffffff;
  --ok-bg: #e3f6ec;
  --ok-text: #11643a;
  --err-bg: #fde8e8;
  --err-text: #9b1c1c;
  --warn: #9a5b00;
  --hover: rgb(0 0 0 / 0.05);
  --accent-soft: rgb(88 101 242 / 0.12);
  --shadow: 0 10px 30px rgb(0 0 0 / 0.12), 0 2px 6px rgb(0 0 0 / 0.06);
  color-scheme: light;
}

/* Dark follows the system unless the toggle saved a choice (data-theme on <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b;
    --surface: #212226;
    --text: #e8e9eb;
    --muted: #a0a5ad;
    --border: #34363c;
    --accent: #6d78f5;
    --ok-bg: #173a29;
    --ok-text: #8fe0b2;
    --err-bg: #43191b;
    --err-text: #f6aaaa;
    --warn: #f0b45a;
    --hover: rgb(255 255 255 / 0.06);
    --accent-soft: rgb(109 120 245 / 0.18);
    --shadow: 0 10px 30px rgb(0 0 0 / 0.45), 0 2px 6px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17181b;
  --surface: #212226;
  --text: #e8e9eb;
  --muted: #a0a5ad;
  --border: #34363c;
  --accent: #6d78f5;
  --ok-bg: #173a29;
  --ok-text: #8fe0b2;
  --err-bg: #43191b;
  --err-text: #f6aaaa;
  --warn: #f0b45a;
  --hover: rgb(255 255 255 / 0.06);
  --accent-soft: rgb(109 120 245 / 0.18);
  --shadow: 0 10px 30px rgb(0 0 0 / 0.45), 0 2px 6px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Column layout keeps the footer at the bottom of short pages */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 920px;
  margin: 0 auto;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.brand img { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.brand-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tag {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.topnav { display: flex; gap: 4px; }
.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.topnav a:hover { background: var(--hover); color: var(--text); }
.topnav a[aria-current="page"] { color: var(--text); background: var(--hover); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon { width: 18px; height: 18px; flex: none; }

/* Theme toggle: the sun shows in light mode, the moon in dark, and they swap with a spin.
   Driven by the effective theme in CSS, so following the system needs no JavaScript. */
.theme-toggle { width: 38px; justify-content: center; padding: 0; text-decoration: none; }
.theme-icons { position: relative; width: 18px; height: 18px; transition: transform 0.1s; }
.theme-icons .icon { position: absolute; inset: 0; transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s; }
.theme-icons .icon:first-child { color: #e8a317; }
.theme-icons .icon:last-child { color: #a5adff; opacity: 0; transform: rotate(-90deg) scale(0.4); }
:root[data-theme="dark"] .theme-icons .icon:first-child { opacity: 0; transform: rotate(90deg) scale(0.4); }
:root[data-theme="dark"] .theme-icons .icon:last-child { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icons .icon:first-child { opacity: 0; transform: rotate(90deg) scale(0.4); }
  :root:not([data-theme="light"]) .theme-icons .icon:last-child { opacity: 1; transform: none; }
}
.theme-toggle:active .theme-icons { transform: scale(0.85); }
.theme-switching, .theme-switching *:not(.icon), .theme-switching *::before, .theme-switching *::after {
  transition: background-color 0.3s, border-color 0.3s, color 0.3s !important;
}

.avatar { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.avatar-fallback { display: grid; place-items: center; background: var(--accent); color: var(--accent-text); font-size: 0.8rem; font-weight: 700; }
.flag { width: 22px; height: 16px; border-radius: 3px; object-fit: cover; flex: none; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12); }

/* Dropdowns: <details class="menu"> with a pill summary */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.pill:hover { background: var(--hover); }
.pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill > .icon:last-child { width: 16px; height: 16px; color: var(--muted); transition: transform 0.15s; }
.menu[open] > .pill { border-color: var(--accent); }
.menu[open] > .pill > .icon:last-child { transform: rotate(180deg); }
.user-pill { padding-left: 5px; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 190px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: menu-in 0.12s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .menu-list { animation: none; } .pill, .pill > .icon:last-child, .theme-icons, .theme-icons .icon { transition: none; } }
.menu-list a, .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-list a:hover, .menu-item:hover { background: var(--hover); }
.menu-list a:focus-visible, .menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu-list a > span { flex: 1; }
.menu-list a > .icon { color: var(--accent); }
.menu-list a[aria-current="true"] { font-weight: 700; }
.menu-heading { margin: 0; padding: 6px 10px 8px; color: var(--muted); font-size: 0.8rem; border-bottom: 1px solid var(--border); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-list form { margin: 0; }
.menu-item.danger { color: var(--err-text); }
.menu-item.danger:hover { background: var(--err-bg); }

@media (max-width: 600px) {
  .topbar-inner { gap: 8px; }
  .brand-tag, .topnav span, .user-name { display: none; }
  .topnav a { padding: 8px; }
}
@media (max-width: 380px) {
  .brand-name { display: none; }
}

main { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 0; }
.muted, small { color: var(--muted); }
small { display: block; margin-top: 4px; font-size: 0.85rem; }
small.warn { color: var(--warn); }

.hero { text-align: center; padding: 40px 0 48px; }
.hero h1 { font-size: 2.2rem; margin-bottom: 4px; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 24px; }
.hero .hero-tagline { color: var(--accent); font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; }
.hero-avatar { width: 96px; height: 96px; border-radius: 50%; margin-bottom: 16px; box-shadow: 0 0 0 6px var(--accent-soft), var(--shadow); }
.hero-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }
.hero-actions .button { border-radius: 999px; padding: 11px 22px; }

.intro-section { margin-bottom: 40px; }
.intro-section > h2 { font-size: 1.3rem; margin-bottom: 16px; text-align: center; }
.feature-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; transition: border-color 0.15s, transform 0.15s; }
.feature:hover { border-color: var(--accent); transform: translateY(-2px); }
.feature h3 { font-size: 1rem; margin: 12px 0 6px; }
.feature p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.feature-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.feature-icon .icon { width: 20px; height: 20px; }
@media (prefers-reduced-motion: reduce) { .feature { transition: none; } .feature:hover { transform: none; } }

.steps { counter-reset: step; list-style: none; margin: 0 auto; padding: 0; max-width: 560px; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 12px; }
.steps li::before {
  content: counter(step);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.85rem;
}

.site-footer { display: flex; width: 100%; justify-content: center; flex-wrap: wrap; gap: 8px 24px; max-width: 920px; margin: 0 auto; padding: 20px 16px 32px; border-top: 1px solid var(--border); font-size: 0.88rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.site-footer a[aria-current="page"] { color: var(--text); }

.legal { max-width: 720px; margin: 0 auto; line-height: 1.65; }
.legal h1 { font-size: 2rem; margin-bottom: 8px; }
.legal h2 { font-size: 1.25rem; margin: 32px 0 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.legal h3 { font-size: 1.05rem; margin: 24px 0 8px; }
.legal p, .legal ul, .legal ol { margin: 0 0 14px; }
.legal li { margin-bottom: 6px; }
.legal li > p { margin: 0; }
.legal table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 0.92rem; display: block; overflow-x: auto; }
.legal th, .legal td { text-align: left; padding: 8px 12px; border: 1px solid var(--border); }
.legal th { background: var(--surface); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.08); }
.button-sm { padding: 7px 14px; font-size: 0.9rem; border-radius: 999px; }
.button.discord { background: #5865f2; color: #fff; }
.button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

.flash { padding: 10px 14px; border-radius: 6px; margin: 0 0 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

.guild-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.guild-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.guild-list a:hover { border-color: var(--accent); }
.guild-list a.add-bot { border-style: dashed; color: var(--accent); }
.guild-list img, .icon-fallback { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.icon-fallback { display: grid; place-items: center; background: var(--accent); color: var(--accent-text); }

.crumbs { margin: 0 0 8px; color: var(--muted); }
.guild-title { display: flex; align-items: center; gap: 12px; }
.guild-title img { width: 40px; height: 40px; border-radius: 50%; }

.settings { margin: 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.card > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card > p { margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
.grid label:first-child, .card > header label { margin-top: 0; }
label.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
label.switch.inline { display: flex; margin-top: 12px; }
.grid label.switch.inline:first-child { margin-top: 0; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

select, input[type="number"], input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
select.narrow { max-width: 320px; }
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.actions { display: flex; justify-content: flex-end; margin: 8px 0 24px; }
.card .actions { margin-bottom: 0; }

@media (max-width: 520px) {
  .actions .button { width: 100%; }
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 16px; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

textarea, input[type="url"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
textarea:focus, input[type="url"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="color"] { width: 64px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.static-field { margin: 0; padding: 8px 0; font-weight: 600; }

.sent-list { list-style: none; margin: 0 0 8px; padding: 0; }
.sent-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.sent-list li:first-child { border-top: 0; }
.sent-list li > div:first-child { min-width: 0; }
.sent-list .preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 12px; flex: none; }
