:root {
    color-scheme: light dark;
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1e1f22;
    --muted: #5c5e66;
    --line: #e3e5e8;
    --accent: #5865f2;
    --on: #248046;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1e1f22;
        --card: #2b2d31;
        --text: #f2f3f5;
        --muted: #a5a8ad;
        --line: #3a3c42;
    }
}

body { margin: 0; background: var(--bg); color: var(--text); }
main { max-width: 56rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
h1 { font-size: 1.6rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
code { font-size: 0.9em; }
.muted { color: var(--muted); }

.top { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.05em; }
.top .who { margin-left: auto; color: var(--muted); }
.top form { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem; padding: 1.25rem; margin-bottom: 1rem; }
.center { text-align: center; max-width: 24rem; margin: 4rem auto; }

.button { display: inline-block; background: var(--accent); color: #fff; padding: 0.6rem 1.2rem; border-radius: 0.5rem; text-decoration: none; font-weight: 600; }
button.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

.guilds { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.75rem; }
.guilds a { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem; color: var(--text); text-decoration: none; }
.guilds a:hover { border-color: var(--accent); }
.guilds img, .guilds .initial { width: 2.5rem; height: 2.5rem; border-radius: 50%; flex: none; }
.guilds .initial { display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; }

.modules { list-style: none; padding: 0; margin: 0; }
.modules li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.modules li:first-child { border-top: none; }
.modules div { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }

.toggle { min-width: 4rem; padding: 0.4rem 0.8rem; border-radius: 1rem; border: 1px solid var(--line); font-weight: 600; cursor: pointer; background: var(--bg); color: var(--muted); }
.toggle.on { background: var(--on); border-color: var(--on); color: #fff; }
.toggle:disabled { cursor: default; opacity: 0.6; }

.crumbs { margin: 0; color: var(--muted); }
.crumbs a, .links a { color: var(--accent); text-decoration: none; }
.links { list-style: none; padding: 0; margin: 0; columns: 2 14rem; }
.links li { padding: 0.25rem 0; }

.field { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.card h2 + .field, .card > .field:first-child { border-top: none; }
.field label { font-weight: 600; }
.field label.check { display: flex; align-items: center; gap: 0.5rem; }
.field input:not([type=checkbox]), .field select { font: inherit; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 0.4rem; background: var(--bg); color: var(--text); max-width: 24rem; }
.field input[type=number] { width: 9rem; }
.field .with-unit { display: flex; align-items: center; gap: 0.5rem; }
.field.invalid input, .field.invalid select { border-color: #da373c; }
.field .problem { color: #da373c; }
.field input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

.notice { padding: 0.6rem 0.8rem; border-radius: 0.5rem; }
.notice.good { background: color-mix(in srgb, var(--on) 18%, transparent); }
.notice.bad { background: color-mix(in srgb, #da373c 18%, transparent); }
form > .button { border: none; cursor: pointer; font: inherit; }

.guildnav { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.5rem; }
.guildnav a { padding: 0.35rem 0.75rem; border-radius: 1rem; color: var(--muted); text-decoration: none; }
.guildnav a:first-child { font-weight: 600; color: var(--text); }
.guildnav a.here { background: var(--card); color: var(--text); border: 1px solid var(--line); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.row select, .row input, .filters select, .filters input { font: inherit; padding: 0.35rem 0.5rem; border: 1px solid var(--line); border-radius: 0.4rem; background: var(--bg); color: var(--text); }
.grow { flex: 1; min-width: 12rem; }
.filters { margin-bottom: 1rem; }
.check { display: inline-flex; align-items: center; gap: 0.4rem; }
.button.small { padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
button.button { border: none; cursor: pointer; font: inherit; }
button.button.secondary { border: 1px solid var(--line); }

.perms { list-style: none; padding: 0; margin: 0; }
.perms li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.perms li:first-child { border-top: none; }
.perms li > div:first-child { display: flex; flex-direction: column; gap: 0.15rem; flex: 1 1 18rem; }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 1rem; background: var(--bg); border: 1px solid var(--role, var(--line)); }
.chip button, .chip a { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0; text-decoration: none; }

.table { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem; margin-bottom: 1rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-top: 1px solid var(--line); vertical-align: top; }
thead th { border-top: none; color: var(--muted); font-weight: 600; }
tr.faded td { opacity: 0.6; }
td a { color: var(--accent); text-decoration: none; }
td.details { word-break: break-word; }
blockquote { margin: 0.3rem 0 0; padding-left: 0.6rem; border-left: 3px solid var(--line); white-space: pre-wrap; }

.helper .avatar { width: 3rem; height: 3rem; border-radius: 50%; }
.helper details { margin-top: 0.5rem; }
.helper .row + .row { margin-top: 0.6rem; }
.steps { margin: 0 0 1rem; padding-left: 1.2rem; line-height: 1.6; }
.steps a, .card p a { color: var(--accent); }
.button.danger, button.button.danger { background: #da373c; color: #fff; border: none; }

.personalities { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.6rem; }
.personalities li { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 0.6rem; align-items: center; padding: 0.6rem; border: 1px solid var(--line); border-left: 4px solid var(--role, var(--line)); border-radius: 0.6rem; }
.personalities .avatar, .personalities .initial { grid-row: span 2; width: 2.5rem; height: 2.5rem; border-radius: 50%; }
.personalities .initial { display: grid; place-items: center; background: var(--role, var(--accent)); color: #fff; font-weight: 700; }
.personalities a { color: var(--text); font-weight: 600; text-decoration: none; }
.field textarea { font: inherit; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 0.4rem; background: var(--bg); color: var(--text); width: 100%; box-sizing: border-box; resize: vertical; }
.field .avatar { width: 3rem; height: 3rem; border-radius: 50%; }
.field input[type=color] { width: 3rem; height: 2rem; padding: 0; border: none; background: none; }
