:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #69707d;
  --line: #dfe3ea;
  --primary: #1663d8;
  --primary-dark: #0f4fae;
  --danger: #c4362e;
  --danger-bg: #fff1f0;
  --success-bg: #edf8f1;
  --success-text: #17633b;
  --error-bg: #fff1f0;
  --error-text: #9f2c26;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

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

button,
input {
  font: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.login-panel,
.upload-panel,
.list-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(22, 24, 29, 0.06);
}

.login-panel {
  width: min(420px, 100%);
  margin: 12vh auto 0;
  padding: 28px;
}

.panel-heading h1,
.admin-header h1,
.upload-panel h2,
.list-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.panel-heading h1 {
  font-size: 24px;
}

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

.admin-header h1 {
  font-size: 28px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.form-stack,
.upload-form {
  display: grid;
  gap: 16px;
}

.form-stack {
  margin-top: 22px;
}

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

input[type="text"],
input[type="password"],
input:not([type]) {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

input[type="file"] {
  width: 100%;
  border: 1px dashed #b8c0cc;
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfe;
}

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

.primary-button,
.ghost-button,
.copy-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

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

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

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

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

.upload-panel,
.list-panel {
  padding: 24px;
  margin-top: 20px;
}

.upload-panel h2,
.list-panel h2 {
  font-size: 20px;
}

.upload-form {
  margin-top: 18px;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(220px, 1.4fr) auto;
  align-items: end;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.count,
.empty {
  color: var(--muted);
}

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

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

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

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

code {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  background: #fbfcfe;
  color: #2b3038;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.link-cell {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.link-cell a {
  overflow-wrap: anywhere;
}

.flash-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.flash {
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
}

.flash-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.flash-error {
  background: var(--error-bg);
  color: var(--error-text);
}

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

.primary-link {
  display: inline-flex;
  margin-top: 10px;
}

.watch-page {
  min-height: 100vh;
  background: #0f1115;
  color: #f7f8fa;
}

.watch-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 12px max(24px, env(safe-area-inset-bottom));
}

.video-player {
  display: block;
  width: 100%;
  max-height: calc(100vh - 88px);
  background: #000;
  border-radius: 0;
}

.watch-shell h1 {
  margin: 14px 2px 0;
  color: #f7f8fa;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 24px, 720px);
    padding-top: 20px;
  }

  .admin-header {
    align-items: flex-start;
  }

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

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 10px;
  }

  td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 0;
    padding: 8px 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
  }

  .link-cell {
    display: grid;
    gap: 8px;
  }
}

@media (max-width: 520px) {
  .login-panel,
  .upload-panel,
  .list-panel {
    padding: 18px;
  }

  .admin-header h1 {
    font-size: 24px;
  }

  .section-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .video-player {
    max-height: calc(100vh - 76px);
  }
}
