:root {
  color-scheme: dark;
  --bg: #02050a;
  --surface: #0a0f14;
  --surface-2: #111820;
  --surface-3: #1a222b;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f7f7f2;
  --muted: #aab3bd;
  --soft: #717c87;
  --accent: #ff5a54;
  --cyan: #28dcc8;
  --gold: #e8c45d;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.48);
  --nav-height: 72px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.player-open,
body.gallery-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

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

img {
  display: block;
  max-width: 100%;
}

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

.hidden {
  display: none !important;
}

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

.app-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) minmax(240px, 420px);
  align-items: center;
  gap: 18px;
  min-height: var(--nav-height);
  padding: 12px 38px;
  background: rgba(8, 12, 17, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-weight: 900;
  font-size: 1.05rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
}

.nav-tabs {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.nav-tab {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  font-weight: 800;
}

.nav-tab:hover,
.nav-tab.active {
  background: rgba(255, 255, 255, 0.11);
  color: var(--text);
}

.nav-search {
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 8, 12, 0.78);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(40, 220, 200, 0.12);
}

.upload-progress {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.83rem;
}

.progress-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 160ms ease;
}

.main {
  min-width: 0;
  padding: 0 38px 54px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  min-height: clamp(420px, 25vw, 560px);
  margin: calc(var(--nav-height) * -1) -38px 26px;
  padding: calc(var(--nav-height) + 72px) 38px 42px;
  display: flex;
  align-items: flex-end;
  background-position: center;
  background-size: cover;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-content {
  width: min(760px, 100%);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero h1 {
  margin-bottom: 14px;
  font-size: clamp(2.5rem, 6vw, 5.7rem);
  line-height: 0.95;
  letter-spacing: 0;
  text-wrap: balance;
}

.hero-copy {
  width: min(650px, 100%);
  margin-bottom: 18px;
  color: #e4e7e8;
  font-size: clamp(1rem, 1.45vw, 1.22rem);
  line-height: 1.55;
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 22px;
}

.meta-pills span,
.tag-row span,
.card-tags span {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #eef1f2;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.meta-pills.compact {
  margin-bottom: 0;
}

.hero-actions,
.detail-actions,
.rating-row,
.media-actions,
.crop-actions,
.player-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.round-button,
.icon-button,
.rating-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 15px;
  font-weight: 850;
}

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

.primary-button.large {
  min-width: 152px;
  min-height: 56px;
  padding: 15px 22px;
  font-size: 1.1rem;
}

.secondary-button:hover,
.ghost-button:hover,
.rating-button:hover {
  border-color: var(--cyan);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.08);
}

.ghost-button.compact {
  padding: 7px 10px;
  font-size: 0.78rem;
}

.round-button,
.icon-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  padding: 0;
  background: rgba(255, 255, 255, 0.14);
  font-size: 1.35rem;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 1rem;
}

.rail-section {
  margin: 0 0 34px;
}

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

.section-head.flush {
  margin-bottom: 0;
}

.section-head h2 {
  margin-bottom: 0;
  font-size: 1.34rem;
}

.section-head span {
  color: var(--muted);
  font-weight: 700;
}

.media-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 310px);
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 10px;
  scroll-snap-type: x proximity;
}

.title-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  scroll-snap-align: start;
  transition: transform 160ms ease, border-color 160ms ease;
}

.title-card:hover,
.title-card.active {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.poster {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(120deg, #251516, #132225 54%, #070b11);
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms ease, filter 260ms ease;
}

.poster img.cycling {
  filter: saturate(1.08) contrast(1.04);
  transform: scale(1.03);
}

.poster-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0, 0, 0, 0.62));
}

.engine-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 5px 8px;
  font-size: 0.75rem;
  font-weight: 900;
}

.title-card-body {
  display: grid;
  gap: 6px;
  padding: 10px 2px 0;
}

.title-card-body strong {
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-card-body small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tags {
  display: flex;
  gap: 6px;
  min-height: 25px;
}

.card-tags span {
  background: rgba(40, 220, 200, 0.16);
  color: #c6fffa;
}

.rail-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  padding: 20px;
}

.title-page {
  margin: 0 -38px -54px;
}

.title-page-hero {
  min-height: clamp(520px, 68vh, 780px);
  margin-top: calc(var(--nav-height) * -1);
  padding: calc(var(--nav-height) + 78px) 38px 46px;
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(120deg, #06111d, #111820 46%, #291817);
  background-position: center;
  background-size: cover;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.title-page-content {
  width: min(860px, 100%);
  display: grid;
  gap: 18px;
}

.title-page-content h1 {
  margin-bottom: 0;
  font-size: clamp(3rem, 7vw, 7rem);
  line-height: 0.94;
  letter-spacing: 0;
  text-wrap: balance;
}

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

.title-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 34px;
  padding: 34px 38px 20px;
}

.title-description {
  display: grid;
  gap: 16px;
}

.title-description h2 {
  margin: 0;
  font-size: 1.45rem;
}

.title-description p {
  width: min(850px, 100%);
  margin: 0;
  color: #dce0e2;
  font-size: 1.05rem;
  line-height: 1.6;
}

.title-controls {
  display: grid;
  gap: 16px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 16px;
}

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

label span,
.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rating-button {
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--gold);
}

.rating-button.active {
  border-color: var(--gold);
  background: rgba(232, 196, 93, 0.16);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.detail-gallery:empty {
  display: none;
}

.title-gallery-section {
  padding: 18px 38px 64px;
}

.gallery-tile {
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 0;
}

.gallery-tile:hover {
  border-color: var(--cyan);
}

.gallery-tile img,
.detail-gallery img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
}

.gallery-tile img {
  transition: transform 180ms ease, filter 180ms ease;
}

.gallery-tile:hover img {
  filter: brightness(1.08);
  transform: scale(1.025);
}

.upload-form {
  width: min(880px, 100%);
  margin: 54px auto;
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 15, 20, 0.88);
  padding: 22px;
  box-shadow: var(--shadow);
}

.file-drop {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 16px;
}

.form-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.form-status.subtle {
  font-size: 0.9rem;
}

.editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(0, 0, 0, 0.62);
}

.editor-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: min(560px, 100vw);
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: #080d12;
  box-shadow: var(--shadow);
  padding: 22px;
}

.drawer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.drawer-head h2 {
  margin: 0;
  font-size: 2rem;
}

.editor-form,
.media-editor {
  display: grid;
  gap: 15px;
}

.media-editor {
  margin-top: 28px;
}

.media-actions {
  align-items: stretch;
}

.media-pick {
  flex: 1 1 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 13px;
}

.paste-panel {
  display: grid;
  gap: 10px;
}

.paste-row {
  display: grid;
  grid-template-columns: 1fr;
}

.paste-zone {
  display: grid;
  place-items: center;
  min-height: 118px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.paste-zone:focus {
  border-color: var(--cyan);
  outline: none;
  box-shadow: 0 0 0 3px rgba(40, 220, 200, 0.12);
}

.media-gallery {
  display: grid;
  gap: 12px;
}

.media-gallery.compact {
  gap: 10px;
}

.media-thumb {
  display: grid;
  grid-template-columns: 126px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 10px;
}

.media-thumb.compact {
  grid-template-columns: 96px 1fr;
}

.media-thumb img {
  width: 126px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
}

.media-thumb.empty {
  color: var(--muted);
}

.media-placeholder {
  width: 126px;
  aspect-ratio: 16 / 9;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.media-thumb.compact .media-placeholder {
  width: 96px;
}

.media-placeholder.ready {
  border-style: solid;
  background:
    linear-gradient(135deg, rgba(255, 90, 84, 0.35), rgba(40, 220, 200, 0.22)),
    rgba(255, 255, 255, 0.06);
}

.media-thumb strong {
  display: block;
  margin-bottom: 8px;
}

.media-thumb span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.preview-count {
  color: var(--muted);
  font-weight: 850;
}

.crop-modal,
.rating-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 50;
  width: min(760px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080d12;
  box-shadow: var(--shadow);
  padding: 18px;
}

.crop-modal {
  display: grid;
  gap: 16px;
}

.crop-modal[data-crop-type="banner"] {
  width: min(1120px, calc(100vw - 32px));
}

.crop-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #000;
  cursor: grab;
  touch-action: none;
}

.crop-frame[data-crop-type="banner"] {
  aspect-ratio: 4 / 1;
}

.crop-frame:active {
  cursor: grabbing;
}

.crop-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.18) inset;
}

.crop-frame img {
  position: absolute;
  max-width: none;
  user-select: none;
  transform: translate(-50%, -50%);
}

.crop-actions {
  justify-content: flex-end;
}

.rating-modal {
  z-index: 81;
  width: min(480px, calc(100vw - 32px));
  display: grid;
  gap: 16px;
  text-align: center;
}

.rating-modal h2 {
  margin: 0;
  font-size: 1.55rem;
}

.rating-prompt-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.rating-button.prompt {
  width: 54px;
  height: 54px;
  font-size: 1.1rem;
}

.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #000;
}

.player-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.86);
}

.player-toolbar strong {
  display: block;
  font-size: 1.05rem;
}

.player-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.player-overlay:fullscreen {
  width: 100vw;
  height: 100vh;
  grid-template-rows: minmax(0, 1fr);
}

.player-overlay:fullscreen .player-toolbar {
  display: none;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 92px;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  background: rgba(0, 0, 0, 0.92);
  padding: 72px 26px 24px;
}

.gallery-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
}

.gallery-stage {
  grid-column: 2;
  margin: 0;
  display: grid;
  gap: 12px;
  justify-items: center;
  min-width: 0;
}

.gallery-stage img {
  max-width: min(100%, 1380px);
  max-height: calc(100vh - 190px);
  border-radius: 8px;
  object-fit: contain;
  box-shadow: var(--shadow);
}

.gallery-stage figcaption {
  color: var(--muted);
  font-weight: 800;
}

.gallery-nav {
  width: 58px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 2rem;
  font-weight: 900;
}

.gallery-nav:hover {
  border-color: var(--cyan);
  background: rgba(255, 255, 255, 0.16);
}

.gallery-prev {
  grid-column: 1;
  justify-self: center;
}

.gallery-next {
  grid-column: 3;
  justify-self: center;
}

.gallery-thumbs {
  grid-column: 1 / -1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 126px;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 4px;
  justify-content: center;
}

.gallery-thumb {
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 0;
}

.gallery-thumb.active {
  border-color: var(--cyan);
}

.gallery-thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 70;
  max-width: min(420px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-nav {
    grid-template-columns: auto 1fr;
    gap: 10px 14px;
  }

  .nav-tabs,
  .upload-progress,
  .nav-search {
    grid-column: 1 / -1;
  }

  .main {
    padding: 0 20px 42px;
  }

  .hero {
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
  }

  .title-info {
    grid-template-columns: 1fr;
  }

  .title-page {
    margin-left: -20px;
    margin-right: -20px;
  }

  .title-page-hero,
  .title-info,
  .title-gallery-section {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 640px) {
  :root {
    --nav-height: 64px;
  }

  .app-nav {
    padding: 10px 14px;
  }

  .brand span:last-child {
    display: none;
  }

  .nav-tab {
    padding: 9px 11px;
  }

  .hero {
    min-height: 430px;
    padding-top: 134px;
  }

  .hero h1 {
    font-size: 2.55rem;
  }

  .title-page-content h1 {
    font-size: 2.8rem;
  }

  .media-rail {
    grid-auto-columns: minmax(220px, 78vw);
  }

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

  .upload-form {
    margin: 30px auto;
    padding: 16px;
  }

  .editor-drawer {
    padding: 16px;
  }

  .media-thumb {
    grid-template-columns: 1fr;
  }

  .media-thumb img {
    width: 100%;
  }

  .player-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .gallery-lightbox {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr) auto auto;
    padding: 68px 14px 18px;
  }

  .gallery-stage {
    grid-column: 1 / -1;
  }

  .gallery-stage img {
    max-height: calc(100vh - 230px);
  }

  .gallery-prev,
  .gallery-next {
    grid-column: auto;
    width: 100%;
    height: 52px;
  }

  .gallery-thumbs {
    grid-column: 1 / -1;
    justify-content: start;
  }
}
