:root {
    --bg: #0a0a0d;
    --bg-alt: #111217;
    --bg-card: #15161c;
    --bg-elevated: #1c1d26;
    --text: #f5f5f7;
    --text-muted: #8b8d98;
    --text-faint: #555765;
    --accent: #7c5cff;
    --accent-2: #22d3ee;
    --accent-hover: #9078ff;
    --accent-active: #6a49e6;
    --accent-soft: rgba(124, 92, 255, 0.14);
    --gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
    --green: #10b981;
    --red: #f43f5e;
    --border: #23242d;
    --border-soft: rgba(255, 255, 255, 0.07);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
    --glow: 0 0 0 1px rgba(124, 92, 255, 0.4), 0 0 24px rgba(124, 92, 255, 0.25);
    --radius: 14px;
    --radius-sm: 9px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scrollbar-color: var(--bg-elevated) var(--bg);
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15.5px;
    line-height: 1.6;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 900px 500px at 12% -8%, rgba(124, 92, 255, 0.16), transparent 60%),
        radial-gradient(ellipse 700px 500px at 92% 0%, rgba(34, 211, 238, 0.10), transparent 55%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 999px;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3, h4 {
    font-weight: 750;
    letter-spacing: -0.02em;
    margin: 0 0 8px;
}

h1 {
    font-size: 1.7rem;
}

h3 {
    font-size: 1.02rem;
    color: var(--text);
    margin-top: 34px;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

p {
    color: var(--text-muted);
}

code {
    background: var(--bg-elevated);
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 0.85em;
    color: var(--accent-2);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: rgba(10, 10, 13, 0.72);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border-bottom: 1px solid var(--border-soft);
}

.brand {
    font-weight: 800;
    font-size: 1.08rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 9px;
}

.brand-logo {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--border-soft), 0 0 14px rgba(124, 92, 255, 0.35);
}

.hero-logo {
    width: 88px;
    height: 88px;
    border-radius: 24px;
    margin: 0 auto 20px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(124, 92, 255, 0.25);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.89rem;
    color: var(--text-muted);
}

.content {
    padding: 40px 24px 72px;
    max-width: 1120px;
    margin: 0 auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border-soft);
    cursor: pointer;
    font-size: 0.89rem;
    font-weight: 600;
    font-family: inherit;
    transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
    background: #24252f;
    border-color: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Primary actions (Save/Add/etc. - any submit button that isn't small/danger) get the gradient treatment */
.btn:not(.btn-small):not(.btn-danger),
.btn-discord {
    background: var(--gradient);
    border: none;
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn:not(.btn-small):not(.btn-danger):hover,
.btn-discord:hover {
    box-shadow: var(--glow);
    transform: translateY(-1px);
}

.btn-small {
    padding: 6px 13px;
    font-size: 0.82rem;
}

.btn-danger {
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.3);
    color: #ff8fa3;
}

.btn-danger:hover {
    background: rgba(244, 63, 94, 0.2);
    border-color: rgba(244, 63, 94, 0.5);
}

.btn-discord {
    padding: 13px 30px;
    font-size: 0.95rem;
    border-radius: 11px;
}

.center-card {
    max-width: 430px;
    margin: 110px auto;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    padding: 48px 38px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.center-card h1 {
    font-size: 1.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin-top: -8px;
}

.guild-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.guild-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 24px 18px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.guild-card:not(.disabled):hover {
    transform: translateY(-4px);
    box-shadow: var(--glow);
    border-color: rgba(124, 92, 255, 0.4);
}

.guild-card.disabled {
    opacity: 0.45;
}

.guild-icon, .guild-icon-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto 14px;
    box-shadow: 0 0 0 3px var(--bg-alt);
}

.guild-icon-placeholder {
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.guild-name {
    font-weight: 650;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.badge {
    display: inline-block;
    font-size: 0.76rem;
    color: var(--text-muted);
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-soft);
}

.guild-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.sidebar {
    width: 216px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 92px;
}

.sidebar-guild {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-soft);
    letter-spacing: -0.01em;
}

.guild-icon-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100vh - 230px);
    overflow-y: auto;
    padding-right: 4px;
}

.sidebar-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    padding: 14px 12px 4px;
}

.sidebar-group-label:first-child {
    padding-top: 4px;
}

.sidebar-nav a {
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.89rem;
    font-weight: 550;
    border-left: 2px solid transparent;
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.sidebar-nav a:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--accent-soft);
    color: #c9bfff;
    border-left-color: var(--accent);
    font-weight: 650;
}

.back-link {
    display: block;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-soft);
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: color 160ms ease;
}

.back-link:hover {
    color: var(--text);
}

.guild-content {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 30px 32px;
    box-shadow: var(--shadow-sm);
}

.stat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 16px;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 16px 24px;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--text-muted);
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
select,
input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    max-width: 400px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea {
    resize: vertical;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus,
select:focus,
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 18px;
    font-size: 0.91rem;
}

table.data-table th,
table.data-table td {
    text-align: left;
    padding: 13px 10px;
    border-bottom: 1px solid var(--border-soft);
}

table.data-table th {
    color: var(--text-faint);
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

table.data-table tbody tr {
    transition: background-color 160ms ease;
}

table.data-table tbody tr:hover {
    background: var(--bg-elevated);
}

.pill {
    display: inline-block;
    background: var(--bg-elevated);
    border: 1px solid var(--border-soft);
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.79rem;
    margin: 2px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    border: 1px solid transparent;
    border-left-width: 3px;
}

.flash-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.25);
    border-left-color: var(--green);
    color: #5eead4;
}

.flash-error {
    background: rgba(244, 63, 94, 0.1);
    border-color: rgba(244, 63, 94, 0.25);
    border-left-color: var(--red);
    color: #ff9eae;
}

.inline-form {
    display: inline;
}

.empty-state {
    color: var(--text-muted);
    padding: 34px 20px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.91rem;
    background: rgba(255, 255, 255, 0.015);
}

.site-footer {
    text-align: center;
    padding: 36px 16px 44px;
    color: var(--text-faint);
    font-size: 0.82rem;
}

.site-footer a {
    color: var(--text-faint);
    text-decoration: none;
    transition: color 160ms ease;
}

.site-footer a:hover {
    color: var(--text);
    text-decoration: underline;
}

.site-footer span {
    margin: 0 8px;
}

.legal-page {
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.7;
}

.legal-page h3 {
    margin-top: 28px;
}

@media (max-width: 760px) {
    .content {
        padding: 24px 16px 56px;
    }

    .topbar {
        padding: 14px 16px;
    }

    .guild-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
        overflow-y: visible;
    }

    .sidebar-group-label {
        flex-basis: 100%;
        padding: 10px 4px 2px;
    }

    .sidebar-nav a {
        border-left: none;
        border-bottom: 2px solid transparent;
    }

    .sidebar-nav a.active {
        border-bottom-color: var(--accent);
    }

    .guild-content {
        padding: 22px;
        width: 100%;
    }

    .stat-grid {
        flex-direction: column;
    }

    table.data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ---- Grouped settings sections (cards in a grid, instead of a flat stack) ---- */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.page-head p {
    margin: 4px 0 0;
    max-width: 60ch;
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: start;
    gap: 16px;
    margin-bottom: 16px;
}

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

.section-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 20px 22px;
}

.section-card > h4 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.section-card .section-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 16px;
    line-height: 1.5;
}

.section-card form {
    margin: 0;
}

.section-card .form-group:last-child {
    margin-bottom: 0;
}

.section-card .form-group select,
.section-card .form-group input {
    max-width: none;
}

.field-row {
    display: flex;
    gap: 12px;
}

.field-row .form-group {
    flex: 1;
    min-width: 0;
}

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.pill-list:empty {
    display: none;
}

/* Real sliding track-and-thumb toggle switch (iOS/Material pattern) - still a
   plain <button type="submit"> under the hood, state comes from the
   server-rendered .is-on class, no JS involved. */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 40px;
    height: 23px;
    padding: 3px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--bg-alt);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 160ms ease, border-color 160ms ease;
}

.toggle-switch:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.toggle-switch .dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--text-faint);
    transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.toggle-switch.is-on {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch.is-on .dot {
    background: #fff;
    transform: translateX(17px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.switch-field {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
}

.rule-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rule-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.rule-card .rule-name {
    font-weight: 650;
    font-size: 0.9rem;
}

.log-row {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
}

.log-row:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.log-row:first-child {
    padding-top: 0;
}

.log-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.log-row-label {
    font-size: 0.87rem;
    font-weight: 550;
}

.log-row-channel {
    display: flex;
    gap: 6px;
}

.log-row-channel select {
    font-size: 0.82rem;
    padding: 6px 8px;
}

.channel-search-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.channel-search-native {
    display: none;
}

.channel-search-input {
    width: 100%;
    max-width: none;
    font-size: 0.82rem;
    padding: 6px 8px;
    box-sizing: border-box;
}

.channel-search-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 20;
}

.channel-search-item {
    padding: 7px 10px;
    font-size: 0.82rem;
    cursor: pointer;
}

.channel-search-item:hover,
.channel-search-item.is-selected {
    background: var(--accent);
    color: #fff;
}

.channel-search-empty {
    padding: 7px 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.hero {
    text-align: center;
    padding: 56px 20px 8px;
}

.hero-title {
    font-size: 3rem;
    letter-spacing: -0.03em;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 14px;
}

.hero-tagline {
    max-width: 580px;
    margin: 0 auto 28px;
    font-size: 1.06rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px var(--border-soft);
}
