:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #eef3f1;
  --ink: #1f2328;
  --muted: #68707d;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-2: #b45309;
  --accent-3: #2563eb;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(32, 39, 55, 0.13);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.09), transparent 36%),
    linear-gradient(315deg, rgba(180, 83, 9, 0.08), transparent 34%),
    var(--bg);
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1500px;
  margin: 0 auto 18px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 2vw, 2.4rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.topbar-actions,
.form-actions,
.utility-section {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}

.admin-panel {
  display: grid;
  gap: 14px;
}

.panel-section {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(31, 35, 40, 0.06);
}

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

.status-pill,
.type-badge,
.version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  color: #0d564f;
  background: #dff3ee;
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.version-badge {
  min-height: 40px;
  border: 1px solid var(--line);
  color: #475467;
  background: rgba(255, 255, 255, 0.76);
}

.screen-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.display-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.screen-stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.screen-stats strong,
.screen-stats span {
  display: block;
}

.screen-stats strong {
  font-size: 1.1rem;
}

.screen-stats span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

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

.field + .field,
.form-grid,
.form-actions {
  margin-top: 12px;
}

.field span,
legend {
  color: #394150;
  font-size: 0.78rem;
  font-weight: 800;
}

fieldset {
  padding: 0;
  border: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 92px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f7;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: #475467;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 800;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

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

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

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

.compact {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 0.82rem;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
  font-size: 1.25rem;
}

.icon-button.wide {
  width: 82px;
  font-size: 0.9rem;
}

.playlist-section {
  max-height: 395px;
  overflow: hidden;
}

.playlist-list {
  display: grid;
  gap: 9px;
  max-height: 315px;
  overflow: auto;
  padding-right: 4px;
}

.playlist-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.playlist-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.playlist-title {
  overflow: hidden;
  margin: 0 0 7px;
  font-size: 0.92rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.playlist-actions {
  display: flex;
  gap: 5px;
}

.playlist-actions button {
  width: 30px;
  min-height: 30px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.upload-field input {
  padding: 8px;
}

.gmail-section {
  display: grid;
  gap: 12px;
}

.gmail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gmail-actions > * {
  flex: 1 1 140px;
}

.gmail-query-card {
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.gmail-query-card span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.gmail-query-card code {
  overflow-wrap: anywhere;
  color: #101828;
}

.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.import-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.player-column {
  position: sticky;
  top: 18px;
}

.fullscreen-gate {
  display: none;
}

.player-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #111827;
  border-radius: 8px;
  background: #05070d;
  box-shadow: var(--shadow);
}

.player-frame:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.player-status,
.lower-third,
.player-controls {
  position: absolute;
  z-index: 4;
}

.player-status {
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  color: #fff;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent);
}

.player-status p {
  margin: 0 0 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.player-status strong {
  display: block;
  max-width: 55vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 850;
}

#currentDate {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
  white-space: nowrap;
}

#currentClock {
  white-space: nowrap;
}

.online-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.16);
}

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: #05070d;
}

.stage img,
.stage video,
.stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.fit-cover {
  object-fit: cover;
}

.fit-contain {
  object-fit: contain;
  background: #05070d;
}

.fit-stretch {
  object-fit: fill;
}

.poster-slide {
  display: grid;
  align-content: center;
  width: 100%;
  height: 100%;
  padding: min(8vw, 88px);
  background:
    linear-gradient(145deg, rgba(15, 118, 110, 0.92), rgba(18, 24, 38, 0.96)),
    radial-gradient(circle at 80% 24%, rgba(245, 158, 11, 0.38), transparent 26%);
}

.poster-slide .poster-kicker {
  margin-bottom: 16px;
  color: #99f6e4;
  font-size: clamp(0.82rem, 1.1vw, 1.1rem);
  font-weight: 850;
  text-transform: uppercase;
}

.poster-slide h3 {
  max-width: 980px;
  margin: 0;
  color: #fff;
  font-size: clamp(2.2rem, 6vw, 6.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.poster-slide p {
  max-width: 760px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(1rem, 1.9vw, 1.65rem);
  line-height: 1.38;
}

.empty-slide,
.blocked-slide {
  display: grid;
  gap: 10px;
  place-items: center;
  width: min(680px, calc(100% - 42px));
  min-height: 280px;
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
}

.empty-slide strong,
.blocked-slide strong {
  font-size: clamp(1.4rem, 3vw, 2.4rem);
}

.empty-slide span,
.blocked-slide span {
  color: rgba(255, 255, 255, 0.7);
}

.mail-slide {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  color: #101828;
  background: #f8fafc;
}

.mail-summary {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 14px 22px;
  color: #fff;
  background: linear-gradient(90deg, #0f766e, #1d4ed8);
}

.mail-summary h3 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 2.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.mail-summary p {
  margin: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(0.82rem, 1.2vw, 1.05rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-summary span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.mail-list-viewport {
  position: relative;
  overflow: hidden;
  min-height: 0;
  padding: 18px 24px;
  --mail-scroll-window: calc(100vh - 130px);
}

.mail-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 100%;
}

.mail-list-viewport:hover .mail-list {
  animation-play-state: paused;
}

.mail-list-scrolling {
  animation: mail-scroll var(--mail-scroll-duration, 45s) linear infinite;
}

.mail-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 11px 13px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 7px 16px rgba(16, 24, 40, 0.07);
}

.mail-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent-2);
  font-weight: 900;
}

.mail-card strong,
.mail-card span {
  display: block;
}

.mail-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-card span {
  margin-top: 3px;
  color: #667085;
  font-size: 0.8rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-time {
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.mail-loading {
  color: #0f766e;
}

@keyframes mail-scroll {
  0%,
  14% {
    transform: translateY(0);
  }
  86%,
  100% {
    transform: translateY(calc(-100% + var(--mail-scroll-window)));
  }
}

.lower-third {
  left: 22px;
  right: 22px;
  bottom: 24px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  pointer-events: none;
}

.lower-third .note {
  max-width: 72%;
  overflow: hidden;
  border-radius: 7px;
  padding: 10px 13px;
  background: rgba(0, 0, 0, 0.5);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-controls {
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  opacity: 0.22;
  transition: opacity 160ms ease;
}

.player-frame:hover .player-controls,
.player-controls:focus-within {
  opacity: 1;
}

.progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  height: 5px;
  background: rgba(255, 255, 255, 0.16);
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f59e0b);
  transition: width 200ms linear;
}

.app-shell.player-only {
  padding: 0;
  background: #05070d;
}

.player-only .topbar,
.player-only .admin-panel {
  display: none;
}

.player-only .workspace {
  display: block;
  width: 100vw;
  max-width: none;
  min-height: 100vh;
  margin: 0;
}

.player-only .player-column {
  position: static;
}

.player-only .player-frame {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.player-only .lower-third {
  display: none;
}

.fullscreen-wanted:not(.is-fullscreen) .fullscreen-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 0;
  color: #fff;
  background: rgba(5, 7, 13, 0.36);
  backdrop-filter: blur(2px);
}

.fullscreen-gate span,
.fullscreen-gate strong {
  display: block;
  padding: 0 18px;
  text-align: center;
}

.fullscreen-gate span {
  align-self: end;
  font-size: clamp(1rem, 2vw, 1.4rem);
  font-weight: 850;
}

.fullscreen-gate strong {
  align-self: start;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  background: rgba(17, 24, 39, 0.94);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .player-column {
    position: static;
    order: -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .form-actions,
  .utility-section {
    width: 100%;
  }

  .topbar-actions > *,
  .form-actions > *,
  .utility-section > * {
    flex: 1 1 auto;
  }

  .screen-stats,
  .form-grid,
  .mail-slide {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .player-status {
    padding: 12px;
  }

  .player-status strong {
    max-width: 62vw;
  }

  .status-right {
    align-items: flex-end;
    flex-direction: column;
    gap: 3px;
  }

  .lower-third {
    left: 12px;
    right: 12px;
    bottom: 18px;
  }

  .mail-summary,
  .mail-list {
    padding: 24px;
  }
}
