:root {
  /* 使用相对单位 */
  --base-font-size: 16px;
  --scale-factor: 1;
}

/* 响应式字体大小 */
@media (max-width: 768px) {
  :root {
    --base-font-size: 14px;
  }
}

@media (max-width: 480px) {
  :root {
    --base-font-size: 13px;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* 合并到这里 */
}

body {
  background-color: #f8f9fa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  -webkit-text-size-adjust: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding: 20px;
  margin: 0;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 440px;
  text-align: center;
  margin: 0 auto;
  padding: 20px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100vh;     /* 新增：设置高度为视口高度 */
  overflow-y: auto;  /* 新增：允许容器内滚动 */
  overflow-x: hidden;
}

/* === 搜索控件（含进度条）=== */
.search-toggle {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto;
  max-width: 440px;
  border-radius: 28px;
  background: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: all 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
  transform-origin: center;
}

.search-toggle.state-button {
  cursor: pointer;
}

.search-toggle.state-input,
.search-toggle.state-searching {
  width: 100%;
  max-width: 440px;
  height: 52px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  padding: 0 20px;
  display: flex;
  align-items: center;
  margin: 0 auto;
}

.search-toggle .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  cursor: pointer;
}

.search-toggle.state-button .icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin-right: 0;
}

.search-toggle .icon svg {
  width: 24px;
  height: 24px;
}

.search-toggle.state-button .icon svg {
  width: 28px;
  height: 28px;
}

.search-toggle input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 18px;
  background: transparent;
}

.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 28px;
  background: #f8f8f8;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.search-toggle.state-searching .progress-bar {
  opacity: 1;
  visibility: visible;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: #e0e0e0;
  transition: width 0.1s ease;
}

/* === 抽屉（结果容器）=== */
.drawer {
  background: transparent;
  margin-top: 24px;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.3s ease,
              margin-top 0.3s ease;
  display: flex;
  justify-content: center;
  width: 100%;
}

.drawer.open {
  max-height: 320px;
  opacity: 1;
  margin-top: 24px;
}

.drawer-content {
  padding: 20px 0;
  width: 100%;
  max-width: 440px;
  margin: 0 auto; 
  box-sizing: border-box;
}

/* === 翻转卡片容器 === */
.result-container {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 440px;
  height: 180px;
  margin: 0 auto;
}

.flip-card {
  flex: 1;
  min-width: 0;
  height: 180px;
  perspective: 1000px;
  cursor: pointer;
  padding: 5px;
  outline: none;
}

.flip-card:focus {
  outline: none;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
  border-radius: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  overflow: visible;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow: hidden;
  outline: none;
}

.flip-card-front:focus,
.flip-card-back:focus {
  outline: none;
}

.flip-card-front {
  background: white;
}

.flip-card-back {
  background: white;
  transform: rotateY(180deg);
  padding: 15px;
}

/* 卡片正面样式 */
.format-icon {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
}

.format-icon svg {
  width: 48px;
  height: 48px;
  transition: transform 0.3s ease;
}

.flip-card:hover .format-icon svg {
  transform: scale(1.1);
}

.format-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.tap-hint {
  position: absolute;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.tap-hint svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.flip-card:hover .tap-hint svg {
  transform: scale(1.1);
}

/* 卡片背面样式 */
.book-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
  text-align: center;
  line-height: 1.3;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-section {
  width: 100%;
  margin-bottom: 12px;
}

.detail-label {
  font-size: 11px;
  color: #666;
  margin-bottom: 4px;
  text-align: left;
}

.extract-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.code-text {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  letter-spacing: 1px;
}

.copy-btn {
  background: #f0f0f0;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  outline: none;
}	

.copy-btn:focus {
  outline: none;
}

.copy-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
  fill: #666;
}

.copy-btn:hover {
  background: #e0e0e0;
  transform: translateY(-1px);
}

.copy-btn:hover svg {
  transform: scale(1.1);
  fill: #333;
}

.copy-btn.copied {
  background: #e8f5e9;
}

.copy-btn.copied svg {
  fill: #4caf50;
  transform: scale(1);
}

.netdisk-link {
  display: block;
  background: #333;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
  margin-top: 4px;
  transition: all 0.3s ease;
  border: 1px solid #444;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.netdisk-link:focus {
  outline: none;
}

.netdisk-link:hover {
  background: #444;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 为网盘链接添加一个简单的图标 */
.netdisk-link {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  text-align: center !important; /* 文字居中 */
}

.netdisk-link::before {
  content: "" !important; /* 移除之前的文字图标 */
  margin-right: 0 !important;
}

.netdisk-link .cloud-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-block;
  filter: brightness(0) invert(1);
  margin-top: 4px;
}
.cloud-icon {
  transition: transform 0.3s ease;
}

.netdisk-link:hover .cloud-icon {
  transform: scale(1.1) translateY(-1px);
}

/* 确保图标颜色正确 */
.cloud-icon path,
.cloud-icon circle,
.cloud-icon polygon {
  fill: white !important; /* 如果是单色图标 */
  stroke: white !important;
}

/* === 提示卡片样式 === */
.hint-card {
  width: 100%;
  max-width: 440px;
  height: 180px;
  background: white;
  border-radius: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px 20px;
  margin: 0 auto;
  box-sizing: border-box;
}

.hint-icon {
  padding-top: 20px;
  margin-bottom: 25px!important;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 68px;
}

.hint-icon svg {
  width: 48px;
  height: 48px;
  fill: #999;
}

.hint-title {
  font-size: 20px;
  font-weight: 600;
  color: #666;
  margin-bottom: 12px;
  margin-top: -15px;  /* 负值上移 */
}

.hint-text {
  font-size: 14px;
  color: #aaa;
  text-align: center;
  line-height: 1.5;
  max-width: 300px;  /* 限制最大宽度 */
  margin: -8px auto 0;  /* 上、左右、下：-8px auto 0 */
}

.hint-text br {
  display: block;
  margin: 8px 0;  /* 两行之间的间距 */
}

.hint-text br + * {
  font-size: 9px;
  color: #777;
  margin-top: 4px;
  display: block;
  line-height: 1.4;
}

/* === 修复图标显示问题 === */
.copy-btn img {
  width: 16px;
  height: 16px;
  display: block;
}

.copy-btn.copied img {
  width: 16px;
  height: 16px;
}

/* 确保TXT和EPUB卡片中的图标一致 */
#txtCard .copy-btn img,
#epubCard .copy-btn img {
  width: 16px;
  height: 16px;
}

/* 隐藏格式标题文字 */
.format-title {
  display: none !important;
}

/* 调整图标容器 */
.format-icon {
  margin: 0 !important;                /* 移除所有外边距 */
  padding: 0 !important;               /* 移除内边距 */
  height: auto !important;             /* 高度自适应 */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 auto !important;           /* 不伸缩，固定大小 */
}

/* 放大图标 */
.format-icon img {
  width: 120px !important; /* 放大图标尺寸 */
  height: 120px !important;
}

/* 增强悬停效果 */
.flip-card:hover .format-icon img {
  transform: scale(1.15);
  transition: transform 0.3s ease;
}

/* 调整卡片正面内边距 */
.flip-card-front {
  padding: 0; /* 移除内边距，让图标占满 */
  justify-content: center; /* 垂直居中 */
}

/* 调整提示图标位置 */
.tap-hint {
  display: none !important;
}

.tap-hint img {
  width: 22px;
  height: 22px;
}

.flip-card:hover .tap-hint img {
  transform: scale(1.1);
}

/* 调整卡片正面的内边距，让内容更好看 */
.flip-card-front {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;  /* 垂直居中 */
  align-items: center !important;      /* 水平居中 */
  padding-top: 0 !important;           /* 移除内边距 */
  height: 100% !important;             /* 确保占满高度 */
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 确保输入框有足够的空间 */
.search-toggle.state-input,
.search-toggle.state-searching {
  position: relative; /* 为绝对定位的label提供参考 */
}

/* ===== 替换内联样式的CSS类 ===== */

/* 颜色类 */
.text-error { color: #ff4444 !important; }
.text-success { color: #4CAF50 !important; }
.text-warning { color: #FF9800 !important; }

/* 字体大小类 */
.fs-12 { font-size: 12px !important; }
.fs-14 { font-size: 14px !important; }
.fs-16 { font-size: 16px !important; }
.fs-18 { font-size: 18px !important; }

/* 边框类 */
.border-error { 
  border: 2px solid #ff4444 !important; 
  border-radius: 4px !important;
}

.border-success { 
  border: 2px solid #4CAF50 !important; 
  border-radius: 4px !important;
}

/* 显示/隐藏类 */
.hidden { display: none !important; }
.show-flex { display: flex !important; }
.show-block { display: block !important; }
.show-inline { display: inline !important; }

/* 布局类 */
.flex-center {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

/* 清除样式（用于恢复默认） */
.reset-styles {
  color: inherit !important;
  font-size: inherit !important;
  border: none !important;
  background: none !important;
}

/* ============================================= */
/* 以下是所有媒体查询，按顺序排列 */
/* ============================================= */

/* 1. 触摸设备适配 */
@media (hover: none) {
  .flip-card:active .format-icon svg {
    transform: scale(1.1);
  }
  
  .flip-card:active .tap-hint svg {
    transform: scale(1.1);
  }
  
  /* 确保输入框在 iOS 上不会缩放 */
  input[type="text"],
  input[type="search"] {
    font-size: 16px !important;
  }
  
  /* 改善 iOS 上的滚动体验 */
  html {
    -webkit-overflow-scrolling: touch;
  }
}


/*  平板和手机（768px及以下） */
@media (max-width: 768px) {
  /* 调整搜索框高度 */
  .search-toggle.state-input,
  .search-toggle.state-searching {
    height: 48px;
    max-width: 90vw;
  }
  
  /* 调整容器边距 */
  .container {
    padding: 10px;
    width: 100vw;
  }
  
  /* 调整卡片容器 */
  .result-container {
    flex-direction: row !important;
    height: 150px !important;
    gap: 10px;
    max-width: 90vw;
  }
  
  .flip-card {
    height: 150px !important;
    width: 50% !important;
    min-width: 0;
  }
  
  /* 调整字体大小 */
  .flip-card-back .book-title {
    font-size: 13px !important;
    margin-bottom: 10px !important;
  }
  
  .extract-code {
    padding: 6px 10px;
  }
  
  .code-text {
    font-size: 13px;
  }
  
  .netdisk-link {
    display: none !important;
  }

  .detail-label {
    display: none !important;
  }

  .netdisk-portal {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100%;
    margin-top: 8px !important;
  }
  
  .portal-label {
    font-size: 13px !important;
    color: #333;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  
  .portal-label .cloud-icon {
    display: none !important;
  }

  .portal-icon-btn {
    background: #414141;
    border: none;
    border-radius: 6px;
    width: 60px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .portal-icon-btn:hover {
    background: #444;
    transform: translateY(-1px);
  }
  
  .portal-icon-btn:active {
    transform: scale(0.95);
  }
  
  .portal-icon-btn .cloud-icon {
    width: 18px;
    height: 18px;
    filter: brightness(0) invert(1);
  }
  
  /* 提示卡片调整 */
  .hint-card {
    height: 160px;
    padding: 20px 15px;
    max-width: 90vw;
  }
  
  .hint-title {
    font-size: 18px;
  }
  
  .hint-text {
    font-size: 13px;
  }
  
  /* 防止 iOS Safari 缩放输入框 */
  input, select, textarea {
    font-size: 16px;
  }
  
  /* 触摸反馈效果 */
  .copy-btn:active,
  .portal-icon-btn:active,
  .flip-card:active {
    opacity: 0.7;
    transform: scale(0.97);
    transition: all 0.1s ease;
  }
  
  /* 防止 iOS 上的长按菜单 */
  .copy-btn,
  .portal-icon-btn,
  .netdisk-link {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* 滚动相关修复 */
  html, body {
    overflow-y: auto;
    position: static !important;
    min-height: 100vh;
    -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
  }
  
  .drawer.open {
    max-height: 250px !important;
  }
  
  .result-container {
    height: 320px !important;
  }
}

/* 4. 小屏手机特别优化（375px及以下） */
@media (max-width: 375px) {
  /* 搜索框更小 */
  .search-toggle.state-input,
  .search-toggle.state-searching {
    height: 44px;
  }
  
  /* 卡片和图标更小 */
  .flip-card {
    height: 140px !important;
  }
  
  .format-icon img {
    width: 100px !important;
    height: 100px !important;
  }
  
  .result-container {
    height: 140px !important;
    gap: 8px;
  }
  
  /* 提示卡片更紧凑 */
  .hint-card {
    height: 140px;
    padding: 15px 12px;
  }
  
  .hint-title {
    font-size: 16px;
  }
  
  .hint-text {
    font-size: 12px;
  }
  
  /* 字体更小 */
  .flip-card-back .book-title {
    font-size: 12px !important;
    margin-bottom: 8px !important;
  }
  
  .code-text {
    font-size: 12px;
  }
  
  .portal-label {
    font-size: 12px !important;
  }
  
  /* 按钮更小 */
  .portal-icon-btn {
    width: 55px;
    height: 26px;
  }
  
  .copy-btn {
    padding: 4px 8px;
    width: 30px;
    height: 26px;
  }
}

/* 触摸反馈 */
.flip-card.touch-active {
  transform: scale(0.98);
  transition: transform 0.1s ease;
}

/* 防止 iOS 长按菜单 */
.copy-btn, .netdisk-link {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ============================================= */
/* 强力隐藏所有滚动条 - 100%有效 */
/* ============================================= */

/* 1. 隐藏所有滚动条（所有浏览器，所有元素） */
* {
  scrollbar-width: none !important; /* Firefox */
  -ms-overflow-style: none !important; /* IE/Edge */
}

/* 2. 隐藏Webkit滚动条（Chrome, Safari, Edge, Opera） */
::-webkit-scrollbar,
::-webkit-scrollbar-track,
::-webkit-scrollbar-thumb,
::-webkit-scrollbar-corner,
::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

/* 3. 针对每个可能的滚动元素 */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.container::-webkit-scrollbar,
.drawer::-webkit-scrollbar,
.result-container::-webkit-scrollbar {
  display: none !important;
}

/* 4. 确保body正确设置 */
body {
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

/* 5. 移动端优化 */
@media (max-width: 768px) {
  html, body, .container {
    -webkit-overflow-scrolling: touch; /* iOS顺滑滚动 */
  }
}