:root {
    color-scheme: dark;
    --background: #0b0d12;
    --surface: #141820;
    --surface-hover: #1a1f29;
    --text: #f4f5f7;
    --muted: #9299a6;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #ff4655;
    --accent-soft: rgba(255, 70, 85, 0.16);
    --content-width: 1440px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--background);
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 12% -10%, rgba(255, 70, 85, 0.13), transparent 30rem),
        var(--background);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.video-link:focus-visible,
.retry-button:focus-visible,
.bottom-nav-item:focus-visible {
    outline: 3px solid rgba(255, 70, 85, 0.5);
    outline-offset: 3px;
}

.page-shell {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    padding: 0 14px calc(102px + env(safe-area-inset-bottom));
}

.discovery-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    min-height: 82px;
    margin: 0 -14px 26px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 13, 18, 0.9);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
    backdrop-filter: blur(20px);
}

h1 {
    margin: 0;
    font-size: clamp(26px, 4vw, 38px);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

.result-count {
    margin: 0 2px 16px;
    color: #e8eaf0;
    font-size: 15px;
    font-weight: 720;
    letter-spacing: -0.01em;
}

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

.search-form {
    display: flex;
    width: min(100%, 680px);
    gap: 10px;
    margin: 0;
}

.search-field {
    position: relative;
    display: flex;
    flex: 1;
    align-items: center;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 16px;
    width: 14px;
    height: 14px;
    border: 2px solid #79818e;
    border-radius: 50%;
    pointer-events: none;
}

.search-icon::after {
    position: absolute;
    right: -5px;
    bottom: -3px;
    width: 6px;
    height: 2px;
    border-radius: 2px;
    background: #79818e;
    content: "";
    transform: rotate(45deg);
}

.search-field input {
    width: 100%;
    height: 43px;
    padding: 0 68px 0 43px;
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: none;
    background: rgba(20, 24, 32, 0.88);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.search-field input::placeholder {
    color: #747b87;
}

.search-field input:focus {
    border-color: rgba(255, 70, 85, 0.52);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(255, 70, 85, 0.1);
}

.search-field input::-webkit-search-cancel-button {
    display: none;
}

.clear-search {
    position: absolute;
    right: 12px;
    min-height: 34px;
    padding: 0 5px;
    border: 0;
    background: transparent;
    color: #a5abb5;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 650;
}

.clear-search[hidden] {
    display: none;
}

.search-button {
    flex: none;
    min-width: 82px;
    min-height: 43px;
    padding: 0 18px;
    border: 0;
    border-radius: 13px;
    background: var(--accent);
    box-shadow: 0 10px 26px rgba(255, 70, 85, 0.2);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 750;
    transition: filter 160ms ease, transform 160ms ease;
}

.search-button:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.search-button:focus-visible,
.clear-search:focus-visible {
    outline: 3px solid rgba(255, 70, 85, 0.5);
    outline-offset: 2px;
}

.bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: calc(58px + env(safe-area-inset-bottom));
    padding: 3px 12px calc(3px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(10, 12, 17, 0.9);
    box-shadow: 0 -14px 38px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(22px);
}

.bottom-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    width: min(34vw, 180px);
    min-height: 52px;
    gap: 3px;
    border-radius: 13px;
    color: #858c98;
    font-size: 11px;
    font-weight: 720;
    transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.bottom-nav-item:hover {
    color: #dfe2e8;
    transform: translateY(-1px);
}

.bottom-nav-item.active {
    background: rgba(255, 255, 255, 0.055);
    color: #fff;
}

.bottom-nav-icon {
    position: relative;
    display: block;
    width: 22px;
    height: 22px;
}

.plaza-icon::before {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: currentColor;
    box-shadow: 10px 0 currentColor, 0 10px currentColor, 10px 10px currentColor;
    content: "";
}

.swipe-icon::before {
    position: absolute;
    top: 3px;
    left: 5px;
    width: 13px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 6px;
    content: "";
}

.swipe-icon::after {
    position: absolute;
    top: 8px;
    left: 10px;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 6px solid currentColor;
    content: "";
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 10px;
}

.video-card {
    min-width: 0;
}

.video-link {
    display: block;
    border-radius: 13px;
}

.thumbnail {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(135deg, #20252f, #12151c);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.thumbnail::after {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #6f7784;
    content: "暂无图片";
    font-size: 12px;
    opacity: 0;
}

.thumbnail.image-error::after {
    opacity: 1;
}

.thumbnail img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 220ms ease, filter 220ms ease;
}

.duration {
    position: absolute;
    right: 7px;
    bottom: 7px;
    z-index: 2;
    padding: 3px 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    line-height: 1;
}

.video-title {
    display: -webkit-box;
    overflow: hidden;
    min-height: 2.8em;
    margin: 10px 2px 0;
    color: #e8eaf0;
    font-size: 14px;
    font-weight: 620;
    line-height: 1.4;
    letter-spacing: -0.01em;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.video-link:hover .thumbnail img {
    filter: brightness(1.05);
    transform: scale(1.035);
}

.video-link:hover .video-title {
    color: #fff;
}

.skeleton-card {
    min-height: 132px;
    border-radius: 12px;
    background: linear-gradient(105deg, #141820 35%, #202530 50%, #141820 65%);
    background-size: 200% 100%;
    animation: skeleton 1.3s linear infinite;
}

.load-state {
    display: grid;
    min-height: 112px;
    place-items: center;
    padding: 28px 0 8px;
    text-align: center;
}

.loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 13px;
}

.loading-indicator[hidden] {
    display: none;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--accent-soft);
    animation: pulse 1.2s ease-out infinite;
}

.load-message {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.retry-button {
    min-width: 112px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid rgba(255, 70, 85, 0.32);
    border-radius: 11px;
    background: var(--accent-soft);
    color: #ff7883;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
}

.retry-button[hidden] {
    display: none;
}

.scroll-sentinel {
    width: 100%;
    height: 1px;
}

.noscript-message {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
}

@keyframes skeleton {
    to {
        background-position-x: -200%;
    }
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 8px rgba(255, 70, 85, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 70, 85, 0);
    }
}

@media (min-width: 600px) {
    .page-shell {
        padding-inline: 20px;
    }

    .discovery-bar {
        margin-inline: -20px;
        padding-inline: 24px;
    }

    .video-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 24px 16px;
    }

    .skeleton-card {
        min-height: 180px;
    }
}

@media (min-width: 900px) {
    .page-shell {
        padding: 0 28px calc(102px + env(safe-area-inset-bottom));
    }

    .discovery-bar {
        margin: 0 -28px 30px;
        padding-inline: 28px;
    }

    .video-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 28px 18px;
    }

    .video-title {
        font-size: 15px;
    }
}

@media (min-width: 1200px) {
    .video-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (min-width: 1420px) {
    .video-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .discovery-bar {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        min-height: 0;
        padding-block: 14px;
    }

    .result-count {
        font-size: 14px;
    }

    .search-form {
        width: 100%;
    }

    .search-button {
        min-width: 72px;
        padding-inline: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
