:root {
    --site-bg: #010409;
    --site-text: #ffffff;
    --site-accent: #2f8cff;
    --site-accent-soft: rgba(47, 140, 255, 0.25);
    --site-accent-faint: rgba(47, 140, 255, 0.15);
    --site-accent-glow: rgba(47, 140, 255, 0.05);
    --site-bottom-glow: rgba(47, 140, 255, 0.2);

    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-right: env(safe-area-inset-right, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-safe-left: env(safe-area-inset-left, 0px);

    --app-mobile-header-content-height: 56px;
    --app-mobile-header-total-height: calc(
        var(--app-mobile-header-content-height) + var(--app-safe-top)
    );
    --app-bottom-nav-content-height: 64px;
    --app-bottom-nav-border-height: 1px;
    --app-bottom-nav-total-height: calc(
        var(--app-bottom-nav-content-height) +
        var(--app-safe-bottom) +
        var(--app-bottom-nav-border-height)
    );
}

body[data-site-theme="black"] {
    --site-bg: #000000;
}

body[data-site-theme="white"] {
    --site-bg: #F5F7FA;
    --site-text: #111827;
    --site-accent: #2563EB;
    --site-accent-soft: rgba(37, 99, 235, 0.14);
    --site-accent-faint: rgba(37, 99, 235, 0.08);
    --site-accent-glow: rgba(37, 99, 235, 0.04);
    --site-bottom-glow: rgba(37, 99, 235, 0.10);

    --card-analytics-bg: #FFFFFF;
}

body[data-site-theme="midnight"] {
    color-scheme: dark;
}

body[data-site-theme="white"] {
    color-scheme: light;
}

body[data-site-theme="white"] .analytics-title,
body[data-site-theme="white"] .analytics-toolbar h2,
body[data-site-theme="white"] .analytics-card__title,
body[data-site-theme="white"] .analytics-card__title a,
body[data-site-theme="white"] .analytics-create-form__section-head h4,
body[data-site-theme="white"] .analytics-compose-box__header label,
body[data-site-theme="white"] .analytics-section-card__header h4 {
    color: #111827;
}

body[data-site-theme="white"] .analytics-subtitle,
body[data-site-theme="white"] .analytics-toolbar p,
body[data-site-theme="white"] .category-group-title,
body[data-site-theme="white"] .analytics-card__excerpt,
body[data-site-theme="white"] .analytics-create-form__section-head p,
body[data-site-theme="white"] .analytics-compose-box__header p,
body[data-site-theme="white"] .analytics-section-card__header p,
body[data-site-theme="white"] .analytics-cover-upload__filename,
body[data-site-theme="white"] .analytics-color-field__hint {
    color: #6B7280;
}

body[data-site-theme="white"] .analytics-search input {
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #111827;
}

body[data-site-theme="white"] .analytics-search input::placeholder {
    color: #9CA3AF;
}

body[data-site-theme="white"] .analytics-search input:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

body[data-site-theme="white"] .category-btn {
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #374151;
}

body[data-site-theme="white"] .category-btn:hover {
    border-color: rgba(37, 99, 235, 0.35);
    color: #2563EB;
    background: #F8FAFC;
}

body[data-site-theme="white"] .category-btn.active {
    background: #2563EB;
    border-color: #2563EB;
    color: #FFFFFF !important;
}

body[data-site-theme="white"] .analytics-card {
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

body[data-site-theme="white"] .analytics-card:hover {
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.10);
}

body[data-site-theme="white"] .analytics-meta-chip {
    background: #F3F4F6;
    color: #6B7280;
}

body[data-site-theme="white"] .analytics-stat__label {
    color: #9CA3AF;
}

body[data-site-theme="white"] .analytics-stat__value {
    color: #111827;
}

body[data-site-theme="white"] .analytics-card__button {
    background: rgba(37, 99, 235, 0.10);
    color: #2563EB;
}

body[data-site-theme="white"] .analytics-card__button:hover {
    background: #2563EB;
    color: #FFFFFF;
}

body[data-site-theme="white"] .analytics-card__manage {
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #374151;
}

body[data-site-theme="white"] .analytics-empty__box {
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #111827;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

body[data-site-theme="white"] .analytics-modal__backdrop {
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

body[data-site-theme="white"] .analytics-modal__dialog {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(229, 231, 235, 0.95);
    box-shadow: 0 35px 80px rgba(15, 23, 42, 0.22);
    color: #111827;
}

body[data-site-theme="white"] .analytics-modal__header h3 {
    color: #111827;
}

body[data-site-theme="white"] .analytics-modal__close {
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #374151;
}

body[data-site-theme="white"] .analytics-create-form__section {
    border-top-color: #E5E7EB;
}

body[data-site-theme="white"] .analytics-create-form__field label {
    color: #374151;
}

body[data-site-theme="white"] .analytics-create-form__field input[type="text"],
body[data-site-theme="white"] .analytics-create-form__field input[type="file"],
body[data-site-theme="white"] .analytics-create-form__field select,
body[data-site-theme="white"] .analytics-create-form__field textarea {
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #111827;
}

body[data-site-theme="white"] .analytics-create-form__field input:focus,
body[data-site-theme="white"] .analytics-create-form__field select:focus,
body[data-site-theme="white"] .analytics-create-form__field textarea:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

body[data-site-theme="white"] .analytics-cover-upload {
    border-color: #D1D5DB;
    background: radial-gradient(circle at top, rgba(37, 99, 235, 0.08), transparent 45%),
    #FFFFFF;
}

body[data-site-theme="white"] .analytics-cover-upload:hover {
    border-color: rgba(37, 99, 235, 0.45);
    background: #F8FAFC;
}

body[data-site-theme="white"] .analytics-cover-upload__empty {
    color: #374151;
}

body[data-site-theme="white"] .analytics-cover-upload__empty span {
    color: #6B7280;
}

body[data-site-theme="white"] .markdown-editor-surface,
body[data-site-theme="white"] .analytics-editor-surface {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    color: #111827;
}

body[data-site-theme="white"] .markdown-editor-surface:empty::before,
body[data-site-theme="white"] .analytics-editor-surface:empty::before {
    color: #9CA3AF;
}

body[data-site-theme="white"] .markdown-editor-surface:focus,
body[data-site-theme="white"] .analytics-editor-surface:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

body[data-site-theme="white"] .analytics-create-form__actions {
    background: rgba(255, 255, 255, 0.86);
    border-top: 1px solid #E5E7EB;
}

body[data-site-theme="white"] .analytics-create-form__secondary {
    border: 1px solid #D1D5DB;
    background: #FFFFFF;
    color: #374151;
}

body[data-site-theme="white"] .analytics-create-form__secondary:hover {
    background: #F3F4F6;
}

body[data-site-theme="white"] .analytics-create-form__submit,
body[data-site-theme="white"] .analytics-create-btn {
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
    color: #FFFFFF;
}

body[data-site-theme="white"] .analytics-create-form__submit:hover,
body[data-site-theme="white"] .analytics-create-btn:hover {
    background: linear-gradient(135deg, #1D4ED8, #1E40AF);
}

body[data-site-theme="white"] .analytics-create-form input[type="checkbox"] {
    accent-color: #2563EB;
}

body[data-site-theme="white"] .analytics-context-menu {
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

body[data-site-theme="white"] .analytics-context-menu__item {
    color: #374151;
}

body[data-site-theme="white"] .analytics-context-menu__item:hover {
    background: rgba(37, 99, 235, 0.10);
    color: #2563EB;
}

body[data-site-theme="white"] .analytics-context-menu__shortcut {
    color: #9CA3AF;
}

body[data-site-theme="white"] ::-webkit-scrollbar-thumb {
    background: rgba(17, 24, 39, 0.20);
}

body[data-site-theme="white"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(17, 24, 39, 0.34);
}


html {
    scrollbar-gutter: stable;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html.chat-page-root {
    scrollbar-gutter: auto;
}

html.feed-page-root {
    scrollbar-gutter: auto;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

main {
    flex: 1;
    width: 100%;
}

body {
    font-family: 'Tahoma', sans-serif;
    background: var(--site-bg);
    color: var(--site-text);
    line-height: 1.5;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);

    width: 1200px;
    height: 800px;

    background: radial-gradient(
            circle,
            var(--site-accent-soft) 0%,
            var(--site-accent-faint) 30%,
            var(--site-accent-glow) 50%,
            transparent 70%
    );

    filter: blur(120px);
    z-index: -1;
}

body::after {
    content: "";
    position: fixed;
    bottom: -200px;
    right: -200px;

    width: 600px;
    height: 600px;

    background: radial-gradient(
            circle,
            var(--site-bottom-glow),
            transparent 70%
    );

    filter: blur(100px);
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

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

button {
    border: none;
    background: none;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

img {
    max-width: 100%;
    display: block;
}

@media (max-width: 768px) {
    main {
        padding-top: var(--app-safe-top);
    }

    body {
        padding-bottom: var(--app-bottom-nav-total-height);
    }

    html.feed-page-root main {
        padding-top: 0;
    }

    html.feed-page-root body {
        padding-bottom: 0;
    }

    body.chat-page.chat-mobile-open {
        padding-bottom: 0;
    }
}

/* Cookie notice: floating in the lower-left corner, never changes document layout. */
.cookie-consent {
    height: 0;
    flex: 0 0 auto;
    pointer-events: none;
}

.cookie-consent__banner {
    position: fixed;
    z-index: 10020;
    left: calc(20px + var(--app-safe-left));
    bottom: calc(20px + var(--app-safe-bottom));
    width: min(352px, calc(100vw - 40px - var(--app-safe-left) - var(--app-safe-right)));
    padding: 16px 16px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(10, 13, 18, 0.96);
    color: #f3f4f6;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
    pointer-events: auto;
    animation: cookie-consent-appear 220ms ease-out both;
}

.cookie-consent__line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px;
    align-items: start;
    gap: 12px;
}

.cookie-consent__content {
    min-width: 0;
}

.cookie-consent__title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.01em;
    color: #ffffff;
}

.cookie-consent__text {
    margin: 6px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: #a1a1aa;
    text-align: left;
}

.cookie-consent__policy-link {
    color: #d4d4d8;
    text-decoration: underline;
    text-decoration-color: rgba(212, 212, 216, 0.34);
    text-underline-offset: 3px;
    white-space: nowrap;
}

.cookie-consent__policy-link:hover,
.cookie-consent__policy-link:focus-visible {
    color: #ffffff;
    text-decoration-color: rgba(255, 255, 255, 0.58);
}

.cookie-consent__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 13px;
}

.cookie-consent__accept {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: #171b22;
    color: #f8fafc;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.cookie-consent__accept:hover,
.cookie-consent__accept:focus-visible {
    background: #1e232c;
    border-color: rgba(255, 255, 255, 0.12);
}

.cookie-consent__accept:active {
    transform: translateY(1px);
}

.cookie-consent__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 9px;
    color: #7c8594;
    background: rgba(255, 255, 255, 0.02);
    transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.cookie-consent__close svg {
    width: 14px;
    height: 14px;
}

.cookie-consent__close:hover,
.cookie-consent__close:focus-visible {
    color: #d4d4d8;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.10);
}

body[data-site-theme="white"] .cookie-consent__banner {
    background: rgba(255, 255, 255, 0.96);
    color: #111827;
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
}

body[data-site-theme="white"] .cookie-consent__title {
    color: #0f172a;
}

body[data-site-theme="white"] .cookie-consent__text {
    color: #6b7280;
}

body[data-site-theme="white"] .cookie-consent__policy-link {
    color: #374151;
    text-decoration-color: rgba(55, 65, 81, 0.28);
}

body[data-site-theme="white"] .cookie-consent__policy-link:hover,
body[data-site-theme="white"] .cookie-consent__policy-link:focus-visible {
    color: #111827;
    text-decoration-color: rgba(17, 24, 39, 0.48);
}

body[data-site-theme="white"] .cookie-consent__accept {
    background: #111827;
    color: #ffffff;
    border-color: #111827;
}

body[data-site-theme="white"] .cookie-consent__accept:hover,
body[data-site-theme="white"] .cookie-consent__accept:focus-visible {
    background: #1f2937;
    border-color: #1f2937;
}

body[data-site-theme="white"] .cookie-consent__close {
    color: #6b7280;
    border-color: rgba(15, 23, 42, 0.08);
    background: rgba(15, 23, 42, 0.02);
}

body[data-site-theme="white"] .cookie-consent__close:hover,
body[data-site-theme="white"] .cookie-consent__close:focus-visible {
    color: #111827;
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.12);
}

@media (max-width: 768px) {
    .cookie-consent__banner {
        left: calc(12px + var(--app-safe-left));
        bottom: calc(var(--app-bottom-nav-total-height) + 12px);
        width: min(340px, calc(100vw - 92px - var(--app-safe-left) - var(--app-safe-right)));
        padding: 14px 14px 13px;
        border-radius: 15px;
    }

    .cookie-consent__line {
        grid-template-columns: minmax(0, 1fr) 24px;
        gap: 8px;
    }

    .cookie-consent__title {
        font-size: 13.5px;
    }

    .cookie-consent__text {
        font-size: 12.5px;
        line-height: 1.45;
    }

    .cookie-consent__accept {
        min-height: 32px;
        padding: 0 13px;
        font-size: 12px;
    }

    .cookie-consent__close {
        width: 24px;
        height: 24px;
        border-radius: 8px;
    }
}

.cookie-consent__banner.is-closing {
    animation: cookie-consent-disappear 170ms ease-in both;
}

@keyframes cookie-consent-appear {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes cookie-consent-disappear {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
    .cookie-consent__banner,
    .cookie-consent__banner.is-closing {
        animation: none;
    }

    .cookie-consent__accept,
    .cookie-consent__close {
        transition: none;
    }
}

body[data-site-theme="black"] {
    color-scheme: dark;

    --site-bg: #000000;
    --site-text: #f5f5f5;

    --site-accent: #2f8cff;
    --site-accent-soft: rgba(47, 140, 255, 0.18);
    --site-accent-faint: rgba(47, 140, 255, 0.10);
    --site-accent-glow: transparent;
    --site-bottom-glow: transparent;

    --black-bg: #000000;
    --black-surface: #070707;
    --black-surface-raised: #0d0d0d;
    --black-surface-hover: #141414;

    --black-border: #202020;
    --black-border-soft: #171717;

    --black-text: #f5f5f5;
    --black-text-secondary: #b0b0b0;
    --black-text-muted: #737373;
}

body[data-site-theme="black"] {
    background: #000000;
    color: var(--black-text);
}

body[data-site-theme="black"]::before,
body[data-site-theme="black"]::after {
    display: none;
}

body[data-site-theme="black"] ::selection {
    background: rgba(47, 140, 255, 0.35);
    color: #ffffff;
}

body[data-site-theme="black"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body[data-site-theme="black"] ::-webkit-scrollbar-track {
    background: #000000;
}

body[data-site-theme="black"] ::-webkit-scrollbar-thumb {
    background: #262626;
    border-radius: 999px;
}

body[data-site-theme="black"] ::-webkit-scrollbar-thumb:hover {
    background: #383838;
}

.push-notification-prompt[hidden] {
    display: none !important;
}

.push-notification-prompt {
    position: fixed;
    z-index: 11000;
    right: 20px;
    bottom: 20px;

    width: min(390px, calc(100vw - 32px));
    padding: 16px;

    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;

    background: rgba(11, 18, 32, 0.97);
    color: #f8fafc;

    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(16px);
}

.push-notification-prompt__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.push-notification-prompt__text {
    margin: 5px 0 0;
    color: #b7c1d1;
    font-size: 13px;
    line-height: 1.45;
}

.push-notification-prompt__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.push-notification-prompt__button {
    min-height: 40px;
    padding: 8px 14px;

    border: 0;
    border-radius: 10px;

    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.push-notification-prompt__button--primary {
    background: #2f80ed;
    color: #ffffff;
}

.push-notification-prompt__button--secondary {
    background: rgba(255, 255, 255, 0.09);
    color: inherit;
}

body[data-site-theme="white"] .push-notification-prompt {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.98);
    color: #0f172a;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

body[data-site-theme="white"] .push-notification-prompt__text {
    color: #64748b;
}

body[data-site-theme="white"] .push-notification-prompt__button--secondary {
    background: #edf2f7;
}

@media (max-width: 700px) {
    .push-notification-prompt {
        right: 12px;
        bottom: calc(88px + env(safe-area-inset-bottom));
        left: 12px;

        width: auto;
        max-width: none;
    }

    .push-notification-prompt__actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .push-notification-prompt__button {
        width: 100%;
    }
}