:root {
    --bg: #f4efe6;
    --bg-2: #e8dfd0;
    --card: rgba(255, 252, 246, 0.88);
    --text: #1d1b19;
    --muted: #6a6158;
    --line: rgba(29, 27, 25, 0.12);
    --accent: #0d8f8f;
    --accent-2: #dd6b2d;
    --danger: #b2342d;
    --good: #1a7f4b;
    --shadow: 0 15px 45px rgba(36, 32, 27, 0.14);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 10% -5%, #f8d8ba 0%, transparent 60%),
        radial-gradient(900px 600px at 95% 100%, #b6e2db 0%, transparent 65%),
        linear-gradient(160deg, var(--bg), var(--bg-2));
    font-family: 'Space Grotesk', sans-serif;
}

h1, h2, h3 {
    font-family: 'Sora', sans-serif;
    margin-top: 0;
    letter-spacing: -0.02em;
}

.bg-orb {
    position: fixed;
    border-radius: 999px;
    filter: blur(45px);
    opacity: 0.42;
    pointer-events: none;
    z-index: 0;
}

.orb-a {
    width: 300px;
    height: 300px;
    background: #f2a664;
    top: 5%;
    left: 2%;
}

.orb-b {
    width: 380px;
    height: 380px;
    background: #57c9bb;
    bottom: 8%;
    right: 3%;
}

.landing {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.hero-card {
    width: min(760px, 96%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    padding: 2rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--accent);
    font-weight: 700;
    margin: 0 0 0.6rem;
}

.hero-card h1 {
    font-size: clamp(1.8rem, 4vw, 3rem);
    margin-bottom: 0.4rem;
}

.sub {
    color: var(--muted);
    max-width: 60ch;
}

.btn-discord {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1.4rem;
    padding: 0.75rem 1.4rem;
    background: #5865F2;
    color: #fff;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-discord:hover { background: #4752c4; }

.login-form {
    margin-top: 1.4rem;
    display: grid;
    gap: 0.7rem;
}

.login-form input,
.login-form button,
label input,
label textarea,
label select,
.inline-form input,
.inline-form select,
.inline-form button {
    font: inherit;
}

label {
    display: grid;
    gap: 0.45rem;
    font-weight: 600;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.75);
    border-radius: 12px;
    padding: 0.65rem 0.8rem;
    color: var(--text);
}

button {
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #35a8a8);
    color: #fff;
    font-weight: 700;
    padding: 0.72rem 1rem;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(13, 143, 143, 0.35);
}

button.danger {
    background: linear-gradient(135deg, var(--danger), #d34b43);
}

.hint {
    color: var(--muted);
    margin-top: 1rem;
}

.shell {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    border-right: 1px solid var(--line);
    background: rgba(255, 248, 239, 0.9);
    backdrop-filter: blur(8px);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.brand {
    font-family: 'Sora', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
}

.guild-pill {
    background: rgba(13, 143, 143, 0.12);
    color: #075e5f;
    border: 1px solid rgba(13, 143, 143, 0.22);
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    width: fit-content;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 0.56rem 0.72rem;
    border-radius: 11px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.nav-link:hover {
    background: rgba(13, 143, 143, 0.08);
    transform: translateX(3px);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(13, 143, 143, 0.2), rgba(221, 107, 45, 0.2));
    font-weight: 700;
}

.logout {
    margin-top: auto;
    color: var(--danger);
    text-decoration: none;
    font-weight: 700;
}

.main {
    padding: 1.2rem;
    display: grid;
    gap: 1rem;
}

.header-card,
.card {
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 1rem;
}

.header-card {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr auto;
    align-items: start;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(84px, 1fr));
    gap: 0.6rem;
}

.stat {
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.55rem;
    text-align: center;
}

.stat span {
    display: block;
    font-size: 1.35rem;
    font-family: 'Sora', sans-serif;
}

.stat small {
    color: var(--muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.form-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid button {
    align-self: end;
}

.grid.two {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 0.8rem;
}

.mini-card {
    background: rgba(255, 255, 255, 0.58);
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 0.8rem;
}

.mini-card ul {
    margin: 0;
    padding-left: 1rem;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
    margin-top: 0.8rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border-bottom: 1px solid var(--line);
    padding: 0.55rem;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 700;
    font-size: 0.92rem;
}

.inline-form {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
}

.inline-form-stacked {
    display: grid;
    gap: 0.4rem;
}

.flash {
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.8rem;
    border: 1px solid transparent;
}

.flash.success {
    background: rgba(26, 127, 75, 0.14);
    border-color: rgba(26, 127, 75, 0.3);
}

.flash.error {
    background: rgba(178, 52, 45, 0.14);
    border-color: rgba(178, 52, 45, 0.3);
}

.code-pill {
    font-family: 'Sora', sans-serif;
    font-size: 1.6rem;
    letter-spacing: 0.1em;
    margin: 0;
}

.muted {
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.sync-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.8rem;
}

.reveal {
    opacity: 0;
    transform: translateY(8px);
    animation: rise 0.55s ease forwards;
}

.delay-1 {
    animation-delay: 0.08s;
}

.delay-2 {
    animation-delay: 0.14s;
}

@keyframes rise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .nav {
        display: grid;
        grid-template-columns: repeat(4, minmax(80px, 1fr));
    }

    .header-card {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(84px, 1fr));

    /* ── Sidebar upgrades ──────────────────────────────────────────────── */
    .sidebar-brand {
        display: flex;
        align-items: center;
        gap: .55rem;
        padding: .1rem 0 .4rem;
    }
    .brand-icon { font-size: 1.5rem; line-height: 1; }
    .brand-text {
        font-family: 'Sora', sans-serif;
        font-size: 1.08rem;
        font-weight: 800;
    }

    .sidebar-guild {
        display: flex;
        align-items: center;
        gap: .55rem;
        background: rgba(13,143,143,.1);
        border: 1px solid rgba(13,143,143,.2);
        border-radius: 12px;
        padding: .45rem .7rem;
        min-width: 0;
    }
    .guild-icon {
        width: 28px; height: 28px;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
    }
    .guild-icon-fallback { font-size: 1.2rem; flex-shrink: 0; }
    .guild-name-text {
        font-weight: 700;
        font-size: .9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-icon {
        display: inline-block;
        width: 1.4em;
        text-align: center;
        font-size: .95em;
    }

    .sidebar-user {
        margin-top: auto;
        display: flex;
        align-items: center;
        gap: .6rem;
        padding-top: .8rem;
        border-top: 1px solid var(--line);
    }
    .sidebar-avatar {
        width: 34px; height: 34px;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
    }
    .sidebar-avatar-fallback {
        font-size: 1.6rem;
        flex-shrink: 0;
    }
    .sidebar-user-info { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
    .sidebar-username {
        font-weight: 700;
        font-size: .88rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .sidebar-logout {
        color: var(--danger);
        text-decoration: none;
        font-size: .8rem;
        font-weight: 700;
    }

    /* ── Page headers ──────────────────────────────────────────────────── */
    .page-header {
        margin-bottom: -.2rem;
    }
    .page-header h1 { margin-bottom: .2rem; font-size: 1.6rem; }
    .page-header .muted { margin: 0; }

    /* ── Stats as links ─────────────────────────────────────────────────── */
    a.stat {
        text-decoration: none;
        color: inherit;
        transition: transform .15s, box-shadow .15s;
    }
    a.stat:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 18px rgba(13,143,143,.2);
    }

    /* ── Quick action cards ─────────────────────────────────────────────── */
    .quick-actions {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: .7rem;
    }
    .quick-card {
        display: flex;
        flex-direction: column;
        gap: .25rem;
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 1rem;
        text-decoration: none;
        color: inherit;
        box-shadow: 0 4px 16px rgba(36,32,27,.07);
        transition: transform .18s, box-shadow .18s;
    }
    .quick-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow);
    }
    .quick-icon { font-size: 1.6rem; }
    .quick-card strong { font-weight: 700; }
    .quick-card .muted { font-size: .83rem; }

    /* ── Form enhancements ──────────────────────────────────────────────── */
    .form-section { margin-bottom: 1.2rem; }
    .form-section:last-of-type { margin-bottom: 0; }
    .form-section-title {
        font-size: .78rem;
        text-transform: uppercase;
        letter-spacing: .1em;
        color: var(--muted);
        margin: 0 0 .6rem;
        font-weight: 700;
    }
    .form-row {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: .75rem;
        margin-bottom: .6rem;
    }
    .form-row:last-child { margin-bottom: 0; }
    .form-actions {
        display: flex;
        gap: .6rem;
        flex-wrap: wrap;
        margin-top: .8rem;
    }
    .field-hint {
        display: block;
        font-weight: 400;
        font-size: .78rem;
        color: var(--muted);
        margin-bottom: .15rem;
    }
    .event-form, .setup-form { display: grid; gap: .1rem; }
    .btn-cancel {
        background: transparent !important;
        color: var(--muted) !important;
        border: 1px solid var(--line) !important;
        box-shadow: none !important;
    }
    .btn-cancel:hover { background: rgba(0,0,0,.04) !important; transform: none !important; }
    .btn-sm {
        padding: .45rem .8rem !important;
        font-size: .88rem !important;
    }

    /* ── Event cards ────────────────────────────────────────────────────── */
    .event-list { display: grid; gap: .65rem; margin-top: .6rem; }
    .event-card {
        background: rgba(255,255,255,.62);
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: .85rem 1rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        flex-wrap: wrap;
    }
    .event-card-main { flex: 1; min-width: 0; }
    .event-card-header {
        display: flex;
        align-items: baseline;
        gap: .5rem;
        flex-wrap: wrap;
        margin-bottom: .4rem;
    }
    .event-number {
        font-family: 'Sora', sans-serif;
        font-weight: 800;
        font-size: .9rem;
        color: var(--muted);
    }
    .event-name {
        font-weight: 700;
        font-size: 1rem;
    }
    .event-meta {
        display: flex;
        flex-wrap: wrap;
        gap: .4rem .8rem;
        font-size: .82rem;
        color: var(--muted);
        align-items: center;
    }
    .event-card-actions {
        display: flex;
        gap: .5rem;
        flex-shrink: 0;
        align-items: center;
        flex-wrap: wrap;
    }
    .btn-edit {
        background: rgba(13,143,143,.12);
        color: var(--accent);
        border: 1px solid rgba(13,143,143,.25);
        border-radius: 10px;
        padding: .4rem .75rem;
        font-weight: 700;
        font-size: .85rem;
        cursor: pointer;
        transition: background .15s, transform .15s;
    }
    .btn-edit:hover {
        background: rgba(13,143,143,.22);
        transform: translateY(-1px);
        box-shadow: none;
    }

    /* ── Tags & badges ──────────────────────────────────────────────────── */
    .tag {
        display: inline-block;
        background: rgba(29,27,25,.08);
        border-radius: 999px;
        padding: .18rem .6rem;
        font-size: .78rem;
        font-weight: 600;
        white-space: nowrap;
    }
    .tag-type {
        background: rgba(13,143,143,.12);
        color: var(--accent);
    }
    .tag-green {
        background: rgba(26,127,75,.12);
        color: var(--good);
    }
    .count-badge {
        display: inline-block;
        background: rgba(13,143,143,.15);
        color: var(--accent);
        border-radius: 999px;
        padding: .1rem .55rem;
        font-size: .78rem;
        font-weight: 700;
        vertical-align: middle;
        margin-left: .3rem;
    }
    .status-badge {
        display: inline-block;
        border-radius: 999px;
        padding: .2rem .65rem;
        font-size: .82rem;
        font-weight: 700;
    }
    .status-pending  { background: rgba(200,150,0,.12); color: #a07800; }
    .status-approved { background: rgba(26,127,75,.12); color: var(--good); }
    .status-denied   { background: rgba(178,52,45,.12); color: var(--danger); }

    /* ── Profile cards ──────────────────────────────────────────────────── */
    .profile-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: .7rem;
        margin-top: .6rem;
    }
    .profile-card {
        background: rgba(255,255,255,.62);
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: .85rem 1rem;
        display: flex;
        flex-direction: column;
        gap: .5rem;
    }
    .profile-card-id {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: .3rem;
    }
    .profile-genres, .profile-links {
        display: flex;
        flex-wrap: wrap;
        gap: .3rem;
        align-items: center;
    }
    .profile-links a {
        font-size: .82rem;
        font-weight: 600;
        color: var(--accent);
        text-decoration: none;
        background: rgba(13,143,143,.08);
        border-radius: 8px;
        padding: .2rem .5rem;
        transition: background .15s;
    }
    .profile-links a:hover { background: rgba(13,143,143,.18); }
    .profile-card-actions {
        display: flex;
        gap: .4rem;
        align-items: center;
        margin-top: .2rem;
        flex-wrap: wrap;
    }

    /* ── Genre chips ────────────────────────────────────────────────────── */
    .genre-category { margin-bottom: 1.1rem; }
    .genre-category:last-child { margin-bottom: 0; }
    .genre-category-title {
        font-size: .75rem;
        text-transform: uppercase;
        letter-spacing: .1em;
        color: var(--muted);
        margin: 0 0 .4rem;
        font-weight: 700;
    }
    .genre-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
    .genre-chip {
        display: inline-flex;
        align-items: center;
        gap: .3rem;
        background: rgba(29,27,25,.07);
        border-radius: 999px;
        padding: .28rem .75rem;
        font-size: .85rem;
        font-weight: 600;
    }
    .genre-chip-custom {
        background: rgba(13,143,143,.1);
        color: #066262;
        border: 1px solid rgba(13,143,143,.18);
    }
    .chip-delete { display: contents; }
    .chip-delete-btn {
        background: none;
        border: none;
        color: var(--muted);
        cursor: pointer;
        font-size: .75rem;
        padding: 0;
        line-height: 1;
        border-radius: 50%;
        transition: color .15s, transform .15s;
        box-shadow: none;
    }
    .chip-delete-btn:hover { color: var(--danger); transform: none; box-shadow: none; }

    /* ── Subscriber list ────────────────────────────────────────────────── */
    .subscriber-list { display: grid; gap: .45rem; margin-top: .5rem; }
    .subscriber-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        background: rgba(255,255,255,.55);
        border: 1px solid var(--line);
        border-radius: 11px;
        padding: .6rem .85rem;
        flex-wrap: wrap;
    }

    /* ── Application cards ──────────────────────────────────────────────── */
    .app-list { display: grid; gap: .75rem; }
    .app-card {
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 1rem 1.1rem;
        display: grid;
        gap: .65rem;
    }
    .app-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        flex-wrap: wrap;
        gap: .5rem;
    }
    .app-notes {
        margin: 0;
        font-size: .88rem;
        padding: .4rem .7rem;
        background: rgba(0,0,0,.04);
        border-radius: 8px;
    }
    .app-review-form { margin-top: .1rem; }

    /* ── Empty states ───────────────────────────────────────────────────── */
    .empty-state {
        text-align: center;
        padding: 2rem 1rem;
        color: var(--muted);
    }
    .empty-state p { margin: .5rem 0 0; }

    /* ── Guild switcher in header ───────────────────────────────────────── */
    #guild-switch-form select {
        background: rgba(255,255,255,.8);
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: .4rem .65rem;
        font-size: .9rem;
        max-width: 220px;
    }

    /* ── Responsive additions ───────────────────────────────────────────── */
    @media (max-width: 980px) {
        .quick-actions { grid-template-columns: repeat(2, 1fr); }
        .profile-grid  { grid-template-columns: 1fr; }
        .event-card    { flex-direction: column; align-items: flex-start; }
        .event-card-actions { width: 100%; justify-content: flex-end; }
        .form-row      { grid-template-columns: 1fr; }
        .sidebar-guild { display: none; }
    }
    }

    .grid.two {
        grid-template-columns: 1fr;
    }
}
