:root {
    --bg: #f6f5ef;
    --surface: #ffffff;
    --surface-soft: #eef5ef;
    --text: #18231f;
    --muted: #66736d;
    --line: #dfe5de;
    --primary: #147d64;
    --primary-strong: #0d5f4d;
    --coral: #d8644f;
    --gold: #c8942f;
    --blue: #2f6fad;
    --shadow: 0 18px 44px rgba(31, 45, 39, 0.12);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 16px;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(238, 245, 239, 0.86), rgba(246, 245, 239, 0.2) 360px),
        var(--bg);
}

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

button {
    cursor: pointer;
}

img,
video {
    display: block;
    max-width: 100%;
}

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

.app-shell {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    min-height: 100vh;
}

.side-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px);
    z-index: 20;
}

.brand-mark,
.rail-link {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 8px;
}

.brand-mark {
    margin-bottom: 22px;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 10px 26px rgba(20, 125, 100, 0.26);
}

.brand-mark span,
.brand-line span {
    font-weight: 800;
}

.side-rail nav {
    display: grid;
    gap: 10px;
}

.rail-link {
    color: var(--muted);
    background: transparent;
}

.rail-link:hover,
.rail-link.active {
    color: var(--primary);
    background: var(--surface-soft);
}

.rail-link svg,
.icon-button svg,
.text-button svg,
.search-box svg {
    width: 19px;
    height: 19px;
    stroke-width: 2.2;
}

.workspace {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: grid;
    grid-template-columns: auto minmax(280px, 560px) auto;
    align-items: center;
    gap: 18px;
    padding: 18px clamp(18px, 4vw, 44px);
    border-bottom: 1px solid rgba(223, 229, 222, 0.86);
    background: rgba(246, 245, 239, 0.82);
    backdrop-filter: blur(18px);
}

.identity {
    display: grid;
    gap: 2px;
}

.identity-kicker {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.identity strong {
    font-size: 22px;
}

.search-box {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 38px;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 4px 6px 4px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.search-box input {
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.topbar-actions,
.metric-row,
.filter-strip,
.sort-actions,
.card-body,
.player-details,
.admin-head,
.admin-actions,
.row-actions,
.field-row {
    display: flex;
    align-items: center;
}

.topbar-actions {
    justify-content: flex-end;
    gap: 10px;
}

.icon-button,
.text-button,
.account-chip,
.segment {
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 8px;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 38px;
    padding: 0;
    color: var(--muted);
    background: var(--surface);
    border-color: var(--line);
}

.icon-button:hover,
.icon-button.active {
    color: var(--primary);
    border-color: rgba(20, 125, 100, 0.28);
    background: var(--surface-soft);
}

.icon-button.danger {
    color: var(--coral);
}

.text-button,
.account-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 88px;
    padding: 0 15px;
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 700;
}

.text-button:hover {
    background: var(--primary-strong);
}

.text-button.ghost {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line);
}

.text-button.wide {
    width: 100%;
}

.account-chip {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line);
}

.account-chip span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    background: var(--blue);
}

.content-board {
    display: grid;
    gap: 24px;
    width: min(1280px, 100%);
    margin: 0 auto;
    padding: 26px clamp(18px, 4vw, 44px) 54px;
}

.watch-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
    gap: 22px;
    align-items: stretch;
}

.lead-player {
    position: relative;
    min-height: 330px;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #111;
    box-shadow: var(--shadow);
}

.lead-player img {
    width: 100%;
    height: 100%;
    min-height: 330px;
    object-fit: cover;
    filter: saturate(1.03);
    transition: transform 180ms ease;
}

.lead-player:hover img {
    transform: scale(1.02);
}

.lead-player::after {
    position: absolute;
    inset: 0;
    content: "";
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.58));
}

.play-orb {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    color: #fff;
    background: rgba(20, 125, 100, 0.92);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.play-orb svg {
    width: 26px;
    height: 26px;
    margin-left: 3px;
}

.lead-meta {
    position: absolute;
    left: 22px;
    right: 22px;
    bottom: 20px;
    z-index: 2;
    display: grid;
    gap: 6px;
    color: #fff;
    text-align: left;
}

.lead-meta small,
.video-card p,
.modal-title span,
.responsive-table small {
    color: var(--muted);
    font-size: 13px;
}

.lead-meta small {
    color: rgba(255, 255, 255, 0.78);
}

.lead-meta strong {
    font-size: 26px;
}

.watch-copy {
    display: grid;
    align-content: center;
    gap: 18px;
    min-height: 330px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 8px 10px;
    color: var(--primary);
    background: var(--surface-soft);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
}

.live-pill span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--coral);
}

.watch-copy h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.15;
}

.watch-copy p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.metric-row {
    flex-wrap: wrap;
    gap: 10px;
}

.metric-row span {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fbfbf8;
}

.metric-row strong {
    color: var(--text);
}

.filter-strip {
    justify-content: space-between;
    gap: 16px;
}

.segment-control,
.auth-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.74);
}

.segment {
    flex: 0 0 auto;
    padding: 0 14px;
    color: var(--muted);
    background: transparent;
    font-weight: 700;
    white-space: nowrap;
}

.segment:hover,
.segment.active {
    color: #fff;
    background: var(--primary);
}

.sort-actions {
    gap: 8px;
}

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

.video-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.video-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(31, 45, 39, 0.12);
}

.thumb-button {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    padding: 0;
    border: 0;
    background: #17211d;
}

.thumb-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.duration,
.vip-badge {
    position: absolute;
    z-index: 2;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
}

.duration {
    right: 10px;
    bottom: 10px;
    padding: 5px 7px;
    color: #fff;
    background: rgba(0, 0, 0, 0.72);
}

.vip-badge {
    left: 10px;
    top: 10px;
    padding: 5px 8px;
    color: #201706;
    background: var(--gold);
}

.card-body {
    justify-content: space-between;
    gap: 12px;
    min-height: 92px;
    padding: 13px;
}

.card-body h2 {
    display: -webkit-box;
    min-height: 44px;
    margin: 0 0 6px;
    overflow: hidden;
    font-size: 16px;
    line-height: 1.35;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.card-body p {
    margin: 0;
}

.modal[hidden],
.hidden,
.toast[hidden] {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 21, 0.58);
    backdrop-filter: blur(12px);
}

.modal-panel {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.52);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.player-panel {
    width: min(980px, 100%);
    background: #0f1513;
}

.player-panel video {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
}

.player-details {
    justify-content: space-between;
    gap: 18px;
    padding: 18px;
    color: #fff;
}

.player-details h2 {
    margin: 4px 0 8px;
}

.player-details p {
    margin: 0;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.7;
}

.player-details span {
    color: #9ed8c9;
    font-size: 13px;
    font-weight: 800;
}

.auth-panel,
.upload-panel {
    padding: 26px;
}

.modal-title {
    display: grid;
    gap: 4px;
    margin-bottom: 18px;
}

.modal-title h2,
.admin-shell h1 {
    margin: 0;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.stack-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: #fbfbf8;
    outline: 0;
}

.stack-form textarea {
    resize: vertical;
}

.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus {
    border-color: rgba(20, 125, 100, 0.46);
    box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.12);
}

.auth-tabs {
    margin-bottom: 16px;
}

.form-message {
    min-height: 20px;
    margin: 12px 0 0;
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 120;
    max-width: min(360px, calc(100vw - 40px));
    padding: 12px 14px;
    border-radius: 8px;
    color: #fff;
    background: var(--text);
    box-shadow: var(--shadow);
}

.admin-shell {
    width: min(1280px, 100%);
    margin: 0 auto;
    padding: 24px clamp(18px, 4vw, 42px) 60px;
}

.admin-head {
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.brand-line {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand-line span {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #fff;
    border-radius: 8px;
    background: var(--primary);
}

.empty-state,
.login-card,
.editor-panel,
.table-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 10px 26px rgba(31, 45, 39, 0.08);
}

.empty-state,
.login-card {
    width: min(520px, 100%);
    margin: 68px auto;
    padding: 28px;
}

.video-grid .empty-state {
    grid-column: 1 / -1;
    width: 100%;
    margin: 0;
}

.empty-state p {
    color: var(--muted);
    line-height: 1.7;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.editor-panel,
.table-panel {
    padding: 20px;
}

.editor-panel {
    position: sticky;
    top: 20px;
    display: grid;
    gap: 14px;
}

.field-row {
    gap: 12px;
}

.check-field {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 8px !important;
}

.check-field input {
    width: 18px;
    min-height: 18px;
}

.responsive-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 13px;
}

td strong,
td small {
    display: block;
}

td small {
    margin-top: 4px;
}

.row-actions {
    gap: 8px;
    justify-content: flex-end;
}

.row-actions form {
    margin: 0;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.alert.success {
    color: #0d5f4d;
    background: var(--surface-soft);
}

.alert.error {
    color: #9c3324;
    background: #f9e5df;
}

.app-view {
    display: grid;
    gap: 24px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.section-head span {
    display: block;
    margin-bottom: 4px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.section-head h2 {
    margin: 0;
    font-size: 28px;
}

.feed-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.short-feed {
    height: min(760px, calc(100vh - 150px));
    min-height: 560px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-snap-type: y mandatory;
    border-radius: 8px;
    background: #0d1210;
    box-shadow: var(--shadow);
}

.short-card {
    position: relative;
    height: min(760px, calc(100vh - 150px));
    min-height: 560px;
    overflow: hidden;
    scroll-snap-align: start;
    background: #0d1210;
}

.short-card video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #050706;
}

.short-card::after {
    position: absolute;
    inset: 0;
    content: "";
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(5, 7, 6, 0.7), transparent 46%, rgba(5, 7, 6, 0.2)),
        linear-gradient(180deg, transparent 40%, rgba(5, 7, 6, 0.78));
}

.short-overlay {
    position: absolute;
    left: clamp(18px, 4vw, 42px);
    bottom: 32px;
    z-index: 2;
    display: grid;
    gap: 8px;
    width: min(560px, calc(100% - 118px));
    color: #fff;
}

.short-overlay span {
    color: #9ed8c9;
    font-size: 13px;
    font-weight: 800;
}

.short-overlay h2 {
    margin: 0;
    font-size: clamp(24px, 4vw, 42px);
    line-height: 1.1;
}

.short-overlay p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.7;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.short-tools {
    position: absolute;
    right: 22px;
    bottom: 34px;
    z-index: 2;
    display: grid;
    gap: 12px;
}

.icon-button.glass {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(12px);
}

.image-masonry {
    column-count: 4;
    column-gap: 16px;
}

.image-card {
    display: inline-block;
    width: 100%;
    margin: 0 0 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    break-inside: avoid;
    box-shadow: 0 10px 24px rgba(31, 45, 39, 0.08);
}

.image-card button {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: #121816;
}

.image-card img {
    width: 100%;
    height: auto;
}

.image-meta {
    display: grid;
    gap: 5px;
    padding: 12px;
}

.image-meta strong {
    line-height: 1.35;
}

.image-meta span {
    color: var(--muted);
    font-size: 13px;
}

.image-panel {
    width: min(980px, 100%);
    background: #0f1513;
}

.image-panel img {
    width: 100%;
    max-height: min(76vh, 820px);
    object-fit: contain;
    background: #050706;
}

.image-preview-copy {
    padding: 18px;
    color: #fff;
}

.image-preview-copy span {
    color: #9ed8c9;
    font-size: 13px;
    font-weight: 800;
}

.image-preview-copy h2 {
    margin: 6px 0 8px;
}

.image-preview-copy p {
    margin: 0;
    color: rgba(255, 255, 255, 0.74);
}

.chat-shell {
    display: grid;
    grid-template-rows: minmax(420px, 1fr) auto;
    min-height: min(720px, calc(100vh - 170px));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(238, 245, 239, 0.78), rgba(255, 255, 255, 0.88)),
        var(--surface);
}

.chat-message {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    width: min(680px, 100%);
}

.chat-message > span {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: #fff;
    border-radius: 50%;
    background: var(--blue);
    font-weight: 800;
}

.chat-message div {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.chat-message strong {
    display: block;
    margin-bottom: 4px;
    color: var(--primary);
    font-size: 13px;
}

.chat-message p {
    margin: 0;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.chat-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: #fbfbf8;
}

.chat-compose input {
    min-width: 0;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: 0;
}

.chat-compose input:focus {
    border-color: rgba(20, 125, 100, 0.46);
    box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.12);
}

@media (max-width: 1120px) {
    .video-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .image-masonry {
        column-count: 3;
    }

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

    .watch-copy {
        min-height: auto;
    }
}

@media (max-width: 820px) {
    .app-shell {
        display: block;
        padding-bottom: 72px;
    }

    .side-rail {
        position: fixed;
        top: auto;
        right: 12px;
        bottom: 12px;
        left: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 58px;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: var(--shadow);
    }

    .brand-mark {
        display: none;
    }

    .side-rail nav {
        display: flex;
        justify-content: space-around;
        width: 100%;
        gap: 4px;
    }

    .rail-link {
        width: 48px;
        height: 44px;
    }

    .topbar {
        grid-template-columns: 1fr auto;
        gap: 12px;
    }

    .search-box {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
    }

    .topbar-actions .ghost {
        display: none;
    }

    .content-board {
        padding-top: 18px;
    }

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

    .image-masonry {
        column-count: 2;
    }

    .short-feed,
    .short-card {
        height: calc(100vh - 190px);
        min-height: 480px;
    }

    .short-overlay {
        width: calc(100% - 100px);
    }

    .watch-copy h1 {
        font-size: 28px;
    }

    .lead-player,
    .lead-player img {
        min-height: 230px;
    }

    .filter-strip {
        align-items: stretch;
        flex-direction: column;
    }

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

    .editor-panel {
        position: static;
    }
}

@media (max-width: 520px) {
    body {
        font-size: 15px;
    }

    .topbar {
        padding: 14px;
    }

    .identity strong {
        font-size: 20px;
    }

    .text-button {
        min-width: 74px;
        padding: 0 12px;
    }

    .text-button span {
        display: none;
    }

    .content-board {
        padding-right: 14px;
        padding-left: 14px;
    }

    .watch-copy {
        padding: 20px;
    }

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

    .section-head h2 {
        font-size: 24px;
    }

    .image-masonry {
        column-count: 1;
    }

    .short-feed,
    .short-card {
        min-height: 520px;
    }

    .short-overlay {
        left: 16px;
        bottom: 20px;
        width: calc(100% - 88px);
    }

    .short-tools {
        right: 14px;
        bottom: 22px;
    }

    .chat-shell {
        min-height: calc(100vh - 210px);
    }

    .card-body {
        min-height: 82px;
    }

    .player-details {
        align-items: stretch;
        flex-direction: column;
    }

    .auth-panel,
    .upload-panel {
        padding: 22px;
    }
}
