:root {
    --bg: #111418;
    --panel: #181c22;
    --panel-2: #1f242c;
    --line: #2b313b;
    --text: #e4e7eb;
    --muted: #8b939e;
    --accent: #3fb68b;
    --accent-2: #2a8f6a;
    --danger: #e0565b;
    --warn: #e0a84a;
    --info: #5b9be0;
    --radius: 8px;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

h1 { font-size: 22px; margin: 0 0 4px; }
/* Focused on navigation for screen readers (FocusOnNavigate); not a visible box. */
h1:focus, h1:focus-visible { outline: none; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 12px; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 16px 10px; position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); padding: 4px 10px 16px; }
.brand span { color: var(--accent); font-weight: 500; }
.nav { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text); }
.nav:hover { background: var(--panel-2); text-decoration: none; }
.nav.active { background: var(--panel-2); color: var(--accent); }
.nav-group { margin: 14px 10px 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.whoami { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.content { flex: 1; padding: 24px 32px 48px; min-width: 0; max-width: 1400px; }
.topbar, .scrim { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }

/* Panels and grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
/* Edit pages: two columns that use the whole width, one on narrow screens. */
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2 { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
    width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
    padding: 7px 10px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.inline { display: inline-flex; width: auto; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
/* A field with its button (a picture select and Upload): same height, side by side. */
.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group > input, .input-group > select { flex: 1; min-width: 0; }
.input-group > button, .input-group > .button { flex: none; }
.file-button { margin: 0; color: var(--text); }
.picker-error { margin-top: 6px; }
.input-group > .thumb { flex: none; align-self: center; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 10px 0; }

button, .button {
    display: inline-flex; align-items: center; gap: 6px; background: var(--accent-2); color: #fff; border: none;
    border-radius: 6px; padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
button:hover, .button:hover { background: var(--accent); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
button.secondary:hover { border-color: var(--accent); }
button.danger { background: #8f2f33; }
button.danger:hover { background: var(--danger); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }
/* A ConfirmButton waiting for its second click. */
button.armed, button.armed:hover { background: var(--danger); color: #fff; box-shadow: 0 0 0 2px #e0565b55; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.actions .spacer { flex: 1; }
button.small, .button.small { padding: 3px 9px; font-size: 12px; }

/* Badges and notices */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); }
.badge.green { color: var(--accent); border-color: #2a5a49; }
.badge.red { color: var(--danger); border-color: #6a2e31; }
.badge.yellow { color: var(--warn); border-color: #6a5326; }
.badge.blue { color: var(--info); border-color: #2c4a6b; }
.notice { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.notice.ok { border-color: #2a5a49; background: #15281f; }
.notice.error { border-color: #6a2e31; background: #2a1517; }
.notice.warn { border-color: #6a5326; background: #2a2215; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.state-page { max-width: 560px; margin: 64px auto; text-align: center; }
.state-page .row { justify-content: center; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.nowrap { white-space: nowrap; }
.thumb.small { width: 36px; height: 36px; }
.thumb.empty-thumb { display: inline-block; }

/* Collapsible sections (details/summary): long lists stay one line until opened. */
details.fold { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; background: var(--panel); }
details.fold > summary { cursor: pointer; padding: 8px 12px; list-style: none; display: flex; gap: 10px; align-items: center; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--muted); width: 10px; }
details.fold[open] > summary::before { content: "▾"; }
details.fold[open] > summary { border-bottom: 1px solid var(--line); }
details.fold > .fold-body { padding: 4px 12px 12px; }

.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.diff { white-space: pre-wrap; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; max-height: 240px; overflow: auto; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login { width: 340px; }

/* Blazor */
#blazor-error-ui {
    background: #5a2023; color: #fff; bottom: 0; display: none; left: 0; padding: 10px 20px; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 12px; top: 10px; }
#blazor-error-ui .reload { color: #fff; text-decoration: underline; }

/* Phones and narrow windows: the sidebar becomes a menu behind a button. */
@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .topbar {
        display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel);
        border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
    }
    .topbar .brand { padding: 0; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; transform: translateX(-100%);
        transition: transform .15s ease; overflow-y: auto;
    }
    .nav-open .sidebar { transform: none; }
    .nav-open .scrim { display: block; position: fixed; inset: 0; background: #0008; z-index: 30; }
    .content { padding: 16px; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .page-head { flex-direction: column; align-items: flex-start; }
}

/* Sub-panels inside a card (a world's builds), and compact list tables that open to edit. */
.subcard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-top: 12px; }
table.compact td { vertical-align: middle; padding: 6px 10px; }
table.compact tr.open td { background: var(--panel-2); border-bottom-color: transparent; }
table.compact tr.editor-row td { background: var(--panel-2); padding: 4px 14px 14px; }
table.compact tr.editor-row:hover { background: none; }
.thumb-cell { width: 48px; }
input.search { width: 220px; padding: 4px 10px; }
.clickable { cursor: pointer; }
.fold-toggle { width: 16px; color: var(--muted); }
.card.shelf .card-head { margin-bottom: 0; }
.card.shelf .card-head + * { margin-top: 12px; }
td.right { text-align: right; }
.add-item { margin-top: 12px; max-width: 560px; }

/* A filter bar over a long page, and tab-like buttons. */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar .check { margin: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; font-weight: 500; font-size: 12.5px; }
.tabs button:hover { color: var(--text); background: var(--panel-2); }
.tabs button.active { color: var(--accent); border-color: var(--accent-2); background: var(--panel-2); }

/* Configuration rows. */
table.settings td.setting-name { width: 34%; }
table.settings .tags { margin-top: 4px; }
.setting-value { display: flex; gap: 10px; align-items: flex-start; }
.setting-value .value { flex: 1; min-width: 0; word-break: break-all; }
.setting-value .value.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
textarea.tall { min-height: 160px; }
textarea.template { min-height: 480px; width: 100%; white-space: pre; margin: 8px 0 10px; }
.list-item { margin-bottom: 10px; }
button, .button { white-space: nowrap; }
.page-head > :last-child:not(:first-child) { flex: none; }
.right { text-align: right; }
.faded { opacity: .55; }
.credit-adjust { margin: 8px 0; }
.credit-adjust input { width: 160px; }

/* Underlined tabs (as LarpTwitter's admin): one section of a page at a time. */
.tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 18px; overflow-x: auto; }
.tabbar button {
    position: relative; background: none; border: 0; border-radius: 0; color: var(--muted); font-weight: 500;
    padding: 12px 14px; white-space: nowrap;
}
.tabbar button:hover { background: none; color: var(--text); }
.tabbar button.on { color: var(--text); font-weight: 700; }
.tabbar button.on::after {
    content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px; border-radius: 3px; background: var(--accent);
}

/* A detail page's header: picture, name, badges, facts. */
.hero { display: flex; gap: 16px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 4px; }
.hero .hero-pic { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--line); flex: none; }
.hero .hero-pic.round { border-radius: 50%; }
.hero .hero-main { flex: 1; min-width: 0; }
.hero h1 { margin: 0; }
.hero .hero-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.hero .hero-facts { text-align: right; color: var(--muted); font-size: 12px; flex: none; }
.back { display: inline-block; margin-bottom: 12px; font-size: 13px; }

/* Dialogs. */
.modal-backdrop { position: fixed; inset: 0; background: #000a; z-index: 60; }
.modal {
    position: fixed; z-index: 61; left: 50%; top: 8vh; transform: translateX(-50%); width: min(640px, 94vw); max-height: 84vh;
    display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 20px 60px #000a; outline: none;
}
.modal.wide { width: min(900px, 94vw); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 4px 18px 16px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
button.close { color: var(--muted); font-size: 16px; }

/* Toasts. */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 8px; max-width: min(420px, 90vw); }
.toast {
    display: flex; gap: 12px; align-items: flex-start; background: var(--panel-2); border: 1px solid var(--line);
    border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 12px; box-shadow: 0 8px 24px #0008;
}
.toast span { flex: 1; }
.toast.error { border-left-color: var(--danger); }

/* The save bar pinned under an edit page. */
.savebar {
    position: sticky; bottom: 0; z-index: 15; display: flex; gap: 10px; align-items: center; margin-top: 16px;
    padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 -8px 24px #0006;
}
.savebar .reason { flex: 1; }

/* Clickable list rows and a two-pane list beside its selection. */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
.split { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.split-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; position: sticky; top: 16px; }
.split-list button.item {
    display: flex; width: 100%; gap: 8px; align-items: center; background: none; border: 0; color: var(--text);
    padding: 8px 10px; border-radius: 6px; font-weight: 500; text-align: left; white-space: normal;
}
.split-list button.item:hover { background: var(--panel-2); }
.split-list button.item.on { background: var(--panel-2); color: var(--accent); }
.split-list button.item .count { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
@media (max-width: 900px) {
    .split { grid-template-columns: minmax(0, 1fr); }
    .split-list { position: static; }
    .hero { flex-wrap: wrap; }
    .hero .hero-facts { text-align: left; }
}
.hero-pic.initial { display: grid; place-items: center; font-size: 30px; font-weight: 700; color: var(--accent); }
td.pos { color: var(--accent); }
td.neg { color: var(--danger); }
.credit-adjust { margin: 0; }
.credit-adjust input { width: 150px; }
.scroll-box { max-height: 360px; overflow: auto; }
.pre-wrap { white-space: pre-wrap; }
.danger-text { color: var(--danger); }
input.search.wide { width: 380px; max-width: 100%; }
