:root {
    --ease-out-cubic: cubic-bezier(0.33, 1, 0.68, 1);
    --ease-in-out-cubic: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --focus-ring: 0 0 0 3px rgba(255, 184, 0, 0.45);
}

.home-layout {
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 2.5vh, 32px);
    margin-top: clamp(8px, 1.5vh, 16px);
    width: 100%;
    contain: layout style;
}

.hero-max {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(24px, 4vw, 40px);
    padding: clamp(20px, 3.5vh, 44px) clamp(24px, 4vw, 40px);
    border-radius: var(--r6, 20px);
    background:
        radial-gradient(ellipse 700px 500px at 100% 50%, var(--glow-strong, rgba(255, 184, 0, 0.15)), transparent 70%),
        var(--hero-grad, #11141a);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    box-shadow: var(--shadow-lg, 0 20px 40px rgba(0, 0, 0, 0.4));
    position: relative;
    z-index: 20;
    overflow: visible;

    animation: fadeUp var(--dur-3, 400ms) var(--ease-out-cubic) both;
    transition: background-color var(--dur-2, 200ms) ease, border-color var(--dur-2, 200ms) ease;
}

.hero-max::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--a-5, #ffb800), transparent);
    opacity: 0.75;
    pointer-events: none;
    border-top-left-radius: var(--r6, 20px);
    border-top-right-radius: var(--r6, 20px);
}

.hero-content {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2.2vh, 22px);
    z-index: 2;
    min-width: 0;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s2, 8px);
    width: fit-content;
    padding: 6px 14px;
    border-radius: var(--r-full, 9999px);
    background: var(--badge-dir-bg, rgba(255, 184, 0, 0.1));
    border: 1px solid var(--badge-dir-border, rgba(255, 184, 0, 0.25));
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-accent, #ffb800);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    user-select: none;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--a-5, #ffb800);
    box-shadow: 0 0 10px var(--a-5, #ffb800);
    animation: statusPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.hero-content h1 {
    font-size: clamp(1.9rem, 3.8vw + 0.5rem, 3.5rem);
    font-weight: 900;
    letter-spacing: -0.035em;
    line-height: 1.08;
    color: var(--text, #ffffff);
    text-wrap: balance;
}

.hero-content h1 span {
    background: linear-gradient(135deg, var(--text, #fff) 0%, var(--a-5, #ffb800) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.hero-desc {
    font-size: clamp(0.9rem, 0.6vw + 0.75rem, 1.05rem);
    line-height: 1.6;
    color: var(--text-3, #94a3b8);
    max-width: 540px;
    text-wrap: pretty;
}

.hero-search {
    display: flex;
    gap: var(--s3, 12px);
    align-items: center;
    margin-top: clamp(2px, 0.5vh, 8px);
    width: 100%;
    max-width: 580px;
    position: relative;
    z-index: 50;
}

.hero-search .input-wrap {
    flex: 1;
    height: clamp(44px, 5.5vh, 52px);
    border-radius: var(--r3, 12px);
    position: relative;
}

.hero-search .input-wrap input {
    width: 100%;
    height: 100%;
    font-size: 1rem;
    padding: 0 var(--s4, 16px);
    border-radius: inherit;
    border: 1px solid var(--border, #334155);
    background: var(--bg-input, rgba(15, 23, 42, 0.6));
    color: var(--text, #fff);
    outline: none;
    transition: border-color var(--dur-2, 200ms) ease, box-shadow var(--dur-2, 200ms) ease;
}

.hero-search .input-wrap input:focus-visible {
    border-color: var(--a-5, #ffb800);
    box-shadow: var(--focus-ring);
}

.hero-search .btn {
    height: clamp(44px, 5.5vh, 52px);
    padding: 0 var(--s6, 24px);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--r3, 12px);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--dur-1, 150ms) ease, filter var(--dur-1, 150ms) ease;
}

.hero-search .btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.hero-search .btn:active {
    transform: scale(0.97);
}

.hero-visual {
    flex: 1.1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.logo-shader {
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(280px, 42vh, 520px);
    height: clamp(280px, 42vh, 520px);
    transform: translate3d(-50%, -50%, 0) scale(1);
    background: radial-gradient(circle, var(--glow-strong, rgba(255, 184, 0, 0.22)) 0%, transparent 70%);
    filter: blur(56px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.85;
    transition:
        transform 0.55s cubic-bezier(0.34, 1.4, 0.64, 1),
        opacity 0.45s ease;
    will-change: transform, opacity;
}

.logo-swap:hover~.logo-shader,
.hero-visual:hover .logo-shader {
    transform: translate3d(-50%, -58%, 0) scale(1.12);
    opacity: 1;
}

@keyframes floatLogo {

    0%,
    100% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }

    50% {
        transform: translate3d(0, -10px, 0) rotate(0deg);
    }
}

@media (hover: none) {
    .logo-swap:hover {
        animation-play-state: running;
        transform: none;
    }
}

.logo-swap {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: min(560px, 58vh);
    aspect-ratio: 1 / 1;
    isolation: isolate;
    cursor: pointer;
    transform-origin: center center;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    transition: transform 0.55s cubic-bezier(0.34, 1.4, 0.64, 1);
    will-change: transform;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.35));
    animation: floatLogo 6s ease-in-out infinite;
}

[data-theme="light"] .logo-swap {
    filter: drop-shadow(0 16px 32px rgba(0, 0, 0, 0.12));
}

.logo-swap:hover {
    animation-play-state: paused;
    transform: translate3d(0, -18px, 0) rotate(-8deg) scale(1.04);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logo-swap:active {
    transform: translate3d(0, -6px, 0) rotate(-3deg) scale(1.01);
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.logo-swap.is-flipping {
    animation: logoFlip 0.7s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

@keyframes logoFlip {
    0% {
        transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    }

    35% {
        transform: translate3d(0, -28px, 0) rotate(-12deg) scale(1.06);
    }

    70% {
        transform: translate3d(0, -8px, 0) rotate(6deg) scale(1.02);
    }

    100% {
        transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    }
}

@media (max-width: 1200px) {
    .logo-swap {
        max-width: min(440px, 48vh);
    }

    .logo-shader {
        width: clamp(240px, 36vh, 420px);
        height: clamp(240px, 36vh, 420px);
    }
}

@media (max-width: 1024px) {
    .logo-swap {
        animation: none;
    }

    .logo-swap:hover {
        transform: translate3d(0, -10px, 0) rotate(-5deg) scale(1.03);
    }
}

@media (max-width: 768px) {
    .logo-swap {
        max-width: min(280px, 34vh);
    }
}

@media (max-height: 720px) and (min-width: 1025px) {
    .logo-swap {
        max-width: min(420px, 48vh);
    }
}

.logo-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    backface-visibility: hidden;
    transition:
        opacity 0.5s var(--ease-smooth),
        transform 0.55s var(--ease-smooth),
        filter 0.5s var(--ease-smooth);
}

.logo-dark {
    opacity: 1;
    transform: scale(1) translateZ(0);
    filter: blur(0) saturate(1);
    z-index: 2;
}

.logo-light {
    opacity: 0;
    transform: scale(1.04) translateZ(0);
    filter: blur(8px) saturate(0.85);
    z-index: 1;
}

[data-theme="light"] .logo-dark {
    opacity: 0;
    transform: scale(0.96) translateZ(0);
    filter: blur(8px) saturate(0.85);
    z-index: 1;
}

[data-theme="light"] .logo-light {
    opacity: 1;
    transform: scale(1) translateZ(0);
    filter: blur(0) saturate(1);
    z-index: 2;
}

.cat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: clamp(12px, 1.2vw, 16px);
    width: 100%;
    position: relative;
    z-index: 1;
}

.cat-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: clamp(10px, 1.4vh, 14px);
    padding: clamp(14px, 1.8vh, 18px) clamp(14px, 1.2vw, 18px);
    border-radius: var(--r4, 16px);
    background: var(--surface-glass, rgba(30, 41, 59, 0.4));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    position: relative;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    transition:
        transform var(--dur-2, 200ms) var(--ease-out-cubic),
        background-color var(--dur-2, 200ms) ease,
        border-color var(--dur-2, 200ms) ease,
        box-shadow var(--dur-2, 200ms) ease;
}

.cat-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: var(--n-5, rgba(255, 255, 255, 0.1));
    transition: background-color var(--dur-2, 200ms) ease;
}

.cat-card:hover {
    background-color: var(--bg-hover, rgba(51, 65, 85, 0.6));
    border-color: rgba(255, 184, 0, 0.35);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.5);
}

.cat-card:hover::before {
    background-color: var(--a-5, #ffb800);
}

.cat-card:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--a-5, #ffb800);
}

.cat-card:active {
    transform: translateY(-1px) scale(0.99);
}

.cat-icon {
    width: clamp(38px, 4vh, 44px);
    height: clamp(38px, 4vh, 44px);
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r2, 8px);
    background: var(--bg-input, rgba(15, 23, 42, 0.5));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    transition:
        transform var(--dur-3, 300ms) var(--ease-out-cubic),
        border-color var(--dur-2, 200ms) ease,
        background-color var(--dur-2, 200ms) ease;
}

.cat-card:hover .cat-icon {
    transform: scale(1.08) rotate(-4deg);
    border-color: rgba(255, 184, 0, 0.4);
    background-color: var(--badge-dir-bg, rgba(255, 184, 0, 0.15));
}

.cat-icon img {
    width: 60%;
    height: 60%;
    object-fit: contain;
}

.cat-meta {
    min-width: 0;
    width: 100%;
}

.cat-meta h3 {
    font-size: clamp(0.88rem, 0.9vw + 0.5rem, 0.98rem);
    font-weight: 700;
    color: var(--text, #fff);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cat-meta p {
    font-size: clamp(0.75rem, 0.5vw + 0.55rem, 0.82rem);
    color: var(--text-3, #94a3b8);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.results-panel {
    border-radius: var(--r4, 16px);
    background: var(--bg-card, #131822);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    overflow: hidden;
    position: relative;
    z-index: 1;

    animation: scaleIn var(--dur-3, 300ms) var(--ease-out-cubic) both;
}

.results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 var(--s5, 20px);
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    background: var(--bg-input, rgba(15, 23, 42, 0.7));
}

.results-bar-title {
    display: flex;
    align-items: center;
    gap: var(--s2, 8px);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-accent, #ffb800);
}

.results-bar-meta {
    font-size: 0.8rem;
    color: var(--text-3, #94a3b8);
    font-variant-numeric: tabular-nums;
}

.results-body {
    max-height: 45vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.res-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: var(--s3, 12px) var(--s5, 20px);
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.05));
    transition: background-color var(--dur-1, 150ms) ease;
    content-visibility: auto;
    contain-intrinsic-size: 0 48px;
}

.res-row:last-child {
    border-bottom: none;
}

.res-row:hover,
.res-row:focus-within {
    background-color: var(--bg-hover, rgba(255, 255, 255, 0.04));
}

.res-info a {
    font-weight: 600;
    font-size: 0.925rem;
    color: var(--text, #f1f5f9);
    text-decoration: none;
    transition: color 150ms ease;
    outline: none;
}

.res-info a:focus-visible {
    color: var(--text-accent, #ffb800);
    text-decoration: underline;
}

.res-info a:hover {
    color: var(--text-accent, #ffb800);
}

.res-info .res-path {
    font-family: var(--mono, ui-monospace, SFMono-Regular, monospace);
    font-size: 0.75rem;
    color: var(--text-4, #64748b);
    display: block;
    margin-top: 2px;
}

@media (max-width: 1280px) {
    .cat-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 10px;
    }

    .cat-meta p {
        -webkit-line-clamp: 1;
    }
}

@media (max-width: 1024px) {
    .hero-max {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: clamp(20px, 3vh, 32px);
        padding: clamp(24px, 4vh, 40px) clamp(20px, 4vw, 32px);
    }

    .hero-content {
        align-items: center;
        width: 100%;
    }

    .hero-search {
        justify-content: center;
    }

    .hero-visual {
        order: -1;
        justify-content: center;
        width: 100%;
    }

    .logo-swap {
        max-width: min(260px, 30vh);
        animation: none;
    }

    .cat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .cat-meta p {
        -webkit-line-clamp: 2;
    }
}

@media (max-width: 700px) {
    .cat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .hero-search {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-search .btn {
        width: 100%;
    }

    .cat-grid {
        grid-template-columns: 1fr;
    }

    .hero-max {
        border-radius: var(--r4, 16px);
    }
}

@media (max-height: 720px) and (min-width: 1025px) {
    .hero-max {
        padding: 20px 32px;
        gap: 24px;
    }

    .hero-content {
        gap: 12px;
    }

    .hero-content h1 {
        font-size: clamp(1.6rem, 2.8vw, 2.4rem);
    }

    .hero-desc {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .logo-swap {
        max-width: min(280px, 35vh);
    }

    .home-layout {
        gap: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .logo-swap {
        animation: none;
        transition: none;
    }

    .logo-swap:hover {
        transform: none;
    }

    .logo-shader {
        transition: none;
    }
}

*,
*::before,
*::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

.status-dot,
.logo-swap,
.hero-max {
    animation: none !important;
}
}