:root {
    --bg: #13151a;
    --panel: #1c1f26;
    --border: #2a2e38;
    --text: #e6e8ee;
    --muted: #8b90a0;
    --accent: #c2185b;
    --accent-hover: #e91e63;
    --ok: #2e9e5b;
    --bad: #d33c3c;
    --warn: #d9922a;
    --discord: #5865f2;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #0e1014; padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.9em; }

.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.topbar .brand { color: var(--text); font-weight: 600; font-size: 1.1rem; }
.topbar .brand span { color: var(--accent-hover); font-weight: 400; }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--text); }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; color: var(--muted); }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

h1 { margin: 0 0 1rem; font-size: 1.6rem; }
h2 { margin: 0 0 0.75rem; font-size: 1.1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
}
.card.center { max-width: 480px; margin: 4rem auto; text-align: center; }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; padding: 1rem; display: flex; flex-direction: column; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.6rem; font-weight: 600; }
.stat.ok { border-left-color: var(--ok); }
.stat.bad { border-left-color: var(--bad); }
.stat.warn { border-left-color: var(--warn); }

.search { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search input { flex: 1; }

input[type="text"], input[type="search"], input[type="number"] {
    background: #0e1014;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font: inherit;
    width: 100%;
}
input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

label { display: block; margin-bottom: 0.9rem; color: var(--muted); font-size: 0.9rem; }
label input { margin-top: 0.3rem; }
label.check { display: flex; align-items: center; gap: 0.5rem; color: var(--text); }
label.check input { margin: 0; width: auto; }

button {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 0.55rem 1.1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button.link { background: none; color: var(--muted); padding: 0; font-weight: 400; }
button.link:hover { color: var(--text); text-decoration: underline; }
button.discord { background: var(--discord); width: 100%; padding: 0.75rem; }
button.discord:hover { background: #4752c4; }
button.steam { background: #171a21; border: 1px solid #3a4150; }
button.steam:hover { background: #2a475e; }
button.secondary { background: var(--border); color: var(--text); font-weight: 500; }
button.secondary:hover { background: #3a3f4c; }

select {
    background: #0e1014;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font: inherit;
    width: 100%;
}
select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

h2.section { margin-top: 2rem; }

.viewas { display: flex; align-items: center; gap: 0.25rem; background: #0e1014; border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.3rem 0.2rem 0.75rem; }
.viewas .label { font-size: 0.8rem; color: var(--muted); margin-right: 0.25rem; }
.viewas button { background: none; color: var(--muted); padding: 0.25rem 0.7rem; border-radius: 999px; font-size: 0.85rem; font-weight: 500; }
.viewas button:hover { color: var(--text); background: var(--border); }
.viewas button.on { background: var(--accent); color: #fff; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1, .page-head h2 { margin: 0; }
a.button { display: inline-block; background: var(--accent); color: #fff; border-radius: 6px; padding: 0.5rem 1rem; font-weight: 600; }
a.button:hover { background: var(--accent-hover); text-decoration: none; }

.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 4px; font-weight: 600; color: var(--badge, #fff); background: color-mix(in srgb, var(--badge, #fff) 14%, transparent); border: 1px solid color-mix(in srgb, var(--badge, #fff) 50%, transparent); }

textarea { background: #0e1014; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.65rem; font: inherit; width: 100%; resize: vertical; }
textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.perms { margin-top: 1rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.25rem 1rem; }
.perm-grid label { margin-bottom: 0.35rem; }

.node-group { border-top: 1px solid var(--border); padding-top: 0.75rem; margin-top: 0.75rem; }
.node-group .perm-grid { margin-left: 1.5rem; }
label.wildcard { margin-bottom: 0.5rem; }
.perms textarea { margin-top: 0.3rem; }
.perms > label { margin-top: 1rem; }

.actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
button.danger { background: var(--bad); margin-left: auto; }
button.danger:hover { background: #b42f2f; }
button.small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.small { font-size: 0.8rem; }
.field-error { color: var(--bad); font-size: 0.85rem; }
.validation:empty, .validation.validation-summary-valid { display: none; }
.validation ul { margin: 0.25rem 0 0 1.2rem; }

/* ---- wiki ---- */
.wiki-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .wiki-layout { grid-template-columns: 1fr; } }
.wiki-actions { display: flex; gap: 1rem; align-items: center; }
.wiki-group { margin-bottom: 1.5rem; }
.search.inline { margin: 0; }
.search.inline input { width: 220px; }

/* Tile grid: square cards, image fills the tile, coloured name bar across the bottom.
   --tile is the accent (rarity / kind); without an image the whole tile is that colour. */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.tile { position: relative; display: block; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background-color: var(--tile); background-size: cover; background-position: center; border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 4px 16px rgba(0,0,0,0.3); color: #fff; text-decoration: none; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,0.45); text-decoration: none; }
.tile::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.45) 100%); }
.tile-initial { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 3rem; font-weight: 800; color: rgba(255,255,255,0.35); letter-spacing: 0.05em; }
.tile-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.55rem 0.7rem; background: color-mix(in srgb, var(--tile) 78%, #000); border-top: 2px solid color-mix(in srgb, var(--tile) 60%, #fff); display: flex; flex-direction: column; gap: 0.1rem; }
.tile-name { font-weight: 700; font-size: 0.95rem; line-height: 1.2; text-shadow: 0 1px 2px rgba(0,0,0,0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-note { font-size: 0.7rem; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.05em; }
.tile.inactive { filter: grayscale(0.8); opacity: 0.7; }

.wiki-body { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem 1.5rem; line-height: 1.6; min-width: 0; }
.wiki-body h1, .wiki-body h2, .wiki-body h3, .wiki-body h4 { color: var(--text); text-transform: none; letter-spacing: 0; margin: 1.2em 0 0.5em; }
.wiki-body h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
.wiki-body h3 { font-size: 1.15rem; }
.wiki-body h4 { font-size: 1rem; }
.wiki-body p { margin: 0.6em 0; }
.wiki-body img { max-width: 100%; height: auto; border-radius: 6px; }
.wiki-body table { border-collapse: collapse; margin: 0.75rem 0; width: 100%; }
.wiki-body th, .wiki-body td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
.wiki-body th { background: #0e1014; }
.wiki-body blockquote { border-left: 3px solid var(--accent); margin: 0.75rem 0; padding: 0.25rem 1rem; color: var(--muted); }
.wiki-body pre { background: #0e1014; padding: 0.75rem 1rem; border-radius: 6px; overflow-x: auto; }
.wiki-body footer { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }
.wiki-body .live { border-bottom: 1px dotted var(--accent-hover); cursor: help; }

/* Infobox: a wiki-style card. Header band carries the name and kind; rows are
   label/value pairs with subtle striping; complex values get their own block. */
.infobox { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; box-shadow: 0 6px 24px rgba(0,0,0,0.25); font-size: 0.92rem; position: sticky; top: 1rem; }
.infobox .infobox-head { padding: 0.9rem 1rem 0.8rem; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 55%, #1c1f26) 0%, #1c1f26 70%); border-bottom: 1px solid var(--border); }
.infobox .infobox-head h2 { margin: 0; font-size: 1.15rem; color: #fff; text-transform: none; letter-spacing: 0; line-height: 1.2; }
.infobox .infobox-head .kind { display: inline-block; margin-top: 0.35rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.75); }
.infobox .infobox-head .updated { float: right; margin-top: 0.4rem; font-size: 0.7rem; color: rgba(255,255,255,0.55); }
.infobox table.rows { width: 100%; border-collapse: collapse; margin: 0; }
.infobox table.rows tr:nth-child(even) { background: rgba(255,255,255,0.025); }
.infobox table.rows th { text-align: left; vertical-align: top; color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.5rem 0.6rem 0.5rem 1rem; width: 44%; border-top: 1px solid var(--border); }
.infobox table.rows td { vertical-align: top; text-align: right; padding: 0.5rem 1rem 0.5rem 0.4rem; border-top: 1px solid var(--border); color: var(--text); font-weight: 600; }
.infobox table.rows tr.block-label th { width: auto; padding-bottom: 0.15rem; }
.infobox table.rows tr.block-value td { text-align: left; font-weight: 400; padding: 0 1rem 0.7rem; border-top: 0; line-height: 1.45; }
.infobox table.rows tr.block-value { background: transparent !important; }
.infobox table.rows tr.block-label { background: transparent !important; }
.infobox ul { margin: 0; padding-left: 1.1rem; }
.infobox table.mini { width: 100%; margin: 0.2rem 0 0; font-size: 0.82rem; border-collapse: collapse; }
.infobox table.mini th { text-align: left; width: auto; padding: 0.15rem 0.4rem 0.25rem 0; border: 0; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.infobox table.mini td { text-align: left; padding: 0.25rem 0.4rem 0.25rem 0; border: 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-weight: 400; }
.infobox table.mini tr:last-child td { border-bottom: 0; }
.infobox dl.nested { display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 0.6rem; margin: 0; font-weight: 400; }
.infobox .pill { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em; }
.infobox .pill.yes { background: color-mix(in srgb, var(--ok) 25%, transparent); color: #6fe09a; border: 1px solid color-mix(in srgb, var(--ok) 60%, transparent); }
.infobox .pill.no { background: rgba(255,255,255,0.05); color: var(--muted); border: 1px solid var(--border); }
ul.traits { list-style: none; padding: 0; margin: 0.2rem 0 0; }
ul.traits li { padding: 0.15rem 0; font-weight: 500; }
.trait .sign { display: inline-block; width: 1.1em; font-weight: 800; }
.trait.positive { color: #4cd17a; }
.trait.negative { color: #ff6b6b; }
.trait.neutral { color: #ffd43b; }
.trait.note { color: var(--text); font-weight: 400; }
.infobox-empty { padding: 0.8rem 1rem; color: var(--muted); }

.editor-toolbar { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; background: #0e1014; border: 1px solid var(--border); border-bottom: 0; border-radius: 6px 6px 0 0; padding: 0.4rem; }
.editor-toolbar button, .editor-toolbar select { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 0.3rem 0.55rem; font-size: 0.85rem; font-weight: 500; width: auto; }
.editor-toolbar button:hover { background: var(--border); }
.editor-toolbar button.on { background: var(--accent); }
.editor-toolbar .sep { width: 1px; height: 1.4rem; background: var(--border); margin: 0 0.2rem; }
.editor { min-height: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 0 0 6px 6px; padding: 1rem 1.25rem; line-height: 1.6; outline: none; }
.editor:focus { border-color: var(--accent); }
.editor h2, .editor h3, .editor h4 { color: var(--text); text-transform: none; letter-spacing: 0; }
.editor table { border-collapse: collapse; width: 100%; }
.editor th, .editor td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; }
.editor img { max-width: 100%; }
.editor-source { min-height: 360px; font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; border-radius: 0 0 6px 6px; }

.field-list { list-style: none; margin: 0; padding: 0; }
.field-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 0.25rem 0.5rem; align-items: center; padding: 0.4rem 0.25rem; border-top: 1px solid var(--border); cursor: grab; }
.field-list li .preview { grid-column: 2 / span 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field-list li.dragging { opacity: 0.4; }
.field-list li.hidden-field .name { text-decoration: line-through; color: var(--muted); }
.field-list .grip { color: var(--muted); }
.field-list label.check { margin: 0; gap: 0.3rem; }
.revision-preview { margin-top: 0.5rem; max-height: 300px; overflow: auto; }

.preview-banner { background: var(--warn); color: #1a1200; text-align: center; padding: 0.5rem 1rem; font-size: 0.9rem; }
.linked { margin-bottom: 1rem; }
.tag.ok { background: var(--ok); color: #fff; }

.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.grid th, .grid td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
.grid th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr.dnt td { color: var(--muted); }
.grid .num { text-align: right; }

.tag { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; background: var(--border); margin-right: 0.3rem; }
.tag.bad { background: var(--bad); color: #fff; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

.muted { color: var(--muted); }
.error { color: #fff; background: var(--bad); padding: 0.6rem 0.9rem; border-radius: 6px; }
.notice { color: #fff; background: var(--ok); padding: 0.6rem 0.9rem; border-radius: 6px; }
