/* ============================================================
   viewer-common/kit.css — Spine 查看器统一主题（2026 现代化版）
   设计语言: 分层暗色表面 + 玻璃拟态浮动层 + 微交互
   用法: <html data-accent="blue"> (雀魂) / <html data-accent="gold"> (BD2)
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- 主题变量 ---------- */
/* 背景由调色板动态设置；强调色由 data-accent 决定 */
:root, html[data-accent="blue"] {
  --accent: #7d92f2;
  --accent-hi: #a3b3f7;
  --accent-ink: #ffffff;
  --accent-dim-bg: rgba(125, 146, 242, .13);
  --accent-glow: 0 0 0 1px rgba(125, 146, 242, .30);
  --star: #f5c542;
  --sel: rgba(125, 146, 242, .13);
}
html[data-accent="gold"] {
  --accent: #e2c288;
  --accent-hi: #f2dcae;
  --accent-ink: #201806;
  --accent-dim-bg: rgba(226, 194, 136, .10);
  --accent-glow: 0 0 0 1px rgba(226, 194, 136, .25);
  --star: #e2c288;
  --sel: rgba(226, 194, 136, .09);
}

/* 默认背景 */
:root {
  --bg: #000000;
  --bg-glow: none;
  --panel: #0f1219;
  --panel-grad: linear-gradient(180deg, #121620, #0e1119);
  --panel2: #171d28;
  --panel3: #212a39;
  --glass: rgba(13, 16, 24, .74);
  --glass-hi: rgba(255, 255, 255, .06);
}
/* 全主题共用 token */
:root {
  --border: rgba(255, 255, 255, .05);
  --border2: rgba(255, 255, 255, .095);
  --text: #e4e9f2;
  --text-dim: #99a4b8;
  --text-faint: #657082;
  --glass-hi: rgba(255, 255, 255, .06);
  --shadow-1: 0 2px 10px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .55);
  --danger-bg: rgba(214, 69, 69, .16);
  --danger-bd: rgba(214, 69, 69, .45);
  --danger-tx: #ffb9b9;
}

/* ---------- 整体布局 ---------- */
.app { display: flex; height: 100vh; background: var(--bg-glow); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.work { flex: 1; display: flex; min-height: 0; }

/* ---------- 左侧角色栏 ---------- */
.sidebar {
  width: 300px; min-width: 300px; height: 100%;
  background: var(--panel-grad);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  backdrop-filter: blur(10px);
}
.brand {
  padding: 16px 14px 13px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.brand .logo {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; flex: none;
  background: var(--accent-dim-bg);
  border: 1px solid var(--border2);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-1);
}
html[data-accent="gold"] .brand .logo {
  background: linear-gradient(135deg, #ffd98c, #c8912f);
  color: #241a05; font-size: 11px; letter-spacing: .5px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
}
.brand h1 { font-size: 15px; color: var(--accent); font-weight: 700; letter-spacing: .2px; }
.brand p { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.search-wrap { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.search-wrap input {
  width: 100%; padding: 9px 12px 9px 32px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 10px; color: var(--text); font-size: 13px; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23677285' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  transition: border-color .16s, box-shadow .16s, background-color .16s;
}
.search-wrap input::placeholder { color: var(--text-faint); }
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
}
.char-list { flex: 1; overflow-y: auto; padding: 8px; }
.side-foot {
  padding: 9px 12px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-faint); line-height: 1.6;
  background: rgba(0, 0, 0, .14);
}
.side-foot a { color: var(--accent); text-decoration: none; }
.side-foot a:hover { text-decoration: underline; }

/* ---------- 角色列表项 ---------- */
.char-item {
  position: relative;
  width: 100%; padding: 8px 9px 8px 12px;
  background: transparent; border: 1px solid transparent;
  border-radius: 10px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; text-align: left; font-family: inherit;
  margin-bottom: 3px;
  transition: background .14s, border-color .14s;
}
.char-item::before {
  content: ""; position: absolute; left: 3px; top: 22%; bottom: 22%;
  width: 3px; border-radius: 2px;
  background: var(--accent); opacity: 0;
  transition: opacity .15s, top .15s, bottom .15s;
}
.char-item:hover { background: var(--panel2); }
.char-item:hover::before { opacity: .35; }
.char-item.active {
  background: var(--sel);
  border-color: var(--border2);
  box-shadow: inset 0 1px 0 var(--glass-hi);
}
.char-item.active::before { opacity: 1; top: 14%; bottom: 14%; }
.char-item .names { flex: 1; min-width: 0; }
.char-item .name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.char-item.active .name { color: var(--accent); }
.char-item .sub {
  font-size: 10.5px; color: var(--text-faint);
  font-family: Consolas, "Cascadia Mono", monospace; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.char-item .star {
  flex: none; background: none; border: none; cursor: pointer;
  font-size: 15px; color: var(--text-faint); padding: 2px 3px; line-height: 1;
  transition: transform .15s cubic-bezier(.34, 1.56, .64, 1), color .15s;
}
.char-item .star.on { color: var(--star); }
.char-item .star:hover { color: var(--star); transform: scale(1.25); }
.badge {
  font-size: 10px; color: var(--accent);
  background: var(--accent-dim-bg); border: 1px solid var(--border2);
  padding: 2.5px 7px; border-radius: 999px; white-space: nowrap; flex: none;
  font-variant-numeric: tabular-nums;
}
.empty-tip { padding: 16px 14px; color: var(--text-faint); font-size: 12px; line-height: 1.7; }

/* ---------- 顶栏 ---------- */
.topbar {
  min-height: 58px; padding: 10px 14px;
  background: var(--panel-grad);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.char-meta { min-width: 140px; max-width: 300px; }
.char-meta .m-name {
  font-size: 15.5px; font-weight: 700; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .2px;
}
.char-meta .m-id {
  font-size: 11px; color: var(--text-faint); margin-top: 2px;
  font-family: Consolas, "Cascadia Mono", monospace;
}
.controls {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-left: auto;
}

/* ---------- 控件（幽灵风格：悬停浮现，激活淡染） ---------- */
.ctl {
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); border-radius: 9px;
  padding: 7px 10px; font-size: 12px; outline: none;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: background .14s, color .14s, border-color .14s, transform .1s;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.2;
}
.ctl:hover { background: var(--panel2); color: var(--text); }
.ctl:active { transform: translateY(1px); }
.ctl.active {
  background: var(--accent-dim-bg); color: var(--accent);
  font-weight: 600; border-color: transparent;
}
.ctl.active:hover { color: var(--accent); background: var(--accent-dim-bg); }
.ctl svg { flex: none; display: block; }
button.ctl.icon { min-width: 34px; justify-content: center; padding: 7px 8px; }
label.ctl { display: flex; align-items: center; gap: 6px; cursor: default; color: var(--text-dim); }
label.ctl:hover { color: var(--text); }
label.ctl select, select.ctl { color: var(--text); }
label.ctl select { max-width: 170px; }
select.ctl {
  max-width: 180px;
  appearance: none; -webkit-appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238b95a8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
select.ctl:hover { background-color: var(--panel2); }
select.ctl option { background: var(--panel); color: var(--text); }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 86px; height: 4px; border-radius: 2px;
  background: var(--panel3); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
  transition: transform .12s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="color"] {
  width: 30px; height: 26px; border: 1px solid var(--border2);
  border-radius: 7px; background: none; padding: 1px; cursor: pointer;
}
.ctl-sep { width: 1px; height: 20px; background: var(--border2); margin: 0 3px; flex: none; }
.ctl-group {
  display: flex; align-items: center; gap: 2px;
  background: rgba(255, 255, 255, .028);
  border: 1px solid var(--border);
  border-radius: 11px; padding: 2px;
}

/* ---------- 舞台 ---------- */
.stage {
  flex: 1; position: relative; min-height: 0;
  background:
    radial-gradient(900px 600px at 50% 38%, rgba(255, 255, 255, .022), transparent 70%),
    var(--bg);
  overflow: hidden; cursor: grab;
}
.stage.panning { cursor: grabbing; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.status {
  position: absolute; left: 14px; top: 12px; bottom: auto;
  background: var(--glass);
  border: 1px solid var(--border2);
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
  color: var(--text); padding: 6px 12px; border-radius: 999px;
  font-size: 12px; pointer-events: none; max-width: calc(100% - 180px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi);
}
.hint {
  position: absolute; right: 14px; bottom: 14px;
  color: var(--text-faint); font-size: 11px;
  pointer-events: none; text-align: right; max-width: 46%;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.zoom-bar {
  position: absolute; right: 14px; top: 12px;
  display: flex; gap: 5px; align-items: center;
  background: var(--glass);
  border: 1px solid var(--border2);
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
  padding: 5px 7px; border-radius: 12px;
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--glass-hi);
}
.zoom-bar button { min-width: 30px; }
.zoom-bar .pct { min-width: 44px; text-align: center; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- 舞台弹出菜单(部件/导出/调试) ---------- */
.stage-popup {
  position: absolute; z-index: 10;
  background: var(--glass);
  border: 1px solid var(--border2);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-radius: 12px; padding: 9px 10px;
  display: flex; align-items: center; gap: 7px;
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi);
  white-space: nowrap;
}
.stage-popup span { font-size: 12px; color: var(--text); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.stage-popup button {
  background: var(--panel2); border: 1px solid var(--border2); color: var(--text);
  border-radius: 7px; padding: 4.5px 10px; font-size: 12px; cursor: pointer;
  font-family: inherit; transition: border-color .14s, background .14s;
}
.stage-popup button:hover { border-color: var(--accent); color: var(--accent-hi); }
.stage-popup button.danger { background: var(--danger-bg); border-color: var(--danger-bd); color: var(--danger-tx); }
.stage-popup button.danger:hover { border-color: var(--danger-tx); color: var(--text); }
.stage-popup .col { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.stage-popup .col-title { font-size: 11px; color: var(--text-faint); }
.stage-popup .opt-row { display: flex; gap: 5px; align-items: center; }
.stage-popup .opt-row button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.stage-popup label { font-size: 12px; color: var(--text); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.stage-popup input[type="checkbox"] { accent-color: var(--accent); }

/* Named quality presets and a separate playable animation format. */
.stage-popup .export-options { width: min(260px, calc(100vw - 44px)); white-space: normal; gap: 10px; }
.export-formats { display: flex; gap: 6px; width: 100%; }
.stage-popup .export-formats button { flex: 1; min-height: 40px; }
.stage-popup .export-formats button.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.export-choices { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.stage-popup .export-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; min-height: 52px; padding: 9px 12px; text-align: left; }
.export-choice strong { font-size: 13px; }
.export-choice small { font-size: 11px; color: var(--text-dim); line-height: 1.45; }
.stage-popup .export-choice.on { background: var(--accent-bg); border-color: var(--accent); }
.export-choice.on strong { color: var(--accent); }
.export-detail { color: var(--text-dim); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.export-actions { display: flex; gap: 6px; width: 100%; }
.stage-popup .export-actions button { flex: 1; min-height: 40px; }
.stage-popup .export-go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stage-popup .export-go:hover { color: var(--accent-ink); }
.export-progress { position: fixed; inset: 0; z-index: 5000; background: rgba(0,0,0,.48); display: grid; place-items: center; padding: 20px; }
.export-progress-card { box-sizing: border-box; width: min(320px,100%); display: flex; flex-direction: column; gap: 16px; padding: 22px; border: 1px solid var(--border2); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: var(--shadow-2); }
.export-progress-text { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.export-progress progress { width: 100%; height: 8px; accent-color: var(--accent); }
.export-progress button { min-height: 42px; border: 1px solid var(--border2); border-radius: 8px; background: var(--panel2); color: var(--text); cursor: pointer; font: inherit; }

/* ---------- 主题调色板 ---------- */
.theme-palette {
  position: fixed; z-index: 1200; width: 254px;
  padding: 12px; border: 1px solid var(--border2); border-radius: 14px;
  background: var(--glass); color: var(--text);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi);
}
.theme-palette-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.theme-palette-head strong { font-size: 13px; color: var(--accent-hi); }
.theme-palette-close {
  width: 24px; height: 24px; padding: 0; border: 1px solid var(--border2); border-radius: 7px;
  background: var(--panel2); color: var(--text-dim); font: 17px/1 inherit; cursor: pointer;
}
.theme-palette-close:hover { color: var(--text); border-color: var(--accent); }
.theme-palette .theme-palette-close { display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: auto; min-width: 64px; height: 36px; padding: 5px 8px; font-size: 12px; }
.theme-palette-close .arthub-icon { width: 14px; height: 14px; }
.theme-palette { box-sizing: border-box; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; }
.theme-palette-picker {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px;
  padding: 7px 8px; border: 1px solid var(--border2); border-radius: 8px;
  background: var(--panel2); color: var(--text-dim); font-size: 12px; cursor: pointer;
}
.theme-palette-picker input[type="color"] { width: 34px; height: 23px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.theme-palette-reset {
  width: 100%; margin-top: 9px; padding: 6px 8px; border: 1px solid var(--border2); border-radius: 8px;
  background: transparent; color: var(--text-dim); font-size: 11px; font-family: inherit; cursor: pointer;
}
.theme-palette-reset:hover { border-color: var(--accent); color: var(--accent-hi); }

/* ---------- 右侧面板 ---------- */
.right-panel {
  width: 316px; min-width: 316px; height: 100%;
  background: var(--panel-grad);
  border-left: 1px solid var(--border);
  display: none; flex-direction: column;
}
.right-panel.open { display: flex; }
.rp-head {
  padding: 12px 14px 4px; font-size: 13px; font-weight: 700; color: var(--accent);
  letter-spacing: .3px;
}
.rp-tabs { display: flex; gap: 5px; padding: 10px 10px 0; }
.rp-tabs button {
  flex: 1; background: var(--panel2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 2px; font-size: 12px; cursor: pointer; font-family: inherit;
  white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: border-color .14s, color .14s, background .14s;
}
.rp-tabs button.on { background: var(--accent-dim-bg); border-color: var(--accent); color: var(--text); font-weight: 600; }
.rp-page { flex: 1; overflow-y: auto; padding: 10px 12px 14px; display: none; }
.rp-page.on { display: block; }

/* ---------- 面板通用小件 ---------- */
.lbl { font-size: 12px; color: var(--text-dim); margin: 10px 0 5px; }
.lbl:first-child { margin-top: 0; }
.row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 5px 0; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border2); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; cursor: pointer; font-family: inherit;
  transition: border-color .14s, background .14s, color .14s;
}
.chips button:hover { border-color: var(--accent); color: var(--accent-hi); }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.text-input {
  flex: 1; min-width: 0; padding: 7px 10px;
  background: var(--bg); border: 1px solid var(--border2); border-radius: 8px;
  color: var(--text); font-size: 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.text-input::placeholder { color: var(--text-faint); }
.text-input:focus { border-color: var(--accent); box-shadow: var(--accent-glow); }
.kbd-tips { font-size: 12px; color: var(--text-dim); line-height: 1.9; }
.kbd-tips kbd {
  background: var(--panel2); border: 1px solid var(--border2); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; font-size: 11px;
  font-family: Consolas, "Cascadia Mono", monospace;
}

/* ---------- 图层行 ---------- */
.layer-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 8px; font-size: 13px; margin-bottom: 5px;
  transition: border-color .14s, background .14s;
}
.layer-row.sel { background: var(--accent-dim-bg); border-color: var(--accent); }
.layer-row .nm { flex: 1; min-width: 0; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-row button {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 2px 5px; font-size: 13px; border-radius: 5px;
  transition: color .14s, background .14s;
}
.layer-row button:hover { color: var(--text); background: var(--panel3); }
.layer-row input[type="range"] { width: 64px; flex: none; }

/* ---------- 部件行 ---------- */
.slot-list { padding-bottom: 6px; }
.slot-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4.5px 7px; border-radius: 8px; margin-bottom: 2px;
  transition: background .12s;
}
.slot-row:hover { background: var(--panel2); }
.slot-row .eye {
  background: var(--panel2); border: 1px solid var(--border2); color: var(--text);
  width: 27px; height: 24px; border-radius: 7px; cursor: pointer;
  font-size: 12px; line-height: 1; padding: 0; flex: none;
  transition: border-color .14s, color .14s, background .14s;
}
.slot-row .eye:hover { border-color: var(--accent); color: var(--accent-hi); }
.slot-row.off .eye { background: var(--danger-bg); border-color: var(--danger-bd); color: var(--danger-tx); }
.slot-row .sn {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: Consolas, "Cascadia Mono", monospace;
}
.slot-row.off .sn { color: var(--text-faint); text-decoration: line-through; }
.parts-tools { display: flex; gap: 6px; padding: 0 0 8px; }
.parts-tools button {
  flex: 1; background: var(--panel2); border: 1px solid var(--border2);
  color: var(--text-dim); border-radius: 8px; padding: 5.5px 0;
  font-size: 12px; cursor: pointer; font-family: inherit;
  transition: border-color .14s, color .14s, background .14s;
  box-shadow: inset 0 1px 0 var(--glass-hi);
}
.parts-tools button:hover { border-color: var(--accent); color: var(--text); }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
.char-list::-webkit-scrollbar, .rp-page::-webkit-scrollbar, .slot-list::-webkit-scrollbar { width: 9px; }
.char-list::-webkit-scrollbar-thumb, .rp-page::-webkit-scrollbar-thumb, .slot-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .10); border-radius: 8px;
  border: 2px solid transparent; background-clip: content-box;
}
.char-list::-webkit-scrollbar-thumb:hover, .rp-page::-webkit-scrollbar-thumb:hover, .slot-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, .2); background-clip: content-box;
}
.char-list::-webkit-scrollbar-track, .rp-page::-webkit-scrollbar-track, .slot-list::-webkit-scrollbar-track { background: transparent; }

/* ---------- 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- 侧栏过滤行（类型 chips + 排序） ---------- */
.filter-row {
  display: flex; gap: 4px; align-items: center;
  padding: 8px 12px 2px; flex-wrap: wrap;
}
.filter-chip {
  background: transparent; border: 1px solid transparent;
  color: var(--text-faint); border-radius: 999px;
  padding: 3.5px 9px; font-size: 11.5px; cursor: pointer; font-family: inherit;
  transition: background .13s, color .13s, border-color .13s;
}
.filter-chip:hover { background: var(--panel2); color: var(--text); }
.filter-chip.on { background: var(--accent-dim-bg); color: var(--accent); border-color: transparent; font-weight: 600; }
.filter-chip .n { opacity: .6; font-size: 10px; margin-left: 2px; font-variant-numeric: tabular-nums; }
.sort-sel {
  margin-left: auto;
  background: transparent; border: none; color: var(--text-faint);
  font-size: 11.5px; cursor: pointer; font-family: inherit; outline: none;
  padding: 3px 2px; border-radius: 6px;
}
.sort-sel:hover { color: var(--text); background: var(--panel2); }
.sort-sel option { background: var(--panel); color: var(--text); }

/* ---------- 共享资源库搜索工具 ---------- */
.kit-search-box {
  position: relative;
  display: flex;
  min-width: 0;
}
.kit-grid-search {
  flex: 0 1 300px;
  min-width: 170px;
  margin-left: auto;
}
.grid-head .kit-grid-search input {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  margin-left: 0;
  padding-right: 32px;
}
.kit-gallery-search { width: 100%; }
.kit-gallery-search input { width: 100%; padding-right: 32px !important; }
.kit-search-clear {
  position: absolute;
  top: 50%; right: 6px;
  width: 22px; height: 22px;
  transform: translateY(-50%);
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-faint);
  font-family: inherit; font-size: 17px; line-height: 1; cursor: pointer;
}
.kit-search-clear:hover { background: var(--panel2); color: var(--text); }
.kit-search-clear[hidden] { display: none; }
.kit-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.kit-action {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 26px; padding: 4px 8px;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--text-faint);
  font-family: inherit; font-size: 11px; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  cursor: pointer;
}
.kit-action:hover { color: var(--accent); background: var(--accent-dim-bg); border-color: var(--border2); }
.kit-facet-select {
  max-width: 150px; min-width: 92px;
  margin-left: 8px; padding: 5px 7px;
  border: 1px solid var(--border2); border-radius: 7px;
  background: var(--panel2); color: var(--text-dim);
  font-family: inherit; font-size: 11.5px; outline: none;
}
.kit-facet-select:focus { border-color: var(--accent); box-shadow: var(--accent-glow); }
.kit-facet-select option { background: var(--panel); color: var(--text); }
.kit-density-select {
  min-width: 58px; max-width: 78px; padding: 4px 5px;
  border: 1px solid var(--border2); border-radius: 7px;
  background: var(--panel2); color: var(--text-faint);
  font-family: inherit; font-size: 11px; outline: none; cursor: pointer;
}
.kit-density-select:hover, .kit-density-select:focus {
  color: var(--text); border-color: var(--accent);
}
.kit-density-select option { background: var(--panel); color: var(--text); }

/* 资源量很大时，按阅读任务切换缩略图密度 */
.thumb-grid[data-density="compact"] {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px; padding: 14px;
}
.thumb-grid[data-density="large"] {
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 18px; padding: 24px;
}

/* ---------- 切换箭头（上/下家） ---------- */
.nav-arrows { display: flex; gap: 2px; flex: none; }
.nav-arrows .ctl { padding: 6px 8px; }

/* ---------- 重命名按钮 ---------- */
.edit-btn {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; padding: 3px 5px; border-radius: 6px; line-height: 1;
  transition: color .14s, background .14s;
}
.edit-btn:hover { color: var(--accent); background: var(--panel2); }

/* ---------- 动画列表（右栏·动画页） ---------- */
.anim-list { margin-top: 4px; }
.anim-row {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5.5px 8px; border-radius: 8px;
  background: transparent; border: none; color: var(--text);
  cursor: pointer; text-align: left; font-family: inherit; font-size: 12px;
  transition: background .12s;
}
.anim-row:hover { background: var(--panel2); }
.anim-row.on { background: var(--sel); color: var(--accent); font-weight: 600; }
.anim-row .an { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: Consolas, "Cascadia Mono", monospace; }
.anim-row .ad { flex: none; color: var(--text-faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.anim-row.on .ad { color: var(--accent); }

/* ---------- 时间轴 ---------- */
.timeline-row { padding: 2px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.timeline-row input[type="range"] { width: 100%; }
.tl-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-faint); margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.step-btns { display: flex; gap: 4px; }
.step-btns .ctl { padding: 4px 8px; font-size: 11px; }

/* ---------- 棋盘格透明底 ---------- */
.stage.checker { background: var(--bg); }
.stage.checker::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, .045) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .045) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, .045) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .045) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
  pointer-events: none;
}
.stage.checker canvas { position: absolute; z-index: 1; }

/* ---------- 缩放百分比 ---------- */
.zoom-pct {
  min-width: 46px; text-align: center; font-size: 11.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; padding: 0 2px; user-select: none;
}

/* ---------- 动效 ---------- */
@keyframes popIn {
  from { opacity: 0; transform: scale(.96) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.stage-popup { animation: popIn .14s ease; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toast 通知 ---------- */
.toast-wrap {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--glass); border: 1px solid var(--border2);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  color: var(--text); font-size: 12.5px;
  padding: 9px 14px; border-radius: 11px;
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi);
  animation: toastIn .18s ease;
  max-width: 340px; display: flex; align-items: center; gap: 8px;
}
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.ok::before { background: #57c785; }
.toast.err::before { background: #e06a6a; }

/* ---------- 右键菜单 ---------- */
.ctx-menu {
  position: fixed; z-index: 210; min-width: 168px;
  background: var(--glass); border: 1px solid var(--border2);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-radius: 12px; padding: 5px;
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--glass-hi);
  animation: popIn .13s ease;
}
.ctx-menu button {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--text);
  padding: 7px 10px; border-radius: 8px; font-size: 12.5px;
  cursor: pointer; font-family: inherit; text-align: left;
  transition: background .1s;
}
.ctx-menu button:hover { background: var(--accent-dim-bg); color: var(--accent); }
.ctx-menu button.danger { color: var(--danger-tx); }
.ctx-menu button.danger:hover { background: var(--danger-bg); }
.ctx-menu .sep { height: 1px; background: var(--border2); margin: 4px 6px; }

/* Settings and More menus share a visible exit and stay inside the viewport. */
.ctx-menu, .stage-popup.arthub-tool-popup {
  box-sizing: border-box; max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px); overflow: auto; overscroll-behavior: contain;
}
.stage-popup.arthub-tool-popup { flex-direction: column; align-items: stretch; z-index: 310; white-space: normal; }
.arthub-popup-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding-bottom: 8px; margin-bottom: 2px; border-bottom: 1px solid var(--border); }
.arthub-popup-head strong { font-size: 13px; line-height: 1.5; color: var(--text); }
:is(.ctx-menu,.stage-popup) .arthub-popup-head .arthub-popup-close {
  flex: none; width: auto; min-width: 64px; min-height: 36px; padding: 6px 9px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--panel2); border: 1px solid var(--border2); color: var(--text-dim);
  border-radius: 8px; font-size: 12px; white-space: nowrap;
}
.arthub-popup-close .arthub-icon { width: 14px; height: 14px; }
.stage-popup.arthub-tool-popup > .col { flex: none; }
.stage-popup.arthub-tool-popup .opt-row { flex-wrap: wrap; }
.ctx-menu:has(.arthub-popup-head) { min-width: 232px; }
.ctx-menu .arthub-popup-head { padding: 3px 3px 8px 9px; }
:is(.ctx-menu,.stage-popup) button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
button[data-action-label]:not([data-action-label=""])::after { content: attr(data-action-label); white-space: nowrap; font: 12px/1.3 var(--arthub-font, sans-serif); }
#gridView.library-ui .library-top-row > #btnTheme[data-action-label] { width: auto !important; padding-inline: 10px !important; gap: 5px; }

/* ---------- 快捷键速查浮层 ---------- */
.kbd-overlay {
  position: fixed; inset: 0; z-index: 220;
  background: rgba(0, 0, 0, .5);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.kbd-overlay .panel {
  background: var(--panel-grad); border: 1px solid var(--border2);
  border-radius: 16px; padding: 22px 24px;
  box-shadow: var(--shadow-2);
  display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 6px 32px;
  max-width: 620px;
}
.kbd-overlay h3 { grid-column: 1 / -1; font-size: 14px; color: var(--accent); margin-bottom: 8px; }
.kbd-overlay .krow { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 12.5px; color: var(--text-dim); padding: 3px 0; }
.kbd-overlay .krow span:last-child { color: var(--text); }

/* ---------- 面板拖拽分隔条 ---------- */
.col-drag {
  flex: none; width: 5px; cursor: col-resize;
  background: transparent; border-left: 1px solid transparent; border-right: 1px solid transparent;
  transition: background .15s, border-color .15s;
  position: relative; z-index: 5;
}
.col-drag:hover, .col-drag.dragging {
  background: var(--accent-dim-bg);
  border-left-color: var(--accent); border-right-color: var(--accent);
}
body.immersive .sidebar, body.immersive .right-panel, body.immersive .col-drag { display: none !important; }
body.immersive .immersive-exit {
  position: fixed; top: 12px; right: 12px; z-index: 90;
  opacity: .25; transition: opacity .2s;
}
body.immersive .immersive-exit:hover { opacity: 1; }

@media (max-width: 1100px) {
  .sidebar { width: 252px; min-width: 252px; }
  .right-panel { width: 282px; min-width: 282px; }
  .controls { gap: 6px; }
}

@media (max-width: 720px) {
  .kit-grid-search { order: 5; flex: 1 1 100%; min-width: 0; margin-left: 0; }
  .kit-facet-select { max-width: 120px; margin-left: 4px; }
  .kit-actions { flex-wrap: wrap; }
  .kit-action { padding-inline: 6px; }
  .kit-density-select { min-width: 56px; }
  .kbd-overlay .panel {
    width: calc(100% - 24px); max-width: 420px;
    grid-template-columns: 1fr; gap: 5px 0; padding: 18px;
  }
}

/* ============================================================
   清爽浏览模式
   只作用于加载共享层的资源库/舞台页面；主页仍由 server 模板单独负责。
   目标：减少玻璃层和按钮噪音，让“找资源”和“看资源”成为两条清楚的路径。
   ============================================================ */
html[data-gav-ui="clean"] {
  /* 保留页面布局调整，颜色 token 由背景调色板统一控制。 */
}

html[data-gav-ui="clean"] body {
  background: var(--bg);
}

/* 舞台：四个常用入口留在边缘，其余工具进“更多” */
html[data-gav-ui="clean"] body .rail {
  left: 16px !important;
  top: 16px !important;
  bottom: auto !important;
  transform: none !important;
  flex-direction: row !important;
  gap: 2px !important;
  padding: 5px !important;
  border-radius: 13px !important;
  background: var(--glass) !important;
  border: 1px solid var(--border2) !important;
  box-shadow: var(--shadow-1) !important;
}
html[data-gav-ui="clean"] body .rail button {
  width: 34px !important;
  height: 34px !important;
  border-radius: 9px !important;
}
html[data-gav-ui="clean"] body .rail .strip-sep,
html[data-gav-ui="clean"] body .rail .sep {
  width: 1px !important;
  height: 20px !important;
  margin: 7px 3px !important;
}
html[data-gav-ui="clean"] body .top-pill {
  top: 16px !important;
  max-width: min(360px, calc(100% - 420px)) !important;
  background: var(--glass) !important;
  border-color: var(--border2) !important;
  box-shadow: var(--shadow-1) !important;
}
html[data-gav-ui="clean"] body .zoom-bar {
  top: 16px !important;
  right: 16px !important;
  background: var(--glass) !important;
  border-color: var(--border2) !important;
  box-shadow: var(--shadow-1) !important;
}
html[data-gav-ui="clean"] body .tool-strip {
  top: 16px !important;
  right: 16px !important;
  bottom: auto !important;
  transform: none !important;
  flex-direction: row !important;
  gap: 2px !important;
  padding: 5px !important;
  border-radius: 13px !important;
  background: var(--glass) !important;
  border: 1px solid var(--border2) !important;
  box-shadow: var(--shadow-1) !important;
}
html[data-gav-ui="clean"] body .tool-strip button,
html[data-gav-ui="clean"] body .kit-more-tool {
  width: 36px !important;
  height: 36px !important;
  border-radius: 9px !important;
}
html[data-gav-ui="clean"] body .tool-strip .strip-sep {
  width: 1px !important;
  height: 20px !important;
  margin: 8px 3px !important;
}
html[data-gav-ui="clean"] body .tool-strip .zoom-bar {
  position: static !important;
  top: auto !important;
  right: auto !important;
  display: flex !important;
  gap: 2px !important;
  margin: 0 !important;
  padding: 2px !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
html[data-gav-ui="clean"] body .tool-strip .zoom-bar button {
  display: flex !important;
  min-width: 30px !important;
  width: 30px !important;
  height: 34px !important;
  border-radius: 9px !important;
}
html[data-gav-ui="clean"] body .tool-strip .zoom-bar .zoom-pct {
  min-width: 42px !important;
}
/* 保留适应窗口/复位视图，隐藏容易误触且占空间的连续缩放三键。 */
html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zOut,
html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zPct,
html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zIn {
  display: none !important;
}
/* 右上角只保留主要操作；适应窗口和原始比例改由手势/快捷键完成。 */
html[data-gav-ui="clean"] body .tool-strip .tool-zoom #btnFit,
html[data-gav-ui="clean"] body .tool-strip .tool-zoom #btn100,
html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zFit,
html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zReset,
html[data-gav-ui="clean"] body .tool-strip .tool-zoom,
html[data-gav-ui="clean"] body .tool-strip .tool-zoom + .strip-sep {
  display: none !important;
}
html[data-gav-ui="clean"] body .tool-strip .kit-secondary-tool {
  display: none !important;
}
html[data-gav-ui="clean"] body .kit-more-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font: 700 18px/1 inherit;
  cursor: pointer;
}
html[data-gav-ui="clean"] body .kit-more-tool:hover {
  color: var(--accent);
  background: var(--accent-dim-bg);
}
html[data-gav-ui="clean"] body .status {
  left: 16px !important;
  top: 66px !important;
  background: var(--glass) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}
html[data-gav-ui="clean"] body .hint {
  opacity: .62;
  font-size: 10px !important;
}
html[data-gav-ui="clean"] body #floatPanel {
  right: 16px !important;
  max-height: calc(100vh - 126px) !important;
  box-shadow: var(--shadow-2) !important;
}
html[data-gav-ui="clean"] body #floatPanel .rp-tabs {
  gap: 5px !important;
  padding: 11px 11px 0 !important;
}
html[data-gav-ui="clean"] body #floatPanel .rp-tabs button {
  min-height: 35px !important;
  padding: 7px 9px !important;
  border-radius: 9px !important;
  color: var(--text-dim) !important;
  background: var(--panel2) !important;
  border-color: var(--border) !important;
}
html[data-gav-ui="clean"] body #floatPanel .rp-tabs button:hover {
  color: var(--text) !important;
  border-color: var(--border2) !important;
  background: var(--panel2) !important;
}
html[data-gav-ui="clean"] body #floatPanel .rp-tabs button.on {
  color: var(--accent-hi) !important;
  background: var(--accent-dim-bg) !important;
  border-color: var(--accent) !important;
}
html[data-gav-ui="clean"] body #floatPanel .rp-page {
  padding: 12px 13px 16px !important;
}
html[data-gav-ui="clean"] body #floatPanel .anim-row {
  min-height: 34px !important;
  padding: 7px 9px !important;
}
html[data-gav-ui="clean"] body .playbar {
  border-color: var(--border2) !important;
  background: var(--glass) !important;
  box-shadow: var(--shadow-1) !important;
}

/* 网格：标题、筛选、操作分层；卡片统一留白和弱化装饰 */
html[data-gav-ui="clean"] body #gridView {
  background: var(--bg) !important;
  background-image: none !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head {
  padding: 16px 22px 13px !important;
  gap: 8px 10px !important;
  background: var(--glass) !important;
  border-bottom-color: var(--border2) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .16) !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head > .grid-title {
  order: 1;
  font-size: 18px !important;
  letter-spacing: 0 !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head > .grid-sub {
  order: 2;
  flex: 1 1 auto;
  min-width: 160px;
}
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-grid-search {
  order: 3;
  flex: 1 1 270px !important;
  min-width: 220px !important;
  margin-left: 0 !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head > #filterChips {
  order: 4;
  flex: 1 0 100% !important;
  gap: 5px !important;
  padding-top: 3px !important;
  border-top: 1px solid var(--border) !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-actions {
  order: 5;
  margin-left: auto;
  gap: 3px !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head > #btnTheme { order: 6; }
html[data-gav-ui="clean"] body #gridView .grid-head > #gridClose { order: 7; }
html[data-gav-ui="clean"] body #gridView .grid-head .filter-chip {
  padding: 5px 10px !important;
  color: var(--text-faint) !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head .filter-chip.on {
  color: var(--accent) !important;
  background: var(--accent-dim-bg) !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head .sort-sel {
  min-height: 28px;
  padding: 4px 8px !important;
  border: 1px solid var(--border2) !important;
  background: var(--panel2) !important;
  color: var(--text-dim) !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head .kit-action {
  min-height: 30px !important;
  padding: 5px 9px !important;
  border-color: var(--border) !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head .kit-action:hover {
  border-color: var(--border2) !important;
}
html[data-gav-ui="clean"] body .kit-secondary-action {
  display: none !important;
}
html[data-gav-ui="clean"] body #gridView .thumb-grid {
  max-width: 1680px;
  margin: 0 auto;
  gap: 14px !important;
  padding: 18px 22px 28px !important;
}
html[data-gav-ui="clean"] body #gridView .thumb-card {
  border-radius: 12px !important;
  border-color: var(--border) !important;
  background: var(--panel-grad) !important;
  box-shadow: none !important;
  animation-delay: 0ms !important;
}
html[data-gav-ui="clean"] body #gridView .thumb-card:hover {
  transform: translateY(-2px) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .25), var(--accent-glow) !important;
}
html[data-gav-ui="clean"] body #gridView .thumb-card .ph {
  aspect-ratio: 5 / 4 !important;
  background: var(--panel2) !important;
}
html[data-gav-ui="clean"] body #gridView .thumb-card .tm {
  padding: 8px 10px 9px !important;
}
html[data-gav-ui="clean"] body #gridView .thumb-card .tn {
  font-size: 12px !important;
}
html[data-gav-ui="clean"] body #gridView .thumb-card .ts {
  display: none !important;
}
html[data-gav-ui="clean"] body #gridView .thumb-card .tt {
  top: 8px !important;
  left: 8px !important;
  padding: 3px 7px !important;
  background: rgba(10, 14, 20, .72) !important;
}

@media (max-width: 720px) {
  html[data-gav-ui="clean"] body .rail {
    left: 10px !important;
    top: 10px !important;
  }
  html[data-gav-ui="clean"] body .top-pill {
    top: 58px !important;
    max-width: calc(100% - 20px) !important;
  }
  html[data-gav-ui="clean"] body .tool-strip {
    top: 10px !important;
    right: 10px !important;
    max-width: calc(100% - 20px) !important;
  }
  html[data-gav-ui="clean"] body .status {
    top: 106px !important;
    left: 10px !important;
    max-width: calc(100% - 20px) !important;
  }
  html[data-gav-ui="clean"] body .playbar {
    left: 10px !important;
    right: 10px !important;
    bottom: 10px !important;
    width: auto !important;
    transform: none !important;
  }
  html[data-gav-ui="clean"] body .hint {
    left: 10px !important;
    right: 10px !important;
    bottom: 62px !important;
    text-align: center !important;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head {
    padding: 13px 14px 11px !important;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .grid-sub {
    flex-basis: auto;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .kit-grid-search {
    min-width: 0 !important;
    flex-basis: 100% !important;
    order: 3;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > #filterChips {
    order: 4;
    overflow-x: auto;
    flex-wrap: nowrap !important;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .kit-actions {
    order: 5;
    margin-left: 0 !important;
    width: 100%;
    justify-content: flex-end;
  }
  html[data-gav-ui="clean"] body #gridView .thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
    padding: 12px 10px 22px !important;
  }
}

/* Portrait viewer chrome: use two full-width rows so navigation and tools cannot overlap. */
@media (max-width: 720px) and (orientation: portrait) {
  html[data-gav-ui="clean"] body .rail {
    left: 10px !important;
    right: 10px !important;
    top: 8px !important;
    bottom: auto !important;
    width: auto !important;
    max-width: calc(100% - 20px) !important;
    box-sizing: border-box !important;
    gap: 3px !important;
    padding: 4px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    justify-content: flex-start !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch;
  }
  html[data-gav-ui="clean"] body .rail::-webkit-scrollbar { display: none; }
  html[data-gav-ui="clean"] body .rail button,
  html[data-gav-ui="clean"] body .rail .rail-thumb {
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    border-radius: 9px !important;
  }
  html[data-gav-ui="clean"] body .rail .strip-sep,
  html[data-gav-ui="clean"] body .rail .sep {
    flex: 0 0 1px !important;
    width: 1px !important;
    height: 20px !important;
    margin: 7px 3px !important;
  }
  html[data-gav-ui="clean"] body .tool-strip {
    left: 10px !important;
    right: 10px !important;
    top: 52px !important;
    bottom: auto !important;
    width: auto !important;
    max-width: calc(100% - 20px) !important;
    box-sizing: border-box !important;
    justify-content: flex-start !important;
    gap: 3px !important;
    padding: 4px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
  }
  html[data-gav-ui="clean"] body .tool-strip::-webkit-scrollbar { display: none; }
  html[data-gav-ui="clean"] body .tool-strip button,
  html[data-gav-ui="clean"] body .tool-strip .kit-more-tool {
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    border-radius: 9px !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .zoom-bar {
    flex: 0 0 auto !important;
    gap: 3px !important;
    padding: 1px !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .zoom-bar button {
    flex: 0 0 30px !important;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .zoom-bar .zoom-pct {
    min-width: 38px !important;
    width: 38px !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .strip-sep {
    flex: 0 0 1px !important;
    width: 1px !important;
    height: 20px !important;
    margin: 7px 3px !important;
  }
  html[data-gav-ui="clean"] body .status {
    left: 10px !important;
    top: 100px !important;
    max-width: calc(100% - 20px) !important;
  }
  html[data-gav-ui="clean"] body #floatPanel {
    left: 10px !important;
    right: 10px !important;
    max-height: calc(100vh - 140px) !important;
  }
  html[data-gav-ui="clean"] body .playbar {
    left: 10px !important;
    right: 10px !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
    overflow: hidden !important;
    flex-wrap: nowrap !important;
    justify-content: stretch !important;
    gap: 3px !important;
    padding: 3px !important;
  }
  html[data-gav-ui="clean"] body .playbar-toggle {
    flex: 0 0 30px !important;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
  }
  html[data-gav-ui="clean"] body .playbar .playbar-controls {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    gap: 3px !important;
    overflow: hidden !important;
  }
  html[data-gav-ui="clean"] body .playbar .playbar-controls > .ctl {
    flex: 0 0 30px !important;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
  }
  html[data-gav-ui="clean"] body .playbar input[type="range"] {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 40px !important;
  }
  html[data-gav-ui="clean"] body .playbar .pb-time {
    flex: 0 0 58px !important;
    width: 58px !important;
    min-width: 58px !important;
    font-size: 10px !important;
  }
  html[data-gav-ui="clean"] body .playbar .pb-speed {
    flex: 0 1 42px !important;
    width: 42px !important;
    min-width: 34px !important;
  }
  html[data-gav-ui="clean"] body .playbar .pb-speed-val {
    flex: 0 0 22px !important;
    width: 22px !important;
    min-width: 22px !important;
    font-size: 10px !important;
  }
}

@media (max-width: 360px) and (orientation: portrait) {
  html[data-gav-ui="clean"] body .playbar #pbStepB,
  html[data-gav-ui="clean"] body .playbar #pbStepF {
    display: none !important;
  }
  html[data-gav-ui="clean"] body .playbar .pb-time {
    flex-basis: 52px !important;
    width: 52px !important;
    min-width: 52px !important;
  }
}



/* ??????????????? */
.sort-dir-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.sort-dir-toggle:hover { color: var(--text); background: var(--panel2); }
.kit-majsoul-filters {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
  min-width: 0;
}
.kit-majsoul-filters .kit-facet-select,
.kit-majsoul-filters .sort-sel {
  margin-left: 0;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: var(--panel2);
  color: var(--text-dim);
  font: inherit;
  font-size: 11.5px;
}
.kit-search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--text-faint);
  font: inherit;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
.kit-search-toggle:hover { color: var(--text); border-color: var(--accent); }
.kit-grid-search.is-collapsed {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  margin-left: auto;
}
.kit-grid-search.is-collapsed input { display: none; }
.kit-grid-search.is-collapsed .kit-search-clear { display: none; }
.kit-grid-search:not(.is-collapsed) .kit-search-toggle { display: inline-flex; }
.grid-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 42px;
  padding: 8px 14px 18px;
  color: var(--text-faint);
}
.grid-pagination[hidden] { display: none; }
.grid-page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.grid-page-btn:hover:not(:disabled) { color: var(--text); border-color: var(--accent); background: var(--panel2); }
.grid-page-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-dim-bg); font-weight: 600; }
.grid-page-btn:disabled { opacity: .38; cursor: default; }
.grid-page-gap { min-width: 20px; text-align: center; color: var(--text-faint); }
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-grid-search.is-collapsed {
  flex: 0 0 34px !important;
  width: 34px !important;
  min-width: 34px !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-grid-search.is-collapsed input { display: none !important; }
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-majsoul-filters { gap: 5px !important; }
@media (max-width: 720px) {
  .kit-majsoul-filters { flex: 1 1 100%; order: 4; overflow-x: auto; }
  .kit-majsoul-filters .kit-facet-select,
  .kit-majsoul-filters .sort-sel { flex: 0 0 auto; }
  html[data-gav-ui="clean"] body #gridView .grid-head > .kit-grid-search.is-collapsed {
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
  }
  .grid-pagination { gap: 3px; padding-left: 8px; padding-right: 8px; }
  .grid-page-btn { min-width: 28px; padding-left: 6px; padding-right: 6px; }
}


/* ---------- Consolidated viewer controls ---------- */
/* Compact playback controls and mobile resource-library chrome. */
.playbar {
  width: auto !important;
  min-width: 0 !important;
  flex-wrap: nowrap !important;
  padding: 4px !important;
  gap: 4px !important;
}
.playbar .playbar-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  width: min(790px, calc(100vw - 60px));
}
.playbar-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--panel2);
  color: var(--text-dim);
  font: 700 18px/1 inherit;
  cursor: pointer;
}
.playbar-toggle:hover { color: var(--accent); background: var(--accent-dim-bg); }
.playbar.collapsed .playbar-controls { display: none !important; }
.playbar.collapsed { border-radius: 11px !important; }
html[data-gav-ui="clean"] body .hint,
html[data-gav-ui="clean"] body .kbd-tips { display: none !important; }

/* Resource-library actions. */
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-home-action {
  order: 0;
  flex: 0 0 auto;
  margin: 0 !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-actions {
  order: 0;
  margin: 0 !important;
}
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-home-action,
html[data-gav-ui="clean"] body #gridView .grid-head > .kit-actions .kit-home-action {
  min-height: 30px !important;
  padding: 5px 9px !important;
  border-color: var(--border) !important;
}

/* Thumbnail density selector inside the theme palette. */
.theme-palette-density {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  padding: 7px 8px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--text-dim);
  font-size: 12px;
}
.theme-palette-density select {
  min-width: 74px;
  padding: 4px 6px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
.theme-palette-density select:focus { border-color: var(--accent); }

/* Mobile layout. */
@media (max-width: 720px) {
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom {
    display: flex !important;
    position: static !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 1px !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zOut,
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zIn,
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zPct {
    display: inline-flex !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom #btnFit,
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom #btn100,
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zFit,
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zReset {
    display: none !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom #zPct,
  html[data-gav-ui="clean"] body .tool-strip .zoom-pct {
    min-width: 44px !important;
    width: 44px !important;
  }

  html[data-gav-ui="clean"] body #gridView .grid-head {
    padding: 8px 10px 7px !important;
    gap: 5px 6px !important;
    transition: transform .18s ease, opacity .18s ease, max-height .18s ease, padding .18s ease;
  }
  html[data-gav-ui="clean"] body #gridView.kit-grid-scrolling .grid-head {
    transform: translateY(-105%);
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .grid-sponsor {
    order: 4;
    display: inline-flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: 30px !important;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    gap: 3px !important;
    margin-left: auto !important;
    margin-right: 0 !important;
    padding: 0 8px !important;
    border-radius: 9px !important;
    font-size: 0 !important;
    line-height: 1;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .grid-sponsor::before {
    content: '\2665  \7231\53d1\7535';
    font-size: 11px;
    line-height: 1;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .grid-title {
    order: 1;
    flex: 0 1 auto;
    min-width: 0;
    font-size: 15px !important;
    white-space: nowrap;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .grid-sub {
    order: 3;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .kit-home-action {
    order: 0;
    min-height: 30px !important;
    padding: 5px 7px !important;
    font-size: 10px !important;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .kit-grid-search {
    order: 5;
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    margin-left: 0 !important;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > .kit-grid-search:not(.is-collapsed) {
    flex: 1 1 100% !important;
    width: auto !important;
    order: 6;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > #btnTheme {
    order: 6;
    flex: 0 0 34px;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > #gridClose {
    order: 7;
    min-height: 30px !important;
    padding: 5px 7px !important;
    font-size: 10px !important;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > #filterChips {
    order: 8;
    flex: 1 0 100% !important;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap !important;
    white-space: nowrap;
    scrollbar-width: none;
    padding-top: 2px !important;
    border-top: 0 !important;
  }
  html[data-gav-ui="clean"] body #gridView .grid-head > #filterChips::-webkit-scrollbar { display: none; }
  html[data-gav-ui="clean"] body #gridView .thumb-grid {
    padding-top: 9px !important;
  }
  .playbar .playbar-controls {
    width: min(790px, calc(100vw - 62px));
  }
  .playbar.collapsed { bottom: 10px !important; }
}

/* Mobile portrait zoom and animation dock. */
@media (max-width: 720px) and (orientation: portrait) {
  html[data-gav-ui="clean"] body .tool-strip {
    left: auto !important;
    right: 10px !important;
    top: auto !important;
    bottom: calc(58px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100vh - 150px) !important;
    box-sizing: border-box !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 3px !important;
    padding: 4px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-width: none !important;
    touch-action: pan-y !important;
  }
  html[data-gav-ui="clean"] body .tool-strip::-webkit-scrollbar { display: none; }
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom {
    flex-direction: column !important;
    align-items: center !important;
    gap: 2px !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .strip-sep {
    flex: 0 0 1px !important;
    width: 20px !important;
    height: 1px !important;
    margin: 3px auto !important;
  }
  html[data-gav-ui="clean"] body .status {
    top: 60px !important;
    max-width: calc(100% - 20px) !important;
  }
}

/* Phone controls have a separate bottom layout; desktop keeps its two corners. */
.status.load-error { pointer-events: auto !important; cursor: pointer; }
.grid-pagination-top { display: none; }
.grid-head .grid-sponsor {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border: 1px solid var(--accent); border-radius: 9px;
  color: var(--accent); font-size: 11px; text-decoration: none; white-space: nowrap;
}
.rail .rail-thumb { font-size: 8px; text-align: center; color: var(--text-faint); }
.thumb-card .ph:has(img) { color: transparent; }
@media (max-width: 720px) {
  html[data-gav-ui="clean"] body .status.status-quiet { visibility: hidden; }
  .grid-pagination-top { display: flex; padding: 6px 8px 0; }
  .grid-pagination { min-height: 44px; }
  .grid-page-btn { height: 40px; min-width: 32px; }
  html[data-gav-ui="clean"] body .rail {
    top: auto !important; left: calc(8px + env(safe-area-inset-left)) !important;
    right: auto !important; bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    transform: none !important; width: auto !important; max-width: calc(100vw - 84px) !important;
    min-height: 0 !important; flex-direction: row !important; gap: 2px !important;
    padding: 4px !important; border-radius: 14px !important; overflow: visible !important;
  }
  html[data-gav-ui="clean"] body .rail .rail-thumb,
  html[data-gav-ui="clean"] body .rail .rail-sep,
  html[data-gav-ui="clean"] body .rail .strip-sep,
  html[data-gav-ui="clean"] body .rail .sep { display: none !important; }
  html[data-gav-ui="clean"] body .rail button {
    flex: 0 0 44px !important; width: 44px !important; height: 44px !important;
  }
  html[data-gav-ui="clean"] body .tool-strip {
    top: auto !important; left: auto !important;
    right: calc(8px + env(safe-area-inset-right)) !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    transform: none !important; flex-direction: column !important;
    width: 56px !important; max-height: calc(100dvh - 96px) !important;
    padding: 4px !important; gap: 2px !important; border-radius: 14px !important;
    overflow-x: hidden !important; overflow-y: auto !important;
  }
  html[data-gav-ui="clean"] body .tool-strip button,
  html[data-gav-ui="clean"] body .tool-strip .kit-more-tool,
  html[data-gav-ui="clean"] body .tool-strip .zoom-bar button {
    flex: 0 0 44px !important; width: 44px !important; height: 44px !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .tool-zoom {
    flex-direction: column !important; gap: 0 !important;
  }
  html[data-gav-ui="clean"] body .tool-strip .zoom-pct {
    display: flex !important; align-items: center; justify-content: center;
    min-height: 36px !important; font-size: 11px;
  }
  html[data-gav-ui="clean"] body .tool-strip .strip-sep { display: none !important; }
  html[data-gav-ui="clean"] body .status {
    top: calc(10px + env(safe-area-inset-top)) !important; left: 10px !important;
    max-width: calc(100vw - 20px) !important; font-size: 11px !important;
  }
  html[data-gav-ui="clean"] body #floatPanel {
    top: auto !important; left: 8px !important; right: 8px !important;
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    transform: none !important; width: auto !important;
    height: min(440px, 54dvh) !important; max-height: calc(100dvh - 108px) !important;
    border-radius: 18px 18px 12px 12px !important; z-index: 32 !important;
    animation: none !important;
  }
  #floatPanel .rp-panel-close, #floatPanel .rp-tabs button { min-height: 40px; }
  html[data-gav-ui="clean"] body .playbar {
    top: auto !important; left: 8px !important; right: 76px !important;
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    transform: none !important; max-width: none !important; width: auto !important;
    align-items: flex-start !important; overflow: visible !important;
  }
  html[data-gav-ui="clean"] body .playbar.collapsed {
    right: auto !important; width: 54px !important; height: 54px !important;
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    box-sizing: border-box !important;
  }
  html[data-gav-ui="clean"] body .playbar-toggle {
    flex: 0 0 44px !important; width: 44px !important; height: 44px !important;
  }
  html[data-gav-ui="clean"] body .playbar .playbar-controls {
    display: grid !important; grid-template-columns: 44px minmax(24px, 1fr) 58px;
    grid-template-rows: 44px 44px; gap: 0 4px !important;
    flex: 1 1 auto !important; width: auto !important; min-width: 0 !important;
  }
  html[data-gav-ui="clean"] body .playbar.collapsed .playbar-controls { display: none !important; }
  html[data-gav-ui="clean"] body .playbar .playbar-controls > .ctl {
    width: 44px !important; min-width: 0 !important; height: 44px !important; padding: 0 !important;
  }
  .playbar #pbPlay { grid-row: 1; grid-column: 1; }
  .playbar #pbRange { grid-row: 1; grid-column: 2; }
  .playbar #pbTime { grid-row: 1; grid-column: 3; }
  .playbar #pbLoop { grid-row: 2; grid-column: 1; }
  .playbar #pbSpeed { grid-row: 2; grid-column: 2; }
  .playbar #pbSpeedVal { grid-row: 2; grid-column: 3; }
  html[data-gav-ui="clean"] body .playbar #pbStepB,
  html[data-gav-ui="clean"] body .playbar #pbStepF { display: none !important; }
  html[data-gav-ui="clean"] body .playbar input[type="range"] {
    min-width: 0 !important; width: 100% !important; height: 44px; margin: 0 !important;
    background: transparent !important; border: 0 !important; appearance: none;
  }
  html[data-gav-ui="clean"] body .playbar input[type="range"]::-webkit-slider-runnable-track {
    height: 4px; border-radius: 4px; background: var(--border2);
  }
  html[data-gav-ui="clean"] body .playbar input[type="range"]::-webkit-slider-thumb {
    margin-top: -7px; width: 18px; height: 18px;
  }
  html[data-gav-ui="clean"] body .playbar input[type="range"]::-moz-range-track {
    height: 4px; border-radius: 4px; background: var(--border2);
  }
  html[data-gav-ui="clean"] body .playbar .pb-time {
    min-width: 0 !important; width: auto !important; padding: 0 !important;
    white-space: normal !important; font-size: 10px !important; line-height: 1.4;
  }
  html[data-gav-ui="clean"] body .playbar .pb-speed-val {
    display: flex; align-items: center; justify-content: center; min-width: 0 !important;
  }
  html[data-gav-ui="clean"] body #gridView.kit-grid-scrolling .grid-head {
    max-height: none; padding: 8px 10px 7px !important;
  }
  .thumb-card .tstar { min-width: 40px; min-height: 40px; }
  .stage-popup {
    max-width: calc(100vw - 16px); max-height: 60dvh;
    box-sizing: border-box; overflow: auto; white-space: normal;
  }
  .stage-popup button { min-height: 40px; }
  .stage-popup .col-title { line-height: 1.5; }
}

/* Keep visibility controls in place while only the part rows scroll. */
#floatPanel .rp-page.parts-panel.on { display: flex !important; flex-direction: column; min-height: 0; overflow: hidden; }
#floatPanel .parts-controls { flex: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 7px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
#floatPanel .parts-controls .parts-search-row { position: relative; flex: none; display: flex; align-items: center; gap: 7px; min-width: 0; margin: 0; flex-wrap: nowrap; }
#floatPanel .parts-controls .text-input { flex: 1 1 0; width: 0; min-width: 0; height: 34px; min-height: 34px; box-sizing: border-box; padding: 6px 9px 6px 30px; border: 1px solid var(--border2); border-radius: 8px; background: var(--panel2); color: var(--text); font: 12px/1.4 var(--font, sans-serif); }
#floatPanel .parts-search-icon { position: absolute; left: 9px; top: 10px; display: flex; color: var(--text-faint); pointer-events: none; }
#floatPanel .parts-toolbar, #floatPanel .parts-filters { display: flex; align-items: center; gap: 4px; min-width: 0; }
#floatPanel .parts-toolbar { gap: 3px; }
html[data-gav-ui="clean"] #floatPanel .parts-panel .parts-controls button { flex: none; min-width: 0; min-height: 32px; padding: 5px 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--text-dim); font: 12px/1.35 var(--font, sans-serif); white-space: nowrap; cursor: pointer; }
html[data-gav-ui="clean"] #floatPanel .parts-panel .parts-controls button[aria-pressed="true"] { border-color: transparent; background: var(--accent-dim-bg); color: var(--accent-hi); }
html[data-gav-ui="clean"] #floatPanel .parts-panel .parts-controls button:hover:not(:disabled) { background: var(--panel2); color: var(--text); }
html[data-gav-ui="clean"] #floatPanel .parts-panel .parts-controls button:disabled { opacity: .35; cursor: default; }
html[data-gav-ui="clean"] #floatPanel .parts-panel .parts-controls button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#floatPanel .parts-toolbar .parts-undo { margin-left: auto; }
#floatPanel .parts-toolbar .parts-more { display: inline-flex; align-items: center; gap: 3px; }
#floatPanel .parts-panel .parts-actions, #floatPanel .parts-panel > #partEditHint { display: none !important; }
#floatPanel .parts-controls .parts-pick-control { flex: none; margin: 0; min-width: 0; flex-wrap: nowrap !important; }
#floatPanel .parts-controls .parts-pick-control > :is(small, .vp-mode-state) { display: none; }
#floatPanel .parts-panel .parts-controls #exitPartEdit { width: auto; min-height: 34px !important; height: 34px; margin: 0; padding: 5px 9px; border: 1px solid var(--border2); font-size: 12px; }
#floatPanel .parts-panel .parts-controls #exitPartEdit[aria-pressed="true"] { border-color: var(--accent); }
#floatPanel .parts-panel .parts-list { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
#floatPanel .parts-list > :is(.slot-row, .viewer-part-row) { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 2px 4px; border-radius: 8px; }
html[data-gav-ui="clean"] #floatPanel .parts-panel .parts-list .eye { display: grid; place-items: center; flex: none; width: 32px; height: 32px; min-height: 32px; padding: 6px !important; border: 0; border-radius: 6px; background: transparent; color: var(--text-dim); }
html[data-gav-ui="clean"] #floatPanel .parts-panel .parts-list .eye:hover { background: var(--panel2); color: var(--text); }
#floatPanel .parts-list .parts-part-name { flex: 1; min-width: 0; white-space: normal; overflow: visible; overflow-wrap: anywhere; text-overflow: clip; line-height: 1.5; }
#floatPanel .parts-list .off .parts-part-name { color: var(--text-faint); text-decoration: line-through; }
#floatPanel .parts-list .parts-focused { background: var(--accent-dim-bg); box-shadow: inset 0 0 0 1px var(--accent); }
@media (max-height: 560px) {
  html[data-gav-ui="clean"] body #floatPanel[aria-label].open:has(> .parts-panel.on) { top: 8px !important; bottom: 8px !important; height: auto !important; max-height: calc(100dvh - 16px) !important; transform: none !important; }
}

.png-size-settings { padding: 8px 0; border-top: 1px solid var(--border2); }
.png-size-settings summary { cursor: pointer; color: var(--text-dim); line-height: 1.6; }
.png-size-settings label { display: grid; gap: 6px; margin-top: 10px; }
.png-size-settings label[hidden] { display: none; }
.png-size-settings select, .png-size-settings input { width: 100%; box-sizing: border-box; min-height: 40px; padding: 8px 10px; color: var(--text); background: var(--panel2); border: 1px solid var(--border2); border-radius: 8px; font: inherit; }
.png-size-settings small { display: block; margin-top: 8px; line-height: 1.6; }
.export-detail { overflow-wrap: anywhere; }
/* Full-resolution transparent posters fit the same stage as the final model. */
.stage-loading-preview {
  position: absolute; inset: 0; z-index: 2;
  display: block;
  pointer-events: none;
}
.stage-loading-preview[hidden] { display: none; }
.stage.loading-preview-active > canvas { opacity: 0; }
.stage-loading-picture { position: absolute; inset: 4%; }
.stage-loading-preview[data-fit="0.85"] .stage-loading-picture { inset: 7.5%; }
.stage-loading-image { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
.stage-loading-preview.has-preview .stage-loading-image { opacity: 1; }
.stage-loading-notice {
  position: absolute; left: 50%; bottom: calc(94px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: min(480px, calc(100% - 40px)); padding: 10px 15px; box-sizing: border-box;
  color: var(--text); background: var(--glass); border: 1px solid var(--border2);
  border-radius: 14px; text-align: center; backdrop-filter: blur(12px);
}
.stage-loading-title { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.stage-loading-preview.has-preview .stage-loading-title { display: none; }
.stage-loading-state { display: flex; align-items: center; justify-content: center; gap: 9px; font-size: 13px; }
.stage-loading-spinner {
  width: 17px; height: 17px; flex: none; border: 2px solid var(--border2);
  border-top-color: var(--accent-hi); border-radius: 50%; animation: stage-loading-spin .8s linear infinite;
}
.stage-loading-preview[data-state="error"] .stage-loading-spinner { display: none; }
.stage-loading-retry { pointer-events: auto; min-width: 76px; min-height: 40px; }
.stage-loading-retry[hidden] { display: none; }
@keyframes stage-loading-spin { to { transform: rotate(360deg); } }
@media (max-width: 720px) {
  .stage-loading-notice { left: calc((100% - 68px) / 2); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 90px); padding: 10px 13px; }
  .stage-loading-retry { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .stage-loading-spinner { animation: none; }
}
