:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f0f3f6;
  --ink: #171b22;
  --muted: #637080;
  --line: #dce2e8;
  --accent: #d71920;
  --accent-dark: #a91118;
  --accent-2: #243746;
  --accent-3: #f6b31a;
  --shadow: 0 22px 56px rgba(23, 27, 34, 0.14);
  --soft-shadow: 0 10px 26px rgba(23, 27, 34, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f8fafc 0, var(--bg) 340px),
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px clamp(16px, 4vw, 44px);
  background: #101820;
  border-bottom: 3px solid var(--accent);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  text-decoration: none;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 150px;
  height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(216, 222, 228, 0.9);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(23, 27, 34, 0.1);
}

.brand-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: #fff;
  font-size: 18px;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  font-weight: 700;
}

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

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 21px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  text-decoration: none;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 18px rgba(215, 25, 32, 0.22);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #f9fbfc;
  color: var(--ink);
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.audio-button {
  border-color: rgba(246, 179, 26, 0.72);
  background: rgba(246, 179, 26, 0.2);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(246, 179, 26, 0.12);
}

.danger-button {
  background: #ffe9e5;
  color: var(--accent-dark);
}

.app {
  min-height: calc(100vh - 78px);
}

body.is-player-view .topbar {
  position: fixed;
  right: 0;
  left: 0;
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
  background: rgba(16, 24, 32, 0.88);
}

body.is-player-view .app {
  min-height: 100vh;
}

.portal-shell,
.admin-shell {
  width: min(1260px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 52px;
}

.portal-heading,
.admin-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.portal-heading h1,
.admin-header h1 {
  max-width: 780px;
  margin-bottom: 0;
  font-size: clamp(28px, 3.3vw, 44px);
  line-height: 1.08;
}

.lead {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.projection-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.projection-guide h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.projection-guide p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.access-link-box {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.access-link-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.access-link-box a {
  overflow: hidden;
  color: var(--accent-2);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.channel-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.channel-card:hover {
  transform: translateY(-2px);
  border-color: rgba(215, 25, 32, 0.32);
  box-shadow: var(--shadow);
}

.channel-card__media {
  position: relative;
  aspect-ratio: 21 / 9;
  background: #101820;
}

.channel-card__media video,
.channel-card__media img,
.channel-card__fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.channel-card__fallback {
  background:
    linear-gradient(135deg, rgba(16, 24, 32, 0.96), rgba(215, 25, 32, 0.68));
}

.fallback-logo {
  position: absolute;
  left: 18px;
  bottom: 14px;
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.channel-card__body {
  padding: 16px 18px 18px;
}

.channel-card h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.channel-card p {
  min-height: 44px;
  color: var(--muted);
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff1f1;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.player-shell {
  min-height: 100vh;
  background: #07090c;
}

.screen-stage {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 480px;
  overflow: hidden;
  background: #000;
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.screen-stage video,
.screen-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease;
}

.screen-image {
  display: block;
}

.screen-stage.is-media-ready video:not([hidden]),
.screen-stage.is-media-ready .screen-image:not([hidden]) {
  opacity: 1;
  visibility: visible;
}

.screen-stage video::-webkit-media-controls,
.screen-stage video::-webkit-media-controls-panel,
.screen-stage video::-webkit-media-controls-overlay-play-button,
.screen-stage video::-webkit-media-controls-start-playback-button,
.screen-stage video::-webkit-media-controls-enclosure,
.screen-stage video::-webkit-media-controls-loading-panel,
.screen-stage video::-webkit-media-controls-timeline,
.screen-stage video::-webkit-media-controls-current-time-display,
.screen-stage video::-webkit-media-controls-time-remaining-display {
  display: none !important;
  -webkit-appearance: none;
}

.screen-stage:fullscreen,
.screen-stage:fullscreen *,
.screen-stage:-webkit-full-screen,
.screen-stage:-webkit-full-screen *,
.screen-stage:-ms-fullscreen,
.screen-stage:-ms-fullscreen * {
  cursor: none !important;
  -webkit-tap-highlight-color: transparent;
}

.screen-watermark {
  position: absolute;
  top: clamp(82px, 8vw, 112px);
  right: clamp(18px, 4vw, 54px);
  z-index: 2;
  width: clamp(150px, 18vw, 280px);
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  opacity: 1;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.screen-watermark img {
  display: block;
  width: 100%;
  height: auto;
}

.screen-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}

.screen-empty h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 52px);
}

.screen-overlay {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 28px clamp(18px, 5vw, 54px);
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  user-select: none;
  -webkit-user-select: none;
}

.screen-overlay h1 {
  margin: 0;
  font-size: clamp(28px, 4.2vw, 56px);
}

.screen-kicker,
.screen-status span {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

.screen-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.fullscreen-button {
  min-height: 44px;
  padding: 0 18px;
  border-width: 2px;
  font-size: 14px;
  font-weight: 900;
}

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

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

.channel-list,
.editor-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.channel-list {
  position: sticky;
  top: 88px;
  align-self: start;
  padding: 10px;
}

.channel-row {
  display: grid;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.channel-row strong {
  margin-bottom: 4px;
}

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

.channel-row.is-active {
  background: #101820;
  color: var(--accent-dark);
  box-shadow: inset 3px 0 0 var(--accent);
}

.channel-row.is-active strong {
  color: #fff;
}

.channel-row.is-active span {
  color: rgba(255, 255, 255, 0.68);
}

.editor-panel {
  padding: clamp(18px, 3vw, 26px);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.field.is-wide {
  grid-column: 1 / -1;
}

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

.field input,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.12);
  outline: 0;
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.upload-zone {
  position: relative;
  display: grid;
  gap: 7px;
  margin-top: 16px;
  padding: 22px;
  border: 2px dashed #c8d0da;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.upload-zone::before {
  content: "";
  width: 48px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
}

.upload-zone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.upload-zone strong {
  color: var(--ink);
  font-size: 19px;
}

.upload-zone span {
  line-height: 1.4;
}

.upload-zone.is-dragging {
  border-color: var(--accent);
  background: #fff7f7;
  box-shadow: 0 0 0 4px rgba(215, 25, 32, 0.1);
}

.upload-progress {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.upload-progress__bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e7ed;
}

.upload-progress__bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  transition: width 120ms linear;
}

.upload-progress__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.video-list {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.video-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(23, 27, 34, 0.05);
}

.video-row input[type="hidden"] {
  display: none;
}

.media-info {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.media-info strong,
.media-info span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-info strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.media-info span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.media-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff1f1;
  color: var(--accent-dark);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.media-remove {
  min-height: 36px;
  padding: 0 13px;
  white-space: nowrap;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-top: 18px;
}

.editor-actions__left,
.editor-actions__right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.helper {
  color: var(--muted);
  line-height: 1.45;
}

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

.audit-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.audit-table th,
.audit-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.audit-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.audit-table td:last-child {
  min-width: 260px;
  max-width: 520px;
  overflow-wrap: anywhere;
}

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

.login-card {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.login-logo {
  width: 174px;
  height: 50px;
  margin-bottom: 24px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.08;
}

.login-card .field {
  margin: 22px 0 12px;
}

.login-card .primary-button {
  width: 100%;
  justify-content: center;
}

@media (max-width: 780px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 14px;
  }

  .brand {
    align-items: flex-start;
    min-width: 0;
    flex: 1 1 260px;
  }

  .brand > span:last-child {
    min-width: 0;
  }

  .brand-logo {
    width: 128px;
    height: 40px;
    padding: 7px 10px;
  }

  .screen-watermark {
    top: 92px;
    width: clamp(120px, 36vw, 180px);
  }

  .top-actions {
    margin-left: auto;
  }

  .version-pill {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .portal-heading,
  .admin-header,
  .screen-overlay {
    align-items: stretch;
    flex-direction: column;
  }

  .projection-guide {
    grid-template-columns: 1fr;
  }

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

  .channel-list {
    position: static;
  }

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

  .card-actions {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 560px) {
  .video-row {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .media-remove {
    grid-column: 1 / -1;
    width: 100%;
  }
}
