/* ==========================================================================
   瀑布流图片浏览器 · 样式表
   设计系统：双主题（毛玻璃 / 极简暗色）+ 统一变量 + 平滑动效
   ========================================================================== */

/* ---------- 基础变量 ---------- */
:root {
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.22s;

  /* JS 写入的动态变量（保持原名，供 script 使用） */
  --colgap: 0px;
  --rowgap: 0px;
  --imgradius: 0px;
  --imgborder: 0px;
  --opacity: 1;
  --bg-image: none;
  --blur-strength: 22px;
}

/* ---------- 主题一：毛玻璃 ---------- */
:root[data-theme="glass"],
:root[data-theme="glass"] {
  --bg: #0a0c11;
  --bg-glow:
    radial-gradient(1100px 560px at 82% -8%, rgba(99, 139, 255, 0.16), transparent 62%),
    radial-gradient(900px 520px at -6% 108%, rgba(140, 90, 255, 0.10), transparent 60%);
  --panel-bg: rgba(19, 21, 27, 0.55);
  --panel-bg-solid: rgba(17, 19, 24, 0.92);
  --panel-blur: var(--blur-strength, 22px);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #eef1f6;
  --text-dim: rgba(233, 238, 248, 0.55);
  --accent: #6ea8ff;
  --accent-strong: #8dbcff;
  --on-accent: #0b0e14;
  --accent-soft: rgba(110, 168, 255, 0.16);
  --hover-bg: rgba(255, 255, 255, 0.08);
  --shadow: 0 12px 44px rgba(0, 0, 0, 0.55);
}

/* ---------- 主题二：极简暗色 ---------- */
:root[data-theme="minimal"] {
  --bg: #0d0d0f;
  --bg-glow: none;
  --panel-bg: #15161a;
  --panel-bg-solid: #15161a;
  --panel-blur: 0px;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #ececec;
  --text-dim: rgba(255, 255, 255, 0.48);
  --accent: #ffffff;
  --accent-strong: #ffffff;
  --on-accent: #0d0d0f;
  --accent-soft: rgba(255, 255, 255, 0.10);
  --hover-bg: rgba(255, 255, 255, 0.06);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

/* ---------- 基础与全局 ---------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color, var(--bg, #0b0d12));
  background-image: var(--bg-image, none), var(--bg-glow, none);
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  display: flex;
  overflow-y: scroll;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  transition: background-color 0.3s var(--ease);
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

/* 自定义滚动条（WebKit） */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.30);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 图标基础 ---------- */
.ico {
  width: 20px;
  height: 20px;
  display: block;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* ---------- 空状态提示 ---------- */
#hint {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 24px;
}
.hint-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 44px 52px;
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease);
}
#hint:hover .hint-card {
  transform: translateY(-3px);
  border-color: var(--border-strong);
}
.hint-card .hint-ico {
  width: 56px;
  height: 56px;
  color: var(--accent);
  stroke-width: 1.4;
}
.hint-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hint-card p {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
}
.hint-btn {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 6px 18px var(--accent-soft);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.hint-card:hover .hint-btn {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px var(--accent-soft);
}
.hint-btn .ico {
  width: 18px;
  height: 18px;
}
.hint-foot {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.75;
}

/* ---------- 定位辅助 ---------- */
#cursorplace {
  position: fixed;
  height: 100%;
  width: 1px;
  z-index: 1;
}

/* ---------- 滚动指示器 ---------- */
#indicator {
  position: fixed;
  top: 0;
  right: 20px;
  min-width: 46px;
  height: 34px;
  padding: 0 10px;
  display: none;
  place-items: center;
  pointer-events: none;
  background: var(--panel-bg-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: scrollmove linear;
  animation-timeline: scroll();
}
#indicator.show {
  display: grid;
}
@keyframes scrollmove {
  from {
    top: 10px;
  }
  to {
    top: calc(100vh - 44px);
  }
}

/* ---------- 瀑布流布局 ---------- */
#imgbox {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  line-height: 0;
  column-gap: var(--colgap);
  padding: 0;
  transition: margin-right 0.3s var(--ease);
}
body.tree-pinned:not(.pin-overlay) #imgbox {
  margin-right: var(--treebar-width, 320px);
}
.colflex {
  align-items: flex-start;
}
/* 混合式瀑布流（拼贴 / 宽窄）：非等高、不同尺寸混排 */
/* 注意：#imgbox 是 ID 选择器，须用 #imgbox.xxx 覆盖其 display:flex */
#imgbox.mosaic {
  display: block;
}
#imgbox.mixedcols {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
}

/* 拼贴（马赛克砖块）：CSS Grid 密集填充，砖块按宽高比匹配、等比缩放少量裁剪 */
.mosgrid {
  display: grid;
  grid-auto-flow: row dense;
  align-items: stretch;
  justify-items: stretch;
}
.mosgrid .wrap {
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}
.mosgrid .wrap > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 宽窄栏：复用 .imgcol，通过 flex-grow 权重（2:1 交替）实现宽窄不一 */
#imgbox.mixedcols .imgcol {
  min-width: 0;
}

.imgcol {
  flex: 1;
  display: flex;
  flex-direction: column;
  row-gap: var(--rowgap);
  min-width: 0;
}
.wrap {
  position: relative;
  cursor: pointer;
  border-radius: calc(var(--imgradius) + 3px);
  overflow: visible;
}
.wrap > img {
  width: 100%;
  height: auto;
  display: block;
  box-sizing: border-box;
  border: solid var(--text);
  border-radius: var(--imgradius);
  border-width: var(--imgborder);
  transition: filter 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.wrap:hover > img {
  filter: brightness(1.08);
}
img {
  user-select: none;
  -webkit-user-drag: none;
}
#rep {
  visibility: hidden;
}

/* ---------- 图片信息条（hover） ---------- */
.wrap:hover > .info {
  visibility: visible;
  opacity: 1;
}
.info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 4px 4px;
  padding: 8px 10px;
  text-align: center;
  line-height: 1.45;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.6);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}
.info > span {
  cursor: text;
  word-break: break-all;
}

/* ---------- 图片选择框 ---------- */
.imgsel {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  z-index: 3;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.30);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  user-select: none;
  opacity: 0.55;
  transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.wrap:hover .imgsel {
  opacity: 1;
}
.imgsel.checked {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
}
.imgsel.checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 7px;
  height: 11px;
  border-right: 2.5px solid var(--on-accent);
  border-bottom: 2.5px solid var(--on-accent);
  transform: rotate(45deg);
}

/* ---------- 图片标签 ---------- */
.imgtag {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.imgtag:empty {
  display: none;
}

/* ---------- 文件夹分隔线 ---------- */
.foldersep {
  width: 100%;
  border-top: 1px solid var(--border);
  margin: 16px 0;
  box-sizing: border-box;
}

/* ---------- 目录标记（隐藏占位） ---------- */
.mark {
  height: 0;
  width: 0;
  overflow: hidden;
}

/* ---------- 图片查看遮罩（lightbox） ---------- */
#cover {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  outline: none;
  background: rgba(5, 6, 9, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  cursor: zoom-out;
}
#cover.show {
  display: block;
  animation: fadeIn 0.18s var(--ease);
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.zoom {
  position: fixed;
  will-change: transform;
}

/* ---------- 浮动按钮 ---------- */
.floatbtn,
.scrollbtn {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  box-shadow: var(--shadow);
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    color 0.16s var(--ease), transform 0.16s var(--ease), opacity 0.16s var(--ease),
    right 0.3s var(--ease);
  outline: none;
}
.floatbtn:hover,
.scrollbtn:hover {
  border-color: var(--border-strong);
  background: var(--panel-bg-solid);
  color: var(--accent-strong);
}
.floatbtn:active,
.scrollbtn:active {
  transform: scale(0.94);
}

.floatbtn {
  position: fixed;
  z-index: 30;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 20px;
}

#previmg,
#nextimg {
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
  z-index: 41;
}
#previmg {
  left: 18px;
}
#nextimg {
  right: 18px;
}
#previmg:hover,
#nextimg:hover {
  opacity: 1;
}

#sidebtn {
  top: 18px;
  right: 18px;
  left: auto;
  opacity: var(--opacity);
}
#sidebtn:hover {
  opacity: 1;
}

#treebtn {
  top: calc(50% - 52px);
  right: 0;
  left: auto;
  height: 104px;
  width: 40px;
  border-radius: 12px 0 0 12px;
  border-right: none;
  opacity: var(--opacity);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
#treebtn .treebtn-label {
  font-size: 12px;
  letter-spacing: 0.18em;
  writing-mode: vertical-rl;
  color: var(--text-dim);
  pointer-events: none;
}
#treebtn:hover {
  opacity: 1;
}
#treebtn.open {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
#treebtn.open .treebtn-label {
  color: var(--on-accent);
}

/* 目录树触发位置的小图标提示（导入文件后显示） */
.treebadge {
  position: fixed;
  top: calc(50% - 46px);
  right: 6px;
  z-index: 29;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 0 10px var(--accent-soft);
  display: none;
  pointer-events: none;
  animation: treepulse 2.2s ease-in-out infinite;
}
body.hasfiles .treebadge {
  display: block;
}
@keyframes treepulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.5; }
}

.scrollbtn {
  position: fixed;
  z-index: 30;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), background 0.16s var(--ease),
    border-color 0.16s var(--ease), color 0.16s var(--ease);
}
body.scrolled .scrollbtn {
  opacity: 0.7;
  pointer-events: auto;
}
.scrollbtn:hover {
  opacity: 1;
}
#totop {
  bottom: 88px;
  left: 20px;
}
#toend {
  bottom: 44px;
  left: 20px;
}

/* ---------- 侧边栏 ---------- */
#sidebar {
  position: fixed;
  top: 16px;
  right: 16px;
  left: auto;
  z-index: 32;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  white-space: nowrap;
  transform: translateX(calc(100% + 40px));
  visibility: hidden;
  transition: transform 0.3s var(--ease), visibility 0.3s, right 0.3s var(--ease);
}
#sidebar.show {
  transform: translateX(0);
  visibility: visible;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.sidebar-header .app-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.sidebar-header .app-sub {
  font-size: 12px;
  color: var(--text-dim);
}
#sidebarClose {
  position: relative;
  width: 30px;
  height: 30px;
  padding: 0;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
#sidebarClose .ico {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
}
#sidebarClose:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 14px 2px 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.group-title:first-of-type {
  margin-top: 6px;
}

.row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
}
.row > label {
  width: 46px;
  flex: 0 0 46px;
  font-size: 13px;
  color: var(--text-dim);
}
.row .grow {
  flex: 1 1 auto;
  min-width: 0;
}
.row output {
  width: 26px;
  flex: 0 0 26px;
  text-align: right;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.row .wide {
  flex: 1 1 auto;
}

/* 统计信息行 */
.stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 2px 0;
}
.stat {
  flex: 1 1 auto;
  min-width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  background: var(--hover-bg);
  border: 1px solid var(--border);
}
.stat b {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stat span {
  font-size: 11px;
  color: var(--text-dim);
}

/* ---------- 侧边栏控件 ---------- */
#sidebar button,
#sidebar select,
#sidebar [type="text"] {
  outline: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    color 0.15s var(--ease);
}
#sidebar button {
  padding: 7px 12px;
  white-space: nowrap;
}
#sidebar button:hover,
#sidebar select:hover,
#sidebar [type="text"]:hover {
  border-color: var(--border-strong);
  background: var(--hover-bg);
}
#sidebar button:active {
  background: var(--accent-soft);
}
#sidebar button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
#sidebar select {
  padding: 7px 8px;
  text-align: center;
  text-align-last: center;
  width: 100%;
}
#sidebar [type="text"] {
  width: 100%;
  padding: 7px 10px;
  text-align: center;
  box-sizing: border-box;
}
#sidebar select option {
  background: var(--panel-bg-solid);
  color: var(--text);
}

/* 双按钮分段（纵向/横向） */
.seg {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
}
.seg button {
  flex: 1;
  padding: 7px 0;
}

/* 主题切换 */
.theme-switch {
  display: flex;
  gap: 8px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--hover-bg);
  border: 1px solid var(--border);
}
.theme-switch button {
  flex: 1;
  padding: 8px 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}
.theme-switch button.active {
  background: var(--panel-bg-solid);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ---------- 滑块 ---------- */
#sidebar [type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
#sidebar [type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
}
#sidebar [type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}
#sidebar [type="range"]:hover::-webkit-slider-thumb {
  background: var(--accent);
  transform: scale(1.12);
}
#sidebar [type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
}
#sidebar [type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  border: none;
}
#sidebar [type="range"]:hover::-moz-range-thumb {
  background: var(--accent);
}

/* 颜色选择 */
#sidebar [type="color"] {
  width: 40px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}
#sidebar [type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}
#sidebar [type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

/* 提示浮层 */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: help;
  color: var(--text-dim);
  font-size: 13px;
}
.tip .tootip {
  display: none;
  position: absolute;
  left: 0;
  bottom: 130%;
  width: 260px;
  padding: 10px 12px;
  background: var(--panel-bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
  z-index: 5;
}
.tip:hover .tootip {
  display: block;
}

/* ---------- 目录树侧栏 ---------- */
#treebar {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 34;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  box-shadow: var(--shadow);
  width: clamp(240px, 32vw, 520px);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s var(--ease), visibility 0.3s;
}
#treebar.show {
  transform: translateX(0);
  visibility: visible;
}

/* 目录树固定·叠加模式：背景完全透明，图片不移动 */
body.pin-overlay.tree-pinned #treebar {
  background: transparent;
  border-left: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.pin-overlay.tree-pinned #treeToolbar {
  background: rgba(10, 12, 17, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
body.pin-overlay.tree-pinned #dirtree li {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 6px rgba(0, 0, 0, 0.5);
}
body.pin-overlay.tree-pinned #dirtree li:hover {
  background: rgba(0, 0, 0, 0.34);
}
body.pin-overlay.tree-pinned #dirtree li.active {
  background: rgba(110, 168, 255, 0.28);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

/* ---------- 固定目录树时，右侧浮层让位（设置/快捷工具/侧边按钮/速度条） ---------- */
body.tree-pinned #sidebar {
  right: calc(16px + var(--treebar-width, 320px));
  width: min(380px, calc(100vw - 32px - var(--treebar-width, 320px)));
}
body.tree-pinned #quickbarHost {
  right: calc(14px + var(--treebar-width, 320px));
}
body.tree-pinned #floatSpeed {
  right: calc(84px + var(--treebar-width, 320px));
}
body.tree-pinned #sidebtn {
  right: calc(18px + var(--treebar-width, 320px));
}

#resizebar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100vh;
  width: 8px;
  cursor: ew-resize;
  background: var(--border);
  opacity: 0.4;
  transition: opacity 0.15s var(--ease);
  z-index: 2;
}
#resizebar:hover {
  opacity: 0.9;
  background: var(--accent);
}

#dirtree {
  position: absolute;
  left: 8px;
  top: 0;
  width: calc(100% - 8px);
  height: 100vh;
  overflow-y: auto;
  line-height: 1.2;
}

#treeToolbar {
  position: sticky;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px;
  background: var(--panel-bg-solid);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  z-index: 3;
}
#treeToolbar.hidden {
  display: none;
}
#treeToolbar button {
  min-width: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--hover-bg);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    color 0.15s var(--ease);
}
#treeToolbar button:hover {
  border-color: var(--border-strong);
  background: var(--panel-bg);
  color: var(--accent-strong);
}
#treeToolbar button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
#treeToolbar #pinReserve,
#treeToolbar #pinOverlay {
  display: flex;
  align-items: center;
  gap: 5px;
}
#treeToolbar #pinReserve .ico,
#treeToolbar #pinOverlay .ico {
  width: 15px;
  height: 15px;
}
.treebar-title {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 2px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.treebar-title .ico {
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.treebar-title b {
  margin-left: auto;
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  color: var(--text-dim);
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
}
#treeToolbar button.danger:hover {
  border-color: rgba(255, 96, 96, 0.6);
  color: #ff7a7a;
}

/* 目录树列表 */
#dirtree > ul {
  margin: 8px 0;
  padding-left: 4px;
}
ul {
  direction: ltr;
  margin: 0 0 0 12px;
  padding: 0 0 0 6px;
  list-style: none;
  border-left: 1px solid var(--border);
}
li {
  position: relative;
  z-index: 1;
  min-width: 100%;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 5px 8px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
}
li:hover {
  border-color: var(--border);
  background: var(--hover-bg);
}
li.active {
  background: var(--accent-soft);
  border-color: var(--border-strong);
}
li.visited {
  opacity: 0.72;
}
li .name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
li .tag {
  margin-left: 6px;
  opacity: 0.85;
  font-size: 12px;
  color: var(--text-dim);
}
li .dir-ico {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  color: var(--text-dim);
  opacity: 0.8;
}

/* 折叠箭头（twisty） */
li .twisty {
  display: inline-block;
  width: 16px;
  flex: 0 0 16px;
  margin-left: auto;
  font-size: 0;
  position: relative;
}
li .twisty::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  color: var(--text-dim);
  transition: transform 0.16s var(--ease);
}
li.collapsed .twisty::before {
  transform: rotate(-90deg);
}
li.leaf .twisty {
  display: none;
}

/* 文件夹浏览进度条（当前高亮文件夹底部） */
li .prog {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 0 3px 3px 0;
  opacity: 0;
  pointer-events: none;
  transition: width 0.2s var(--ease), opacity 0.2s var(--ease);
}
li.has-prog .prog {
  opacity: 1;
}

/* 目录勾选框 */
li .sel {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-right: 3px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  position: relative;
  cursor: pointer;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
}
li .sel.checked {
  background: var(--accent);
  border-color: var(--accent);
}
li .sel.checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border-right: 2px solid var(--on-accent);
  border-bottom: 2px solid var(--on-accent);
  transform: rotate(45deg);
}

/* ---------- 快捷工具栏 ---------- */
#quickbarHost {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 31;
  width: 56px;
  height: 56px;
  transition: right 0.3s var(--ease);
}
#qbToggle {
  width: 56px;
  height: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    color 0.16s var(--ease);
}
#qbToggle:hover {
  border-color: var(--border-strong);
  color: var(--accent-strong);
}
#quickbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: absolute;
  right: 0;
  bottom: 66px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
#quickbarHost.open #quickbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#quickbar button {
  width: 48px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    color 0.15s var(--ease);
}
#quickbar button:hover {
  border-color: var(--border-strong);
  color: var(--accent-strong);
}
#quickbar button.danger:hover {
  border-color: rgba(255, 96, 96, 0.6);
  color: #ff7a7a;
}

/* ---------- 浮动速度条（自动滚动时） ---------- */
#floatSpeed {
  position: fixed;
  right: 84px;
  bottom: 22px;
  z-index: 32;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  transition: right 0.3s var(--ease);
}
#floatSpeed.show {
  display: flex;
}
#floatSpeed .ico {
  width: 15px;
  height: 15px;
  color: var(--accent);
}
#floatSpeed output {
  min-width: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#floatSpeed input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 92px;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
#floatSpeed input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
}
#floatSpeed input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
#floatSpeed input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
}
#floatSpeed input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
#floatSpeedStop {
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--hover-bg);
  color: var(--text);
  cursor: pointer;
}
#floatSpeedStop:hover {
  border-color: var(--border-strong);
  color: #ff7a7a;
}
#floatSpeedStop .ico {
  width: 13px;
  height: 13px;
  position: static;
}

/* ---------- 响应式 ---------- */
@media (max-width: 520px) {
  #sidebar {
    width: calc(100vw - 20px);
    right: 10px;
    top: 10px;
  }
  #imgbox {
    padding: 8px;
  }
}
