: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);
}

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

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 20px 18px;
  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: 12px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.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: 17px;
  font-weight: 700;
}

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

.stat-icon {
  width: 24px;
  height: 18px;
  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.5em;
  line-height: 1;
  color: #8e2a2a;
}

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

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

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

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

.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: 11px 14px;
  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: 12px;
}

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

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

.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: 2.4em;
  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,
#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: min(520px, 100%);
}

.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: hidden;
  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 {
  object-fit: cover;
}

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

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

.favorite-button {
  border: 1px solid rgba(151, 163, 184, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 5px 8px;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.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: space-between;
  gap: 10px;
  margin-top: 12px;
}

.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 {
  margin-top: 10px;
  width: auto;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid rgba(240, 122, 59, 0.28);
  border-radius: 10px;
  background: rgba(240, 122, 59, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

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

.player-dialog {
  width: min(1000px, calc(100vw - 32px));
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: rgba(12, 15, 22, 0.96);
  color: #f5f7fb;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

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

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
}

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

.player-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

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

.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(240, 122, 59, 0.18);
  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(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;
}

#player {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 120px);
  background: #000;
  object-fit: contain;
}

@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,
  .player-header {
    flex-direction: column;
    align-items: stretch;
  }

  .player-actions {
    flex-wrap: wrap;
  }

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

  .search {
    width: 100%;
  }

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