:root {
    color-scheme: dark;
    --app-width: 520px;
    --bg: #0b0d10;
    --surface: #15181e;
    --surface-raised: #1b1f27;
    --surface-soft: #11141a;
    --text: #f5f7fa;
    --text-secondary: #a5abb5;
    --text-tertiary: #707782;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --brand: #ff4d5e;
    --brand-soft: rgba(255, 77, 94, 0.12);
    --success: #38c985;
    --header-height: 56px;
}

* { box-sizing: border-box; }
html { background: #050608; scroll-behavior: smooth; }
body {
    margin: 0;
    background: #050608;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}
body.modal-open { overflow: hidden; }
body.subview-open .category-rail,
body.subview-open .site-footer { display: none; }
body.modal-open .mobile-nav { display: none; }
button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
[hidden], .u-hidden { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.shell { width: auto; margin-inline: 12px; }
.skip-link { position: fixed; z-index: 3000; left: 12px; top: -60px; padding: 10px 14px; background: white; color: #111; border-radius: 8px; }
.skip-link:focus { top: 10px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.site-header,
main,
.site-footer,
.mobile-nav {
    width: min(100%, var(--app-width));
    margin-inline: auto;
}

.site-header {
    position: sticky;
    z-index: 100;
    top: 0;
    height: calc(var(--header-height) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    background: rgba(11, 13, 16, 0.98);
    border-bottom: 1px solid var(--line);
}
.header-inner {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
}
.brand { flex: 0 0 auto; display: flex; align-items: center; height: 44px; }
.brand-mark { display: inline-flex; align-items: baseline; font-size: 22px; line-height: 1; font-style: normal; font-weight: 800; letter-spacing: -0.5px; }
.brand-mark b { color: var(--text); font: inherit; }
.brand-mark i { color: var(--brand); font: inherit; }
.search-form {
    flex: 1 1 auto;
    min-width: 0;
    height: 36px;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 18px;
    background: var(--surface-raised);
}
.search-form:focus-within { border-color: rgba(255, 77, 94, 0.45); }
.search-form svg { flex: 0 0 auto; width: 17px; height: 17px; margin-left: 12px; color: var(--text-tertiary); }
.search-form input {
    width: 100%; min-width: 0; height: 100%; padding: 0 10px 0 8px;
    border: 0; outline: 0; border-radius: inherit; background: transparent;
    color: var(--text); font-size: 16px;
}
.search-form input::placeholder { color: var(--text-tertiary); }
.header-icon {
    flex: 0 0 auto; width: 40px; height: 44px; display: grid; place-items: center;
    padding: 0; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer;
}
.header-icon svg { width: 21px; height: 21px; }

main {
    min-height: calc(100dvh - var(--header-height));
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
    background: var(--bg);
}
.home-anchor { display: none; }

.category-rail {
    position: sticky;
    z-index: 80;
    top: calc(var(--header-height) + env(safe-area-inset-top));
    margin: 0;
    padding: 0 12px;
    background: rgba(11, 13, 16, 0.98);
    border-bottom: 1px solid var(--line);
}
.chip-scroller {
    height: 43px;
    display: flex;
    align-items: stretch;
    gap: 22px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
.chip-scroller::-webkit-scrollbar { display: none; }
.category-chip {
    position: relative;
    flex: 0 0 auto;
    min-width: 36px;
    height: 43px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.category-chip svg { display: none; }
.category-chip.is-active { color: var(--text); font-weight: 600; }
.category-chip.is-active::after {
    position: absolute; left: 50%; bottom: 0; width: 18px; height: 2px;
    content: ""; border-radius: 2px; background: var(--brand); transform: translateX(-50%);
}
.chip-skeleton { flex: 0 0 54px; height: 15px; margin-block: 14px; border-radius: 4px; background: var(--surface-raised); animation: pulse 1.2s ease-in-out infinite alternate; }

.content-section { margin-top: 22px; }
.content-section:first-child { margin-top: 16px; }
.section-heading {
    min-height: 36px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}
.section-heading h2 { margin: 0; font-size: 18px; line-height: 24px; font-weight: 650; }
.eyebrow { display: none; }
.text-button {
    min-width: 48px; min-height: 36px; display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px;
    padding: 0; border: 0; background: transparent; color: var(--text-tertiary); font-size: 13px; cursor: pointer;
}
.text-button span { font-size: 20px; line-height: 1; }
.refresh-button { gap: 5px; color: var(--text-secondary); }
.refresh-button svg { width: 16px; height: 16px; }

.video-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 8px;
    min-height: 120px;
}
#popular-grid .video-card:nth-child(n+7),
#latest-grid .video-card:nth-child(n+7),
#discover-grid .video-card:nth-child(n+7) { display: none; }
.video-card { min-width: 0; }
.card-button { width: 100%; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.card-cover {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    background: var(--surface-raised);
}
.card-cover img {
    width: 100%; height: 100%; display: block; object-fit: cover;
    transition: filter 160ms ease, opacity 160ms ease;
}
.privacy-on .card-cover img,
.privacy-on .related-card img { filter: blur(18px); transform: scale(1.1); }
.card-badges {
    position: absolute;
    z-index: 2;
    inset: auto 6px 6px 6px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    pointer-events: none;
}
.card-badge { display: none; }
.duration-badge {
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.68);
    color: white;
    font-size: 10px;
    line-height: 16px;
}
.play-bubble { display: none; }
.card-copy { padding-top: 7px; }
.card-title {
    min-height: 40px;
    margin: 0;
    display: -webkit-box;
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    word-break: break-all;
}
.card-meta {
    min-height: 16px;
    margin-top: 3px;
    display: flex;
    align-items: center;
    color: var(--text-tertiary);
    font-size: 11px;
    line-height: 16px;
}
.card-meta span { display: none; }
.card-meta strong { font-weight: 400; }

.skeleton-card .card-cover,
.skeleton-line { background: var(--surface-raised); animation: pulse 1.2s ease-in-out infinite alternate; }
.skeleton-line { width: 96%; height: 12px; margin-top: 9px; border-radius: 3px; }
.skeleton-line.short { width: 58%; margin-top: 6px; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }

.results-view,
.profile-view { padding-top: 12px; }
.results-toolbar {
    min-height: 52px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
}
.back-button {
    width: 44px; height: 44px; display: grid; place-items: center;
    margin-left: -10px; padding: 0; border: 0; background: transparent; color: var(--text); cursor: pointer;
}
.back-button svg { width: 24px; height: 24px; }
.results-heading { min-width: 0; }
.results-heading h1 { margin: 0; overflow: hidden; font-size: 18px; line-height: 26px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.sort-tabs {
    display: flex;
    height: 34px;
    padding: 2px;
    border-radius: 7px;
    background: var(--surface-raised);
}
.sort-tabs button {
    min-width: 48px; padding: 0 10px; border: 0; border-radius: 6px;
    background: transparent; color: var(--text-tertiary); font-size: 12px; cursor: pointer;
}
.sort-tabs button.is-active { background: #2a2f39; color: var(--text); }
.results-grid .video-card { display: block; }
.load-more-wrap { display: flex; justify-content: center; padding: 28px 0 16px; }
.secondary-button {
    min-width: 132px; min-height: 42px; padding: 0 20px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--surface); color: var(--text-secondary); cursor: pointer;
}
.secondary-button:disabled { opacity: .5; }
.empty-state {
    grid-column: 1 / -1;
    min-height: 280px;
    display: grid;
    place-items: center;
    padding: 20px;
    color: var(--text-tertiary);
    text-align: center;
}
.empty-state strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 16px; font-weight: 600; }

.profile-header {
    min-height: 98px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 4px 16px;
}
.age-seal {
    flex: 0 0 auto; width: 56px; height: 56px; display: grid; place-items: center;
    border-radius: 16px; background: var(--brand-soft); color: var(--brand); font-size: 18px; font-weight: 700;
}
.profile-header h1 { margin: 0; font-size: 22px; font-weight: 650; }
.profile-header p { margin: 6px 0 0; color: var(--text-tertiary); font-size: 12px; }
.profile-group {
    overflow: hidden;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}
.profile-row {
    position: relative;
    width: 100%; min-height: 60px; display: flex; align-items: center; gap: 12px;
    padding: 9px 14px; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.profile-row + .profile-row::before { position: absolute; left: 54px; right: 0; top: 0; height: 1px; content: ""; background: var(--line); }
.profile-row-icon { flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center; color: var(--text-secondary); }
.profile-row-icon svg { width: 21px; height: 21px; }
.profile-row > span:not(.profile-row-icon):not(.switch) { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.profile-row b { font-size: 14px; line-height: 21px; font-weight: 500; }
.profile-row small { color: var(--text-tertiary); font-size: 11px; line-height: 17px; }
.profile-row > i { color: var(--text-tertiary); font-size: 22px; font-style: normal; }
.switch { position: relative; flex: 0 0 auto; width: 42px; height: 24px; border-radius: 12px; background: #343943; transition: background 160ms; }
.switch i { position: absolute; left: 2px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: white; transition: transform 160ms; }
#privacy-button[aria-pressed="true"] .switch { background: var(--brand); }
#privacy-button[aria-pressed="true"] .switch i { transform: translateX(18px); }
.profile-links .profile-row { min-height: 52px; }
.profile-links .profile-row::before { left: 14px; }
.profile-legal { margin: 20px 8px 0; color: var(--text-tertiary); font-size: 11px; line-height: 18px; text-align: center; }

.site-footer {
    min-height: 92px;
    padding: 20px 12px calc(76px + env(safe-area-inset-bottom));
    background: var(--bg);
    color: var(--text-tertiary);
    text-align: center;
}
.site-footer p { margin: 0 0 5px; font-size: 12px; }
.site-footer small { font-size: 10px; }

.mobile-nav {
    position: fixed;
    z-index: 120;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(58px + env(safe-area-inset-bottom));
    padding: 3px 8px env(safe-area-inset-bottom);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line);
    background: rgba(15, 17, 21, 0.98);
}
.mobile-nav button {
    min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 0; border: 0; background: transparent; color: var(--text-tertiary); cursor: pointer;
}
.mobile-nav svg { width: 21px; height: 21px; }
.mobile-nav span { font-size: 11px; line-height: 14px; }
.mobile-nav button.is-active { color: var(--brand); }

.modal[hidden] { display: none; }
.modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.82);
}
.player-panel,
.info-panel {
    width: min(100%, var(--app-width));
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
}
.player-topbar,
.info-topbar {
    position: sticky;
    z-index: 10;
    top: 0;
    height: calc(50px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 8px 0;
    display: grid;
    grid-template-columns: 48px 1fr 82px;
    align-items: center;
    background: var(--bg);
}
.player-topbar > span { justify-self: center; font-size: 15px; font-weight: 600; }
.modal-close,
.info-topbar button {
    width: 44px; height: 44px; display: grid; place-items: center;
    padding: 0; border: 0; background: transparent; color: var(--text); cursor: pointer;
}
.modal-close svg,
.info-topbar button svg { width: 25px; height: 25px; }
.favorite-toggle {
    justify-self: end; min-width: 76px; height: 42px; display: flex; align-items: center; justify-content: center; gap: 5px;
    padding: 0 8px; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer;
}
.favorite-toggle svg { width: 19px; height: 19px; }
.favorite-toggle span { font-size: 12px; }
.favorite-toggle[aria-pressed="true"] { color: var(--brand); }
.favorite-toggle[aria-pressed="true"] svg { fill: currentColor; }
.player-shell { position: relative; aspect-ratio: 16 / 9; background: black; }
.player-shell video { width: 100%; height: 100%; display: block; background: black; }
.player-loading,
.player-error {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #050506; color: var(--text-secondary); text-align: center;
}
.player-loading span { width: 28px; height: 28px; border: 2px solid #30343b; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.player-loading p,
.player-error p { margin: 10px 0 0; color: var(--text-tertiary); font-size: 12px; }
.player-error strong { color: var(--text); font-size: 15px; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-info { padding: 16px 12px 18px; border-bottom: 1px solid var(--line); }
.category-label { color: var(--brand); font-size: 12px; }
.player-info h2 { margin: 8px 0 7px; font-size: 17px; line-height: 25px; font-weight: 600; word-break: break-all; }
.player-info p { margin: 0; color: var(--text-tertiary); font-size: 11px; line-height: 18px; }
.related-block { padding: 20px 12px calc(30px + env(safe-area-inset-bottom)); }
.related-block h3 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.related-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 8px; }
.related-card { min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.related-card div { overflow: hidden; aspect-ratio: 16 / 9; border-radius: 8px; background: var(--surface-raised); }
.related-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.related-card span { min-height: 40px; margin-top: 7px; display: -webkit-box; overflow: hidden; font-size: 13px; line-height: 20px; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.age-modal { align-items: stretch; background: var(--bg); }
.age-panel {
    width: min(100%, var(--app-width));
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: calc(28px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
    overflow-y: auto;
    background: var(--bg);
}
.age-icon {
    width: 56px; height: 56px; display: grid; place-items: center;
    margin-bottom: 24px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); font-size: 18px; font-weight: 700;
}
.age-panel h2 { margin: 0 0 12px; font-size: 23px; line-height: 32px; font-weight: 650; }
.age-panel > p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 23px; }
.remember-check { min-height: 46px; display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--text-secondary); font-size: 13px; cursor: pointer; }
.remember-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.primary-button {
    width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 9px; background: var(--brand); color: white; font-size: 15px; font-weight: 600; cursor: pointer;
}
.leave-button { min-height: 48px; display: flex; align-items: center; justify-content: center; margin-top: 8px; color: var(--text-tertiary); font-size: 13px; }

.info-modal { background: rgba(0, 0, 0, .82); }
.info-topbar { grid-template-columns: 48px 1fr 48px; border-bottom: 1px solid var(--line); }
.info-topbar h2 { margin: 0; justify-self: center; font-size: 16px; font-weight: 600; }
.info-content { padding: 20px 16px calc(30px + env(safe-area-inset-bottom)); color: var(--text-secondary); font-size: 14px; line-height: 1.8; }
.info-content h3 { margin: 20px 0 8px; color: var(--text); font-size: 16px; }
.info-content h3:first-child { margin-top: 0; }
.info-content p { margin: 0 0 12px; }

.toast {
    position: fixed;
    z-index: 2000;
    left: 50%;
    bottom: calc(76px + env(safe-area-inset-bottom));
    max-width: min(calc(100vw - 32px), 420px);
    padding: 10px 14px;
    border-radius: 7px;
    background: rgba(245, 247, 250, .94);
    color: #14161a;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity 160ms, transform 160ms;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 521px) {
    .site-header,
    main,
    .site-footer,
    .mobile-nav,
    .player-panel,
    .info-panel,
    .age-panel { border-inline: 1px solid #181b21; }
}

@media (max-width: 340px) {
    .header-inner { gap: 7px; padding-inline: 9px; }
    .brand-mark { font-size: 20px; }
    .header-icon { width: 36px; }
    .shell { margin-inline: 10px; }
    .category-rail { padding-inline: 10px; }
    .video-grid, .related-grid { gap-inline: 7px; }
    .card-title { font-size: 13px; line-height: 19px; }
}

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