:root {
    --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --brand: #e62852;
    --brand-hot: #f91555;
    --brand-soft: #f45b7d;
    --on-brand: #ffffff;
    --primary-gradient: linear-gradient(51deg, #e62852 50%, #f91555 70%, #f45b7d 100%);
    --primary-gradient-hover: linear-gradient(51deg, #e62852 50%, #f91555 70%, #f86888 100%);
    --bg: #f7f6f2;
    --bg-soft: #f0ede6;
    --surface: #fffdf9;
    --surface-strong: #ffffff;
    --surface-muted: #f4f1ea;
    --text: #17211d;
    --muted: #66736f;
    --line: #ded8cd;
    --accent: var(--brand);
    --danger: #b3382f;
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--brand) 24%, transparent);
    --shadow: 0 18px 50px rgba(28, 35, 31, 0.12);
    --shadow-lg: 0 28px 80px rgba(4, 18, 13, 0.22);
    --topbar-height: 54px;
    --radius: 8px;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111821;
    --bg-soft: #18212b;
    --surface: #18212b;
    --surface-strong: #202b36;
    --surface-muted: #243140;
    --text: #f4f0e8;
    --muted: #a5b0aa;
    --line: #334252;
    --accent: var(--brand-soft);
    --danger: #f19992;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.55);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(180deg, rgba(255, 253, 249, 0.72), rgba(255, 253, 249, 0) 280px),
        var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.45;
}

[data-theme="dark"] body {
    background:
        linear-gradient(180deg, rgba(230, 40, 82, 0.08), rgba(17, 24, 33, 0) 280px),
        var(--bg);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
    letter-spacing: 0;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 100;
    transform: translateY(-160%);
    border-radius: var(--radius);
    background: var(--text);
    color: var(--surface);
    padding: 10px 14px;
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 50;
    min-height: var(--topbar-height);
    border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 18%);
    background: color-mix(in srgb, var(--bg), transparent 16%);
    backdrop-filter: blur(18px);
}

.topbar-inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: var(--topbar-height);
    width: 100%;
    margin: 0;
    padding: 0 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: max-content;
    color: var(--text);
    font-weight: 850;
    text-decoration: none;
}

.brand-logo-wrap {
    display: inline-flex;
    align-items: center;
    min-width: 108px;
    height: 28px;
}

.brand-logo {
    display: block;
    width: 96px;
    max-height: 28px;
}

.brand-favicon {
    display: none;
    width: 26px;
    height: 26px;
}

.logo-invert,
[data-theme="dark"] .logo-standard {
    display: none;
}

[data-theme="dark"] .logo-invert {
    display: block;
}

.brand-text {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-left: 1px solid var(--line);
    padding-left: 10px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    max-width: 230px;
    flex: 0 0 auto;
    border-radius: 7px;
    padding: 6px 10px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background 0.16s ease,
        color 0.16s ease,
        border-color 0.16s ease;
}

.nav-item:hover,
.nav-item:focus-visible {
    background: color-mix(in srgb, var(--brand) 7%, transparent);
    color: var(--text);
    outline: none;
}

.nav-item:focus-visible,
.theme-toggle:focus-visible,
.nav-toggle:focus-visible,
.primary-action:focus-visible,
.app-card:focus-visible {
    box-shadow: var(--focus-ring);
}

.nav-item.is-active {
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    color: var(--brand);
}

.nav-icon,
.card-icon {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 7px;
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--brand);
    font-size: 0.68rem;
    font-weight: 850;
}

.nav-icon i,
.card-icon i,
.theme-toggle i,
.nav-toggle i,
.primary-action i,
.card-arrow i {
    width: 1em;
    text-align: center;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.tool-count {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 800;
}

.theme-toggle,
.nav-toggle {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    min-height: 34px;
    padding: 0;
    line-height: 1;
    text-transform: none;
}

.theme-toggle:hover,
.nav-toggle:hover {
    background: var(--surface-muted);
}

.nav-toggle {
    display: none;
}

.portal-main {
    min-height: 100vh;
    padding-top: var(--topbar-height);
}

.landing-shell,
.not-found-shell {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 42px 0 64px;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 16px;
    align-items: stretch;
}

.hero-copy,
.stats-panel,
.empty-state,
.not-found-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.hero-copy {
    position: relative;
    overflow: hidden;
    padding: clamp(28px, 5vw, 56px);
}

.hero-copy::after {
    position: absolute;
    right: -90px;
    bottom: -118px;
    width: 360px;
    height: 240px;
    border: 1px solid color-mix(in srgb, var(--brand) 14%, transparent);
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--text) 8%, transparent) 1px, transparent 1px),
        linear-gradient(color-mix(in srgb, var(--text) 6%, transparent) 1px, transparent 1px);
    background-size: 30px 30px;
    content: "";
    opacity: 0.45;
    transform: rotate(-8deg);
}

.logo-area {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    min-height: 40px;
    margin-bottom: 30px;
}

.hero-logo {
    width: 144px;
    height: auto;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    overflow-wrap: anywhere;
}

h1 {
    position: relative;
    z-index: 1;
    max-width: 780px;
    margin: 0;
    color: var(--text);
    font-size: clamp(2.1rem, 4vw, 4.2rem);
    font-weight: 850;
    line-height: 1.02;
}

.hero-text {
    position: relative;
    z-index: 1;
    max-width: 660px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 1.06rem;
    line-height: 1.65;
}

.framework-meta {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.framework-meta span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface-strong);
    color: var(--muted);
    padding: 0 10px;
    font-size: 0.82rem;
    font-weight: 800;
}

.stats-panel {
    display: grid;
    align-content: center;
    justify-items: start;
    padding: 30px;
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.12), transparent 44%),
        linear-gradient(180deg, rgba(23, 33, 29, 0.92), rgba(17, 24, 33, 0.98));
    color: #fffdf9;
}

.stat-icon {
    margin-bottom: 18px;
    color: color-mix(in srgb, var(--brand-soft) 72%, #ffffff);
    font-size: 1.25rem;
}

[data-theme="dark"] .stats-panel {
    border-color: rgba(255, 255, 255, 0.11);
}

.stat-value {
    color: #ffffff;
    font-size: 4rem;
    line-height: 1;
    font-weight: 850;
}

.stat-label {
    margin-top: 10px;
    color: rgba(255, 253, 249, 0.72);
    font-weight: 800;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin: 38px 0 18px;
}

.section-heading h2,
.empty-state h2,
.not-found-panel h1 {
    margin: 0;
    color: var(--text);
    font-size: 1.45rem;
    font-weight: 850;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.app-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    min-height: 118px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 18px;
    text-decoration: none;
    transition:
        border-color 0.16s ease,
        box-shadow 0.16s ease,
        transform 0.16s ease;
}

.app-card:hover,
.app-card:focus-visible {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--brand) 46%, var(--line));
    box-shadow: var(--shadow);
    outline: none;
}

.card-icon {
    width: 44px;
    height: 44px;
    font-size: 0.78rem;
}

.card-content {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.card-title {
    color: var(--text);
    font-weight: 850;
}

.card-description {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.card-arrow {
    color: var(--brand);
    font-weight: 850;
}

.empty-state,
.not-found-panel {
    padding: 30px;
}

.empty-icon {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--brand);
}

.empty-state p,
.not-found-panel p {
    max-width: 620px;
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    margin-top: 24px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--primary-gradient);
    color: var(--on-brand);
    gap: 8px;
    padding: 0 16px;
    font-weight: 850;
    text-decoration: none;
    text-transform: none;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 20%, transparent);
}

.primary-action:hover,
.primary-action:focus-visible {
    background: var(--surface-strong);
    border-color: var(--brand);
    color: var(--brand);
    box-shadow: none;
    outline: none;
}

.app-frame-shell {
    height: calc(100vh - var(--topbar-height));
    min-height: 520px;
    background: var(--surface);
}

.app-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--surface);
}

@media (max-width: 860px) {
    :root {
        --topbar-height: 48px;
    }

    .topbar-inner {
        grid-template-columns: auto auto 1fr auto;
        gap: 10px;
        padding: 0 14px;
    }

    .brand-logo-wrap {
        min-width: 32px;
    }

    .brand-logo {
        display: none;
    }

    .brand-favicon {
        display: block;
    }

    .brand-text {
        padding-left: 8px;
        font-size: 0.84rem;
    }

    .nav-toggle {
        display: inline-grid;
    }

    .app-nav {
        position: fixed;
        top: var(--topbar-height);
        right: 12px;
        left: 12px;
        display: none;
        max-height: calc(100vh - var(--topbar-height) - 20px);
        overflow-y: auto;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow-lg);
        padding: 8px;
    }

    .app-nav.is-open {
        display: grid;
    }

    .nav-item {
        max-width: none;
        width: 100%;
    }

    .topbar-actions {
        justify-self: end;
    }

    .tool-count {
        display: none;
    }

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

    .landing-shell,
    .not-found-shell {
        width: min(100% - 24px, 1180px);
        padding-top: 24px;
    }

    .stats-panel {
        min-height: 140px;
    }
}

@media (max-width: 560px) {
    .brand-text {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-grid {
        grid-template-columns: 1fr;
    }

    .app-card {
        min-height: 104px;
        padding: 14px;
    }

    .card-arrow {
        display: none;
    }
}
