:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #66716b;
  --line: #d9dfdb;
  --surface: #ffffff;
  --canvas: #f4f6f4;
  --green: #16784b;
  --green-dark: #0f603a;
  --blue: #235b8f;
  --danger: #9e2f2f;
  --shadow: 0 10px 30px rgba(19, 36, 28, 0.08);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-lockup div { display: grid; gap: 2px; }
.brand-lockup strong { font-size: 15px; }
.brand-lockup span { color: var(--muted); font-size: 12px; }
.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}
.brand-mark-small { width: 36px; height: 36px; font-size: 12px; border-radius: 6px; }

.admin-shell { width: min(1180px, calc(100% - 32px)); margin: 30px auto 64px; }
.create-section, .library-section { padding: 0 0 34px; }
.library-section { border-top: 1px solid var(--line); padding-top: 32px; }
.section-heading { margin-bottom: 18px; }
.section-heading-row { display: flex; justify-content: space-between; align-items: end; }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 12px; font-weight: 800; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 25px; line-height: 1.25; }
h2 { margin: 0; font-size: 21px; line-height: 1.3; }
h3 { margin: 0; font-size: 17px; line-height: 1.35; }

.create-form {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.4fr) auto;
  align-items: end;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.field { display: grid; gap: 7px; min-width: 0; }
label { color: #39443e; font-size: 13px; font-weight: 700; }
input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #bac4be;
  border-radius: 6px;
  background: #fff;
  padding: 9px 11px;
  color: var(--ink);
  outline: none;
}
input[type="text"]:focus, input[type="password"]:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(35, 91, 143, 0.12); }
select { min-height: 42px; padding: 8px 10px; border: 1px solid #bac4be; border-radius: 6px; background: #fff; color: var(--ink); }
textarea { width: 100%; resize: vertical; padding: 9px 11px; border: 1px solid #bac4be; border-radius: 6px; color: var(--ink); font-family: Consolas, monospace; font-size: 13px; }
input[type="file"] { width: 100%; color: var(--muted); font-size: 13px; }
input[type="file"]::file-selector-button {
  min-height: 38px;
  margin-right: 9px;
  border: 1px solid #bac4be;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 11px;
  cursor: pointer;
}
.file-name { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.button:focus-visible { outline: 3px solid rgba(35, 91, 143, 0.24); outline-offset: 2px; }
.button:disabled { cursor: wait; opacity: 0.68; }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover { background: var(--green-dark); }
.button-dark { background: var(--ink); color: #fff; }
.button-dark:hover { background: #303a36; }
.button-quiet { border-color: var(--line); background: #fff; color: var(--ink); }
.button-quiet:hover { border-color: #aab5af; background: #f8faf8; }
.button-danger { border-color: #d6a2a2; background: #fff5f5; color: var(--danger); }
.button-danger:hover { border-color: #b96c6c; background: #fbe7e7; }
.button-block { width: 100%; }

.notice { margin: 0 0 18px; border-left: 4px solid var(--blue); background: #eaf2f8; padding: 11px 13px; font-size: 14px; }
.notice-success { border-left-color: var(--green); background: #e8f5ee; }
.notice-error { border-left-color: var(--danger); background: #f9ebeb; }

.admin-nav { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.nav-item { padding: 10px 13px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700; border-bottom: 3px solid transparent; }
.nav-item:hover, .nav-item.active { color: var(--ink); border-bottom-color: var(--green); }
.nav-item span { display: inline-grid; place-items: center; min-width: 21px; height: 21px; margin-left: 4px; padding: 0 5px; border-radius: 11px; background: #edf1ee; color: var(--muted); font-size: 11px; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 30px; }
.metric-card { display: grid; gap: 5px; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.metric-card span, .metric-card small { color: var(--muted); font-size: 12px; }
.metric-card strong { font-size: 22px; overflow-wrap: anywhere; }
.panel { margin-bottom: 26px; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.section-note { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.section-heading-row { display: flex; justify-content: space-between; align-items: end; gap: 15px; }
.status-badge { padding: 6px 9px; border: 1px solid #b7d5c3; border-radius: 5px; color: var(--green); font-size: 11px; font-weight: 800; white-space: nowrap; }
.inline-create-form, .account-create-form, .rename-form, .bulk-toolbar, .compact-actions, .captcha-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-create-form input { flex: 1 1 240px; }
.group-filter { display: grid; gap: 8px; margin-top: 16px; }
.group-filter > .group-chip, .group-chip-wrap { width: 100%; }
.group-chip-wrap { display: flex; align-items: center; gap: 4px; }
.group-chip, .chip-download { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; font-size: 12px; font-weight: 700; text-decoration: none; }
.group-filter > .group-chip, .group-chip-wrap > .group-chip { justify-content: space-between; }
.group-chip-wrap > .group-chip { flex: 1 1 auto; }
.group-chip:hover, .group-chip.active { border-color: #80b496; background: #edf7f0; }
.group-chip b { color: var(--muted); font-size: 11px; }
.chip-download { min-height: 28px; padding: 5px 7px; color: var(--blue); font-size: 11px; }
.group-chip-wrap form { display: inline-flex; margin: 0; }
.group-edit { display: inline-flex; align-items: center; }
.group-edit summary { list-style: none; cursor: pointer; }
.group-edit summary::-webkit-details-marker { display: none; }
.chip-edit { min-height: 28px; padding: 5px 7px; border: 1px solid #b7c7da; border-radius: 6px; background: #f4f8fc; color: var(--blue); font-size: 11px; font-weight: 700; }
.group-edit form { display: flex; gap: 4px; align-items: center; margin-top: 5px; }
.group-edit input { width: 150px; min-height: 28px; padding: 4px 6px; font-size: 11px; }
.chip-edit-save { min-height: 28px; padding: 5px 7px; border: 1px solid #80b496; border-radius: 6px; background: #edf7f0; color: var(--green); font-size: 11px; font-weight: 700; cursor: pointer; }
.chip-delete { min-height: 28px; padding: 5px 7px; border: 1px solid #d6a2a2; border-radius: 6px; background: #fff5f5; color: var(--danger); font-size: 11px; font-weight: 700; cursor: pointer; }
.chip-delete:hover { border-color: #b96c6c; background: #fbe7e7; }
.bulk-toolbar { justify-content: end; }
.logs-toolbar, .pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; }
.logs-page-form { display: flex; align-items: center; gap: 8px; }
.logs-page-form select { min-height: 34px; }
.logs-summary { color: var(--muted); font-size: 12px; }
.pagination { justify-content: flex-end; }
.is-disabled { pointer-events: none; opacity: .5; }

.video-list { display: grid; gap: 12px; }
.video-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 22px 148px minmax(300px, 1fr) minmax(220px, 300px);
  gap: 20px;
  align-items: center;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.video-row[data-highlight] { border-color: #6cae8d; box-shadow: 0 0 0 3px rgba(22, 120, 75, 0.1); }
.qr-preview { display: block; width: 148px; height: 148px; border: 1px solid #e3e7e4; background: #fff; }
.qr-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-main { min-width: 0; display: grid; gap: 10px; }
.row-actions { display: grid; align-content: center; gap: 12px; min-width: 0; }
.select-box { display: grid; place-items: center; cursor: pointer; }
.select-box input { position: absolute; opacity: 0; pointer-events: none; }
.select-box span { width: 18px; height: 18px; border: 1px solid #9eaaa3; border-radius: 4px; background: #fff; }
.select-box input:checked + span { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 3px #fff; }
.video-title-line { min-width: 0; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.code-label { border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; color: var(--muted); font-family: Consolas, monospace; font-size: 11px; }
.group-label { padding: 3px 6px; border-radius: 4px; background: #eef3ef; color: var(--green); font-size: 11px; }
.video-meta { margin: 0; color: var(--muted); font-size: 12px; }
.scan-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 0; color: var(--muted); font-size: 12px; }
.scan-stats strong { color: var(--ink); }
.link-line { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.link-line input { min-width: 180px; flex: 1 1 240px; min-height: 38px; font-size: 12px; }
.group-move-form { display: grid; gap: 7px; min-width: 0; }
.group-move-form select { min-height: 36px; padding: 6px 8px; font-size: 12px; }
.group-move-form .button { min-height: 34px; padding: 6px 10px; }
.replace-form { align-self: stretch; display: grid; align-content: center; gap: 8px; border-left: 1px solid var(--line); padding-left: 20px; min-width: 0; }
.rename-form input { min-width: 160px; flex: 1 1 180px; min-height: 34px; font-size: 12px; }
.rename-form .button { min-height: 34px; padding: 6px 10px; }

.progress-wrap { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.progress-wrap[hidden] { display: none; }
.progress-track { flex: 1; height: 6px; border-radius: 3px; overflow: hidden; background: #e5e9e6; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width 120ms linear; }
.progress-wrap > span { width: 86px; color: var(--muted); font-size: 12px; text-align: right; }
.upload-queue, .upload-jobs { display: grid; gap: 4px; margin-top: 8px; }
.upload-item, .upload-job { display: flex; justify-content: space-between; gap: 8px; padding: 5px 7px; background: #f4f7f4; font-size: 12px; }
.upload-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item b, .upload-job b { color: var(--muted); font-weight: 700; white-space: nowrap; }
.upload-job span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { min-height: 180px; display: grid; place-content: center; gap: 6px; border: 1px dashed #b7c1bb; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }

.login-page { min-height: 100vh; background: #e9eeea; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(400px, 100%); border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); padding: 30px; }
.login-panel .brand-mark { margin-bottom: 22px; }
.login-panel h1 { margin-bottom: 22px; }
.login-form { display: grid; gap: 10px; }
.login-form .button { margin-top: 6px; }
.captcha-line { align-items: stretch; }
.captcha-line input { min-width: 0; flex: 1 1 120px; }
.captcha-button { width: 160px; height: 52px; padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #eef3ef; cursor: pointer; }
.captcha-button img { display: block; width: 160px; height: 52px; }
.muted-copy { color: var(--muted); line-height: 1.6; }
.trash-list, .account-list { display: grid; gap: 10px; }
.trash-row, .account-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
.account-row { grid-template-columns: minmax(180px, 1fr) minmax(220px, 360px) auto; }
.trash-row h3, .account-row h3 { margin: 0 0 5px; font-size: 15px; }
.reset-form { display: flex; gap: 7px; }
.reset-form input { min-height: 36px; min-width: 170px; }
.current-ip { display: grid; gap: 4px; margin-bottom: 18px; padding: 14px; border-left: 4px solid var(--green); background: #edf7f0; }
.current-ip span, .current-ip small { color: var(--muted); font-size: 12px; }
.current-ip strong { font-family: Consolas, monospace; font-size: 20px; }
.settings-form { display: grid; gap: 14px; max-width: 620px; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.5; }
.toggle-line { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; }
td code { font-family: Consolas, monospace; }
.table-empty { padding: 30px; color: var(--muted); text-align: center; }

.watch-page { min-height: 100vh; background: #0d1110; color: #fff; }
.watch-shell { width: min(920px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 20px 40px; }
.watch-header { min-height: 64px; display: flex; align-items: center; color: #dbe3df; }
.watch-notice { flex: 1; overflow: hidden; color: #ff3b30; font-weight: 800; white-space: nowrap; }
.watch-notice span { display: inline-block; padding-left: 100%; animation: watch-marquee 20s linear infinite; }
.notice-size-12 { font-size: 12px; }
.notice-size-14 { font-size: 14px; }
.notice-size-16 { font-size: 16px; }
.notice-size-18 { font-size: 18px; }
.notice-size-20 { font-size: 20px; }
.notice-size-24 { font-size: 24px; }
.notice-size-28 { font-size: 28px; }
.notice-size-32 { font-size: 32px; }
.notice-size-36 { font-size: 36px; }
.notice-size-48 { font-size: 48px; }
.notice-bold { font-weight: 700; }
.notice-color-ff3b30 { color: #ff3b30; }
.notice-color-18201d { color: #18201d; }
.notice-color-16784b { color: #16784b; }
.notice-color-235b8f { color: #235b8f; }
.notice-color-7a3e00 { color: #7a3e00; }
.notice-color-6b21a8 { color: #6b21a8; }
.notice-color-ffffff { color: #fff; }
@keyframes watch-marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.published-ad { margin-top: 24px; padding: 16px; background: #fff; color: #18201d; }
.published-ad p { margin: 0 0 12px; white-space: pre-wrap; line-height: 1.7; }
.published-ad img { display: block; max-width: 100%; margin: 10px auto; }
.ad-text.ad-size-12 { font-size: 12px; }
.ad-text.ad-size-14 { font-size: 14px; }
.ad-text.ad-size-16 { font-size: 16px; }
.ad-text.ad-size-18 { font-size: 18px; }
.ad-text.ad-size-20 { font-size: 20px; }
.ad-text.ad-size-24 { font-size: 24px; }
.ad-text.ad-size-28 { font-size: 28px; }
.ad-text.ad-size-32 { font-size: 32px; }
.ad-text.ad-size-36 { font-size: 36px; }
.ad-text.ad-size-48 { font-size: 48px; }
.ad-text.ad-bold { font-weight: 700; }
.ad-text.ad-color-18201d { color: #18201d; }
.ad-text.ad-color-b42318 { color: #b42318; }
.ad-text.ad-color-16784b { color: #16784b; }
.ad-text.ad-color-235b8f { color: #235b8f; }
.ad-text.ad-color-7a3e00 { color: #7a3e00; }
.ad-text.ad-color-6b21a8 { color: #6b21a8; }
.ad-text.ad-color-ffffff { color: #fff; }
.ad-group-editor { margin-top: 14px; border: 1px solid var(--line); padding: 12px; }
.ad-style-controls { display: grid; grid-template-columns: minmax(130px, 180px) auto minmax(130px, 180px); gap: 12px; align-items: end; }
.ad-bold-control { min-height: 42px; display: inline-flex; align-items: center; gap: 7px; color: var(--ink); white-space: nowrap; }
.ad-bold-control input { width: 16px; height: 16px; accent-color: var(--green); }
.ad-group-editor > summary { cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.ad-group-editor .settings-form { margin-top: 14px; }
.ad-image-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ad-image-item { display: grid; gap: 5px; width: 100px; }
.ad-image-grid img { width: 100px; height: 72px; object-fit: cover; border: 1px solid var(--line); }
.ad-image-item .chip-delete { width: 100%; }
.ad-preview { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.ad-preview-body { padding: 12px; background: #f7f9f7; }
.ad-preview-body p { white-space: pre-wrap; }
.ad-preview-body img { max-width: 180px; max-height: 120px; margin: 6px; object-fit: contain; }
.library-toolbar { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.sort-form { display: flex; align-items: center; gap: 8px; }
.sort-form select { min-height: 38px; }
.upload-cancel { display: none; }
.upload-cancel.is-active { display: inline-flex; }
.player-section { padding-top: 6px; }
.player-frame { width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player-frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.player-section h1 { margin-top: 20px; font-size: 21px; }

@media (max-width: 880px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .create-form { grid-template-columns: 1fr 1fr; }
  .create-form .button { min-height: 42px; }
  .video-row { grid-template-columns: 22px 128px 1fr; align-items: start; }
  .qr-preview { width: 128px; height: 128px; }
  .row-actions { grid-column: 2 / -1; }
  .replace-form { border-left: 0; border-top: 1px solid var(--line); padding: 15px 0 0; grid-template-columns: minmax(180px, 1fr) auto; align-items: end; }
  .replace-form label, .replace-form .file-name { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .topbar-inner, .admin-shell { width: min(100% - 24px, 1180px); }
  .admin-shell { margin-top: 22px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 15px; }
  .create-form { grid-template-columns: 1fr; padding: 14px; }
  .video-row { grid-template-columns: 20px 92px 1fr; gap: 10px; padding: 13px; }
  .qr-preview { width: 92px; height: 92px; }
  .video-title-line { align-items: flex-start; }
  .link-line { grid-column: 1 / -1; }
  .link-line input { flex-basis: 100%; }
  .link-line .button { flex: 1 1 auto; }
  .row-actions { grid-column: 1 / -1; }
  .replace-form { grid-template-columns: 1fr; }
  .replace-form label, .replace-form .file-name { grid-column: auto; }
  .ad-style-controls { grid-template-columns: 1fr; align-items: start; }
  .watch-shell { padding-left: 0; padding-right: 0; }
  .watch-header, .player-section h1 { margin-left: 16px; margin-right: 16px; }
  .player-section { padding-top: 0; }
  .login-panel { padding: 24px; }
  .section-heading-row { align-items: start; flex-direction: column; }
  .account-row { grid-template-columns: 1fr; }
  .trash-row { grid-template-columns: 20px 1fr; }
  .trash-row .compact-actions { grid-column: 2; }
  .reset-form { flex-wrap: wrap; }
}
