:root {
  color-scheme: dark;
  --ink: #f7f9fb;
  --muted: #9ba8b6;
  --line: rgba(255, 255, 255, 0.16);
  --glass: rgba(15, 20, 28, 0.68);
  --glass-strong: rgba(15, 20, 28, 0.92);
  --bar: rgba(13, 18, 26, 0.72);
  --bar-strong: rgba(10, 14, 20, 0.9);
  --control: rgba(255, 255, 255, 0.1);
  --control-strong: rgba(255, 255, 255, 0.16);
  --accent: #ff8a1c;
  --accent-2: #2dd4bf;
  --app-bg:
    radial-gradient(circle at 12% 10%, rgba(255, 138, 28, 0.18), transparent 28rem),
    radial-gradient(circle at 88% 0%, rgba(125, 211, 252, 0.15), transparent 26rem),
    radial-gradient(circle at 70% 92%, rgba(45, 212, 191, 0.14), transparent 30rem),
    linear-gradient(145deg, #06080d 0%, #101824 50%, #070b10 100%);
  --video-bg: #000;
  --menu-text: #f7f9fb;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.44);
  --caption-size: 20px;
  --caption-bg: rgba(0, 0, 0, 0.45);
  --caption-color: #ffffff;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #10151d;
  --muted: #607080;
  --line: rgba(15, 23, 42, 0.14);
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --bar: rgba(255, 255, 255, 0.66);
  --bar-strong: rgba(255, 255, 255, 0.9);
  --control: rgba(15, 23, 42, 0.07);
  --control-strong: rgba(15, 23, 42, 0.12);
  --accent: #f97316;
  --accent-2: #0f9f8f;
  --app-bg:
    radial-gradient(circle at 10% 8%, rgba(249, 115, 22, 0.18), transparent 26rem),
    radial-gradient(circle at 90% 4%, rgba(14, 165, 233, 0.18), transparent 28rem),
    radial-gradient(circle at 70% 92%, rgba(15, 159, 143, 0.13), transparent 30rem),
    linear-gradient(145deg, #eef5f8 0%, #dfeaf0 48%, #f8fbfc 100%);
  --video-bg: #050607;
  --menu-text: #10151d;
  --shadow: 0 20px 70px rgba(39, 54, 72, 0.22);
}

:root[data-theme="midnight"] {
  --ink: #f7fbff;
  --muted: #93a6b9;
  --line: rgba(125, 211, 252, 0.18);
  --glass: rgba(6, 10, 18, 0.72);
  --glass-strong: rgba(6, 10, 18, 0.94);
  --bar: rgba(5, 9, 16, 0.78);
  --bar-strong: rgba(5, 9, 16, 0.94);
  --control: rgba(125, 211, 252, 0.08);
  --control-strong: rgba(125, 211, 252, 0.15);
  --accent: #fb923c;
  --accent-2: #38bdf8;
  --app-bg:
    radial-gradient(circle at 18% 12%, rgba(56, 189, 248, 0.17), transparent 30rem),
    radial-gradient(circle at 90% 85%, rgba(251, 146, 60, 0.12), transparent 28rem),
    linear-gradient(145deg, #020617 0%, #07111f 52%, #030712 100%);
  --video-bg: #000;
  --menu-text: #f7fbff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--app-bg);
}

button,
input,
select {
  font: inherit;
}

button,
label,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
label:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.app-shell {
  height: 100svh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 38%);
}

.window-bar,
.menu-bar,
.control-deck,
.drawer {
  backdrop-filter: blur(22px) saturate(1.25);
}

.window-bar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 10px;
  background:
    linear-gradient(90deg, rgba(255, 138, 28, 0.09), rgba(45, 212, 191, 0.06), transparent),
    linear-gradient(180deg, var(--bar-strong), var(--glass));
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  display: block;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.26);
}

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

h1 {
  font-size: 14px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  max-width: min(70vw, 980px);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-select {
  width: 128px;
  height: 32px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}

.menu-bar {
  min-height: 30px;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 6px;
  background:
    linear-gradient(90deg, rgba(255, 138, 28, 0.055), rgba(45, 212, 191, 0.045), transparent),
    linear-gradient(180deg, var(--glass), var(--bar));
  color: var(--menu-text);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.menu-group {
  position: relative;
}

.menu-button {
  height: 30px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.menu-button:hover,
.menu-group:focus-within .menu-button {
  background: var(--control-strong);
}

.menu-popover {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 184px;
  display: none;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: var(--glass-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.menu-group:hover .menu-popover,
.menu-group:focus-within .menu-popover {
  display: grid;
  gap: 4px;
}

.menu-item {
  min-height: 34px;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.compact-help {
  min-width: 150px;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.player-stage {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.video-frame {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  outline: 0 solid transparent;
  touch-action: manipulation;
}

.video-frame.dragging {
  outline: 3px solid var(--accent-2);
  outline-offset: -3px;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  transform-origin: center;
}

video::cue {
  color: var(--caption-color);
  font-size: var(--caption-size);
  background: var(--caption-bg);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.85);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 15px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(255, 138, 28, 0.1), transparent 18rem),
    var(--video-bg);
}

.empty-state.hidden,
.hidden {
  display: none;
}

.empty-state h2 {
  font-size: clamp(28px, 5vw, 58px);
  line-height: 1;
}

.empty-state p {
  color: var(--muted);
}

.empty-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.cone {
  width: 78px;
  height: 92px;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 5px;
  filter: drop-shadow(0 16px 26px rgba(255, 138, 28, 0.34));
}

.cone span {
  display: block;
  background: var(--accent);
  border: 5px solid #f8fbff;
  border-left-width: 0;
  border-right-width: 0;
  transform: perspective(70px) rotateX(16deg);
}

.cone span:nth-child(1) {
  width: 32px;
  height: 18px;
}

.cone span:nth-child(2) {
  width: 52px;
  height: 22px;
}

.cone span:nth-child(3) {
  width: 78px;
  height: 28px;
}

.control-deck {
  padding: 7px 10px 8px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--glass), var(--bar-strong));
  box-shadow: 0 -16px 45px rgba(0, 0, 0, 0.24);
}

.timeline-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.seek,
.volume,
.tool-section input[type="range"] {
  accent-color: var(--accent);
}

.seek,
.volume {
  width: 100%;
}

.controls-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.control-cluster {
  display: flex;
  align-items: center;
  gap: 7px;
}

.utility-cluster {
  min-width: 0;
}

.primary-action,
.secondary-action,
.icon-button,
.play-button,
.text-button,
select,
.theme-select,
.search-input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--control);
}

.primary-action,
.secondary-action,
.icon-button,
.play-button,
.text-button {
  cursor: pointer;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  font-weight: 800;
}

.primary-action {
  border-color: transparent;
  color: #12151a;
  background: linear-gradient(180deg, #ffd08a, var(--accent));
}

.secondary-action {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
}

.icon-button {
  width: 48px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  font-size: 12px;
  font-weight: 850;
}

.open-chip {
  width: 58px;
}

.play-button {
  min-width: 76px;
  height: 42px;
  padding: 0 16px;
  border-color: transparent;
  color: #071111;
  background: linear-gradient(180deg, #6fffee, var(--accent-2));
  font-weight: 950;
}

.text-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
}

.icon-button:hover,
.text-button:hover,
.secondary-action:hover,
select:hover {
  color: var(--ink);
  background: var(--control-strong);
}

.volume {
  width: 116px;
}

select {
  height: 34px;
  padding: 0 8px;
}

select option {
  color: #101419;
  background: #f8fbfc;
}

input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 29;
  display: none;
  background: rgba(0, 0, 0, 0.42);
}

.drawer-scrim.active {
  display: block;
}

.drawer {
  position: fixed;
  top: 92px;
  right: 14px;
  bottom: 88px;
  z-index: 30;
  width: min(390px, calc(100vw - 28px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 24px));
  transition: transform 180ms ease;
}

.tools-drawer {
  grid-template-rows: auto minmax(0, 1fr);
  overflow-y: auto;
}

.drawer.active {
  transform: translateX(0);
}

.drawer-heading,
.mini-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.drawer-heading h2 {
  font-size: 18px;
}

.drawer-heading p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-input {
  width: calc(100% - 20px);
  margin: 10px;
  padding: 0 12px;
  outline: none;
}

.playlist,
.bookmarks {
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow: auto;
}

.playlist li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}

.playlist li:hover,
.playlist li.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.track-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.track-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.bookmark-panel {
  border-top: 1px solid var(--line);
  min-height: 124px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.mini-heading {
  padding: 9px 12px;
}

.mini-heading h3,
.tool-section h3 {
  font-size: 14px;
}

.bookmark-panel li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  color: var(--muted);
}

.bookmark-panel li button {
  min-width: 72px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.bookmark-panel li span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.tool-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.tool-section label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tool-section input[type="range"],
.tool-section select {
  width: 100%;
}

.compact-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-tools h3 {
  grid-column: 1 / -1;
}

.toast,
.gesture-hud {
  position: absolute;
  left: 50%;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 14, 20, 0.82);
  color: var(--ink);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.toast {
  bottom: 18px;
  max-width: min(92%, 520px);
  transform: translateX(-50%) translateY(10px);
  padding: 10px 14px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.gesture-hud {
  top: 50%;
  min-width: 96px;
  transform: translate(-50%, -50%) scale(0.94);
  padding: 14px 18px;
  border-radius: 8px;
  text-align: center;
  font-weight: 900;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
}

.gesture-hud.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.mobile-only {
  display: none;
}

.mobile-rotate {
  display: none;
}

.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: 820px), (hover: none) and (pointer: coarse) {
  body {
    overflow: hidden;
  }

  .app-shell {
    min-height: 100svh;
    height: 100svh;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr);
  }

  .window-bar {
    min-height: 46px;
    padding: 5px 8px;
    background: linear-gradient(180deg, var(--bar-strong), var(--glass));
    color: var(--ink);
  }

  .menu-toggle {
    width: 44px;
    height: 34px;
    flex: 0 0 auto;
  }

  .brand p {
    max-width: 44vw;
    color: var(--muted);
  }

  .menu-bar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 120;
    width: min(290px, 84vw);
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 6px;
    padding: 12px;
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
    border-right: 1px solid var(--line);
    border-radius: 0 14px 14px 0;
    background: linear-gradient(180deg, var(--bar-strong), var(--glass));
    color: var(--ink);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
  }

  .menu-bar::-webkit-scrollbar {
    display: none;
  }

  .menu-bar.active {
    transform: translateX(0);
  }

  .menu-group {
    position: relative;
    flex: 0 0 auto;
  }

  .menu-button {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 10px;
    white-space: nowrap;
    line-height: 1.1;
    font-size: 13px;
    text-align: left;
  }

  .menu-button {
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: var(--control);
  }

  .menu-popover {
    position: static;
    width: 100%;
    max-height: none;
    margin: 5px 0 8px;
    box-shadow: none;
    overflow: auto;
  }

  .menu-group.open .menu-popover {
    display: grid;
    gap: 4px;
  }

  .menu-group:focus-within .menu-popover,
  .menu-group:hover .menu-popover {
    display: none;
  }

  .menu-group.open:focus-within .menu-popover,
  .menu-group.open:hover .menu-popover {
    display: grid;
    gap: 4px;
  }

  .mobile-only {
    display: inline-grid;
  }

  .mobile-rotate {
    display: inline-grid;
  }

  .theme-select {
    width: 108px;
    height: 32px;
    min-height: 32px;
    font-size: 12px;
  }

  .player-stage {
    grid-row: 2;
    min-height: 0;
    height: 100%;
    position: relative;
    display: block;
  }

  .video-frame {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .control-deck {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 8px;
    transition: opacity 160ms ease;
  }

  .player-stage.controls-hidden .control-deck {
    opacity: 0;
    pointer-events: none;
  }

  .controls-grid {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .transport-cluster {
    display: grid;
    grid-template-columns: 1.25fr repeat(5, 1fr);
  }

  .utility-cluster {
    display: grid;
    grid-template-columns: 58px 44px minmax(72px, 1fr) 66px 54px 54px;
  }

  .transport-cluster .icon-button,
  .transport-cluster .play-button,
  .utility-cluster .icon-button,
  .utility-cluster select,
  .utility-cluster .open-chip {
    width: 100%;
    min-width: 0;
    padding-left: 4px;
    padding-right: 4px;
  }

  .mobile-rotate,
  #fullBtn {
    min-width: 50px;
  }

  #fullBtn {
    display: none;
  }

  .volume {
    width: 100%;
  }

  .drawer {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 12px;
    z-index: 110;
    width: auto;
    max-height: min(58svh, 560px);
    border-radius: 12px 12px 0 0;
    visibility: hidden;
    transform: translateY(calc(100% + 24px));
  }

  .drawer.active {
    visibility: visible;
    transform: translateY(0);
  }

  .drawer-scrim {
    z-index: 100;
  }

  .drawer-close {
    position: relative;
    z-index: 2;
    pointer-events: auto;
  }
}

@media (max-width: 500px) {
  .brand-logo {
    width: 28px;
    height: 28px;
  }

  h1 {
    font-size: 12px;
  }

  .brand p {
    max-width: 34vw;
  }

  .header-actions {
    gap: 5px;
  }

  .theme-select {
    width: 88px;
    padding: 0 5px;
  }

  .menu-button {
    height: 38px;
    font-size: 12px;
  }

  .transport-cluster {
    grid-template-columns: 1.35fr repeat(5, 0.9fr);
    gap: 5px;
  }

  .utility-cluster {
    grid-template-columns: 50px 38px minmax(54px, 1fr) 56px 48px 48px;
    gap: 5px;
  }

  .icon-button {
    height: 36px;
    font-size: 10px;
  }

  .play-button {
    height: 40px;
    padding: 0 8px;
  }

  .menu-button {
    min-width: 68px;
    padding: 0 8px;
  }

  .compact-tools {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .theme-select {
    display: none;
  }
}
