:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #1b1f24;
    --muted: #657080;
    --line: #dfe4ea;
    --brand: #0f766e;
    --brand-dark: #0b5f59;
    --danger: #b42318;
    --ok: #157f3b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button,
a {
    min-height: 36px;
    border: 1px solid var(--brand);
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    padding: 7px 12px;
    text-decoration: none;
    cursor: pointer;
}

button.secondary {
    border-color: var(--line);
    background: #fff;
    color: var(--text);
}

button.danger {
    border-color: var(--danger);
    background: var(--danger);
}

button:disabled {
    border-color: #b8c1cc;
    background: #b8c1cc;
    cursor: not-allowed;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 8px 10px;
}

textarea,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
    min-height: 180px;
    margin: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #111827;
    color: #eef2ff;
    padding: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.topbar h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.topbar p {
    margin: 0;
    color: var(--muted);
}

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

.layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
}

.admin-layout {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 16px;
}

.panel.narrow {
    max-width: 420px;
    margin: 40px auto;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel h2,
.panel-head h2,
.dialog h2 {
    margin: 0;
    font-size: 18px;
}

.category-list {
    display: grid;
    gap: 8px;
}

.category-list button {
    width: 100%;
    border-color: var(--line);
    background: #fff;
    color: var(--text);
    text-align: left;
}

.category-list button.active {
    border-color: var(--brand);
    background: #e6f4f1;
    color: var(--brand-dark);
}

.content {
    min-width: 0;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto 160px;
    gap: 8px;
    margin-bottom: 12px;
}

.notice {
    margin: 8px 0 14px;
    color: var(--muted);
}

.error {
    min-height: 20px;
    margin: 0;
    color: var(--danger);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}

.card {
    display: grid;
    gap: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.poster {
    aspect-ratio: 3 / 4;
    background: #e7ebf0;
}

.poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-body {
    display: grid;
    gap: 8px;
    padding: 12px;
}

.card h3 {
    min-height: 44px;
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
}

.meta {
    min-height: 20px;
    color: var(--muted);
    font-size: 13px;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 18px 0;
}

.examples {
    margin-top: 16px;
}

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

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

.stack {
    display: grid;
    gap: 12px;
}

.user-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 16px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-weight: 600;
}

.row-actions {
    display: flex;
    gap: 8px;
}

.dialog {
    width: min(420px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.dialog.wide {
    width: min(840px, calc(100vw - 32px));
}

.player-dialog {
    width: min(980px, calc(100vw - 32px));
}

.video-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: block;
    border-radius: 8px;
    background: #000;
}

.player-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 12px;
}

.debug-details {
    margin-top: 12px;
}

.debug-details summary {
    cursor: pointer;
    color: var(--muted);
    margin-bottom: 8px;
}

.dialog form {
    display: grid;
    gap: 12px;
}

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

@media (max-width: 820px) {
    .topbar,
    .layout {
        display: block;
    }

    .top-actions {
        margin-top: 12px;
    }

    .sidebar {
        margin-bottom: 12px;
    }

    .toolbar,
    .example-grid,
    .user-form {
        grid-template-columns: 1fr;
    }
}
