:root {
  color-scheme: light;
  --bg: #f5f4f0;
  --panel: #ffffff;
  --text: #222426;
  --muted: #6f7478;
  --line: #dedbd2;
  --teal: #0f9f94;
  --teal-dark: #08776f;
  --coral: #d95d39;
  --ink: #20242b;
  --shadow: 0 14px 34px rgba(27, 31, 35, .08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
}

input[type="color"] {
  padding: 4px;
}

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

.primary {
  background: var(--teal);
  color: #fff;
  padding: 0 18px;
}

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

.ghost,
.danger-ghost,
.player-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  font-weight: 700;
}

.danger-ghost {
  color: var(--coral);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-row.compact {
  margin-bottom: 30px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}

.brand-row h1,
.brand-row p,
.topbar h2,
.topbar p,
.panel-heading h3,
.panel-heading p {
  margin: 0;
}

.brand-row h1 {
  font-size: 26px;
}

.brand-row p,
.eyebrow {
  color: var(--muted);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
}

.stack {
  display: grid;
  gap: 16px;
}

.form-error,
.form-note {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.is-error {
  color: var(--coral);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar nav a {
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  color: var(--teal-dark);
  background: #e7f4ef;
}

.sidebar .ghost {
  margin-top: auto;
}

.workspace {
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 28px;
}

.topbar,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 {
  font-size: 30px;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

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

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h3 {
  font-size: 20px;
}

.file-drop {
  min-height: 170px;
  display: grid;
  place-items: center;
  border: 2px dashed #bbb5a7;
  border-radius: 8px;
  background: #faf9f6;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

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

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.check-row.small {
  align-self: end;
  min-height: 42px;
}

.upload-progress {
  width: 100%;
  height: 8px;
  margin-top: 15px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6e1d7;
}

.upload-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width .24s ease;
}

.ads-list {
  display: grid;
  gap: 14px;
}

.ad-card {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdfa;
}

.thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 8px;
  background: #050505;
}

.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.thumb span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #fff;
  background: rgba(0, 0, 0, .58);
  font-size: 12px;
  font-weight: 800;
}

.ad-fields {
  display: grid;
  gap: 12px;
}

.ad-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(88px, 1fr));
  gap: 10px;
}

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

.ad-actions,
.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.url-box input {
  font-family: Consolas, Monaco, monospace;
}

.settings-grid {
  max-width: 780px;
}

.settings-actions {
  margin-top: 16px;
}

.player-body {
  min-height: 100vh;
  overflow: hidden;
  background: #000;
  touch-action: none;
  user-select: none;
}

.player-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.player-body.force-portrait .player-stage {
  inset: auto;
  top: 50%;
  left: 50%;
  width: 100vh;
  height: 100vw;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center;
}

.stage-item {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .55s ease;
}

.stage-item.is-current {
  opacity: 1;
}

.stage-item.is-old {
  opacity: 0;
}

.main-media,
.stage-backdrop {
  display: block;
  max-width: none;
  background: #000;
}

.stage-backdrop {
  position: absolute;
  inset: -5%;
  width: 110%;
  height: 110%;
  object-fit: cover;
  filter: blur(36px);
  opacity: .58;
}

.fit-cover .main-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fit-contain .main-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.fit-stretch .main-media {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.rotate-90 .main-media,
.rotate-270 .main-media {
  width: 100vh;
  height: 100vw;
}

.rotate-90 .main-media {
  transform: rotate(90deg);
}

.rotate-180 .main-media {
  transform: rotate(180deg);
}

.rotate-270 .main-media {
  transform: rotate(270deg);
}

.player-message {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 24px;
  color: #fff;
  text-align: center;
  background: #050505;
}

.player-message h1,
.player-message p {
  margin: 0;
}

.player-message h1 {
  font-size: clamp(42px, 12vw, 112px);
}

.player-message p {
  color: #c9c9c9;
  font-size: 20px;
}

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

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

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .ad-card,
  .ad-grid {
    grid-template-columns: 1fr;
  }

  .thumb {
    width: min(180px, 100%);
  }
}
