:root {
    --ui-navy-950: #07111f;
    --ui-navy-900: #0c192c;
    --ui-navy-800: #14243c;
    --ui-coral: #f24f67;
    --ui-coral-strong: #da334d;
    --ui-cyan: #61c8e8;
    --ui-green: #2fbf7f;
    --ui-canvas: #f5f7fb;
    --ui-card: #ffffff;
    --ui-ink: #162033;
    --ui-muted: #66758c;
    --ui-border: #dfe5ef;
    --ui-shadow-sm: 0 10px 30px rgba(17, 31, 52, 0.08);
    --ui-shadow-lg: 0 28px 80px rgba(17, 31, 52, 0.14);
    --ui-radius-sm: 14px;
    --ui-radius-md: 20px;
    --ui-radius-lg: 30px;
    --bg: var(--ui-canvas);
    --paper: var(--ui-card);
    --text: var(--ui-ink);
    --text-soft: var(--ui-muted);
    --line: var(--ui-border);
    --line-strong: #cbd5e3;
    --red: var(--ui-coral);
    --red-dark: var(--ui-coral-strong);
    --surface: #edf2f8;
    --surface-strong: var(--ui-navy-900);
    --surface-strong-2: var(--ui-navy-800);
    --shadow: var(--ui-shadow-lg);
}

html {
    scroll-behavior: smooth;
    background: var(--ui-canvas);
}

body {
    background:
        radial-gradient(circle at 8% 2%, rgba(242, 79, 103, 0.09), transparent 23rem),
        radial-gradient(circle at 92% 4%, rgba(97, 200, 232, 0.1), transparent 24rem),
        linear-gradient(180deg, #fbfcfe 0%, var(--ui-canvas) 34%, #f1f4f9 100%);
    color: var(--ui-ink);
    font-family: "Sora", "Avenir Next", sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

button,
a,
summary,
input,
select,
textarea {
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(97, 200, 232, 0.35);
    outline-offset: 2px;
}

/* Public navigation */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    min-height: 74px;
    margin: 0;
    padding: 0.75rem max(3vw, 1rem);
    border: 0;
    border-bottom: 1px solid rgba(214, 222, 234, 0.85);
    background: rgba(250, 252, 255, 0.88);
    backdrop-filter: blur(22px) saturate(1.2);
    box-shadow: 0 8px 28px rgba(18, 32, 54, 0.05);
}

.site-brand-logo {
    width: clamp(148px, 17vw, 205px);
    max-height: 48px;
    object-fit: contain;
}

.site-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.7rem;
}

.site-nav {
    gap: 0.15rem;
}

.site-nav a {
    border: 0;
    border-radius: 11px;
    padding: 0.65rem 0.72rem;
    background: transparent;
    color: #344158;
    font-size: 0.79rem;
    font-weight: 650;
}

.site-nav a:hover {
    border: 0;
    background: #eaf0f8;
    color: #111d31;
}

.site-nav .nav-cta,
.site-menu-panel .nav-cta {
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    padding-inline: 1rem;
    background: linear-gradient(110deg, var(--ui-coral), var(--ui-coral-strong));
    color: #fff;
    box-shadow: 0 9px 20px rgba(218, 51, 77, 0.22);
}

.site-nav .nav-cta:hover,
.site-menu-panel .nav-cta:hover {
    background: linear-gradient(110deg, #ff6076, #e23852);
    color: #fff;
    transform: translateY(-1px);
}

.site-menu {
    display: none;
    position: relative;
}

.site-menu summary {
    list-style: none;
    cursor: pointer;
    border: 1px solid #d6deea;
    border-radius: 12px;
    padding: 0.64rem 0.86rem;
    background: #fff;
    color: var(--ui-ink);
    font-size: 0.82rem;
    font-weight: 700;
}

.site-menu summary::-webkit-details-marker {
    display: none;
}

.site-menu-panel {
    position: absolute;
    top: calc(100% + 0.55rem);
    right: 0;
    width: min(18rem, 88vw);
    padding: 0.55rem;
    display: grid;
    gap: 0.2rem;
    border: 1px solid var(--ui-border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--ui-shadow-lg);
}

.site-menu-panel a {
    border-radius: 12px;
    padding: 0.75rem 0.8rem;
    color: var(--ui-ink);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 650;
}

.site-menu-panel a:not(.nav-cta):hover {
    background: #eef3f9;
}

.theme-toggle {
    min-height: 38px;
    border-color: #d8e0eb;
    background: rgba(255, 255, 255, 0.78);
}

/* Public home */
.portal-home,
.portal-page-shell {
    width: min(1180px, calc(100% - 2rem));
    padding: clamp(1.1rem, 2.6vw, 2rem) 0 4.5rem;
    gap: clamp(1.2rem, 2.4vw, 2rem);
}

.portal-hero {
    grid-template-columns: minmax(0, 1.08fr) minmax(330px, 0.92fr);
    gap: clamp(1.2rem, 3vw, 2.4rem);
    padding: clamp(1.35rem, 4vw, 3.4rem);
    overflow: hidden;
    border: 1px solid rgba(76, 99, 132, 0.44);
    border-radius: 34px;
    background:
        radial-gradient(circle at 12% 12%, rgba(242, 79, 103, 0.26), transparent 24rem),
        radial-gradient(circle at 92% 14%, rgba(97, 200, 232, 0.16), transparent 22rem),
        linear-gradient(145deg, #091525 0%, #10213a 56%, #162b48 100%);
    box-shadow: 0 34px 90px rgba(8, 22, 39, 0.24);
}

.portal-hero-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
}

.portal-hero h1 {
    max-width: 12ch;
    margin: 0.5rem 0 0;
    font-size: clamp(3.1rem, 7vw, 5.8rem);
    line-height: 0.91;
    letter-spacing: -0.045em;
    text-wrap: balance;
}

.portal-highlight {
    color: #ff7185;
}

.portal-hero-text {
    max-width: 58ch;
    margin-top: 1.1rem;
    color: #d1dced;
    font-size: clamp(1rem, 1.5vw, 1.12rem);
    line-height: 1.72;
}

.portal-hero .cta-row {
    margin-top: 1.4rem;
}

.portal-hero .btn {
    min-height: 48px;
    padding: 0.78rem 1.15rem;
}

.portal-stat-strip {
    width: 100%;
    margin-top: 1.6rem;
}

.portal-stat-strip article {
    min-height: 92px;
    justify-content: center;
    border-color: rgba(144, 167, 199, 0.25);
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.055);
}

.portal-stat-strip strong {
    color: #fff;
}

.portal-stat-strip span {
    color: #bfcce0;
    font-size: 0.78rem;
    line-height: 1.45;
}

.portal-hero-visual {
    align-content: center;
}

.portal-hero-image-card {
    position: relative;
    min-height: 325px;
    overflow: hidden;
    border: 1px solid rgba(166, 188, 220, 0.26);
    border-radius: 25px;
    background: #07111f;
    box-shadow: 0 24px 55px rgba(0, 0, 0, 0.28);
}

.portal-hero-image-card > img {
    width: 100%;
    height: 100%;
    min-height: 325px;
    display: block;
    object-fit: cover;
    opacity: 0.8;
}

.portal-hero-image-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 36%, rgba(4, 12, 24, 0.9) 100%);
}

.portal-hero-image-overlay {
    position: absolute;
    left: 1.1rem;
    right: 1.1rem;
    bottom: 1rem;
    z-index: 1;
    display: grid;
    gap: 0.2rem;
}

.portal-hero-image-overlay span {
    color: #9fdff1;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.portal-hero-image-overlay strong {
    color: #fff;
    font-size: 1.05rem;
}

.portal-next-step-card {
    gap: 0.65rem;
    border-color: rgba(141, 163, 196, 0.3);
    background: rgba(255, 255, 255, 0.065);
}

.portal-flow-row {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    gap: 0.05rem 0.65rem;
    align-items: center;
    padding: 0.6rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.portal-flow-row > span {
    grid-row: span 2;
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(97, 200, 232, 0.14);
    color: #b9efff;
    font-size: 0.78rem;
    font-weight: 800;
}

.portal-flow-row strong {
    color: #fff;
    font-size: 0.86rem;
}

.portal-flow-row small {
    color: #b8c6dc;
    font-size: 0.72rem;
}

.portal-section,
.portal-slab,
.portal-panel {
    scroll-margin-top: 90px;
}

.portal-section {
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid rgba(221, 228, 238, 0.88);
    border-radius: var(--ui-radius-lg);
    background: rgba(255, 255, 255, 0.7);
    box-shadow: var(--ui-shadow-sm);
}

.portal-slab {
    padding: clamp(1.3rem, 3vw, 2rem);
    box-shadow: var(--ui-shadow-sm);
}

.portal-feature-card,
.portal-stack-card,
.portal-legend-card,
.portal-shop-card,
.portal-category-card,
.portal-thread-card,
.portal-empty-card,
.portal-reply-card,
.portal-product-card {
    border-color: var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: #fff;
    box-shadow: 0 8px 24px rgba(17, 31, 52, 0.05);
}

.portal-feature-card:hover,
.portal-shop-card:hover,
.portal-category-card:hover {
    border-color: #c7d3e3;
    box-shadow: 0 16px 34px rgba(17, 31, 52, 0.09);
    transform: translateY(-2px);
}

.section-kicker,
.portal-kicker {
    color: #687991;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.section-head h2,
.portal-slab h2,
.portal-panel h1 {
    color: var(--ui-ink);
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.section-link {
    color: #d93652;
    font-weight: 750;
    text-underline-offset: 4px;
}

/* Shared buttons and forms */
.btn,
.form-submit,
.auth-submit {
    border-radius: 14px;
    font-weight: 750;
}

.btn-primary,
.form-submit,
.auth-submit {
    background: linear-gradient(110deg, var(--ui-coral), var(--ui-coral-strong));
    box-shadow: 0 10px 24px rgba(218, 51, 77, 0.2);
}

.btn-primary:hover,
.form-submit:hover,
.auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(218, 51, 77, 0.26);
}

input,
select,
textarea {
    border-radius: 13px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #78bcd4;
    box-shadow: 0 0 0 4px rgba(97, 200, 232, 0.13);
}

/* Signed-in portal navigation */
.app-topbar {
    top: 0.6rem;
    width: min(1240px, calc(100% - 1.2rem));
    min-height: 66px;
    margin-top: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-color: rgba(105, 129, 165, 0.28);
    border-radius: 20px;
    background: rgba(9, 22, 39, 0.9);
    box-shadow: 0 18px 48px rgba(7, 17, 31, 0.2);
}

.app-topbar-logo {
    width: clamp(135px, 16vw, 190px);
    max-height: 42px;
    object-fit: contain;
}

.app-portal-nav {
    justify-content: center;
    gap: 0.25rem;
}

.portal-link,
.portal-menu summary {
    min-height: 40px;
    border: 0;
    border-radius: 12px;
    padding: 0.6rem 0.76rem;
    background: transparent;
    color: #bdcbe0;
    font-size: 0.78rem;
}

.portal-link:hover,
.portal-link.is-active,
.portal-menu[open] summary,
.portal-menu summary.is-active {
    border: 0;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: none;
}

.portal-link-primary {
    color: #fff;
    background: rgba(242, 79, 103, 0.16);
}

.portal-link-primary.is-active {
    background: linear-gradient(110deg, rgba(242, 79, 103, 0.94), rgba(218, 51, 77, 0.94));
}

.portal-dropdown-right {
    left: auto;
    right: 0;
}

.portal-dropdown {
    border-color: var(--ui-border);
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--ui-shadow-lg);
}

.portal-dropdown-link {
    color: var(--ui-ink);
}

.portal-dropdown-link:hover {
    background: #edf2f8;
}

.app-theme-toggle {
    border-color: rgba(124, 148, 184, 0.3);
    background: rgba(255, 255, 255, 0.06);
    color: #dce7f8;
}

.app-profile-trigger {
    min-height: 40px;
    border: 0;
    background: rgba(255, 255, 255, 0.075);
}

.app-page-shell {
    width: min(1180px, calc(100% - 2rem));
    gap: 1.15rem;
    padding-top: 1.3rem;
    padding-bottom: 4rem;
}

.hero-slab,
.panel-card {
    border-radius: 25px;
    border-color: rgba(217, 225, 236, 0.92);
    box-shadow: var(--ui-shadow-sm);
}

.hero-slab {
    padding: clamp(1.3rem, 3vw, 2.2rem);
    background:
        radial-gradient(circle at 10% 15%, rgba(242, 79, 103, 0.2), transparent 23rem),
        linear-gradient(145deg, #0a1729, #142845);
}

.hero-slab h1 {
    letter-spacing: -0.04em;
}

.hero-stat-card {
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.07);
}

.panel-card {
    background: rgba(255, 255, 255, 0.9);
}

.metric-pair-grid > div,
.summary-grid > div,
.mini-history-card {
    border-radius: 16px;
    border-color: #e0e6ef;
    background: #f7f9fc;
}

.status-pill {
    border-radius: 999px;
    font-weight: 750;
}

.missed-modal-card {
    border-radius: 25px;
}

/* Footer */
.site-footer {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto 1rem;
    padding: 1.15rem 1.3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    border: 1px solid rgba(214, 222, 234, 0.9);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: var(--ui-shadow-sm);
}

.site-footer-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.site-footer-brand img {
    width: 135px;
    height: auto;
}

.site-footer-brand p {
    max-width: 42ch;
    margin: 0;
    color: var(--ui-muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.site-footer nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem 0.8rem;
}

.site-footer nav a {
    color: #4e5d74;
    font-size: 0.75rem;
    font-weight: 650;
    text-decoration: none;
}

.site-footer nav a:hover {
    color: var(--ui-coral-strong);
}

/* Dark mode uses the same hierarchy, not a separate product personality. */
html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 8% 2%, rgba(242, 79, 103, 0.12), transparent 24rem),
        radial-gradient(circle at 92% 4%, rgba(97, 200, 232, 0.1), transparent 24rem),
        #07111f;
}

html[data-theme="dark"] .site-header,
html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .portal-section,
html[data-theme="dark"] .panel-card {
    border-color: rgba(72, 94, 126, 0.56);
    background: rgba(12, 25, 44, 0.9);
}

html[data-theme="dark"] .site-nav a,
html[data-theme="dark"] .site-menu summary,
html[data-theme="dark"] .site-footer nav a {
    color: #d7e2f3;
}

html[data-theme="dark"] .site-nav a:hover,
html[data-theme="dark"] .site-menu summary,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .metric-pair-grid > div,
html[data-theme="dark"] .summary-grid > div,
html[data-theme="dark"] .mini-history-card {
    border-color: rgba(72, 94, 126, 0.62);
    background: rgba(255, 255, 255, 0.055);
}

html[data-theme="dark"] .site-menu-panel,
html[data-theme="dark"] .portal-dropdown,
html[data-theme="dark"] .portal-feature-card,
html[data-theme="dark"] .portal-shop-card,
html[data-theme="dark"] .portal-category-card,
html[data-theme="dark"] .portal-thread-card,
html[data-theme="dark"] .portal-empty-card,
html[data-theme="dark"] .portal-reply-card,
html[data-theme="dark"] .portal-product-card {
    border-color: rgba(72, 94, 126, 0.62);
    background: #0d1b30;
}

html[data-theme="dark"] .site-menu-panel a,
html[data-theme="dark"] .portal-dropdown-link,
html[data-theme="dark"] .section-head h2,
html[data-theme="dark"] .portal-panel h1,
html[data-theme="dark"] .panel-card {
    color: #eef4ff;
}

@media (max-width: 1020px) {
    .site-nav {
        display: none;
    }

    .site-menu {
        display: block;
    }

    .portal-hero {
        grid-template-columns: 1fr;
    }

    .portal-hero-visual {
        grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
        align-items: stretch;
    }

    .portal-hero-image-card,
    .portal-hero-image-card > img {
        min-height: 270px;
    }

    .portal-link-community {
        display: none;
    }

    .app-theme-toggle .theme-toggle-label,
    .app-profile-trigger .profile-trigger-label {
        display: none;
    }
}

@media (max-width: 760px) {
    .site-header {
        min-height: 66px;
        padding: 0.6rem 0.75rem;
        flex-wrap: nowrap;
    }

    .site-header-actions {
        width: auto;
        flex: 0 0 auto;
    }

    .site-brand-logo {
        width: 144px;
    }

    .site-header .theme-toggle {
        display: none;
    }

    .portal-home,
    .portal-page-shell,
    .app-page-shell {
        width: min(100% - 1rem, 1180px);
    }

    .portal-hero {
        border-radius: 25px;
        padding: 1.25rem;
    }

    .portal-hero h1 {
        font-size: clamp(2.75rem, 15vw, 4.2rem);
    }

    .portal-stat-strip {
        grid-template-columns: 1fr;
    }

    .portal-stat-strip article {
        min-height: 0;
    }

    .portal-hero-visual {
        grid-template-columns: 1fr;
    }

    .portal-hero-image-card,
    .portal-hero-image-card > img {
        min-height: 235px;
    }

    .portal-section,
    .portal-slab {
        border-radius: 23px;
        padding: 1rem;
    }

    .app-topbar {
        top: 0.35rem;
        width: calc(100% - 0.7rem);
        margin-top: 0.35rem;
        padding: 0.5rem 0.55rem;
        min-height: 58px;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        justify-content: stretch;
        flex-wrap: nowrap;
        gap: 0.35rem;
        border-radius: 17px;
    }

    .app-topbar-brand {
        width: auto;
        justify-content: flex-start;
    }

    .app-topbar-logo {
        width: 72px;
    }

    .app-portal-nav {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 0.05rem;
    }

    .portal-link,
    .portal-menu summary {
        min-height: 38px;
        padding: 0.56rem 0.6rem;
        font-size: 0.72rem;
    }

    .portal-link-community,
    .portal-link:not(.portal-link-primary):not(.is-active) {
        display: none;
    }

    .app-portal-nav .portal-more-menu > summary.portal-link {
        display: inline-flex;
    }

    .app-topbar-actions {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 0.2rem;
    }

    .app-theme-toggle {
        display: none;
    }

    .hero-slab,
    .panel-card {
        border-radius: 20px;
    }

    .hero-slab,
    .hero-slab-compact,
    .app-grid-two,
    .app-grid-three,
    .app-grid-four {
        grid-template-columns: minmax(0, 1fr);
    }

    .hero-copy-block,
    .hero-stat-grid {
        width: 100%;
        min-width: 0;
    }

    .hero-stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .hero-stat-card {
        min-width: 0;
        padding: 0.7rem;
    }

    .hero-stat-card strong {
        font-size: 1.15rem;
    }

    .hero-stat-card small {
        font-size: 0.68rem;
    }

    .site-footer {
        width: calc(100% - 1rem);
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 0.5rem;
    }

    .site-footer nav {
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
