:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #16202a;
  --muted: #62707f;
  --line: #d9e0e6;
  --primary: #176b87;
  --primary-dark: #0f5168;
  --accent: #1f8a70;
  --danger: #b42318;
  --danger-dark: #8f1c13;
  --shadow: 0 14px 36px rgba(18, 31, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover {
  background: #edf3f5;
  color: var(--text);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 148px);
  place-items: center;
}

.upload-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  gap: 18px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.upload-tab-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  gap: 18px;
}

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

.upload-panel,
.result-panel,
.list-panel,
.admin-header,
.auth-panel,
.table-panel {
  padding: 22px;
}

.auth-panel {
  width: min(420px, 100%);
}

.result-panel {
  align-self: start;
}

.list-panel {
  grid-column: 1 / -1;
}

.table-panel {
  width: 100%;
}

.admin-tabs {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.tab-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab-button:hover {
  background: #eef3f5;
  color: var(--text);
}

.tab-button.active {
  background: var(--primary);
  color: #ffffff;
}

.section-title {
  margin-bottom: 18px;
}

.section-title p {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-title h1,
.section-title h2 {
  margin: 0;
  color: var(--text);
  line-height: 1.2;
}

.section-title h1 {
  font-size: 30px;
}

.section-title h2 {
  font-size: 22px;
}

.row-title,
.admin-tools,
.toolbar,
.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.form,
.admin-tools {
  display: grid;
  gap: 14px;
}

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

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

.field input,
.copy-row input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.field input:focus,
.copy-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.file-drop {
  display: grid;
  place-items: center;
  min-height: 156px;
  border: 1px dashed #9badb8;
  border-radius: 8px;
  background: #f8fbfc;
  color: var(--primary);
  cursor: pointer;
}

.file-drop:hover {
  border-color: var(--primary);
  background: #eef7f8;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-drop span {
  max-width: calc(100% - 28px);
  overflow: hidden;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
}

progress::-webkit-progress-bar {
  background: #e5ebef;
}

progress::-webkit-progress-value {
  background: var(--accent);
}

.primary-button,
.ghost-button,
.danger-button,
.copy-row button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

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

.ghost-button,
.small-button,
.copy-row button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.ghost-button:hover,
.small-button:hover,
.copy-row button:hover {
  background: #eef3f5;
}

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

.danger-button:hover {
  background: var(--danger-dark);
}

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

.status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--accent);
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px;
}

.preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-top: 16px;
  border-radius: 8px;
  background: #101820;
}

.preview-button {
  width: 100%;
  margin-top: 14px;
}

.video-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.video-item {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.video-item video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #101820;
}

.video-info {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.video-info h3 {
  overflow: hidden;
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.admin-tools {
  grid-template-columns: minmax(220px, 1fr) auto auto;
}

.table-meta {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

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

td {
  color: var(--text);
  font-size: 14px;
}

.check-cell {
  width: 42px;
}

.table-video {
  display: grid;
  grid-template-columns: 92px minmax(160px, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.table-video video {
  width: 92px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #101820;
}

.video-placeholder {
  width: 92px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfc;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.video-placeholder:hover {
  background: #eef7f8;
}

.table-title {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-cell {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 60px;
  gap: 8px;
}

.url-cell input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
  }

  .shell {
    width: min(100% - 24px, 1120px);
    margin-top: 18px;
  }

  .upload-shell {
    grid-template-columns: 1fr;
  }

  .admin-shell,
  .upload-tab-grid {
    grid-template-columns: 1fr;
  }

  .admin-tabs {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

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

  .row-title {
    align-items: flex-start;
  }

  .section-title h1 {
    font-size: 26px;
  }
}
