:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #eef2f6;
  --text: #171a1f;
  --muted: #67707f;
  --line: #dce2ea;
  --brand: #e33d3d;
  --brand-dark: #b6252a;
  --focus: #0f7a78;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(247, 248, 250, 0.88);
  backdrop-filter: blur(10px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 22px 26px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 46px rgba(18, 24, 33, 0.16);
}

.loading-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 650;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #dce2ea;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: max-content minmax(180px, 560px);
  gap: 24px;
  align-items: center;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 760;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
}

.search input {
  width: 100%;
  min-height: 42px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
}

.search input:focus {
  border-color: var(--focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(15, 122, 120, 0.15);
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 56px;
}

.watch-section {
  margin-bottom: 32px;
}

.player-shell {
  overflow: hidden;
  color: white;
  background: #06080b;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(18, 24, 33, 0.22);
  outline: none;
}

.player-shell:focus-visible {
  box-shadow:
    0 18px 60px rgba(18, 24, 33, 0.22),
    0 0 0 3px rgba(15, 122, 120, 0.32);
}

.player-stage {
  position: relative;
  display: grid;
  min-height: 220px;
  background: #06080b;
}

.player-stage video {
  display: block;
  width: 100%;
  max-height: 72vh;
  aspect-ratio: 16 / 9;
  background: #06080b;
  cursor: pointer;
}

.plyr {
  width: 100%;
  background: #000;
  --plyr-video-controls-background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.78));
}

.plyr--video {
  border-radius: 8px 8px 0 0;
}

.plyr__video-wrapper {
  aspect-ratio: 16 / 9;
}

.plyr:fullscreen,
.plyr:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

.plyr:fullscreen .plyr__video-wrapper,
.plyr:-webkit-full-screen .plyr__video-wrapper {
  width: 100vw;
  height: 100vh;
  max-height: none;
  aspect-ratio: auto;
}

.plyr:fullscreen video,
.plyr:-webkit-full-screen video {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
}

.plyr:fullscreen .plyr__controls,
.plyr:-webkit-full-screen .plyr__controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
}

.plyr__control--overlaid {
  width: clamp(58px, 9vw, 82px);
  height: clamp(58px, 9vw, 82px);
  background: rgba(227, 61, 61, 0.92);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

.plyr__controls {
  gap: 4px;
}

.plyr__progress input[type="range"],
.plyr__volume input[type="range"] {
  min-height: 20px;
}

.center-play {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: clamp(62px, 8vw, 86px);
  height: clamp(62px, 8vw, 86px);
  padding: 0;
  background: rgba(6, 8, 11, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.center-play::before {
  content: "";
  margin-left: 5px;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-left: 24px solid white;
}

.player-shell.is-playing .center-play {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.94);
}

.player-shell.uses-native-controls .center-play,
.player-shell.uses-native-controls .player-controls {
  display: none;
}

.player-shell.uses-native-controls video {
  cursor: default;
}

.player-message {
  position: absolute;
  inset: auto 16px 16px;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 12px;
  color: white;
  background: rgba(6, 8, 11, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  font-size: 0.92rem;
}

.player-controls {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  background: linear-gradient(180deg, #151b23, #090d12);
}

.control-row,
.control-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.control-row {
  justify-content: space-between;
}

.right-controls {
  justify-content: flex-end;
}

.icon-button,
.speed-select {
  min-width: 38px;
  height: 38px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.icon-button:hover,
.speed-select:hover {
  background: rgba(255, 255, 255, 0.15);
}

.icon-button:focus-visible,
.speed-select:focus-visible,
.seek-bar:focus-visible,
.volume-bar:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.76);
  outline-offset: 2px;
}

.text-icon {
  min-width: 48px;
  padding: 0 8px;
  font-size: 0.82rem;
  font-weight: 740;
}

.play-icon {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid white;
}

.player-shell.is-playing .play-icon {
  width: 14px;
  height: 16px;
  margin-left: 0;
  border: 0;
  border-right: 4px solid white;
  border-left: 4px solid white;
}

.volume-icon {
  position: relative;
  width: 18px;
  height: 14px;
  border-right: 10px solid white;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}

.volume-icon::before {
  content: "";
  position: absolute;
  left: -6px;
  top: -5px;
  width: 7px;
  height: 10px;
  background: white;
  border-radius: 2px 0 0 2px;
}

.player-shell.is-muted .volume-icon::after {
  content: "";
  position: absolute;
  left: 11px;
  top: -10px;
  width: 3px;
  height: 28px;
  background: #ff6b6b;
  border-radius: 99px;
  transform: rotate(42deg);
}

.fullscreen-icon {
  width: 18px;
  height: 18px;
  border: 2px solid white;
  border-radius: 3px;
}

.speed-select {
  width: 74px;
  padding: 0 8px;
  color: white;
  background-color: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.speed-select option {
  color: #171a1f;
}

.time-text {
  min-width: 112px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.seek-bar,
.volume-bar {
  --progress: 0%;
  height: 6px;
  background:
    linear-gradient(90deg, var(--brand) var(--progress), rgba(255, 255, 255, 0.24) 0);
  border-radius: 99px;
  cursor: pointer;
  appearance: none;
}

.seek-bar {
  width: 100%;
}

.volume-bar {
  width: 96px;
}

.seek-bar::-webkit-slider-thumb,
.volume-bar::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  background: white;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  appearance: none;
}

.seek-bar::-moz-range-thumb,
.volume-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: white;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.player-shell.is-fullscreen {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

.player-shell.is-fullscreen .player-stage {
  min-height: 0;
}

.player-shell.is-fullscreen video {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.watch-meta {
  padding: 16px 0 4px;
}

.watch-meta h1 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.2;
}

.watch-meta p,
.library-head p,
.card-copy p,
.empty-state {
  color: var(--muted);
}

.watch-meta p,
.library-head p {
  margin: 0;
}

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

.library-head h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.breadcrumb button {
  padding: 0;
  color: var(--focus);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.breadcrumb button:disabled {
  color: var(--muted);
  cursor: default;
}

.breadcrumb-separator {
  color: var(--muted);
}

.library-actions {
  display: flex;
  gap: 8px;
}

#refreshButton,
#backButton {
  min-height: 40px;
  padding: 0 14px;
  color: white;
  background: var(--text);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

#backButton {
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

#refreshButton:disabled,
#backButton:disabled {
  cursor: default;
  opacity: 0.64;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px 18px;
}

.item-card {
  min-width: 0;
}

.thumb-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  color: white;
  background: linear-gradient(135deg, #1f2933, #566270);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.item-card[data-kind="folder"] .thumb-button {
  background: linear-gradient(135deg, #c88712, #f5cc3d);
}

.item-card[data-kind="document"] .thumb-button {
  background: linear-gradient(135deg, #264c7a, #48a0b5);
}

.item-card[data-kind="image"] .thumb-button {
  background: #dce2ea;
}

.item-card[data-kind="file"] .thumb-button {
  background: linear-gradient(135deg, #4a5568, #9aa5b1);
}

.item-card[data-kind="video"] .thumb-button::after {
  content: "";
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.58);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.item-card[data-kind="video"] .thumb-button::before {
  content: "";
  position: absolute;
  z-index: 1;
  margin-left: 4px;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 18px solid white;
}

.thumb-button:hover .thumb-image {
  transform: scale(1.04);
}

.thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.thumb-fallback {
  z-index: 1;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
  letter-spacing: 0;
}

.item-card[data-kind="folder"] .thumb-fallback,
.item-card[data-kind="document"] .thumb-fallback,
.item-card[data-kind="file"] .thumb-fallback {
  display: grid;
  place-items: center;
  width: 74px;
  height: 52px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  font-size: 0.88rem;
}

.card-copy {
  padding-top: 10px;
}

.card-copy h3 {
  display: -webkit-box;
  min-height: 2.75rem;
  margin: 0 0 5px;
  overflow: hidden;
  font-size: 0.98rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-copy p {
  margin: 0;
  font-size: 0.9rem;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 32px 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  body {
    background: #f8fafc;
  }

  .loading-overlay.is-inline {
    align-items: start;
    padding-top: 132px;
    background: rgba(247, 248, 250, 0.58);
  }

  .loading-card {
    width: min(240px, calc(100vw - 48px));
    padding: 18px 20px;
  }

  .spinner {
    width: 30px;
    height: 30px;
    border-width: 3px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: 0;
    padding: 12px 16px;
  }

  main {
    padding: 14px 0 44px;
  }

  .brand {
    font-size: 1.08rem;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .search input {
    min-height: 40px;
    padding: 0 14px;
    font-size: 0.96rem;
  }

  .watch-section {
    margin-bottom: 24px;
  }

  .player-shell {
    border-radius: 0;
    box-shadow: none;
  }

  .player-shell.uses-native-controls {
    background: #000;
  }

  .player-stage {
    min-height: auto;
  }

  .player-stage video {
    max-height: none;
    min-height: 210px;
  }

  .plyr--video {
    border-radius: 0;
  }

  .plyr__video-wrapper {
    min-height: 210px;
  }

  .plyr__controls {
    display: grid;
    grid-template-columns: 44px 44px 44px minmax(0, 1fr) 44px 44px;
    gap: 8px;
    padding: 10px;
    background: #070b11;
  }

  .plyr__controls .plyr__progress__container {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
  }

  .plyr__controls .plyr__time--current {
    grid-column: 1 / 4;
    grid-row: 3;
    justify-self: start;
    padding-left: 4px;
  }

  .plyr__controls .plyr__time--duration {
    grid-column: 4 / -1;
    grid-row: 3;
    justify-self: end;
    padding-right: 4px;
  }

  .plyr__controls .plyr__volume {
    grid-column: 4 / -1;
    grid-row: 2;
    min-width: 0;
    max-width: none;
  }

  .plyr__control {
    min-width: 44px;
    min-height: 44px;
  }

  .plyr__menu__container {
    max-width: min(280px, calc(100vw - 28px));
  }

  .plyr:fullscreen .plyr__video-wrapper,
  .plyr:-webkit-full-screen .plyr__video-wrapper,
  .plyr:fullscreen video,
  .plyr:-webkit-full-screen video {
    width: 100vw;
    height: 100vh;
    min-height: 0;
  }

  .center-play {
    width: 64px;
    height: 64px;
  }

  .player-controls {
    gap: 12px;
    padding: 12px;
    background: #070b11;
  }

  .seek-bar {
    height: 10px;
  }

  .control-row {
    align-items: stretch;
    flex-direction: column;
  }

  .control-group,
  .right-controls {
    display: grid;
    gap: 10px;
  }

  .primary-controls {
    grid-template-columns: 52px 52px 52px 52px 1fr;
  }

  .secondary-controls {
    grid-template-columns: minmax(96px, 1fr) 64px 52px;
  }

  .icon-button,
  .speed-select {
    min-width: 0;
    width: 100%;
    height: 48px;
    border-radius: 8px;
  }

  .text-icon {
    min-width: 0;
    padding: 0;
    font-size: 0.9rem;
  }

  .volume-bar {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    height: 10px;
  }

  .time-text {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    padding-top: 2px;
    font-size: 0.95rem;
    text-align: center;
  }

  .speed-select {
    padding: 0 10px;
    text-align: center;
  }

  .watch-meta {
    padding: 14px 16px 4px;
  }

  .library-head,
  .video-grid {
    padding-right: 14px;
    padding-left: 14px;
  }

  .library-head {
    gap: 12px;
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 14px;
  }

  .library-head h2 {
    margin-bottom: 2px;
    font-size: 1.28rem;
  }

  .library-head p {
    font-size: 0.94rem;
    line-height: 1.35;
  }

  .breadcrumb {
    gap: 5px;
    margin-top: 6px;
    font-size: 0.92rem;
  }

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

  #refreshButton,
  #backButton {
    width: 100%;
    min-height: 42px;
  }

  .video-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .thumb-button {
    aspect-ratio: 2.15 / 1;
    border-radius: 8px;
  }

  .item-card[data-kind="folder"] .thumb-button,
  .item-card[data-kind="document"] .thumb-button,
  .item-card[data-kind="file"] .thumb-button {
    aspect-ratio: 2.6 / 1;
  }

  .item-card[data-kind="folder"] .thumb-fallback,
  .item-card[data-kind="document"] .thumb-fallback,
  .item-card[data-kind="file"] .thumb-fallback {
    width: 64px;
    height: 42px;
    font-size: 0.78rem;
  }

  .card-copy {
    padding-top: 8px;
  }

  .card-copy h3 {
    min-height: 0;
    margin-bottom: 3px;
    font-size: 0.98rem;
    line-height: 1.28;
  }

  .card-copy p {
    font-size: 0.86rem;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  main {
    padding-top: 0;
  }

  .topbar {
    position: static;
  }

  .player-shell {
    border-radius: 0;
  }

  .player-stage video {
    max-height: calc(100vh - 112px);
    object-fit: contain;
  }

  .plyr__video-wrapper {
    max-height: calc(100vh - 92px);
  }

  .plyr__controls {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 6px 8px;
  }

  .plyr__controls .plyr__progress__container {
    min-width: 120px;
  }

  .plyr__controls .plyr__volume {
    max-width: 90px;
  }

  .player-controls {
    padding: 8px 10px 10px;
  }

  .control-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .control-group {
    display: flex;
    flex-wrap: nowrap;
  }

  .right-controls {
    display: flex;
  }

  .icon-button,
  .speed-select {
    width: auto;
    min-width: 42px;
    height: 42px;
  }

  .volume-bar {
    width: 90px;
    min-width: 70px;
  }

  .time-text {
    width: auto;
    min-width: 106px;
    text-align: left;
  }
}

/* Video.js player skin */
.video-js.vjs-theme-medvid {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  color: #fff;
  background: #000;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.video-js.vjs-theme-medvid .vjs-tech {
  object-fit: contain;
}

.video-js.vjs-theme-medvid .vjs-big-play-button {
  top: 50%;
  left: 50%;
  width: 76px;
  height: 76px;
  margin: -38px 0 0 -38px;
  background: rgba(227, 61, 61, 0.94);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

.video-js.vjs-theme-medvid:hover .vjs-big-play-button,
.video-js.vjs-theme-medvid .vjs-big-play-button:focus {
  background: var(--brand-dark);
}

.video-js.vjs-theme-medvid .vjs-control-bar {
  min-height: 48px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.86));
}

.video-js.vjs-theme-medvid .vjs-control {
  min-width: 42px;
}

.video-js.vjs-theme-medvid .vjs-progress-control {
  min-width: 120px;
}

.video-js.vjs-theme-medvid .vjs-play-progress,
.video-js.vjs-theme-medvid .vjs-volume-level {
  background-color: var(--brand);
}

.video-js.vjs-theme-medvid .vjs-slider {
  border-radius: 999px;
}

.video-js.vjs-theme-medvid .vjs-menu-button-popup .vjs-menu {
  width: 9em;
}

.video-js.vjs-theme-medvid.vjs-fullscreen,
.video-js.vjs-theme-medvid.vjs-fullscreen .vjs-tech {
  width: 100vw !important;
  height: 100vh !important;
  max-height: none !important;
}

.video-js.vjs-theme-medvid.vjs-fullscreen {
  aspect-ratio: auto;
}

@media (max-width: 640px) {
  .video-js.vjs-theme-medvid {
    border-radius: 0;
  }

  .video-js.vjs-theme-medvid .vjs-big-play-button {
    width: 68px;
    height: 68px;
    margin: -34px 0 0 -34px;
  }

  .video-js.vjs-theme-medvid .vjs-control-bar {
    min-height: 58px;
    padding: 0 4px;
  }

  .video-js.vjs-theme-medvid .vjs-control {
    min-width: 44px;
  }

  .video-js.vjs-theme-medvid .vjs-progress-control {
    position: absolute;
    right: 8px;
    bottom: 54px;
    left: 8px;
    width: auto;
    height: 28px;
  }

  .video-js.vjs-theme-medvid .vjs-volume-panel {
    display: none;
  }

  .video-js.vjs-theme-medvid .vjs-time-control {
    padding-right: 4px;
    padding-left: 4px;
    font-size: 0.82rem;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .video-js.vjs-theme-medvid.vjs-fullscreen .vjs-control-bar {
    min-height: 46px;
  }

  .video-js.vjs-theme-medvid.vjs-fullscreen .vjs-progress-control {
    position: static;
    min-width: 160px;
    height: auto;
  }
}
