:root {
  --bg: #0f1117;
  --panel: rgba(22, 26, 35, 0.92);
  --panel-strong: rgba(28, 33, 44, 0.98);
  --line: rgba(154, 169, 197, 0.14);
  --text: #edf1f8;
  --muted: #97a3b8;
  --accent: #f07a3b;
  --accent-soft: #ffb387;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

@font-face {
  font-family: "DINAltLocal";
  src: local("DIN Alternate Bold"), local("DIN Alternate");
  font-weight: 700;
  font-style: normal;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(240, 122, 59, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(75, 126, 255, 0.12), transparent 28%),
    linear-gradient(140deg, #0b0d12, #121722 52%, #171d29);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

html.is-dialog-scroll-locked,
body.is-dialog-scroll-locked {
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 12px 16px;
  background: rgba(14, 18, 26, 0.82);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.brand h1,
.content-header h2 {
  margin: 0;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-weight: 700;
}

.brand-kicker,
.section-kicker {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.brand-kicker {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.branch-badge {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(240, 122, 59, 0.9);
}

.brand p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

#stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: "DINAltLocal", "DIN Alternate", "DIN Condensed", "DIN 2014", "DIN Pro", "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.stat-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-icon {
  width: 18px;
  height: 14px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.stat-separator {
  color: rgba(151, 163, 184, 0.52);
  font-weight: 500;
}

.brand .brand-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  margin-top: 6px;
  font-family: "DINAltLocal", "DIN Alternate", "DIN Condensed", "DIN 2014", "DIN Pro", "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: clamp(24px, 2.55vw, 29px);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.9;
  text-transform: none;
  color: #f8fbff;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  transform: scaleX(0.88);
  transform-origin: left center;
}

.brand-logo-main,
.brand-logo-sub,
.brand-logo-dot {
  display: inline-block;
}

.brand-logo-main,
.brand-logo-sub {
  color: var(--accent-soft);
}

.brand-logo-main {
  color: #f8fbff;
}

.brand-logo-dot {
  margin-left: 0.05em;
  margin-right: 0.08em;
  font-size: 0.9em;
  line-height: 1;
  color: #67cfff;
}

.brand-logo-sub {
  margin-left: 0;
  letter-spacing: 0;
  color: #67cfff;
}

.sidebar-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 18px 0 14px;
}

.tree,
.content {
  min-width: 0;
}

.tree {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 2px;
}

.sidebar-status {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(151, 163, 184, 0.14);
  border-radius: 12px;
  background: rgba(17, 22, 31, 0.72);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tree-button,
.refresh-button,
.sort,
#sort,
#close-player,
.player-nav-button,
.player-toggle,
.scroll-top-button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
}

.tree-button,
.refresh-button {
  width: 100%;
  padding: 10px 10px;
  text-align: left;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.tree-button.active,
.tree-button:hover,
.refresh-button:hover {
  background: linear-gradient(135deg, rgba(43, 50, 66, 0.98), rgba(61, 36, 26, 0.94));
}

.tree-node {
  margin-bottom: 6px;
}

.tree-node-child {
  position: relative;
}

.tree-node-child::before {
  content: "";
  position: absolute;
  left: 18px;
  top: -6px;
  bottom: -6px;
  width: 1px;
  background: rgba(151, 163, 184, 0.16);
}

.tree-node .tree-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tree-node .tree-button span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.tree-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tree-label span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-toggle {
  flex: 0 0 auto;
  width: 1em;
  color: var(--muted);
  text-align: center;
}

.tree-toggle-empty {
  opacity: 0.35;
}

.tree-icon {
  flex: 0 0 auto;
  width: 1.8em;
  color: var(--accent-soft);
}

.content {
  padding: 24px;
}

.toolbar,
.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toolbar {
  margin-bottom: 22px;
}

.search-panel {
  display: inline-flex;
  align-items: center;
  overflow: visible;
  max-width: 54px;
  border: 1px solid rgba(144, 160, 188, 0.12);
  border-radius: 16px;
  background: rgba(21, 26, 36, 0.9);
  box-shadow: var(--shadow);
  transition: max-width 0.2s ease, border-color 0.2s ease;
}

.search-panel.is-expanded {
  max-width: min(560px, 100%);
  border-color: rgba(103, 207, 255, 0.24);
}

.toolbar-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 52px;
  height: 50px;
  border: 0;
  background: transparent;
  color: rgba(225, 232, 243, 0.72);
  cursor: pointer;
}

.toolbar-icon-button:hover,
.toolbar-icon-button.is-active {
  background: rgba(255, 255, 255, 0.06);
  color: #eef3fb;
}

.toolbar-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-actions > .select-tooltip {
  order: 2;
}

.compare-toolbar-cluster {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  order: 1;
  padding: 4px;
  border: 1px solid rgba(144, 160, 188, 0.12);
  border-radius: 16px;
  background: rgba(21, 26, 36, 0.9);
  box-shadow: var(--shadow);
}

.compare-set-panel {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  order: 1;
  max-width: 0;
  opacity: 0;
  transition: max-width 0.2s ease, opacity 0.16s ease;
}

.compare-set-panel.is-expanded {
  max-width: 360px;
  opacity: 1;
  overflow: visible;
}

.compare-set-toggle {
  order: 2;
  color: rgba(218, 226, 238, 0.68);
}

.compare-toolbar-trigger.is-primary {
  order: 3;
}

.compare-set-toggle.is-active {
  background: rgba(255, 255, 255, 0.06);
  color: #eef3fb;
}

.compare-toolbar-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 48px;
  height: 44px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: rgba(225, 232, 243, 0.82);
  font: inherit;
  cursor: pointer;
}

.compare-toolbar-trigger + .compare-toolbar-trigger {
  border-left: 1px solid rgba(144, 160, 188, 0.12);
}

.compare-set-select {
  min-width: 142px;
  height: 44px;
  padding: 0 34px 0 14px;
  border: 0;
  border-right: 1px solid rgba(144, 160, 188, 0.12);
  border-radius: 12px 0 0 12px;
  background: rgba(10, 15, 22, 0.72);
  color: rgba(236, 242, 250, 0.9);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.compare-set-tool {
  min-width: 44px;
  padding: 0 12px;
  color: rgba(218, 226, 238, 0.68);
  font-size: 13px;
  font-weight: 800;
}

.compare-toolbar-trigger:hover {
  background: rgba(255, 255, 255, 0.06);
}

.compare-toolbar-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.compare-toolbar-trigger.is-primary {
  min-width: 142px;
}

.compare-toolbar-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar-tooltip,
.select-tooltip {
  position: relative;
}

.toolbar-tooltip::before,
.toolbar-tooltip::after,
.select-tooltip::before,
.select-tooltip::after {
  position: absolute;
  left: 50%;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.toolbar-tooltip::before,
.select-tooltip::before {
  content: attr(data-tooltip);
  top: calc(100% + 12px);
  transform: translate(-50%, -6px);
  padding: 6px 9px;
  border: 1px solid rgba(144, 160, 188, 0.18);
  border-radius: 10px;
  background: rgba(12, 16, 24, 0.92);
  color: #eef3fb;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.toolbar-tooltip::after,
.select-tooltip::after {
  content: "";
  top: calc(100% + 6px);
  transform: translate(-50%, -6px);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid rgba(12, 16, 24, 0.92);
}

.toolbar-tooltip:hover::before,
.toolbar-tooltip:hover::after,
.toolbar-tooltip:focus-visible::before,
.toolbar-tooltip:focus-visible::after,
.select-tooltip:hover::before,
.select-tooltip:hover::after,
.select-tooltip:focus-within::before,
.select-tooltip:focus-within::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.compare-toolbar-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.compare-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(103, 207, 255, 0.16);
  color: #dff7ff;
  font-family: "DINAltLocal", "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.search,
#sort {
  background: var(--panel-strong);
  border: 1px solid rgba(144, 160, 188, 0.14);
  border-radius: 14px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  color: var(--text);
}

.search {
  width: 0;
  min-width: 0;
  padding-right: 0;
  padding-left: 0;
  border: 0;
  opacity: 0;
  box-shadow: none;
  transition: width 0.2s ease, padding 0.2s ease, opacity 0.12s ease;
}

.search-panel.is-expanded .search {
  width: min(460px, calc(100vw - 220px));
  padding-right: 15px;
  padding-left: 0;
  opacity: 1;
}

#sort {
  min-width: 132px;
  height: 52px;
  padding: 0 44px 0 18px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(27, 33, 45, 0.98), rgba(20, 24, 34, 0.98)),
    var(--panel-strong);
  border-color: rgba(144, 160, 188, 0.12);
  color: #eef3fb;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(225, 232, 243, 0.82) 50%),
    linear-gradient(135deg, rgba(225, 232, 243, 0.82) 50%, transparent 50%),
    linear-gradient(180deg, rgba(27, 33, 45, 0.98), rgba(20, 24, 34, 0.98));
  background-position:
    calc(100% - 22px) calc(50% - 3px),
    calc(100% - 16px) calc(50% - 3px),
    0 0;
  background-size:
    6px 6px,
    6px 6px,
    100% 100%;
  background-repeat: no-repeat;
}

#sort:hover {
  border-color: rgba(144, 160, 188, 0.2);
}

.search::placeholder {
  color: var(--muted);
}

.scroll-top-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  padding: 11px 14px;
  background: linear-gradient(135deg, rgba(43, 50, 66, 0.96), rgba(61, 36, 26, 0.94));
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.scroll-top-button.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top-button:hover {
  background: linear-gradient(135deg, rgba(58, 67, 86, 0.98), rgba(84, 41, 29, 0.96));
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.card {
  display: flex;
  flex-direction: column;
  overflow: visible;
  border: 1px solid rgba(135, 151, 180, 0.12);
  border-radius: 20px;
  background: rgba(20, 24, 33, 0.9);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.42);
}

.thumb,
.thumb-shell,
.thumb-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.thumb-shell {
  position: relative;
  overflow: visible;
  border-radius: 20px 20px 0 0;
}

.thumb {
  display: block;
  height: 100%;
  object-fit: cover;
  border-radius: 20px 20px 0 0;
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(240, 122, 59, 0.86), rgba(90, 107, 170, 0.72)),
    linear-gradient(180deg, #232a39, #151922);
  color: #fff7f1;
  font-size: 36px;
  border-radius: 20px 20px 0 0;
}

.card-body {
  padding: 14px 14px 16px;
}

.favorite-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(151, 163, 184, 0.2);
  border-radius: 999px;
  background: rgba(25, 30, 41, 0.34);
  color: var(--muted);
  width: 40px;
  height: 36px;
  padding: 0;
  backdrop-filter: blur(10px);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.compare-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(151, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(25, 30, 41, 0.34);
  color: rgba(219, 226, 238, 0.72);
  width: 40px;
  height: 36px;
  padding: 0;
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.compare-button-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.compare-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.compare-button.is-active {
  border-color: rgba(103, 207, 255, 0.48);
  background: rgba(103, 207, 255, 0.2);
  color: #ffffff;
}

.favorite-button:hover {
  background: rgba(240, 122, 59, 0.12);
}

.favorite-button.is-active {
  border-color: rgba(240, 122, 59, 0.38);
  background: rgba(240, 122, 59, 0.16);
  color: #ffd8bf;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 14px 0;
}

.card-footer-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 0;
  background: none;
}

.finder-button-overlay {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
}

.card-title {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.card-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.finder-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(240, 122, 59, 0.32);
  border-radius: 999px;
  background: rgba(25, 30, 41, 0.34);
  color: var(--text);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.finder-button-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.finder-button:hover {
  background: rgba(240, 122, 59, 0.16);
}

.thumb-action-button {
  position: relative;
}

.thumb-action-button::before,
.thumb-action-button::after {
  position: absolute;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.thumb-action-button::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 12px);
  transform: translate(-50%, 6px);
  padding: 6px 9px;
  border: 1px solid rgba(144, 160, 188, 0.18);
  border-radius: 10px;
  background: rgba(12, 16, 24, 0.92);
  color: #eef3fb;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.thumb-action-button::after {
  content: "";
  bottom: calc(100% + 6px);
  transform: translate(-50%, 6px);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(12, 16, 24, 0.92);
}

.thumb-action-button:hover::before,
.thumb-action-button:hover::after,
.thumb-action-button:focus-visible::before,
.thumb-action-button:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.player-dialog {
  display: none;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  max-width: none;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 0;
  background: rgba(12, 15, 22, 0.96);
  color: #f5f7fb;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.player-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-dialog {
  display: none;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  min-height: 100dvh;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: rgba(8, 11, 16, 1);
  color: #f5f7fb;
  box-shadow: none;
}

.compare-dialog[open] {
  display: flex;
  flex-direction: column;
}

.compare-dialog::backdrop {
  background: rgba(5, 8, 13, 1);
}

.player-dialog::backdrop {
  background: rgba(5, 8, 13, 0.7);
}

.compare-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  max-width: 100%;
  overflow: visible;
  padding: 16px 18px 10px;
}

.compare-dialog.is-header-hidden .compare-header {
  display: none;
}

.player-title {
  font-size: 14px;
  line-height: 1.5;
}

.player-video-shell {
  position: relative;
  width: 100%;
  overflow: visible;
}

.player-card-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(0deg, rgba(7, 10, 16, 0.72), rgba(7, 10, 16, 0.18) 20%, rgba(7, 10, 16, 0) 40%);
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
}

.player-video-shell:hover .player-card-overlay {
  opacity: 1;
}

.player-title-overlay {
  position: absolute;
  left: 16px;
  right: 340px;
  bottom: 58px;
  overflow: hidden;
  color: #f5f7fb;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-actions,
.compare-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
}

.compare-menu-panel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  order: 1;
  max-width: min(760px, calc(100vw - 180px));
  opacity: 1;
  transition: max-width 0.2s ease, opacity 0.16s ease;
}

.compare-menu-title {
  flex: 0 0 auto;
  min-width: 120px;
  max-width: 240px;
  overflow: hidden;
  padding: 0 8px 0 2px;
  color: #f5f7fb;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-menu-panel.is-collapsed {
  max-width: 0;
  opacity: 0;
  pointer-events: none;
}

.compare-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  order: 2;
  flex: 0 0 auto;
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0;
  border: 1px solid rgba(151, 163, 184, 0.18);
  border-radius: 14px;
  background: rgba(25, 30, 41, 0.7);
  color: rgba(225, 232, 243, 0.76);
  line-height: 1;
  cursor: pointer;
}

.compare-menu-toggle:hover,
.compare-menu-toggle.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: #eef3fb;
}

#close-compare {
  order: 3;
}

.compare-header-tooltip::before {
  top: calc(100% + 12px);
  bottom: auto;
  z-index: 40;
  transform: translate(-50%, -6px);
}

.compare-header-tooltip::after {
  top: calc(100% + 6px);
  bottom: auto;
  z-index: 40;
  transform: translate(-50%, -6px);
  border-top: 0;
  border-bottom: 6px solid rgba(12, 16, 24, 0.92);
}

.compare-header-tooltip:hover::before,
.compare-header-tooltip:hover::after,
.compare-header-tooltip:focus-visible::before,
.compare-header-tooltip:focus-visible::after {
  transform: translate(-50%, 0);
}

.player-actions-overlay {
  position: absolute;
  top: 14px;
  right: 14px;
  pointer-events: auto;
}

.player-source-status,
.compare-source-status {
  display: none;
  max-width: 280px;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(15, 20, 30, 0.82);
  color: #eef3fb;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.player-source-status.is-visible,
.compare-source-status.is-visible {
  display: inline-flex;
  align-items: center;
}

.player-source-select-wrap,
.compare-source-select-wrap {
  pointer-events: auto;
}

.player-source-select,
.compare-source-select {
  min-width: 92px;
  height: 38px;
  padding: 0 28px 0 10px;
  border: 1px solid rgba(151, 163, 184, 0.22);
  border-radius: 12px;
  background: rgba(15, 20, 30, 0.78);
  color: #eef3fb;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(225, 232, 243, 0.82) 50%),
    linear-gradient(135deg, rgba(225, 232, 243, 0.82) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.player-source-select:disabled,
.compare-source-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.player-actions-overlay .thumb-action-button::before {
  top: calc(100% + 12px);
  bottom: auto;
  transform: translate(-50%, -6px);
}

.player-actions-overlay .thumb-action-button::after {
  top: calc(100% + 6px);
  bottom: auto;
  transform: translate(-50%, -6px);
  border-top: 0;
  border-bottom: 6px solid rgba(12, 16, 24, 0.92);
}

.player-actions-overlay .thumb-action-button:hover::before,
.player-actions-overlay .thumb-action-button:hover::after,
.player-actions-overlay .thumb-action-button:focus-visible::before,
.player-actions-overlay .thumb-action-button:focus-visible::after {
  transform: translate(-50%, 0);
}

.compare-columns-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid rgba(151, 163, 184, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #c7d0df;
}

.compare-columns-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.compare-columns-select {
  min-width: 72px;
  height: 28px;
  padding: 0 28px 0 8px;
  border: 0;
  border-radius: 10px;
  background:
    linear-gradient(45deg, transparent 50%, rgba(225, 232, 243, 0.82) 50%),
    linear-gradient(135deg, rgba(225, 232, 243, 0.82) 50%, transparent 50%),
    rgba(19, 23, 33, 0.9);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px),
    0 0;
  background-size:
    5px 5px,
    5px 5px,
    100% 100%;
  background-repeat: no-repeat;
  color: #eef3fb;
  font: inherit;
  font-size: 12px;
  appearance: none;
  -webkit-appearance: none;
}

.player-toggle,
.player-nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 72px;
  padding: 8px 10px;
  background: rgba(28, 33, 43, 0.78);
  color: #c7d0df;
}

.compare-toolbar-button {
  min-width: 118px;
  padding-inline: 14px;
}

.compare-action-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.player-nav-button {
  min-width: 44px;
  color: #f5f7fb;
}

.player-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.player-nav-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.player-nav-icon-fill {
  fill: currentColor;
  stroke: currentColor;
}

.player-toggle.is-active {
  background: rgba(62, 69, 82, 0.88);
  color: #ffd8bf;
}

.player-toggle-icon {
  width: 30px;
  height: 22px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.player-toggle-icon path {
  fill: none;
}

.player-toggle-icon-fill {
  fill: currentColor;
  stroke: currentColor;
}

.player-toggle-state {
  min-width: 24px;
  font-family: "DINAltLocal", "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

#close-player {
  padding: 10px 14px;
  background: rgba(28, 33, 43, 0.78);
  color: #f5f7fb;
  font-family: "DINAltLocal", "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#close-compare {
  width: 48px;
  height: 44px;
  padding: 0;
}

.dialog-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(151, 163, 184, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  color: #f5f7fb;
  font-family: "DINAltLocal", "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dialog-close-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#player {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100dvh;
  background: #000;
  object-fit: contain;
  border-radius: 0;
}

.compare-grid {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-content: start;
  align-items: start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 18px 16px;
}

.compare-dialog.is-header-hidden .compare-grid {
  padding-top: 0;
}

.compare-card {
  position: relative;
  border: 1px solid rgba(135, 151, 180, 0.14);
  border-radius: 20px;
  overflow: visible;
  background: rgba(20, 24, 33, 0.92);
  box-shadow: var(--shadow);
  cursor: grab;
  transition: border-color 0.14s ease, opacity 0.14s ease, transform 0.14s ease;
}

.compare-card:active {
  cursor: grabbing;
}

.compare-card.is-dragging {
  opacity: 0.52;
  transform: scale(0.985);
}

.compare-card.is-drag-over {
  border-color: rgba(103, 207, 255, 0.62);
}

.compare-video-shell {
  position: relative;
  overflow: visible;
}

.compare-card-title {
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #f5f7fb;
}

.compare-card-title strong,
.compare-card-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-card-title span {
  color: var(--muted);
  font-size: 12px;
}

.compare-card-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(0deg, rgba(7, 10, 16, 0.72), rgba(7, 10, 16, 0.18) 22%, rgba(7, 10, 16, 0) 42%);
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
}

.compare-card:hover .compare-card-overlay,
.compare-card:focus-within .compare-card-overlay {
  opacity: 1;
}

.compare-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  pointer-events: auto;
}

.compare-card-title-overlay {
  position: absolute;
  left: 12px;
  right: 86px;
  bottom: 58px;
}

.compare-source-select-wrap {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.compare-card-actions-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
}

.compare-sound-button,
.compare-remove-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(151, 163, 184, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  width: 38px;
  height: 38px;
  padding: 0;
  cursor: pointer;
}

.compare-card-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.compare-sound-button.is-active {
  border-color: rgba(240, 122, 59, 0.4);
  background: rgba(240, 122, 59, 0.18);
  color: #ffd8bf;
}

.compare-remove-button:hover,
.compare-sound-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.compare-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 20px;
}

.compare-empty {
  padding: 52px 24px 58px;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .toolbar,
  .content-header,
  .compare-header {
    flex-direction: column;
    align-items: stretch;
  }

  .player-actions,
  .compare-actions,
  .toolbar-actions {
    flex-wrap: wrap;
  }

  .player-actions .player-nav-button,
  .player-actions .player-toggle,
  .compare-actions .player-toggle {
    flex: 0 0 auto;
  }

  .search-panel.is-expanded,
  .search-panel.is-expanded .search {
    width: 100%;
    max-width: 100%;
  }

  .compare-dialog {
    width: min(100%, 1320px);
    min-height: auto;
  }

  .compare-grid {
    grid-template-columns: 1fr;
    padding: 8px 12px 14px;
  }

  .scroll-top-button {
    right: 16px;
    bottom: 16px;
  }
}
