:root {
  color-scheme: dark;
  --bg: #08090b;
  --panel: #15181d;
  --panel-2: #1f2329;
  --text: #f3f5f7;
  --muted: #9da7b3;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #39d98a;
  --accent-2: #ffd166;
  --danger: #ff6b6b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  height: 100dvh;
  overflow: hidden;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.55)),
    #050608;
}

.player {
  width: min(100%, calc(100dvh * 9 / 16));
  height: 100dvh;
  max-height: 100dvh;
  object-fit: contain;
  background: #000;
}

.topbar {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 5;
}

.tool-button,
.primary-button,
.secondary-button,
.filter-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(20, 24, 30, 0.72);
  min-height: 38px;
  padding: 0 14px;
  backdrop-filter: blur(16px);
}

.tool-button:hover,
.secondary-button:hover,
.filter-chip:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #04110b;
  font-weight: 700;
}

.secondary-button {
  background: var(--panel-2);
}

.video-info {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  right: 92px;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 4;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.72);
}

.category-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.42);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
}

.video-info h1 {
  max-width: 980px;
  margin: 10px 0 10px;
  font-size: 21px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.keyword-row,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.action-rail {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(36px, env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
  z-index: 6;
}

.round-button,
.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(18, 22, 28, 0.72);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.round-button:hover,
.icon-button:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.drawer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 10;
}

.drawer-head,
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-title,
.editor-title {
  font-size: 18px;
  font-weight: 750;
}

.drawer-subtitle,
.editor-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 22px;
}

.search-box,
.editor-field {
  display: grid;
  gap: 8px;
  padding: 16px 18px 0;
  color: var(--muted);
  font-size: 13px;
}

.search-box input,
.editor-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #0e1116;
  color: var(--text);
  padding: 0 12px;
}

.search-box input:focus,
.editor-field input:focus {
  border-color: var(--accent);
}

.filter-block {
  padding: 16px 18px 12px;
  display: grid;
  gap: 10px;
}

.filter-chip {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.filter-chip.active {
  background: rgba(57, 217, 138, 0.16);
  border-color: rgba(57, 217, 138, 0.7);
  color: #dfffee;
}

.video-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 10px 16px;
}

.video-item {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 12px 10px;
}

.video-item:hover {
  background: var(--panel-2);
}

.video-item.active {
  border-color: rgba(57, 217, 138, 0.68);
  background: rgba(57, 217, 138, 0.1);
}

.video-item-title {
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.video-item-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.editor-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
  z-index: 20;
}

.editor-backdrop[hidden] {
  display: none;
}

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

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(80px);
  min-height: 38px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 20, 26, 0.9);
  color: var(--text);
  opacity: 0;
  transition: 160ms ease;
  z-index: 30;
  overflow-wrap: anywhere;
}

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

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(88vw, 380px);
    transform: translateX(105%);
    transition: transform 180ms ease;
  }

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

  .player {
    width: 100vw;
    height: 100dvh;
  }

  .video-info {
    right: 82px;
  }
}

@media (min-width: 901px) {
  .drawer.closed {
    display: none;
  }

  .app-shell.drawer-closed {
    grid-template-columns: minmax(0, 1fr);
  }
}
