:root {
  --navy: #083884;
  --royal: #0b4fd6;
  --bg: #0b0f1a;
  --surface: #121826;
  --elevated: #1a2337;
  --line: rgba(255, 255, 255, .12);
  --muted: #94a3b8;
  --text: #f8fafc;
  --pending: #b8d2ff;
  --red: #f87171;
  --ok: #69d391;
  --request-outline: #7db0ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  font-family: "Montserrat", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body,
#app {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea,
select { font: inherit; }

button { color: inherit; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid #7db0ff;
  outline-offset: 2px;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.screen {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.center-screen {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 24px;
  background: radial-gradient(circle at 50% 0, #102c5c 0, #0b0f1a 50%);
}

.auth-card,
.alert-card {
  width: min(100%, 390px);
  padding: 28px 22px;
  background: rgba(18, 24, 38, .96);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.alert-card { text-align: center; }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 34px;
}

.alert-card .brand-lockup {
  margin-bottom: 28px;
  text-align: left;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  background: var(--navy);
  border: 1px solid var(--royal);
  border-radius: 12px;
  font-weight: 800;
}

.eyebrow {
  color: #9fc4ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1,
h2,
p { margin: 0; }

h1 {
  font-size: 27px;
  line-height: 1.15;
  letter-spacing: -.03em;
}

h2 { font-size: 18px; }

.muted { color: var(--muted); }

.auth-card .muted {
  margin-top: 10px;
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 22px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  padding: 13px 14px;
  color: var(--text);
  background: #0d1422;
  border: 1px solid var(--line);
  border-radius: 12px;
}

textarea {
  min-height: 116px;
  resize: vertical;
  line-height: 1.5;
}

.primary,
.outline {
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 13px;
  font-weight: 800;
  cursor: pointer;
}

.primary {
  background: var(--royal);
  border: 1px solid #77a4ff;
}

.outline {
  background: transparent;
  border: 1px solid var(--royal);
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.auth-actions,
.alert-actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.alert-card h1 { margin-bottom: 12px; }
.alert-card p { color: var(--muted); line-height: 1.55; }

.topbar {
  z-index: 4;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.top-row,
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-row + .meta-row { margin-top: 7px; }

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  font-weight: 800;
}

.brand .logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 10px;
}

.progress {
  padding: 7px 9px;
  color: var(--muted);
  white-space: nowrap;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 11px;
}

.progress strong { color: var(--text); }

.icon-btn {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.meta-row {
  color: var(--muted);
  font-size: 11px;
}

.channels {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.channels::-webkit-scrollbar {
  display: none;
}

.channel {
  padding: 4px 6px;
  color: #c7dbff;
  white-space: nowrap;
  background: rgba(11, 79, 214, .22);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
}

.meta-date {
  flex: 0 0 auto;
  white-space: nowrap;
}

.meta-right {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
}

.version,
.status {
  padding: 4px 6px;
  border-radius: 6px;
  font-weight: 800;
}

.version {
  color: #b9d2ff;
  background: rgba(11, 79, 214, .2);
  border: 1px solid rgba(11, 79, 214, .55);
}

.status {
  border: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.status.pending,
.status.changes_requested { color: var(--pending); border-color: #4c78be; }
.status.approved { color: var(--ok); border-color: #28794a; }
.status.rejected { color: var(--red); border-color: #963f3f; }

.flag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
  padding: 8px 12px;
  color: #fff;
  background: #3c4656;
  border-radius: 10px;
  font-size: 12px;
}

.flag.old {
  background: transparent;
  border: 1px solid #fff;
}

.feed {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.post-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.post-card.active {
  opacity: 1;
  pointer-events: auto;
}

.artwork-stack {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  flex: 1 1 auto;
}

.artwork-area {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
  background: var(--bg);
  touch-action: none;
}

.gesture-surface {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  touch-action: none;
}

.artwork,
.artwork-video {
  display: block;
  grid-area: 1 / 1;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.artwork { box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.artwork-video { background: #000; }

.play-button {
  position: absolute;
  z-index: 4;
  width: 64px;
  height: 64px;
  background: rgba(8, 56, 132, .88);
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
}

.artwork-area.playing .play-button {
  opacity: 0;
  pointer-events: none;
}

.scrub {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 4px;
  touch-action: none;
}

.scrub-track {
  width: 100%;
  height: 7px;
  background: #465166;
  border-radius: 5px;
}

.scrub-fill {
  width: 0;
  height: 100%;
  background: var(--royal);
  border-radius: 5px;
}

.carousel-rail {
  padding: 7px 14px;
  background: #0d1322;
  border-top: 1px solid var(--line);
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
}

.position-pill {
  padding: 4px 9px;
  color: #c4d9ff;
  background: rgba(11, 79, 214, .22);
  border: 1px solid rgba(11, 79, 214, .6);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
}

.segments {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 7px;
}

.segment {
  min-height: 44px;
  padding: 4px;
  color: var(--muted);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  font-size: 10px;
}

.segment.active {
  color: #fff;
  background: var(--royal);
  border-color: #8eb4ff;
}

.revision-list {
  display: grid;
  flex: 0 0 auto;
  gap: 9px;
  max-height: 150px;
  padding: 10px 14px;
  overflow: auto;
  background: #0d1322;
}

.revision-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.revision-card summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.revision-card p {
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.dock {
  z-index: 4;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.dock-tools,
.dock-decisions {
  display: grid;
  gap: 8px;
}

.dock-tools { grid-template-columns: repeat(3, 1fr); }
.dock-tools.reel-tools { grid-template-columns: repeat(4, 1fr); }
.dock-decisions { grid-template-columns: .7fr 1.3fr 1.5fr; margin-top: 8px; }

.dock button {
  min-height: 50px;
  padding: 8px;
  font-size: 11px;
}

.utility,
.decision {
  cursor: pointer;
  border-radius: 10px;
}

.utility {
  background: transparent;
  border: 1px solid var(--line);
}

.decision { font-weight: 800; }
.decision.request { color: var(--request-outline); background: transparent; border: 1px solid var(--request-outline); }
.decision.approve { background: var(--royal); border: 1px solid #77a4ff; }
.decision.reject { background: #481d25; border: 1px solid #b84b59; }

.message {
  position: static;
  right: 14px;
  margin: 8px 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  background: #17243b;
  border: 1px solid #5f86c9;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 12px;
}

.message.error { border-color: #c55a65; }
.message button { flex: 0 0 auto; min-height: 44px; padding: 8px 14px; }

.toast {
  position: static;
  margin: 8px 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  pointer-events: none;
  background: #17243b;
  border: 1px solid #5e86cc;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
}

.toast button {
  min-height: 44px;
  padding: 9px 14px;
  pointer-events: auto;
  background: var(--royal);
  border: 1px solid #86adff;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 800;
}

.sheet-backdrop,
.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, .7);
}

.sheet-backdrop {
  display: grid;
  align-items: end;
}

.sheet {
  max-height: 82dvh;
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: var(--elevated);
  border-radius: 22px 22px 0 0;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 14px;
  background: #64748b;
  border-radius: 4px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.close {
  width: 48px;
  height: 48px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 22px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 16px 0 10px;
  overflow: auto;
}

.tab {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.tab.active { color: #fff; background: var(--royal); }

.secondary,
.request-outline {
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 13px;
  font-weight: 800;
  cursor: pointer;
}

.secondary {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}

.request-outline {
  color: var(--request-outline);
  background: transparent;
  border: 1px solid var(--request-outline);
}

.status-stack { min-width: 0; }
.logout-button { width: 100%; margin-top: 12px; }
.alerts-enable-button { width: 100%; margin-top: 12px; }
.alerts-status { min-height: 44px; margin-top: 12px; display: grid; place-items: center; color: var(--muted); }

.caption-content {
  max-height: 38dvh;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  background: #0d1422;
  border: 1px solid var(--line);
  border-radius: 12px;
  line-height: 1.55;
}

.anchor-toggle,
.attach-row {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.anchor-toggle button,
.attach-row label,
.link-button {
  flex: 1;
  min-height: 48px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.anchor-toggle button.active { background: var(--navy); border-color: var(--royal); }

.attach-row label,
.link-button {
  display: grid;
  place-items: center;
  font-size: 11px;
}

.attach-row input { display: none; }
.ref-list { min-height: 20px; color: var(--muted); font-size: 11px; }
.filter-grid { display: grid; gap: 10px; margin: 16px 0; }
.filter-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.viewer {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
}

.viewer-stage {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  transform-origin: center;
  touch-action: none;
}

.viewer-stage img,
.viewer-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.viewer-close {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  z-index: 2;
  background: rgba(0, 0, 0, .45);
}

@media (min-width: 700px) {
  .app {
    max-width: 520px;
    margin: auto;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
