/* 电子课本检索 · 与主站同一套视觉（白底、蓝色主色、圆角卡片） */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #7a8699;
  --line: #e4e8f0;
  --brand: #3b6cf6;
  --brand-ink: #ffffff;
  --danger: #e5484d;
  --ok: #18a058;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 39, 51, 0.08);
  --mark: #ffe58a;
  --mark-strong: #ffcf3d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== 顶栏（同主站） ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header h1 { font-size: 20px; margin: 0; letter-spacing: 0.5px; }
.head-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-badge { font-size: 12px; color: var(--muted); white-space: nowrap; }
.app-version {
  display: block;
  font-size: 12px;
  font-weight: normal;
  color: var(--muted);
  margin: 2px 0 0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.btn-home {
  appearance: none; flex: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-home:hover { border-color: var(--brand); color: var(--brand); }

/* ===== 通用 ===== */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: #cdd6e6; background: #fafbff; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover:not(:disabled) { background: #2f5ce0; border-color: #2f5ce0; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.hint { color: var(--muted); font-size: 12px; margin: 0; }

.keben-main { max-width: 1040px; margin: 0 auto; padding: 22px 22px 40px; }
.screen { display: block; }
.step-card { margin-bottom: 16px; }
.step-label {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 15px; font-weight: 700; margin-bottom: 12px;
}
.step-no {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px;
  display: grid; place-items: center;
}
.step-note { font-size: 12px; color: var(--muted); font-weight: 400; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-row-gap { margin-top: 10px; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip .cnt { font-size: 11px; opacity: .75; margin-left: 6px; font-weight: 400; }

.group-load { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.group-load[hidden] { display: none; }
.group-load-track { flex: 1; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.group-load-bar { height: 100%; width: 0; border-radius: 3px; background: var(--brand); transition: width .18s linear; }
.group-load-text { flex: 0 0 auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.browse-open {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 14px; font-size: 14px; color: var(--muted);
}
.browse-open input {
  width: 92px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 15px; color: var(--ink); background: #fff;
}
.browse-open input:focus { outline: none; border-color: var(--brand); }
.browse-pdf { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ===== 搜索 ===== */
.search-form { display: flex; gap: 8px; margin-bottom: 10px; }
.search-form input {
  flex: 1; min-width: 0; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; font-size: 16px; color: var(--ink);
  font-family: inherit;
}
.search-form input:focus { outline: none; border-color: var(--brand); }
.search-form .btn { flex: 0 0 auto; padding: 0 20px; font-size: 15px; }

.mode-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.mode-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  padding: 4px 10px; border-radius: 999px;
}
.mode-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.mode-badge[data-mode="busy"] .dot { background: var(--brand); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.scope-hint { font-size: 12px; color: var(--muted); }

.quick-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.quick-tags button {
  border: 1px dashed var(--line); background: transparent; color: var(--brand);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.quick-tags button:hover { background: #f5f8ff; border-color: var(--brand); }

.empty-tip { color: var(--muted); font-size: 14px; line-height: 1.7; text-align: center; margin: 16px 0 0; padding: 0 10px; }

/* ===== 结果（卡片内的平铺行，不再套一层框） ===== */
.results-title { font-size: 15px; margin: 14px 0 4px; }
.result-count { color: var(--muted); font-weight: 400; font-size: 13px; }
.result-list { list-style: none; margin: 0; padding: 0; }
.result-item {
  padding: 12px 2px; border-bottom: 1px solid var(--line); cursor: pointer;
  border-radius: 8px;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: #f8faff; }
.result-item[aria-current="true"] { background: #f0f5ff; box-shadow: inset 3px 0 0 var(--brand); }
.r-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.r-vol { font-size: 13px; font-weight: 700; color: var(--brand); }
.r-page { font-size: 12px; background: var(--brand); color: #fff; padding: 1px 8px; border-radius: 999px; }
.r-chap { font-size: 12px; color: var(--muted); }
.r-snip { margin: 4px 0 0; font-size: 14px; line-height: 1.7; color: var(--ink); }
.result-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px; }
.result-loading { color: var(--muted); font-size: 14px; text-align: center; padding: 20px 12px; }
.result-loading .spin {
  display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line);
  border-top-color: var(--brand); border-radius: 50%; animation: sp .8s linear infinite;
  vertical-align: -3px; margin-right: 8px;
}

mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 3px; }
mark.strong { background: var(--mark-strong); font-weight: 600; }

/* ===== 阅读 ===== */
#screenReader { max-width: 900px; margin: 0 auto; }
.reader-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.reader-book { font-size: 14px; font-weight: 600; color: var(--brand); flex: 1; min-width: 160px; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager .pager-btn { width: 36px; padding: 6px 0; font-size: 20px; line-height: 1; }
.pager span { font-size: 13px; color: var(--muted); min-width: 66px; text-align: center; }
.reader-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.page-zoom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.page-zoom-label { font-size: 12px; color: var(--muted); }
.page-zoom-btn { padding: 5px 12px; font-size: 13px; }
.page-zoom-btn:disabled { opacity: .45; cursor: default; }

.page {
  padding: 16px;
  min-height: 50vh;
}
.page-meta {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.page-no { font-size: 12px; background: var(--brand); color: #fff; padding: 2px 10px; border-radius: 999px; }
.page-chapter { font-size: 12.5px; color: var(--muted); }
.page-text { font-size: 16px; line-height: 1.95; white-space: pre-wrap; word-break: break-word; color: var(--ink); }

/* 真实书页图片 + 高亮叠加 */
.pageimg-wrap { margin: 4px 0 12px; }
.pageimg-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pageimg-box { position: relative; line-height: 0; margin: 0 auto; }
.pageimg-box img { width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.hl-layer { position: absolute; inset: 0; pointer-events: none; }
.hl { position: absolute; background: rgba(255, 205, 45, .5); border-radius: 2px; box-shadow: 0 0 0 1px rgba(184, 134, 43, .5); }
.pageimg-loading, .pageimg-fail { padding: 40px 12px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; }
.pageimg-fail { color: #a15c00; }
.pageimg-loading .spin {
  display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line);
  border-top-color: var(--brand); border-radius: 50%; animation: sp .8s linear infinite;
  vertical-align: -3px; margin-right: 6px;
}
@keyframes sp { to { transform: rotate(360deg); } }
.page-text-toggle { margin-top: 4px; }
.page-text-toggle summary { cursor: pointer; font-size: 13px; color: var(--brand); padding: 6px 0; }
.page-text-toggle[open] summary { margin-bottom: 8px; }

.page-jump { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.page-jump label { font-size: 13px; color: var(--muted); }
.page-jump input { width: 86px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; background: #fff; color: var(--ink); }
.page-jump input:focus { outline: none; border-color: var(--brand); }

/* ===== 设置抽屉 ===== */
.drawer-mask { position: fixed; inset: 0; background: rgba(15, 20, 32, .45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); z-index: 50;
  background: var(--bg); box-shadow: -4px 0 24px rgba(0,0,0,.18);
  display: flex; flex-direction: column; animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(100%); } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px; background: var(--card); border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-body { padding: 16px; overflow-y: auto; flex: 1; }
.set-block { margin-bottom: 12px; padding: 14px; }
.set-block h3 { margin: 0 0 10px; font-size: 14px; }
.set-note { font-size: 12px; color: var(--muted); line-height: 1.7; margin: 10px 0 0; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 60; box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}

.site-foot {
  max-width: 1040px; margin: 8px auto 26px; padding: 0 22px;
  font-size: 11px; line-height: 1.7; color: var(--muted); text-align: center;
}

@media (max-width: 640px) {
  .app-header { padding: 14px 16px; }
  .app-header h1 { font-size: 18px; }
  .head-badge { display: none; }
  .keben-main { padding: 16px 14px 32px; }
  .reader-head { align-items: center; }
  .reader-book { flex-basis: 100%; order: -1; }
}
