/* ========== 基础重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  /* 阻止选区/长按菜单干扰手势 */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ========== 容器：宽度自适应，最大 800px，居中 ========== */
#app {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #0a0a0a;
  overflow: hidden;
}

/* ========== 图片显示区 ========== */
.viewer {
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  /* 默认只允许纵向原生滚动，横向交给 JS 处理；缩放后改为两轴均可原生滚动 */
  touch-action: pan-y;
  background: #1a1a1a;
}

/* 图片容器：使用普通块级而非 flex，
   避免放大后 justify-content:center 让图片左半边溢出到「负坐标」（scrollLeft<0 无法到达）。
   正常时 width=100% 图片宽度即容器宽度，无需居中；放大时图片从容器左边缘开始向右扩展，
   scrollLeft=0 即可看到图片最左侧，保证整个放大区域可滚动访问。 */
.viewer-inner {
  min-height: 100%;
  min-width: 100%;
  display: block;
}

.page-image {
  display: block;
  /* 宽度默认撑满显示区；缩放时通过修改 width% 实现（布局会重排，原生滚动天然生效） */
  width: 100%;
  height: auto;
  transform-origin: center center;
  transition: opacity .25s ease;
  will-change: width;
}
.page-image.loading {
  opacity: .15;
}

/* 加载提示 */
.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 14px;
  opacity: .8;
  pointer-events: none;
}
.loader::after {
  content: ' 加载中…';
}

/* 操作提示 */
.hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .5);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}

/* 空状态提示 */
.empty-tip {
  color: #888;
  text-align: center;
  padding: 40px 20px;
  line-height: 1.8;
  font-size: 14px;
}

/* ========== 底部浮动工具栏 ========== */
.toolbar {
  flex: 0 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: rgba(0, 0, 0, .88);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 13px;
  /* 极窄屏允许横向滚动，避免挤压 */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  position: relative;
  z-index: 50;
}
.toolbar::-webkit-scrollbar {
  display: none;
}
.toolbar .item {
  flex: 0 0 auto;
  white-space: nowrap;
}
.grade {
  font-weight: 600;
}
.counter {
  color: #ddd;
  min-width: 38px;
  text-align: center;
}
.counter .cur {
  color: #fff;
  font-weight: 600;
}

/* 通用按钮：蓝色背景白色字、圆角长方形 */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  background: #2f80ed;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  padding: 9px 14px;
  border-radius: 10px;
  transition: filter .15s, transform .05s;
}
.btn:active {
  filter: brightness(.88);
  transform: translateY(1px);
}
.btn:disabled {
  background: #4a4a4a;
  color: #9a9a9a;
  cursor: not-allowed;
}

/* 跳转按钮：橘黄色背景白色字、圆角长方形 */
.btn-jump {
  background: #f59e0b;
}

/* 页码输入框 */
.page-input {
  width: 48px;
  height: 32px;
  text-align: center;
  border: 1px solid #555;
  background: #fff;
  color: #111;
  border-radius: 8px;
  font-size: 14px;
  /* 隐藏数字输入框的上下箭头 */
  -moz-appearance: textfield;
}
.page-input::-webkit-outer-spinning,
.page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.spacer {
  flex: 1 1 auto;
}

/* ========== 右下角浮动按钮（主页 / 目录） ========== */
.fab-stack {
  position: absolute;
  right: 14px;
  bottom: 72px;              /* 位于工具栏上方 */
  display: flex;
  flex-direction: column;    /* 上下排列 */
  gap: 12px;
  z-index: 40;
}
.fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;        /* 圆形 */
  background: rgba(120, 120, 120, .88);  /* 灰色背景 */
  color: #fff;               /* 白色字 / 图标 */
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  transition: filter .15s, transform .05s;
  -webkit-user-select: none;
  user-select: none;
}
.fab:active {
  filter: brightness(1.12);
  transform: translateY(1px);
}
.fab svg {
  display: block;
}

/* ========== 目录遮罩与半透明目录表 ========== */
.catalog-backdrop {
  position: absolute;
  inset: 0;
  bottom: 56px;              /* 不遮挡工具栏 */
  background: rgba(0, 0, 0, .25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .3s;
  z-index: 25;
}
.catalog-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.catalog-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 56px;
  width: 72%;
  max-width: 300px;
  background: rgba(20, 20, 20, .72);   /* 半透明 */
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  z-index: 30;
  transform: translateX(100%);
  transition: transform .3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.catalog-panel.open {
  transform: translateX(0);
}

.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.catalog-close {
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #ccc;
  padding: 0 4px;
}
.catalog-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}
.catalog-list li {
  padding: 12px 16px;
  font-size: 14px;
  color: #ddd;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  align-items: center;
  gap: 8px;
}
.catalog-list li:active {
  background: rgba(255, 255, 255, .08);
}
.catalog-list li.active {
  color: #f59e0b;            /* 当前讲高亮（橘黄） */
}
.catalog-list li .idx {
  color: #888;
  font-size: 12px;
  min-width: 22px;
}
.catalog-list li.active .idx {
  color: #f59e0b;
}
