:root {
    --bg: #0e0b16;
    --bg-elev: #17131f;
    --surface: #1d1830;
    --surface-2: #241d3a;
    --border: #2e2745;
    --violet: #8b5cf6;
    --violet-bright: #a78bfa;
    --violet-deep: #6d28d9;
    --violet-glow: rgba(139, 92, 246, 0.35);
    --text: #ece9f5;
    --text-dim: #a49fc0;
    --text-faint: #6f6a8a;
    --danger: #f87171;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

h1:focus {
    outline: none;
}

/* ---- App shell ---- */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 24px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--violet), var(--violet-deep));
    box-shadow: 0 0 18px var(--violet-glow);
    font-size: 1rem;
    color: #fff;
}

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

.app-content {
    flex: 1;
    padding: 32px 24px;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.user-chip img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover {
    background: var(--surface-2);
    border-color: var(--violet);
}

.btn:active {
    transform: translateY(1px);
}

.btn-ghost {
    background: transparent;
}

/* ---- Login screen ---- */
.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1000px 600px at 50% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 36px;
    text-align: center;
}

.login-mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--violet), var(--violet-deep));
    box-shadow: 0 0 30px var(--violet-glow);
    font-size: 1.6rem;
    color: #fff;
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 1.5rem;
}

.login-card .subtitle {
    margin: 0 0 28px;
    color: var(--text-dim);
    font-size: 0.92rem;
}

.btn-google {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.98rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--violet), var(--violet-deep));
    border: none;
    color: #fff;
    box-shadow: 0 6px 24px var(--violet-glow);
}

.btn-google:hover {
    filter: brightness(1.08);
    background: linear-gradient(135deg, var(--violet), var(--violet-deep));
    border: none;
}

.btn-google svg {
    background: #fff;
    border-radius: 3px;
    padding: 2px;
}

.login-hint {
    margin-top: 20px;
    font-size: 0.78rem;
    color: var(--text-faint);
}

/* ---- Loading ---- */
.auth-loading {
    min-height: 100vh;
    display: grid;
    place-items: center;
    color: var(--text-dim);
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--violet);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
}

/* ---- Blazor error UI ---- */
#blazor-error-ui {
    background: var(--surface-2);
    color: var(--text);
    border-top: 1px solid var(--danger);
    bottom: 0;
    box-shadow: 0 -1px 20px rgba(0, 0, 0, 0.5);
    display: none;
    left: 0;
    padding: 0.8rem 1.4rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.75rem;
}

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: #1a0000;
}

/* ---- Top nav ---- */
.topnav {
    display: flex;
    gap: 6px;
    margin-right: auto;
    margin-left: 28px;
}

.topnav-link {
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.topnav-link:hover {
    color: var(--text);
    background: var(--surface-2);
}

.topnav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--violet), var(--violet-deep));
}

/* ---- Mobile top bar ---- */
@media (max-width: 640px) {
    .topbar {
        height: auto;
        flex-wrap: wrap;
        gap: 8px 12px;
        padding: 10px 16px;
    }

    .brand {
        font-size: 1.05rem;
    }

    .topnav {
        order: 3;
        margin: 0;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .topnav::-webkit-scrollbar {
        display: none;
    }

    .topnav-link {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .user-chip {
        margin-left: auto;
        gap: 8px;
        max-width: 55%;
    }

    /* Hide the long email/name text on mobile; keep avatar + sign-out. */
    .user-chip > span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-content {
        padding: 20px 16px;
    }
}

/* ---- Notifications list ---- */
.notif-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notif-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
}

.notif-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.notif-title {
    font-weight: 600;
}

.notif-time {
    flex: 0 0 auto;
    font-size: 0.78rem;
    color: var(--text-faint);
}

.notif-body {
    margin: 6px 0 0;
    color: var(--text-dim);
    overflow-wrap: anywhere;
}

.notif-topic {
    display: inline-block;
    margin-top: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--violet-bright);
}

/* ---- Topics page ---- */
.topics-page {
    max-width: 640px;
    margin: 0 auto;
}

.topics-page h1 {
    margin: 0 0 4px;
    font-size: 1.6rem;
}

.topics-sub {
    color: var(--text-dim);
    margin: 0 0 28px;
}

.topics-empty {
    color: var(--text-faint);
}

.topic-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 28px;
}

.topic-category {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
}

.topic-category-title {
    margin: 6px 0 2px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--violet-bright);
}

.topic-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.topic-row:hover {
    border-color: var(--violet);
    background: var(--surface-2);
}

.topic-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.topic-name {
    font-weight: 600;
}

.topic-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    overflow-wrap: anywhere;
}

.topics-status {
    margin-top: 16px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* ---- Toggle switch ---- */
.switch {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 26px;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: background 0.15s, border-color 0.15s;
    pointer-events: none;
}

.switch .slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: transform 0.15s, background 0.15s;
}

.switch input:checked + .slider {
    background: linear-gradient(135deg, var(--violet), var(--violet-deep));
    border-color: var(--violet);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
    background: #fff;
}
