/* ============================================================
   素材库 · 展示站样式（静态，无后端）
   ============================================================ */

:root {
  --bg: #0a0c11;
  --bg-2: #0f1218;
  --panel: #12161f;
  --panel-2: #171c27;
  --line: #232a38;
  --line-2: #2e3646;
  --text: #e8ecf5;
  --text-2: #9aa6bd;
  --text-3: #6b7688;
  --accent: #7c5cff;
  --accent-2: #ff5c9d;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: #2a3242;
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a445a;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ============================ 顶栏 ============================ */

.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 58px;
  padding: 0 18px;
  background: linear-gradient(180deg, #12161f, #0e1118);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.logo {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px rgba(124, 92, 255, .5);
}

.brand h1 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .4px;
}

.stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  overflow: hidden;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--panel);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.stat b {
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.stat em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-3);
}

/* .stat / .seg 自带 display:flex，会压掉 [hidden]，这里补回来 */
.stat[hidden],
.seg[hidden] {
  display: none !important;
}

.stat.ok b {
  color: var(--ok);
}

.stat.warn b {
  color: var(--warn);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover {
  background: #1e2533;
  border-color: #35405680;
}

.btn.small {
  height: 27px;
  padding: 0 10px;
  font-size: 12px;
}

.btn:disabled {
  opacity: .55;
  cursor: default;
}

.btn:disabled:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

.btn.ghost {
  background: transparent;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.1);
}

.btn:disabled {
  opacity: .5;
  cursor: default;
}

/* ============================ 布局 ============================ */

.body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---------------------------- 侧栏 ---------------------------- */

.sidebar {
  flex: 0 0 216px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 9px;
}

.side-head h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.side-count {
  font-size: 11px;
  color: var(--text-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 1px 8px;
}

.kw-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 8px 14px;
}

.kw {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: .12s;
}

.kw:hover {
  background: #1a2030;
}

.kw.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, .22), rgba(255, 92, 157, .16));
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .4);
}

.kw-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.kw-num {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.kw.active .kw-num {
  color: var(--text-2);
}

/* ---------------------------- 主区 ---------------------------- */

.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 320px;
}

.search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
}

.search input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 31px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  outline: none;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .16);
}

.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.seg button {
  height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: 12.5px;
  transition: .12s;
}

.seg button:hover {
  color: var(--text);
}

.seg button.active {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

.icon-seg button {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
}

.sel {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  outline: none;
  cursor: pointer;
}

.crumb {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 11px 16px 4px;
}

.crumb span {
  font-size: 14px;
  font-weight: 600;
}

.crumb em {
  font-style: normal;
  font-size: 12px;
  color: var(--text-3);
}

/* ============================ 网格 ============================ */

/* 固定 8 列 × 4 行网格：行高由 JS 按可视区实测写入 --rowH，一屏正好 4 行，超出向下滚动 */
.grid {
  --cols: 8;
  --rows: 4;
  --g: 12px;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 16px 14px;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: var(--rowH, 160px);
  gap: var(--g);
  align-content: start;
  min-height: 0;
}

/* 窄屏回落列数，避免卡片被挤扁 */
@media (max-width: 1560px) { .grid { --cols: 7 } }
@media (max-width: 1400px) { .grid { --cols: 6 } }
@media (max-width: 1180px) { .grid { --cols: 5 } }
@media (max-width: 980px)  { .grid { --cols: 4 } }
@media (max-width: 760px)  { .grid { --cols: 3 } }
@media (max-width: 560px)  { .grid { --cols: 2 } }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  transition: .16s;
}

.card:hover {
  border-color: #3b4760;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.thumb {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #0a0c11;
  overflow: hidden;
  cursor: pointer;
}

.thumb video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0c11;
}

/* 封面图 / 图片素材：和 <video> 一样铺满格子 */
.thumb .thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0c11;
  display: block;
}

.thumb-ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #ffffff2e;
  padding: 10px;
  text-align: center;
}

.thumb-ph b {
  font-size: 10.5px;
  font-weight: 500;
  color: #ffffff33;
  word-break: break-all;
  line-height: 1.35;
}

.thumb .play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: .16s;
}

.card:hover .play {
  opacity: 1;
}

.thumb .play i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(12, 14, 20, .62);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  padding-left: 2px;
}

.badge {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 3;
  padding: 2px 7px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 600;
  backdrop-filter: blur(6px);
}

.badge.ok {
  background: rgba(16, 185, 129, .2);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, .35);
}

.badge.warn {
  background: rgba(251, 191, 36, .18);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, .32);
}

.dur {
  position: absolute;
  right: 7px;
  bottom: 7px;
  z-index: 3;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(8, 10, 15, .78);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: #dbe3f0;
}

.card-body {
  flex: 0 0 auto;
  padding: 5px 8px 7px;
}

.card-name {
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  word-break: break-all;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-3);
}

.kw-tag {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 42%;
  color: var(--text-2);
}

.card-acts {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 4;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: .16s;
}

.card:hover .card-acts {
  opacity: 1;
}

.card-acts a,
.card-acts button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  background: rgba(12, 14, 20, .7);
  backdrop-filter: blur(6px);
  cursor: pointer;
  color: #dfe6f2;
}

.card-acts a:hover,
.card-acts button:hover {
  background: rgba(124, 92, 255, .8);
  border-color: transparent;
}

/* ---------------------------- 列表视图 ---------------------------- */

.grid.list {
  grid-template-columns: 1fr;
  grid-auto-rows: auto;
  gap: 8px;
}

.grid.list .card {
  flex-direction: row;
  display: flex;
  align-items: center;
  height: 66px;
  padding: 0 12px 0 0;
}

.grid.list .card:hover {
  transform: none;
}

.grid.list .thumb {
  flex: 0 0 46px;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

.grid.list .thumb .play,
.grid.list .dur {
  display: none;
}

.grid.list .badge {
  position: static;
  margin: 0 10px;
  flex: 0 0 auto;
}

.grid.list .card-body {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  min-width: 0;
}

.grid.list .card-name {
  -webkit-line-clamp: 1;
  min-height: 0;
  flex: 1 1 auto;
  font-size: 12.5px;
}

.grid.list .card-meta {
  margin-top: 0;
  flex: 0 0 auto;
}

.grid.list .card-acts {
  position: static;
  opacity: 1;
  margin-left: 12px;
}

/* ============================ 其他 ============================ */

.more {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 0 0 22px;
}

.empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-3);
}

.empty p {
  font-size: 13px;
}

/* ---------------------------- 弹层 ---------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, .78);
  backdrop-filter: blur(4px);
}

.player-box,
.setup-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  z-index: 1;
}

.player-box {
  display: flex;
  flex-direction: column;
  width: min(94vw, 460px);
  max-height: 92vh;
  overflow: hidden;
}

.player-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}

.player-head>span {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-head-acts {
  display: flex;
  gap: 7px;
  flex: 0 0 auto;
}

.player-body {
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-body video {
  width: 100%;
  max-height: 74vh;
  display: block;
  background: #000;
}

.player-foot {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.setup-box {
  width: min(92vw, 480px);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setup-box h3 {
  font-size: 16px;
}

.setup-box p {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
}

.setup-box code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 11.5px;
  color: #c4b5fd;
  word-break: break-all;
}

.setup-box input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
}

.setup-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .16);
}

.setup-acts {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 4px;
}

.err {
  color: #f87171 !important;
  font-size: 12px !important;
}

/* ---------------------------- 上传弹窗 ---------------------------- */

.up-box {
  width: min(92vw, 520px);
}

.up-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.up-row > label {
  font-size: 12px;
  color: var(--text-2);
}

.up-sel {
  width: 100%;
  height: 38px;
}

.up-drop {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  transition: .15s;
}

.up-drop:hover,
.up-drop.over {
  border-color: var(--accent);
  background: rgba(124, 92, 255, .06);
}

.up-drop input[type="file"] {
  display: none;
}

.up-hint {
  font-size: 11.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.up-item {
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--panel);
  font-size: 12px;
}

.up-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 失败原因 / 画面优化提示：跟在条目下面一行小字。
   之前失败原因只挂在一个 title 提示里，看着就是「失败，没原因」，这里直接摊开写。 */
.up-why {
  margin: 4px 2px 1px;
  font-size: 11px;
  line-height: 1.5;
  color: #fca5a5;
  word-break: break-word;
}

.up-why.warn {
  color: #fcd34d;
}

.up-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-size {
  flex: 0 0 auto;
  color: var(--text-3);
  font-size: 11px;
}

.up-st {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 100px;
  background: var(--panel-2);
  color: var(--text-2);
}

.up-st.run {
  color: #c4b5fd;
  background: rgba(124, 92, 255, .16);
  /* 转码进度文案可能比较长，别把整行撑爆 */
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-st.ok {
  color: #6ee7b7;
  background: rgba(52, 211, 153, .16);
}

.up-st.fail {
  color: #fca5a5;
  background: rgba(248, 113, 113, .16);
}

.up-sum {
  padding: 6px 8px 2px;
  font-size: 11.5px;
  color: var(--text-3);
  text-align: right;
}

/* ---------------------------- 提示条 ---------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 200;
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  max-width: 80vw;
}

.toast.err {
  border-color: rgba(248, 113, 113, .5);
  color: #fca5a5 !important;
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(100deg, #141924 30%, #1c2331 50%, #141924 70%);
  background-size: 220% 100%;
  animation: sk 1.3s linear infinite;
  aspect-ratio: 9 / 16;
}

@keyframes sk {
  to {
    background-position: -220% 0;
  }
}

@media (max-width: 860px) {
  .sidebar {
    display: none;
  }

  .stats .stat:nth-child(n+4) {
    display: none;
  }
}

/* ---------------- 音乐库：播放弹窗别用视频那套黑底大框 ---------------- */

.player.audio-mode .player-body {
  background: var(--panel, #16171b);
  padding: 26px 22px;
}

.player-body audio {
  width: 100%;
  max-width: 520px;
  display: block;
}

/* 音乐卡片不放 <video>，封面留白大一点更耐看 */
.card .thumb-ph b {
  word-break: break-word;
}

/* 列表视图里缩略图很窄，封面上的曲名会被挤成竖排 —— 只留音符图标 */
.grid.list .card-audio .thumb-ph b {
  display: none;
}

/* 音乐卡片在列表里靠曲名认，字号给足 */
.grid.list .card-audio .card-name {
  font-size: 13.5px;
}
