:root {
    --bg: #0d0f17;
    --bg2: #151824;
    --card: #1b1f2e;
    --line: #2a3040;
    --text: #eef1f8;
    --muted: #9aa3b8;
    --brand: #5865f2;
    --brand-hi: #6d78f5;
    --green: #3ba55d;
    --gold: #d4af37;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: radial-gradient(1200px 600px at 50% -10%, #1c2135 0%, var(--bg) 60%);
}

/* ------------------------------------------------------------------ */
/* Top navigation (portal shell — shown when logged in)               */
/* ------------------------------------------------------------------ */
.topbar {
    position: relative;
    width: 100%;
    max-width: 960px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
}

.brand {
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 10px;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { color: var(--text); background: #1b1f2e; }
.nav-link.active { color: var(--text); background: #1b1f2e; }

.nav-spacer { flex: 1; }

/* Script Key + Guides + Log out: inline on desktop, hamburger dropdown on mobile. */
.nav-collapse { display: flex; align-items: center; gap: 10px; }

.hamburger {
    display: none;  /* desktop: hidden — links are inline */
    background: #12151f;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.hamburger:hover { background: #181c2a; }

.lang-select {
    background: #12151f;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.lang-select:hover { background: #181c2a; }
.lang-select:focus { outline: none; border-color: var(--brand); }

.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--line);
}

/* ------------------------------------------------------------------ */
/* Page shell + card                                                  */
/* ------------------------------------------------------------------ */
.shell {
    width: 100%;
    max-width: 640px;
    padding: 24px;
    margin: auto; /* centers vertically in the space under the navbar */
}

.card {
    background: linear-gradient(180deg, var(--card) 0%, var(--bg2) 100%);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 34px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.center { text-align: center; }

.logo { font-size: 46px; margin-bottom: 8px; }

h1 { margin: 8px 0; font-size: 26px; letter-spacing: 0.3px; }

.muted { color: var(--muted); margin: 6px 0 22px; }

.fineprint { color: var(--muted); font-size: 12px; margin-top: 20px; }

/* ------------------------------------------------------------------ */
/* Buttons                                                            */
/* ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    color: #fff;
    border: 1px solid transparent;
    transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-discord { background: var(--brand); }
.btn-discord:hover { background: var(--brand-hi); }

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}
.btn-ghost:hover { background: #222738; }

.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn.full { width: 100%; margin-top: 26px; }
.btn.full + .btn.full { margin-top: 12px; }

/* A gated (subscription-required) button: looks like a button, does nothing. */
.btn-locked {
    background: #12151f;
    border: 1px dashed var(--line);
    color: var(--muted);
    cursor: not-allowed;
    opacity: 0.75;
}
.btn-locked:hover { background: #12151f; }

.unlock-note {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    margin: 14px 0 0;
}

.btn-icon { font-size: 18px; }

/* ------------------------------------------------------------------ */
/* Profile                                                            */
/* ------------------------------------------------------------------ */
.profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
}
.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid var(--brand);
    flex-shrink: 0;
}
.profile-head h1 { margin: 0 0 6px; }

.badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
}
.badge-active { background: rgba(59, 165, 93, 0.15); color: var(--green); border: 1px solid rgba(59,165,93,0.4); }
.badge-expired { background: rgba(230, 126, 34, 0.15); color: #e67e22; border: 1px solid rgba(230,126,34,0.4); }
.badge-guest { background: rgba(154, 163, 184, 0.15); color: var(--muted); border: 1px solid rgba(154,163,184,0.35); }

/* Desktop: 2×2 grid — Serial | Days remaining / Expires | Member since */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-top: 24px;
}

.stat {
    background: #12151f;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    min-width: 0; /* let tiles shrink instead of overflowing the screen */
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 20px; font-weight: 700; margin-top: 6px; overflow-wrap: anywhere; }
.mono { font-family: "Consolas", ui-monospace, monospace; letter-spacing: 1px; }

.footer { color: #4a5164; font-size: 12px; padding: 22px; }

/* ------------------------------------------------------------------ */
/* Server roles                                                       */
/* ------------------------------------------------------------------ */
.roles-section { margin-top: 24px; }
.roles-label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.role-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #12151f;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px 6px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    max-width: 100%;
}
.role-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--rc, var(--muted));
    flex-shrink: 0;
    box-shadow: 0 0 6px -1px var(--rc, transparent);
}
.role-empty { color: var(--muted); font-size: 13px; }
.role-none {
    background: #12151f;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--muted);
    font-size: 14px;
}

/* ------------------------------------------------------------------ */
/* Guides                                                             */
/* ------------------------------------------------------------------ */
.page-head h1 { margin: 0 0 4px; }
.page-head .muted { margin-bottom: 0; }

.guide-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 20px;
}

.guide-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #12151f;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent, var(--brand));
    border-radius: 12px;
    padding: 14px;
    text-decoration: none;
    color: var(--text);
    min-width: 0;
    transition: background 0.15s ease, transform 0.05s ease;
}
.guide-card:hover { background: #181c2a; }
.guide-card:active { transform: translateY(1px); }

.guide-emoji { font-size: 22px; line-height: 1.2; }
.guide-card-text { min-width: 0; }
.guide-title { font-weight: 700; }
.guide-teaser {
    color: var(--muted);
    font-size: 12.5px;
    margin-top: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.guide-page { border-top: 3px solid var(--accent, var(--brand)); }

.crumb {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}
.crumb:hover { color: var(--text); }

.guide-h1 { margin: 12px 0 4px; }

.guide-image {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line);
    margin: 14px 0 2px;
}

.guide-body { color: #d7dceb; line-height: 1.65; font-size: 14.5px; }
.guide-body p { margin: 12px 0; }
.guide-body code {
    background: #12151f;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 1px 6px;
    font-family: "Consolas", ui-monospace, monospace;
    font-size: 13px;
}
.guide-body pre {
    background: #0d1017;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    overflow-x: auto;
}
.guide-body pre code { background: none; border: none; padding: 0; }

.guide-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

.backrow { margin-top: 18px; }

/* ------------------------------------------------------------------ */
/* Script Key                                                         */
/* ------------------------------------------------------------------ */
.key-form { margin-top: 22px; }

.field-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.field-input {
    width: 100%;
    background: #12151f;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 16px;
    font-family: inherit;
}
.field-input:focus { outline: none; border-color: var(--brand); }
.field-input.mono { font-family: "Consolas", ui-monospace, monospace; letter-spacing: 1px; }

.key-result {
    background: rgba(59, 165, 93, 0.1);
    border: 1px solid rgba(59, 165, 93, 0.4);
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    margin-top: 8px;
}
.key-result-label {
    color: var(--green);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}
.key-value {
    font-family: "Consolas", ui-monospace, monospace;
    font-size: 40px;
    font-weight: 800;
    letter-spacing: 6px;
    margin: 8px 0 14px;
    color: var(--text);
}

.key-error {
    background: rgba(237, 66, 69, 0.1);
    border: 1px solid rgba(237, 66, 69, 0.4);
    border-radius: 12px;
    padding: 14px 16px;
    color: #f2b3b4;
    font-size: 14px;
    margin-top: 8px;
}

/* ------------------------------------------------------------------ */
/* Phone layout (same page, tiles rearrange)                          */
/* Serial full width → Days | Expires paired → Member since full      */
/* ------------------------------------------------------------------ */
@media (max-width: 560px) {
    /* Bar: brand | Profile + language ...... hamburger + avatar */
    .topbar { padding: 12px 14px; gap: 8px; }
    .brand { font-size: 15px; }
    .nav-profile { padding: 7px 9px; }
    .nav-lang { max-width: 96px; padding: 7px 8px; }
    .hamburger { display: inline-flex; align-items: center; }

    /* The menu becomes a dropdown anchored under the bar (right side). */
    .nav-collapse {
        display: none;
        position: absolute;
        top: calc(100% - 2px);
        right: 14px;
        left: 14px;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        background: var(--bg2);
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 10px;
        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
        z-index: 60;
    }
    .nav-collapse.open { display: flex; }
    .nav-collapse .nav-link { padding: 12px; }
    .nav-collapse .nav-logout { width: 100%; text-align: center; padding: 12px; margin-top: 4px; }

    .shell { padding: 16px; }
    .card { padding: 22px 18px; }

    .stat-serial, .stat-member { grid-column: 1 / -1; }
    .mono { font-size: 17px; letter-spacing: 0.5px; }

    .profile-head h1 { font-size: 22px; }
    .avatar { width: 54px; height: 54px; }

    .guide-grid { grid-template-columns: 1fr; }
}
