:root {
  color-scheme: dark;
  --bg: #07090c;
  --panel: #141820;
  --panel-2: #202630;
  --text: #f5f7fa;
  --muted: #9ca7b5;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #31d67b;
  --warn: #ffd166;
  --shadow: 0 20px 64px 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,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.viewer {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  background: #000;
}

.player {
  width: min(100%, calc(100dvh * 9 / 16));
  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;
  z-index: 4;
}

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

.text-button:hover,
.filter:hover,
.secondary:hover {
  border-color: rgba(255, 255, 255, 0.32);
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #041109;
  font-weight: 750;
}

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

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

.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(--warn);
  font-size: 13px;
  font-weight: 750;
}

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

.chips,
.filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 13px;
}

.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: 5;
}

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

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

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

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

.panel-title,
.dialog-title {
  font-size: 18px;
  font-weight: 760;
}

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

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

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

.field.compact {
  padding-top: 16px;
}

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

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

.filters {
  display: grid;
  gap: 10px;
  padding: 16px 18px 12px;
}

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

.filter.active {
  background: rgba(49, 214, 123, 0.16);
  border-color: rgba(49, 214, 123, 0.7);
  color: #e0ffee;
}

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

.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;
}

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

.item.active {
  border-color: rgba(49, 214, 123, 0.68);
  background: rgba(49, 214, 123, 0.1);
}

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

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

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

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

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

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

.upload-dialog {
  max-height: min(760px, calc(100dvh - 36px));
  overflow: auto;
}

.progress-wrap {
  padding: 16px 18px 0;
}

.progress-wrap progress {
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(76px);
  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.92);
  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 {
    display: block;
  }

  .panel {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(88vw, 380px);
    transform: translateX(105%);
    transition: transform 180ms ease;
  }

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

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

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

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