:root {
    --page: #f3f5f7;
    --panel: #ffffff;
    --panel-soft: #f8fafb;
    --ink: #20242b;
    --muted: #687382;
    --line: #dbe1e7;
    --line-strong: #c8d0d9;
    --charcoal: #171a1f;
    --charcoal-2: #22262c;
    --kwyll-cyan: #20b7c7;
    --kwyll-blue: #2454bf;
    --kwyll-deep-blue: #183b91;
    --success: #157347;
    --radius: 10px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--page);
    line-height: 1.5;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 15% 0%, rgba(32, 183, 199, .08), transparent 28rem),
        var(--page);
}

a {
    color: var(--kwyll-blue);
}

a:hover {
    color: var(--kwyll-deep-blue);
}

.container {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    position: relative;
    background: var(--charcoal);
    color: #edf5f8;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
}

.header-inner {
    min-height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.kwyll-logo-link {
    display: block;
    flex: 0 0 auto;
    line-height: 0;
}

.kwyll-logo {
    display: block;
    width: 154px;
    height: auto;
}

.site-title {
    padding-left: 18px;
    border-left: 1px solid rgba(255, 255, 255, .2);
    color: #f7fbfc;
    font-size: 1.05rem;
    font-weight: 750;
    letter-spacing: .015em;
    text-decoration: none;
    white-space: nowrap;
}

.site-title:hover {
    color: var(--kwyll-cyan);
}

.spectrum-stripe {
    height: 5px;
    background: linear-gradient(
        90deg,
        #e7352f 0 20%,
        #f1c735 20% 40%,
        #47a947 40% 60%,
        #24b7c8 60% 80%,
        #3c58c7 80% 100%
    );
}

nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

nav a,
.link-button {
    color: #dfe9ed;
}

nav a:hover,
.link-button:hover {
    color: #ffffff;
}

.signed-in {
    color: #aeb9c2;
    font-size: .9rem;
}

.signed-in strong {
    color: #fff;
}

.inline {
    display: inline;
}

.link-button {
    border: 0;
    padding: 0;
    background: none;
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.hero {
    position: relative;
    padding: 52px 0 30px;
}

.hero::before {
    content: "ZX SPECTRUM \00b7 KWYLL";
    display: block;
    width: fit-content;
    margin-bottom: 10px;
    padding: 3px 8px;
    border: 1px solid rgba(36, 84, 191, .18);
    border-radius: 4px;
    color: var(--kwyll-blue);
    background: rgba(255, 255, 255, .62);
    font: 700 .7rem/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    letter-spacing: .12em;
}

.hero h1,
.topic-detail h1,
.narrow h1 {
    margin: 0 0 9px;
    color: #1e2329;
    line-height: 1.12;
    letter-spacing: -.025em;
}

.hero h1 {
    max-width: 820px;
    font-size: clamp(2rem, 4vw, 3.15rem);
}

.hero p {
    max-width: 780px;
    margin: 0;
    color: #5c6775;
    font-size: 1.08rem;
}

.filters {
    display: flex;
    gap: 20px;
    padding: 15px 17px;
    margin-bottom: 22px;
    background: rgba(255, 255, 255, .92);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(28, 38, 49, .04);
}

.filters label {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #404a56;
    font-size: .9rem;
    font-weight: 750;
}

select,
input,
textarea {
    width: 100%;
    font: inherit;
    color: inherit;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    padding: 10px 11px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

select:focus,
input:focus,
textarea:focus {
    border-color: var(--kwyll-cyan);
    box-shadow: 0 0 0 3px rgba(32, 183, 199, .15);
}

select {
    width: auto;
}

textarea {
    resize: vertical;
}

.topic-list {
    display: grid;
    gap: 12px;
}

.topic-card {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 20px;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 3px 12px rgba(27, 37, 49, .035);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.topic-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--kwyll-cyan), var(--kwyll-blue));
    opacity: .72;
}

.topic-card:hover {
    border-color: #c5d3df;
    box-shadow: 0 7px 22px rgba(27, 37, 49, .07);
    transform: translateY(-1px);
}

.vote-column {
    text-align: center;
    border-right: 1px solid #e8edf1;
    padding-right: 20px;
}

.vote-count {
    color: var(--kwyll-blue);
    font-size: 1.85rem;
    font-weight: 850;
    line-height: 1;
}

.vote-label {
    color: var(--muted);
    font-size: .8rem;
    margin: 4px 0 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.vote-button {
    background: linear-gradient(135deg, var(--kwyll-cyan), var(--kwyll-blue));
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 7px 13px;
    cursor: pointer;
    font-weight: 750;
    box-shadow: 0 2px 6px rgba(36, 84, 191, .2);
}

.vote-button:hover {
    filter: brightness(.96);
}

.voted {
    color: var(--success);
    font-weight: 800;
    font-size: .85rem;
}

.voted.larger {
    font-size: 1rem;
}

.topic-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}

.topic-heading h1,
.topic-heading h2 {
    margin: 0;
}

.topic-heading h2 {
    font-size: 1.16rem;
    line-height: 1.35;
}

.topic-heading a {
    color: #222832;
    text-decoration: none;
}

.topic-heading a:hover {
    color: var(--kwyll-blue);
}

.description {
    color: #505b69;
    white-space: pre-wrap;
}

.description.large {
    font-size: 1.06rem;
    max-width: 820px;
}

.meta,
.muted {
    color: #788391;
    font-size: .88rem;
}

.badge {
    display: inline-block;
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: .73rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .035em;
    background: #edf0f3;
    color: #5e6672;
}

.badge.supporters {
    background: #fff0cf;
    color: #805a00;
}

.badge.public {
    background: #daf4ec;
    color: #116145;
}

.button {
    display: inline-block;
    border: 0;
    border-radius: 7px;
    padding: 10px 15px;
    background: linear-gradient(135deg, var(--kwyll-cyan), var(--kwyll-blue));
    color: #fff;
    font: inherit;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 2px 7px rgba(36, 84, 191, .18);
}

.button:hover {
    color: #fff;
    filter: brightness(.96);
}

.button.secondary {
    background: #eaf2f8;
    color: #224c9c;
    box-shadow: none;
}

.site-header .button.secondary {
    background: rgba(32, 183, 199, .14);
    border: 1px solid rgba(32, 183, 199, .38);
    color: #bff7fb;
}

.narrow {
    max-width: 720px;
    margin: 42px auto;
    padding: 30px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    border-top: 3px solid var(--kwyll-cyan);
    background: var(--panel);
    box-shadow: 0 6px 22px rgba(28, 38, 49, .055);
}

.stack-form {
    display: grid;
    gap: 18px;
}

.stack-form label {
    display: grid;
    gap: 6px;
    color: #3e4854;
    font-weight: 700;
}

.stack-form .button {
    justify-self: start;
}

.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.flash-stack {
    margin-top: 18px;
    display: grid;
    gap: 8px;
}

.flash {
    border-radius: 7px;
    padding: 10px 13px;
    background: #eef2f7;
    border-left: 3px solid #8995a4;
}

.flash.error {
    background: #fde8e8;
    border-left-color: #c53c3c;
    color: #8a2525;
}

.flash.success {
    background: #e3f5ea;
    border-left-color: #26915e;
    color: #16613f;
}

.flash.info {
    background: #e7f6f8;
    border-left-color: var(--kwyll-cyan);
    color: #245a63;
}

.topic-detail,
.discussion {
    margin: 36px 0 0;
    padding: 27px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(28, 38, 49, .04);
}

.topic-detail {
    border-top: 3px solid var(--kwyll-cyan);
}

.discussion h2 {
    margin-top: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 24px 0;
}

.detail-grid > div {
    padding: 14px;
    border-radius: 8px;
    background: var(--panel-soft);
    border: 1px solid #edf1f4;
    display: grid;
    gap: 3px;
}

.detail-grid > div:first-child strong {
    color: var(--kwyll-blue);
    font-size: 1.2rem;
}

.detail-grid span {
    color: #6b7483;
    font-size: .84rem;
}

.actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.comment-list {
    display: grid;
    gap: 10px;
    margin: 18px 0 28px;
}

.comment {
    background: #f7f9fa;
    border: 1px solid #e9eef2;
    border-radius: 8px;
    padding: 14px;
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: #687181;
    font-size: .85rem;
    margin-bottom: 8px;
}

.comment-meta strong {
    color: var(--kwyll-blue);
}

.comment-body {
    white-space: pre-wrap;
}

.comment-form {
    margin-top: 24px;
}

.empty-state {
    padding: 42px;
    text-align: center;
    background: var(--panel);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
}

.site-footer {
    margin-top: 46px;
    background: var(--charcoal-2);
    border-top: 1px solid #111317;
    color: #aeb8c1;
    font-size: .85rem;
}

.footer-inner {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.footer-inner strong {
    color: #eafaff;
}

.footer-inner a {
    color: #7bd6df;
}

@media (max-width: 760px) {
    .header-inner,
    nav,
    .filters,
    .topic-heading {
        align-items: stretch;
    }

    .header-inner {
        padding: 14px 0;
        flex-direction: column;
    }

    .brand-lockup {
        width: 100%;
    }

    .kwyll-logo {
        width: 130px;
    }

    .site-title {
        padding-left: 14px;
    }

    nav,
    .filters {
        flex-direction: column;
    }

    .signed-in {
        display: block;
    }

    select {
        width: 100%;
    }

    .hero {
        padding-top: 38px;
    }

    .topic-card {
        grid-template-columns: 1fr;
    }

    .vote-column {
        border-right: 0;
        border-bottom: 1px solid #e8edf1;
        padding: 0 0 12px;
        display: flex;
        align-items: center;
        gap: 10px;
        text-align: left;
    }

    .vote-label {
        margin: 0 auto 0 0;
    }

    .detail-grid,
    .two-columns {
        grid-template-columns: 1fr;
    }

    .footer-inner {
        padding: 20px 0;
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
    }
}

@media (max-width: 460px) {
    .container {
        width: min(100% - 22px, 1100px);
    }

    .kwyll-logo {
        width: 112px;
    }

    .site-title {
        font-size: .92rem;
    }

    .topic-detail,
    .discussion,
    .narrow {
        padding: 21px;
    }
}

/* Invitation / admin account management */
.field-help {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 500;
}

.optional {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 500;
}

.form-footer {
    margin: 24px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .9rem;
}

.admin-page {
    margin: 40px 0;
}

.admin-heading {
    margin-bottom: 22px;
}

.admin-heading h1 {
    margin: 0 0 5px;
    line-height: 1.15;
}

.admin-heading p {
    margin: 0;
    color: var(--muted);
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.admin-panel,
.invite-result {
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(28, 38, 49, .04);
}

.admin-panel h2,
.invite-result h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

.invite-result {
    margin-bottom: 18px;
    border-top: 3px solid var(--kwyll-cyan);
}

.token-display {
    overflow-wrap: anywhere;
    margin: 15px 0;
    padding: 15px;
    background: #171a1f;
    border-radius: 7px;
    color: #bff7fb;
    font: 700 .98rem/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    user-select: all;
}

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

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.admin-table th,
.admin-table td {
    padding: 10px 9px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    color: #4b5663;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .045em;
}

.table-action {
    text-align: right !important;
    white-space: nowrap;
}

.status-pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .035em;
}

.status-pill.active {
    background: #daf4ec;
    color: #116145;
}

.status-pill.used {
    background: #e8eefb;
    color: #244c9d;
}

.status-pill.expired,
.status-pill.revoked {
    background: #eef0f2;
    color: #68717d;
}

.small-button {
    border: 0;
    border-radius: 5px;
    padding: 5px 9px;
    font: inherit;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
}

.small-button.danger {
    background: #fde8e8;
    color: #9a3030;
}

@media (max-width: 850px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
}
