:root {
  color-scheme: light;
  --bg: #f4f7f9;
  --ink: #17202a;
  --muted: #5f6b7a;
  --line: #d9e1ea;
  --panel: #ffffff;
  --accent: #0b6b8f;
  --accent-dark: #074b64;
  --gold: #d49a2a;
  --shadow: 0 16px 36px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #edf4f7 0, var(--bg) 220px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.site-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(217, 225, 234, 0.86);
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px max(20px, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-size: 20px;
  font-weight: 750;
  gap: 12px;
  line-height: 1;
  text-decoration: none;
}

.brand:hover,
.brand:focus {
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  border-radius: 7px;
  box-shadow: 0 5px 14px rgba(5, 7, 9, 0.16);
  display: block;
}

.brand-word {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  letter-spacing: 0;
}

.brand-primary {
  font-weight: 800;
}

.brand-secondary {
  color: var(--muted);
  font-weight: 650;
}

.video-dot {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 0 0 3px #dceff6;
  display: inline-flex;
  height: 18px;
  justify-content: center;
  width: 18px;
}

.video-dot::before {
  border-bottom: 4px solid transparent;
  border-left: 6px solid #fff;
  border-top: 4px solid transparent;
  content: "";
  margin-left: 2px;
}

.site-header nav {
  align-items: center;
  display: flex;
  gap: 6px;
}

.site-header nav a,
.logout-form button {
  border-radius: 6px;
  padding: 7px 9px;
}

.site-header nav a:hover,
.logout-form button:hover {
  background: #eef5f8;
  text-decoration: none;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.logout-form button:hover {
  color: var(--accent-dark);
}

main {
  padding: 0 max(18px, calc((100vw - 1180px) / 2)) 48px;
}

.site-footer {
  border-top: 1px solid rgba(217, 225, 234, 0.86);
  color: var(--muted);
  display: flex;
  justify-content: center;
  padding: 18px max(18px, calc((100vw - 1180px) / 2)) 26px;
}

.site-footer a {
  color: var(--muted);
}

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

.video-library {
  padding-top: 32px;
}

.video-detail {
  margin: 0 auto;
  max-width: 900px;
  padding-top: 34px;
}

.video-detail .video-card {
  box-shadow: var(--shadow);
}

.video-detail h1 {
  font-size: 28px;
  line-height: 1.15;
  margin: 0 0 10px;
}

.about-page {
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  padding-top: 54px;
}

.about-intro {
  border-left: 4px solid var(--accent);
  padding-left: 20px;
}

.about-intro h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
  margin: 0 0 16px;
}

.about-intro p,
.about-copy p {
  color: var(--muted);
  font-size: 18px;
  margin: 0;
}

.about-copy {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  padding: 24px;
}

.primary-link {
  align-self: start;
  background: var(--accent);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  justify-self: start;
  padding: 10px 14px;
}

.primary-link:hover {
  background: var(--accent-dark);
  color: #fff;
  text-decoration: none;
}

.video-toolbar {
  align-items: center;
  display: flex;
  justify-content: flex-end;
  padding-top: 24px;
}

.video-toolbar label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  width: min(100%, 380px);
}

.video-toolbar input,
.list-search input,
.readonly-input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}

.video-card {
  background: var(--panel);
  border: 1px solid rgba(217, 225, 234, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.video-card::before {
  background: var(--accent);
  content: "";
  height: 3px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 1;
}

.video-card:nth-child(3n + 2)::before {
  background: var(--gold);
}

.video-card:nth-child(3n)::before {
  background: #2d7c58;
}

.player-frame {
  background: #0e141b;
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid #16232d;
}

.player-frame video {
  display: block;
  height: 100%;
  width: 100%;
}

.video-meta {
  padding: 17px 18px 18px;
}

.video-meta h2 {
  font-size: 20px;
  line-height: 1.2;
  margin: 0 0 8px;
}

.video-meta p {
  color: var(--muted);
  margin: 0 0 12px;
}

.uploader-byline {
  font-size: 14px;
}

.duration {
  background: #eef5f8;
  border: 1px solid #d3e4eb;
  border-radius: 6px;
  color: var(--accent-dark);
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  padding: 3px 8px;
}

.wiki-links {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 13px;
}

.wiki-links a {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 0;
}

.wiki-links a:hover {
  color: var(--accent-dark);
}

.wiki-suggestions {
  display: grid;
  gap: 8px;
  margin: -6px 0 16px;
}

.wiki-suggestions strong {
  color: var(--muted);
  font-size: 14px;
}

.wiki-suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wiki-suggestion-list button {
  background: #eef5f8;
  border: 1px solid #c5dbe5;
  border-radius: 999px;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
}

.wiki-suggestion-list button:hover {
  background: #dceff6;
}

.admin-layout {
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 680px) minmax(220px, 1fr);
  padding-top: 36px;
}

.account-forms {
  display: grid;
  gap: 18px;
}

.profile-page {
  display: grid;
  gap: 26px;
  padding-top: 42px;
}

.profile-header {
  border-left: 4px solid var(--accent);
  padding-left: 18px;
}

.profile-header h1 {
  font-size: 34px;
  line-height: 1.05;
  margin: 0 0 8px;
}

.profile-header p {
  color: var(--muted);
  font-size: 18px;
  margin: 0;
}

.admin-wide {
  grid-template-columns: minmax(0, 420px) minmax(240px, 1fr) minmax(280px, 1.2fr) minmax(220px, 1fr);
}

.admin-console {
  display: grid;
  gap: 22px;
  padding-top: 34px;
}

.console-header {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.console-header h1 {
  font-size: 34px;
  line-height: 1;
  margin: 0 0 8px;
}

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

.console-grid {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(260px, 0.75fr) minmax(280px, 1fr) minmax(300px, 1.1fr);
}

.console-panel {
  min-width: 0;
}

.video-library-panel {
  grid-column: 1 / -1;
}

.admin-alert {
  background: #e7f5ee;
  border: 1px solid #b9e0ca;
  border-radius: 8px;
  color: #21543a;
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
  justify-content: space-between;
  padding: 12px 14px;
}

.admin-alert.warning {
  background: #fff6df;
  border-color: #efd18a;
  color: #6f4b09;
}

.auth-panel {
  display: grid;
  min-height: calc(100vh - 90px);
  place-items: start center;
  padding-top: 56px;
}

.login-form {
  width: min(100%, 420px);
}

.upload-form,
.existing-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.upload-form h1,
.existing-list h2 {
  font-size: 24px;
  margin: 0 0 18px;
}

.upload-form h2 {
  font-size: 18px;
  margin: 0 0 14px;
}

.upload-form label {
  color: var(--muted);
  display: grid;
  gap: 7px;
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 16px;
}

.label-with-help {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.help-tooltip {
  align-items: center;
  background: #eef5f8;
  border: 1px solid #c5dbe5;
  border-radius: 999px;
  color: var(--accent-dark);
  cursor: help;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 18px;
  justify-content: center;
  line-height: 1;
  width: 18px;
}

.upload-form input,
.upload-form textarea,
.upload-form select {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}

.upload-form button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 11px 16px;
}

.upload-form button:hover {
  background: var(--accent-dark);
}

.upload-studio-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.upload-only-layout {
  margin: 0 auto;
  max-width: 860px;
  padding-top: 36px;
}

.upload-studio {
  display: grid;
  gap: 16px;
  padding: 0;
}

.upload-studio > h1,
.upload-studio > .notice,
.studio-section,
.publish-bar {
  margin-left: 22px;
  margin-right: 22px;
}

.upload-studio > h1 {
  margin-top: 22px;
}

.studio-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.studio-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.publish-bar {
  align-items: center;
  background: #f7fafb;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  margin: 0;
  padding: 16px 22px;
}

.notice {
  background: #e7f5ee;
  border: 1px solid #b9e0ca;
  border-radius: 6px;
  color: #21543a;
  margin: 0 0 16px;
  padding: 10px 12px;
}

.notice.error {
  background: #fbebea;
  border-color: #efc3be;
  color: #7a2d26;
}

.existing-list {
  align-self: start;
  display: grid;
  gap: 10px;
}

.list-search {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  margin-bottom: 4px;
}

.user-row {
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.request-row {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 2px;
  padding: 9px 0;
}

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

.request-row p {
  color: var(--muted);
  margin: 5px 0 0;
}

.status-pill {
  align-self: start;
  border: 1px solid #c5dbe5;
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  justify-self: start;
  padding: 2px 8px;
  text-transform: uppercase;
}

.status-pill.approved {
  background: #e7f5ee;
  border-color: #b9e0ca;
  color: #21543a;
}

.status-pill.denied {
  background: #fbebea;
  border-color: #efc3be;
  color: #7a2d26;
}

.request-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.request-actions input,
.request-actions select {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 8px 9px;
  width: 100%;
}

.request-actions button,
.managed-video button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 8px 10px;
}

.request-actions.compact {
  margin-top: 4px;
}

.hidden-field {
  height: 1px;
  left: -10000px;
  overflow: hidden;
  position: absolute;
  top: auto;
  width: 1px;
}

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

.thumbnail-tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 18px 0;
  padding: 14px;
}

.field-note {
  color: var(--muted);
  margin: 0 0 12px;
}

.thumbnail-preview {
  background: #101820;
  border-radius: 6px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 160px;
  min-height: 120px;
  overflow: hidden;
}

.thumbnail-preview video,
.thumbnail-preview img {
  aspect-ratio: 16 / 9;
  background: #101820;
  display: block;
  object-fit: contain;
  width: 100%;
}

.thumbnail-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.thumbnail-slider {
  margin-top: 12px;
}

.thumbnail-slider input[type="range"] {
  padding: 0;
}

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

.file-inline {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 650;
}

.managed-video {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding: 10px 0;
}

.managed-video form {
  display: grid;
  gap: 7px;
}

.managed-video input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 8px 9px;
  width: 100%;
}

.managed-video .danger-button,
.request-actions.compact button {
  background: #a64038;
}

.managed-video .danger-button:hover,
.request-actions.compact button:hover {
  background: #7a2d26;
}

.admin-video-card {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-columns: 220px minmax(0, 1fr);
  padding: 18px 0;
}

.admin-video-thumb {
  align-self: start;
  background: #101820;
  border-radius: 8px;
  display: block;
  overflow: hidden;
}

.admin-video-thumb img {
  aspect-ratio: 16 / 9;
  display: block;
  object-fit: cover;
  width: 100%;
}

.admin-video-editor {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.admin-video-title-row {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.admin-video-title-row h3 {
  font-size: 20px;
  line-height: 1.2;
  margin: 0 0 3px;
}

.admin-video-title-row span,
.video-edit-actions span {
  color: var(--muted);
  font-size: 13px;
}

.video-edit-form {
  display: grid;
  gap: 12px;
}

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

.video-edit-form label,
.delete-confirmation label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

.video-edit-form input,
.video-edit-form textarea,
.delete-confirmation input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 8px 9px;
  width: 100%;
}

.video-edit-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.video-edit-actions button,
.delete-confirmation button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 9px 12px;
}

.admin-readonly-meta {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.admin-readonly-meta summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 800;
}

.admin-readonly-meta dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.admin-readonly-meta dl div {
  display: grid;
  gap: 4px;
  grid-template-columns: 110px minmax(0, 1fr);
}

.admin-readonly-meta dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-readonly-meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.delete-confirmation details,
details.delete-confirmation {
  background: #fbebea;
  border: 1px solid #efc3be;
  border-radius: 8px;
  padding: 10px 12px;
}

.delete-confirmation summary {
  color: #7a2d26;
  cursor: pointer;
  font-weight: 800;
}

.delete-confirmation p {
  color: #7a2d26;
  margin: 10px 0;
}

.delete-confirmation label {
  margin-top: 10px;
}

.delete-confirmation .checkbox-label {
  align-items: center;
  display: flex;
}

.delete-confirmation input[type="checkbox"] {
  width: auto;
}

.delete-confirmation .danger-button {
  background: #a64038;
  margin-top: 12px;
}

.readonly-input {
  font-size: 13px;
}

.totp-qr {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  justify-content: center;
  margin-bottom: 16px;
  padding: 16px;
}

.totp-qr img {
  display: block;
  height: min(220px, 62vw);
  width: min(220px, 62vw);
}

@media (max-width: 720px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

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

  .console-header {
    align-items: start;
    display: grid;
  }

  .console-grid {
    grid-template-columns: 1fr;
  }

  .about-page {
    grid-template-columns: 1fr;
    padding-top: 36px;
  }

  .admin-alert {
    display: grid;
  }

  .thumbnail-preview {
    grid-template-columns: 1fr;
  }

  .admin-video-card,
  .video-edit-grid {
    grid-template-columns: 1fr;
  }

  .video-edit-actions {
    align-items: start;
    display: grid;
  }

  .admin-readonly-meta dl div {
    grid-template-columns: 1fr;
  }
}
