/* Crowdforge moderation UI.
   Self-hosted, no webfonts, no external requests: the Content-Security-Policy
   forbids them and the droplet has no bandwidth to spare. */

:root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e5e8ee;
    --text-dim: #9aa3b2;
    --accent: #5b8def;
    --accent-dim: #37507f;
    --ok: #3fb950;
    --warn: #d29922;
    --error: #f85149;
    --info: #58a6ff;
    --radius: 8px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 var(--sans);
}

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

a:hover {
    text-decoration: underline;
}

.skip-link {
    position: absolute;
    left: -9999px;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    z-index: 100;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius);
}

/* ---- layout ---- */

.topbar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    font-size: 1.05rem;
}

.brand span {
    color: var(--accent);
}

.topbar nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.topbar nav a {
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 0.92rem;
}

.topbar nav a:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.topbar nav a[aria-current="page"] {
    background: var(--accent-dim);
    color: #fff;
}

.topbar .spacer {
    flex: 1;
}

main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 4rem;
}

h1 {
    font-size: 1.4rem;
    margin: 0 0 1rem;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.1rem;
    margin: 1.75rem 0 0.75rem;
}

h3 {
    font-size: 0.95rem;
    margin: 1.25rem 0 0.5rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.page-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0;
}

/* ---- cards & panels ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.card>h2:first-child,
.card>h3:first-child {
    margin-top: 0;
}

.card.narrow {
    max-width: 34rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid.cols-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid.cols-4 {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.stat {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 0.9rem;
}

.stat .label {
    color: var(--text-dim);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat .value {
    font-size: 1.5rem;
    font-weight: 650;
    margin-top: 0.15rem;
    font-variant-numeric: tabular-nums;
}

.stat .sub {
    color: var(--text-dim);
    font-size: 0.82rem;
}

/* ---- banners ---- */

.banner {
    border-radius: var(--radius);
    padding: 0.7rem 0.95rem;
    margin-bottom: 0.75rem;
    border: 1px solid;
    font-size: 0.93rem;
}

.banner.success {
    background: rgba(63, 185, 80, 0.1);
    border-color: rgba(63, 185, 80, 0.4);
}

.banner.error {
    background: rgba(248, 81, 73, 0.1);
    border-color: rgba(248, 81, 73, 0.45);
}

.banner.warning {
    background: rgba(210, 153, 34, 0.1);
    border-color: rgba(210, 153, 34, 0.45);
}

.banner.info {
    background: rgba(88, 166, 255, 0.1);
    border-color: rgba(88, 166, 255, 0.4);
}

.killswitch {
    background: rgba(210, 153, 34, 0.12);
    border: 1px solid rgba(210, 153, 34, 0.5);
    border-radius: var(--radius);
    padding: 0.7rem 0.95rem;
    margin-bottom: 1rem;
}

/* ---- badges ---- */

.badge {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-dim);
    white-space: nowrap;
}

.badge.pending {
    border-color: rgba(210, 153, 34, 0.5);
    color: var(--warn);
}

.badge.approved {
    border-color: rgba(88, 166, 255, 0.5);
    color: var(--info);
}

.badge.publishing {
    border-color: rgba(88, 166, 255, 0.5);
    color: var(--info);
}

.badge.posted {
    border-color: rgba(63, 185, 80, 0.5);
    color: var(--ok);
}

.badge.rejected,
.badge.failed {
    border-color: rgba(248, 81, 73, 0.5);
    color: var(--error);
}

.badge.ready {
    border-color: rgba(63, 185, 80, 0.5);
    color: var(--ok);
}

.badge.rival,
.badge.nemesis {
    border-color: rgba(248, 81, 73, 0.5);
    color: var(--error);
}

.badge.ally {
    border-color: rgba(63, 185, 80, 0.5);
    color: var(--ok);
}

/* ---- tabs ---- */

.tabs {
    display: flex;
    gap: 0.3rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tabs a {
    padding: 0.5rem 0.8rem;
    color: var(--text-dim);
    border-bottom: 2px solid transparent;
    font-size: 0.92rem;
}

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

.tabs a[aria-current="page"] {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.tabs .count {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* ---- forms ---- */

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.65rem;
    font: inherit;
}

textarea {
    resize: vertical;
    min-height: 6rem;
    font-family: var(--mono);
    font-size: 0.9rem;
    line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

.field {
    margin-bottom: 0.9rem;
}

.field-row {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.field-row>* {
    flex: 1 1 140px;
}

.hint {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

button,
.btn {
    display: inline-block;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.45rem 0.9rem;
    font: inherit;
    font-weight: 550;
    cursor: pointer;
}

button:hover,
.btn:hover {
    border-color: var(--accent);
    text-decoration: none;
}

button:focus-visible,
.btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

button.primary:hover {
    background: #4a7ad8;
}

button.danger {
    border-color: rgba(248, 81, 73, 0.5);
    color: var(--error);
}

button.danger:hover {
    background: rgba(248, 81, 73, 0.12);
}

button.ok {
    border-color: rgba(63, 185, 80, 0.5);
    color: var(--ok);
}

button.ok:hover {
    background: rgba(63, 185, 80, 0.12);
}

button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.8rem;
}

.inline-form {
    display: inline;
}

/* ---- tables ---- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    text-align: left;
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    color: var(--text-dim);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

tbody tr:hover {
    background: var(--surface-2);
}

td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

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

/* ---- content blocks ---- */

.quote {
    background: var(--surface-2);
    border-left: 3px solid var(--accent-dim);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0.7rem 0.9rem;
    margin: 0.5rem 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.quote .who {
    color: var(--text-dim);
    font-size: 0.82rem;
    margin-bottom: 0.3rem;
}

.draft-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
}

.mono {
    font-family: var(--mono);
    font-size: 0.85rem;
}

.dim {
    color: var(--text-dim);
}

.small {
    font-size: 0.85rem;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 22rem;
}

.chips {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.chip {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    font-size: 0.78rem;
    color: var(--text-dim);
}

.meter {
    background: var(--surface-2);
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
    margin-top: 0.3rem;
}

.meter>span {
    display: block;
    height: 100%;
    background: var(--accent);
}

.meter.warn>span {
    background: var(--warn);
}

.meter.error>span {
    background: var(--error);
}

/* ---- pagination ---- */

.pagination {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.88rem;
}

.pagination .current {
    background: var(--accent-dim);
    color: #fff;
    border-color: var(--accent-dim);
}

/* ---- login ---- */

.login-wrap {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
}

.empty {
    color: var(--text-dim);
    text-align: center;
    padding: 2.5rem 1rem;
}

footer.site {
    color: var(--text-dim);
    font-size: 0.82rem;
    text-align: center;
    padding: 1.5rem 1rem 3rem;
}

@media (max-width: 640px) {
    main {
        padding: 1rem 0.8rem 3rem;
    }

    .topbar {
        padding: 0.6rem 0.8rem;
        gap: 0.6rem;
    }

    .truncate {
        max-width: 12rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ---- compact moderation queue ---- */

body.queue main {
    max-width: 720px;
    padding: 0.7rem 0.9rem 3rem;
}

.queue-head {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.queue-head h1 {
    margin: 0;
    font-size: 1.15rem;
}

.queue-head .spacer {
    flex: 1;
}

.pill {
    display: inline-block;
    padding: 0.08rem 0.45rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.pill.warn {
    border-color: rgba(210, 153, 34, 0.5);
    color: var(--warn);
}

.kbd-hint {
    font-variant: small-caps;
    letter-spacing: 0.04em;
}

.filters {
    margin: 0 0 0.6rem;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.filters summary {
    cursor: pointer;
    user-select: none;
}

.filters form {
    margin-top: 0.5rem;
}

body.queue .tabs {
    margin-bottom: 0.5rem;
}

body.queue .tabs a {
    padding: 0.3rem 0.55rem;
    font-size: 0.85rem;
}

.review {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.review-item {
    display: grid;
    /* minmax(0, 1fr) lets the text column shrink; otherwise a long nowrap
       title expands the row and overflow:hidden clips Post/Skip off the right. */
    grid-template-columns: minmax(0, 1fr) 4.75rem;
    gap: 0.25rem 0.55rem;
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid var(--border);
    align-items: start;
}

.review-item:last-child {
    border-bottom: none;
}

.review-item.is-active {
    background: var(--surface-2);
    box-shadow: inset 3px 0 0 var(--accent);
}

.review-body {
    min-width: 0;
}

.review-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.45rem;
    align-items: baseline;
    font-size: 0.78rem;
    line-height: 1.3;
}

.review-edit {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
}

.review-quote {
    margin: 0.15rem 0 0;
    color: var(--text-dim);
    font-size: 0.8rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.banner a {
    color: inherit;
    text-decoration: underline;
}

.review-quote::before {
    content: "re: ";
}

.review-thread {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--accent);
}

.review-text {
    margin: 0.2rem 0 0;
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.review-fail {
    margin: 0.25rem 0 0;
    color: var(--error);
    font-size: 0.8rem;
}

.review-actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: stretch;
    align-self: start;
    width: 4.75rem;
}

.review-actions button {
    min-width: 4.4rem;
    padding: 0.28rem 0.65rem;
    font-size: 0.85rem;
}

.skip-rest {
    margin-top: 0.6rem;
}

.skip-rest button {
    padding: 0.28rem 0.65rem;
    font-size: 0.82rem;
}

.empty-queue {
    color: var(--text-dim);
    padding: 1.4rem 0.4rem;
    text-align: center;
}

@media (max-width: 640px) {
    .review-item {
        grid-template-columns: minmax(0, 1fr);
    }

    .review-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    .kbd-hint {
        display: none;
    }
}