:root {
  color-scheme: dark;
  --bg: #10111f;
  --bg-soft: #18192b;
  --panel: rgba(255, 255, 255, 0.065);
  --panel-strong: rgba(255, 255, 255, 0.095);
  --text: #f7f8ff;
  --muted: #a8adbf;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #f45b5b;
  --accent-2: #f79a2e;
  --good: #17b981;
  --blue: #3b82f6;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

body.light {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --text: #151827;
  --muted: #5f6678;
  --line: rgba(20, 27, 48, 0.12);
  --shadow: 0 16px 50px rgba(30, 42, 80, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  line-height: 1.5;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(244, 91, 91, 0.2), transparent 28rem),
    linear-gradient(135deg, var(--bg), #17264c);
  color: var(--text);
  letter-spacing: 0;
}

body.light {
  background:
    radial-gradient(circle at top left, rgba(244, 91, 91, 0.14), transparent 26rem),
    linear-gradient(135deg, var(--bg), #eef4ff);
}

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

button {
  border: 0;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
  min-height: 100vh;
}

.login-view {
  min-height: calc(100vh - 60px);
  display: grid;
  place-items: center;
  padding: 24px 0;
}

.login-panel {
  width: min(440px, 100%);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 30px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
}

.login-panel h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.login-panel p,
.topbar p,
#resultHint,
.modal-copy {
  color: var(--muted);
  margin: 8px 0 0;
}

label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 7px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}

body.light input,
body.light select,
body.light textarea {
  background: #f8faff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 91, 91, 0.18);
}

.combo {
  position: relative;
}

.combo input {
  padding-right: 46px;
}

.combo-arrow {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 34px;
  height: calc(100% - 12px);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.combo-arrow:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.combo-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: min(760px, max(100%, 520px));
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  padding: 8px;
}

.combo-menu::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 34px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
}

.combo-option {
  position: relative;
  z-index: 1;
  width: 100%;
  display: block;
  min-height: 42px;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.combo-option:hover {
  background: rgba(244, 91, 91, 0.12);
}

.combo-empty {
  color: var(--muted);
  padding: 10px 12px;
}

.login-panel label {
  display: block;
  margin-top: 16px;
}

.form-error {
  min-height: 20px;
  margin-top: 12px;
  color: #ff8a8a;
  font-size: 13px;
}

.login-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.text-button {
  display: block;
  margin: 12px auto 0;
  background: transparent;
  color: var(--accent-2);
  cursor: pointer;
  font-weight: 700;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 16px 0 24px;
}

.eyebrow {
  color: var(--accent-2);
  font-weight: 700;
  margin-bottom: 8px;
}

.topbar-actions,
.actions-row,
.result-actions,
.task-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-panel,
.admin-panel,
.results-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 22px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-header p {
  color: var(--muted);
  margin: 4px 0 0;
}

.panel-actions,
.admin-netdisk-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 18px;
}

.compact-form,
.user-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 14px;
}

.compact-form {
  display: grid;
  gap: 12px;
  align-content: start;
}

.user-list {
  display: grid;
  gap: 12px;
}

.user-card {
  display: grid;
  gap: 12px;
}

.user-card-header,
.user-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.user-card-actions.compact {
  justify-content: flex-end;
}

.user-card-title {
  font-weight: 800;
}

.admin-inherits {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 185, 129, 0.1);
  color: var(--text);
  padding: 11px 12px;
  font-size: 13px;
}

.danger-button {
  color: #ff9b9b;
}

.permission-selector {
  display: grid;
  gap: 10px;
}

.permission-head,
.permission-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.permission-head > span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.permission-count {
  color: var(--muted);
  font-size: 12px;
}

.text-button.small {
  display: inline-flex;
  margin: 0;
  padding: 0;
  min-height: auto;
  font-size: 12px;
}

.muted-action {
  color: var(--muted);
}

.permission-search {
  padding: 10px 12px;
}

.permission-list {
  display: grid;
  gap: 6px;
  max-height: 250px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 8px;
}

.permission-event {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.permission-event.selected {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.permission-empty {
  color: var(--muted);
  margin: 0;
  padding: 8px;
}

.inline-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.inline-control span {
  margin: 0;
}

.inline-control select {
  width: 82px;
  padding: 8px 10px;
}

.section-title {
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 16px;
}

.search-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 14px;
}

.filter-row {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 14px;
  margin-top: 16px;
}

.filter-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.filter-tags {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.filter-tag,
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.good-pill {
  border-color: rgba(23, 185, 129, 0.42);
  background: rgba(23, 185, 129, 0.16);
}

.warning-pill {
  border-color: rgba(247, 154, 46, 0.48);
  background: rgba(247, 154, 46, 0.16);
}

.danger-pill {
  border-color: rgba(244, 91, 91, 0.5);
  background: rgba(244, 91, 91, 0.16);
}

.filter-tag {
  cursor: pointer;
}

.filter-tag.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.actions-row {
  margin-top: 18px;
}

.primary-button,
.success-button,
.blue-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 7px;
  padding: 0 16px;
  color: white;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.success-button {
  background: linear-gradient(135deg, var(--good), #07875f);
}

.blue-button {
  background: linear-gradient(135deg, var(--blue), #2563eb);
}

.blue-button:disabled {
  background: rgba(148, 163, 184, 0.22);
  border: 1px solid var(--line);
  color: var(--muted);
  opacity: 1;
}

.ghost-button,
.icon-button {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  color: var(--text);
}

.icon-button {
  width: 42px;
  padding: 0;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 18px;
}

.netdisk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 12px;
  margin-bottom: 18px;
}

.netdisk-bar > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.netdisk-target {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  font-size: 46px;
  margin-bottom: 8px;
}

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

.video-card {
  position: relative;
  overflow: hidden;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.video-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22);
}

.video-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #24273d;
  cursor: pointer;
}

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

.event-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(0, 0, 0, 0.66);
  color: white;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.card-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  accent-color: var(--blue);
  z-index: 2;
}

.video-body {
  padding: 14px;
}

.video-title {
  min-height: 42px;
  font-weight: 800;
  line-height: 1.35;
}

.video-meta {
  display: grid;
  gap: 5px;
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

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

.card-actions a,
.card-actions button {
  flex: 1;
  min-height: 36px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: white;
  background: var(--blue);
  cursor: pointer;
}

.card-actions a {
  background: var(--good);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.66);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
  position: relative;
}

.confirm-panel {
  width: min(520px, 100%);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.confirm-panel h2 {
  margin: 0 0 10px;
}

.confirm-panel p {
  color: var(--muted);
  margin: 0 0 22px;
}

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

.modal-panel.wide {
  width: min(900px, 100%);
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  background: transparent;
  color: var(--text);
  font-size: 26px;
  cursor: pointer;
}

#modalVideo {
  width: 100%;
  max-height: 62vh;
  background: #000;
}

.modal-meta {
  color: var(--muted);
  margin-top: 12px;
}

#shareDetailText {
  height: 150px;
  margin-top: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.share-result {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 12px;
  margin-top: 14px;
}

.share-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: start;
}

.share-row span {
  color: var(--muted);
}

.share-row strong {
  overflow-wrap: anywhere;
}

.share-field {
  display: grid;
  gap: 7px;
}

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

.share-field input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.share-meta {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
  border-radius: 7px;
  padding: 12px 14px;
}

body:has(.download-progress-panel:not(.hidden)) .toast {
  bottom: min(600px, calc(100vh - 80px));
}

.download-progress-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 18;
  width: min(430px, calc(100vw - 28px));
  max-height: min(560px, calc(100vh - 44px));
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-soft) 94%, transparent);
  box-shadow: var(--shadow);
  padding: 16px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 420ms ease, transform 420ms ease;
}

.download-progress-panel.closing {
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
}

.download-progress-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.download-progress-title {
  font-weight: 900;
}

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

.download-progress-summary {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.danger-small-button {
  min-height: 34px;
  border-radius: 7px;
  padding: 0 12px;
  color: white;
  background: #dc2626;
  cursor: pointer;
  font-weight: 800;
}

.download-close-button {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.download-total-bar,
.download-item-bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
}

.download-total-bar span,
.download-item-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--blue), #2563eb);
  transition: width 180ms ease;
}

.download-progress-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  max-height: calc((74px * 3) + (10px * 2));
  padding-right: 2px;
}

.download-item {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 10px;
}

.download-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.download-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.download-item-status {
  color: var(--muted);
  white-space: nowrap;
}

.download-item-error {
  color: #fca5a5;
  font-size: 12px;
  overflow-wrap: anywhere;
}

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

@media (max-width: 980px) {
  .search-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .results-header,
  .panel-header,
  .netdisk-bar {
    flex-direction: column;
    align-items: stretch;
  }

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

@media (max-width: 620px) {
  .app-shell {
    width: min(100vw - 20px, 1420px);
    padding-top: 10px;
  }

  .login-view {
    min-height: calc(100vh - 20px);
  }

  .login-panel {
    padding: 22px;
  }

  .login-panel h1 {
    font-size: 26px;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-panel,
  .results-panel {
    padding: 16px;
  }

  .share-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
