/* ==========================================================================
   抖音礼物素材库 —— 设计系统 + 两套 UI
   html[data-platform="desktop"]  三栏：侧栏 | 列表 | 详情
   html[data-platform="mobile"]   单栏：列表 + 底栏 + 全屏详情层 + 筛选抽屉
   ========================================================================== */
:root {
  --bg:      #0f1115;
  --bg-2:    #161a21;
  --bg-3:    #1e232c;
  --bg-4:    #262c37;
  --line:    #2a313c;
  --fg:      #e7eaf0;
  --fg-2:    #98a2b3;
  --fg-3:    #667085;
  --accent:  #ff2c55;
  --accent-2:#22d3ee;
  --ok:      #34d399;
  --warn:    #fbbf24;
  --radius:  14px;
  --radius-s: 9px;
  --gap:     14px;
  --topbar-h: 56px;
  --sidebar-w: 248px;
  --detail-w: 400px;
  --card-min: 168px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  overscroll-behavior-y: none;
}
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--fg-2); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }

/* ---------- 平台开关 ---------- */
html[data-platform="desktop"] .only-mobile { display: none !important; }
html[data-platform="mobile"]  .only-desktop { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: var(--topbar-h); padding: 0 14px; padding-top: var(--safe-t);
  display: flex; align-items: center; gap: 12px;
  background: rgba(15,17,21,.86); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand .logo { font-size: 20px; }
.brand .title { font-weight: 650; white-space: nowrap; letter-spacing: .2px; }
.badge {
  background: var(--bg-3); color: var(--fg-2); border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 99px; font-size: 12px;
}
.searchbox {
  flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 99px;
  padding: 0 12px; height: 38px; transition: border-color .15s;
}
.searchbox:focus-within { border-color: var(--accent); }
.searchbox input {
  flex: 1; background: none; border: 0; outline: 0; min-width: 0;
}
.searchbox input::-webkit-search-cancel-button { display: none; }
.s-icon { opacity: .55; font-size: 13px; }
.s-clear { background: none; border: 0; cursor: pointer; color: var(--fg-3); padding: 4px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.icon-btn {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--fg);
  width: 34px; height: 34px; border-radius: var(--radius-s);
  cursor: pointer; display: grid; place-items: center; font-size: 15px;
}
.icon-btn:hover { background: var(--bg-3); }

/* ---------- 主体骨架 ---------- */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.body { flex: 1; display: grid; min-height: 0; }
html[data-platform="desktop"] .body {
  grid-template-columns: var(--sidebar-w) minmax(0,1fr) 0;
}
html[data-platform="desktop"] .body.detail-open {
  grid-template-columns: var(--sidebar-w) minmax(0,1fr) var(--detail-w);
}

/* ---------- 侧栏 ---------- */
.sidebar {
  border-right: 1px solid var(--line); background: var(--bg-2);
  padding: 16px; overflow-y: auto; height: calc(100dvh - var(--topbar-h));
  position: sticky; top: var(--topbar-h);
}
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.side-head h3 { margin: 0; font-size: 13px; letter-spacing: .08em; color: var(--fg-2); text-transform: uppercase; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 12px; color: var(--fg-2); margin-bottom: 7px; }
.field input[type=number], .field select {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 8px 10px; outline: 0;
}
.field input[type=number]:focus, .field select:focus { border-color: var(--accent); }
.field .row input { flex: 1; min-width: 0; }
.dash { color: var(--fg-3); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-2);
  padding: 6px 11px; border-radius: 99px; cursor: pointer; font-size: 12.5px;
  transition: all .12s;
}
.chip:hover { border-color: var(--fg-3); color: var(--fg); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.stats { border-top: 1px solid var(--line); padding-top: 14px; font-size: 12.5px; }
.stats dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin: 0; }
.stats dt { color: var(--fg-2); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.stats h4 { margin: 14px 0 8px; font-size: 12px; color: var(--fg-2); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- 主列表 ---------- */
.main { min-width: 0; padding: 16px; overflow-y: auto; height: calc(100dvh - var(--topbar-h)); }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
}
.grid.as-list { grid-template-columns: 1fr; }

/* 卡片 */
.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .13s, border-color .13s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); border-color: var(--fg-3); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thumb {
  aspect-ratio: 1; width: 100%; position: relative; display: grid; place-items: center;
  background-color: #15181d;
  background-image:
    linear-gradient(45deg, #232830 25%, transparent 25%, transparent 75%, #232830 75%),
    linear-gradient(45deg, #232830 25%, transparent 25%, transparent 75%, #232830 75%);
  background-size: 22px 22px; background-position: 0 0, 11px 11px;
}
.thumb img { width: 78%; height: 78%; object-fit: contain; }
.card-meta { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.card-name {
  font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.price { color: var(--warn); font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 600; }
.tag {
  font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: var(--bg-4); color: var(--fg-2); white-space: nowrap;
}
.tag.hot { background: rgba(255,44,85,.16); color: #ff7d97; }
.tag.video { background: rgba(34,211,238,.14); color: var(--accent-2); }
.tag.engine { background: rgba(251,191,36,.14); color: var(--warn); }

/* 列表视图 */
.grid.as-list .card { flex-direction: row; }
.grid.as-list .thumb { width: 76px; aspect-ratio: 1; flex: none; }
.grid.as-list .card-meta { justify-content: center; }
.grid.as-list .card-name { white-space: normal; }

.empty { text-align: center; color: var(--fg-2); padding: 60px 20px; }
.empty-icon { font-size: 34px; margin-bottom: 8px; }
.sentinel { height: 60px; }
.loading-dot { text-align: center; color: var(--fg-3); padding: 16px; font-size: 13px; }

/* ---------- 详情 ---------- */
.detail {
  border-left: 1px solid var(--line); background: var(--bg-2);
  overflow-y: auto; height: calc(100dvh - var(--topbar-h));
  position: sticky; top: var(--topbar-h);
  display: none;
}
html[data-platform="desktop"] .body.detail-open .detail { display: block; }
.detail-body { padding: 16px; }
.detail-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
html[data-platform="desktop"] .detail-close { display: none; }
.placeholder { color: var(--fg-3); text-align: center; padding: 60px 10px; }

.d-hero {
  border-radius: var(--radius); overflow: hidden; margin-bottom: 14px;
  background-color: #15181d;
  background-image:
    linear-gradient(45deg, #232830 25%, transparent 25%, transparent 75%, #232830 75%),
    linear-gradient(45deg, #232830 25%, transparent 25%, transparent 75%, #232830 75%);
  background-size: 24px 24px; background-position: 0 0, 12px 12px;
  display: grid; place-items: center; padding: 18px;
}
.d-hero img { max-height: 190px; object-fit: contain; }
.d-title { font-size: 19px; font-weight: 700; margin: 0 0 4px; }
.d-desc { color: var(--fg-2); font-size: 13px; margin-bottom: 12px; }
.d-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.fact { background: var(--bg-3); border-radius: var(--radius-s); padding: 9px 11px; }
.fact .k { font-size: 11px; color: var(--fg-2); }
.fact .v { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.d-section { font-size: 12px; color: var(--fg-2); text-transform: uppercase; letter-spacing: .07em; margin: 18px 0 9px; }

.eff {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 11px; margin-bottom: 9px;
}
.eff-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.eff-name { font-weight: 600; font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eff-facts { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--fg-2); margin-bottom: 9px; }
.eff-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.layer-group { margin-bottom: 14px; }
.layer-title {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 8px;
  color: var(--fg); font-size: 12px; font-weight: 700; letter-spacing: .05em;
}
.layer-title::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.btn {
  background: var(--bg-4); border: 1px solid var(--line); color: var(--fg);
  padding: 7px 13px; border-radius: var(--radius-s); cursor: pointer; font-size: 12.5px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { background: #2f3641; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.filelist { max-height: 190px; overflow: auto; font-size: 11.5px; color: var(--fg-2); }
.filelist div { padding: 2px 0; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-preview {
  margin-top: 9px; padding: 12px; min-height: 48px; border: 1px dashed var(--line);
  border-radius: var(--radius-s); background: var(--bg-2); font-size: 20px; line-height: 1.35;
  overflow-wrap: anywhere;
}
.font-preview.error { color: #ff8a8a; font-family: inherit; font-size: 12px; }

/* ---------- 移动端 ---------- */
html[data-platform="mobile"] {
  --card-min: 44%;
}
html[data-platform="mobile"] .topbar { gap: 8px; padding: 0 10px; padding-top: var(--safe-t); }
html[data-platform="mobile"] .brand .title { display: none; }
html[data-platform="mobile"] .main {
  padding: 12px; height: auto; min-height: calc(100dvh - var(--topbar-h) - 58px - var(--safe-b));
  padding-bottom: calc(12px + var(--safe-b));
}
html[data-platform="mobile"] .grid { gap: 10px; }
html[data-platform="mobile"] .card-meta { padding: 8px 9px 10px; }

/* 移动端侧栏 = 抽屉 */
html[data-platform="mobile"] .sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(84vw, 320px);
  transform: translateX(-102%); transition: transform .24s ease;
  z-index: 60; padding-top: calc(16px + var(--safe-t)); border-right: 1px solid var(--line);
}
html[data-platform="mobile"] .sidebar.open { transform: translateX(0); }
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
html[data-platform="mobile"] .scrim.show { opacity: 1; pointer-events: auto; }
html[data-platform="desktop"] .scrim { display: none; }

/* 移动端详情 = 全屏层 */
html[data-platform="mobile"] .detail {
  position: fixed; inset: 0; z-index: 70; display: block;
  transform: translateX(100%); transition: transform .26s ease;
  padding-top: var(--safe-t); padding-bottom: var(--safe-b);
  height: 100dvh;
}
html[data-platform="mobile"] .detail.open { transform: translateX(0); }
html[data-platform="mobile"] .detail-close { display: grid; }

/* 移动端底栏 */
.tabbar {
  position: sticky; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(15,17,21,.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  background: none; border: 0; color: var(--fg-3); padding: 8px 0 9px;
  display: grid; gap: 2px; place-items: center; cursor: pointer; font-size: 10.5px;
}
.tab i { font-size: 18px; font-style: normal; }
.tab.active { color: var(--accent); }

/* ---------- 播放器 ---------- */
.player {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2);
  color: var(--fg); padding: 0; width: min(92vw, 620px); max-height: 92dvh;
  box-shadow: var(--shadow); overflow: hidden;
}
.player::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.player-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.player-stage {
  padding: 16px; display: grid; place-items: center; min-height: 240px;
  background-color: #15181d;
  background-image:
    linear-gradient(45deg, #232830 25%, transparent 25%, transparent 75%, #232830 75%),
    linear-gradient(45deg, #232830 25%, transparent 25%, transparent 75%, #232830 75%);
  background-size: 24px 24px; background-position: 0 0, 12px 12px;
}
#player-canvas { max-width: 100%; max-height: 56dvh; border-radius: 8px; }
/* 视频源保持“已渲染”状态（不能 display:none，否则部分浏览器不解码帧） */
#player-sources { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.d-actions { margin-bottom: 4px; }
.combo-picker {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  margin: 8px 0 10px; padding: 10px; border: 1px solid var(--line);
  border-radius: var(--radius-s); background: var(--bg-3);
}
.combo-select { min-width: 0; }
.combo-select span { display: block; color: var(--fg-2); font-size: 11px; margin-bottom: 4px; }
.combo-select select {
  width: 100%; min-width: 0; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 8px; outline: 0; font-size: 12px;
}
.combo-select select:focus { border-color: var(--accent); }
.player-tip { color: var(--fg-2); font-size: 13px; text-align: center; }
.player-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; border-top: 1px solid var(--line);
}
.range-label { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fg-2); }
.range-label input { width: 110px; accent-color: var(--accent); }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #3a424f; }
::-webkit-scrollbar-track { background: transparent; }

.adminbar{position:sticky;top:56px;z-index:29;display:flex;align-items:center;gap:10px;padding:9px 14px;background:#1e232c;border-bottom:1px solid var(--line)}
.btn.danger{background:#c9304f;border-color:#c9304f}.admin-check{position:absolute;top:9px;left:9px;width:18px;height:18px;accent-color:var(--accent);z-index:2}
