:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --border: #e5e7eb;
  --primary: #2563eb;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
input, textarea, select, button { font: inherit; }
input, textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
textarea { resize: vertical; }

.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; color: var(--primary); }
.nav { display: flex; gap: 12px; flex-wrap: wrap; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--primary); }
.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

.panel, .auth-card, .novel-card, .stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.panel { padding: 20px; margin: 18px 0; }
.auth-card { max-width: 420px; margin: 80px auto; padding: 28px; }
.form-stack { display: grid; gap: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: center; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.checkbox input { width: auto; }
.badge { display: inline-flex; align-items: center; margin: 2px 4px 2px 0; padding: 3px 8px; border-radius: 99px; background: #eff6ff; color: #1d4ed8; font-size: 12px; }
.empty { color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.stat-card { padding: 20px; }
.stat-card strong { display: block; font-size: 32px; }
.stat-card span { color: var(--muted); }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.search-form { display: flex; gap: 10px; margin: 16px 0; }
.novel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.novel-card { overflow: hidden; }
.novel-card img, .cover-placeholder { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #e2e8f0; display: grid; place-items: center; color: var(--muted); }
.novel-card h2 { padding: 0 12px; font-size: 18px; }
.novel-card p { padding: 0 12px; color: var(--muted); }
.meta { font-size: 13px; }

.table-list { display: grid; gap: 10px; }
.table-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.edit-row { grid-template-columns: 1fr 1.3fr .6fr .5fr .4fr .4fr; }
.detail-head { display: grid; grid-template-columns: 1fr 220px; gap: 22px; }
.detail-cover { width: 220px; border-radius: 12px; object-fit: cover; }
.tag-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.chapter-list { display: grid; gap: 8px; }
.chapter-list a { display: flex; justify-content: space-between; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.token-box { white-space: pre-wrap; word-break: break-all; padding: 12px; background: #111827; color: #f9fafb; border-radius: 8px; }
.warning { border-color: #f59e0b; }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); min-width: 160px; max-width: 80vw; padding: 10px 16px; border-radius: 8px; background: rgba(0, 0, 0, 0.82); color: #fff; text-align: center; font-size: 14px; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.toast.show { opacity: 1; }

@media (max-width: 1023px) {
  .container { padding: 18px 14px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .novel-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-form { grid-template-columns: repeat(2, 1fr); }
  .table-row, .edit-row { grid-template-columns: 1fr 1fr; }
  .detail-head { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 12px; }
  .container { padding: 14px 12px; }
  .stat-grid, .novel-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-form, .table-row, .edit-row { grid-template-columns: 1fr; }
  .search-form { flex-direction: column; }
  .page-head { align-items: stretch; flex-direction: column; }
}

@media (max-width: 480px) {
  .stat-grid, .novel-grid { grid-template-columns: 1fr; }
  .auth-card { margin: 30px auto; }
}

/* UI refinement: keep dense forms inside half-modal sheets instead of stacking every form on the page. */
.page-desc { margin: 4px 0 0; color: var(--muted); line-height: 1.6; }
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.compact-panel { padding: 18px; }
.clean-list { gap: 12px; }
.row-main { display: grid; gap: 4px; min-width: 0; }
.row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main span, .muted { color: var(--muted); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.category-row { grid-template-columns: 1.4fr .45fr .35fr .75fr; }
.tag-row { grid-template-columns: 1.5fr .45fr .75fr; }
.token-row { grid-template-columns: 1.25fr .65fr .45fr .7fr .35fr; }
.import-guide { margin-top: 18px; }
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.guide-grid > div { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.guide-grid p { color: var(--muted); line-height: 1.6; margin-bottom: 0; }

.sheet { position: fixed; inset: 0; z-index: 2000; display: none; }
.sheet.is-open { display: block; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.42); backdrop-filter: blur(3px); }
.sheet-panel { position: absolute; top: 0; right: 0; width: min(520px, 94vw); height: 100%; overflow-y: auto; background: var(--card); box-shadow: -18px 0 42px rgba(15, 23, 42, 0.20); padding: 22px; transform: translateX(100%); transition: transform .22s ease; }
.sheet-panel.wide { width: min(720px, 96vw); }
.sheet.is-open .sheet-panel { transform: translateX(0); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { margin: 0 0 4px; }
.sheet-head p { margin: 0; color: var(--muted); line-height: 1.5; }
.sheet-close { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 999px; background: #fff; cursor: pointer; font-size: 22px; line-height: 1; }
.sheet-form label { display: grid; gap: 7px; color: var(--text); font-weight: 600; }
.sheet-form .checkbox { display: inline-flex; font-weight: 400; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 8px; }
body.sheet-locked { overflow: hidden; }

@media (max-width: 1023px) {
  .category-row, .tag-row, .token-row { grid-template-columns: 1fr 1fr; }
  .guide-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .section-head { flex-direction: column; align-items: stretch; }
  .category-row, .tag-row, .token-row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
  .sheet-panel, .sheet-panel.wide { top: auto; bottom: 0; right: 0; width: 100%; height: min(88vh, 760px); border-radius: 18px 18px 0 0; transform: translateY(100%); }
  .sheet.is-open .sheet-panel { transform: translateY(0); }
  .sheet-actions { justify-content: stretch; flex-direction: column; }
  .sheet-actions .btn { width: 100%; }
}

/* Import file management and chapter preview. */
.import-file-row { grid-template-columns: 1.3fr .55fr .35fr .8fr .75fr; }
.row-error { margin: 6px 0 0; color: var(--danger); font-size: 12px; line-height: 1.45; }
.badge.success { background: #ecfdf5; color: #047857; }
.badge.danger-lite { background: #fef2f2; color: #b91c1c; }
.notice { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; line-height: 1.6; }
.success-notice { border-color: #bbf7d0; background: #f0fdf4; color: #047857; }
.preview-panel { width: min(980px, 98vw); }
.preview-meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chapter-select-toolbar { position: sticky; top: -22px; z-index: 2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.chapter-preview-list { display: grid; gap: 8px; max-height: 52vh; overflow: auto; padding-right: 4px; }
.chapter-preview-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; }
.chapter-preview-item input { width: auto; margin-top: 3px; }
.chapter-preview-main { display: grid; gap: 4px; min-width: 0; }
.chapter-preview-main strong { line-height: 1.45; }
.chapter-preview-main small { color: var(--muted); }
.chapter-preview-main em { color: var(--muted); font-style: normal; font-size: 13px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sticky-actions { position: sticky; bottom: -22px; background: rgba(255,255,255,.96); border-top: 1px solid var(--border); padding: 12px 0 0; }

@media (max-width: 1023px) {
  .import-file-row { grid-template-columns: 1fr 1fr; }
  .preview-meta-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .import-file-row { grid-template-columns: 1fr; }
  .chapter-select-toolbar { top: 0; align-items: stretch; }
  .chapter-select-toolbar .btn { flex: 1; }
  .chapter-preview-list { max-height: 46vh; }
  .preview-panel { width: 100%; }
}

.steps {
  margin: 0;
  padding-left: 22px;
  line-height: 1.8;
}

.notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f5f7fb;
  color: #4b5563;
  border: 1px solid #e5e7eb;
}

.alert {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
}

.alert.success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.alert.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.split-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.btn.small {
  padding: 6px 10px;
  font-size: 13px;
}

.copy-input {
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.code-block {
  max-height: 560px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 14px;
  border-radius: 12px;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.55;
}

.legado-login-card {
  max-width: 560px;
}

.full {
  width: 100%;
}

.small-text {
  font-size: 13px;
}

@media (max-width: 767px) {
  .split-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .code-block {
    max-height: 420px;
    font-size: 12px;
  }
}


/* Copy/mobile layout fix. */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 18px 0;
}

.novel-cover-link {
  display: block;
  background: #e2e8f0;
}

.novel-card {
  display: flex;
  flex-direction: column;
}

.novel-card-body {
  display: grid;
  gap: 6px;
  padding: 12px;
  min-width: 0;
}

.novel-card h2,
.novel-card p {
  padding: 0;
  margin: 0;
}

.novel-card h2 {
  font-size: 18px;
  line-height: 1.35;
}

.novel-card-body h2 a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-info {
  min-width: 0;
}

@media (max-width: 767px) {
  .novel-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .novel-card {
    flex-direction: row;
    min-height: 132px;
  }

  .novel-cover-link {
    flex: 0 0 96px;
    width: 96px;
  }

  .novel-card img,
  .novel-card .cover-placeholder {
    width: 96px;
    height: 132px;
    aspect-ratio: auto;
  }

  .novel-card-body {
    flex: 1;
    align-content: start;
    padding: 12px 12px 10px;
  }

  .novel-card h2 {
    font-size: 16px;
  }

  .detail-head.detail-has-cover {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
  }

  .detail-head.detail-has-cover .detail-cover {
    order: -1;
    grid-column: 1;
    grid-row: 1;
    width: 104px;
    height: 138px;
    aspect-ratio: auto;
    border-radius: 10px;
  }

  .detail-head.detail-has-cover .detail-info {
    grid-column: 2;
    grid-row: 1;
  }

  .detail-info h1 {
    margin-top: 0;
    font-size: 22px;
    line-height: 1.25;
  }

  .detail-info p {
    margin: 8px 0;
    line-height: 1.55;
  }

  .detail-info .actions {
    grid-column: 1 / -1;
  }

  .detail-info .actions .btn,
  .detail-info .actions form,
  .detail-info .actions form .btn {
    width: 100%;
  }

  .chapter-list a {
    align-items: flex-start;
    gap: 8px;
  }
}

/* JJWXC online catalog replacement. */
.form-label { display: block; margin-bottom: 8px; font-weight: 700; }
.jjwxc-fetch-form { display: grid; gap: 10px; }
.jjwxc-url-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.jjwxc-select-form .jjwxc-url-row { grid-template-columns: minmax(0, 1fr) 180px auto; }
.jjwxc-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 18px; align-items: start; }
.jjwxc-pane { min-width: 0; }
.jjwxc-table-scroll { overflow: auto; max-height: 68vh; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.jjwxc-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.jjwxc-table th, .jjwxc-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; line-height: 1.45; }
.jjwxc-table th { position: sticky; top: 0; z-index: 1; background: #f8fafc; color: #475569; font-size: 13px; }
.jjwxc-table td:first-child, .jjwxc-table th:first-child { width: 72px; white-space: nowrap; }
.jjwxc-table .empty { text-align: center; padding: 28px; }
.replace-table tr.changed { background: #f8fbff; }
.jjwxc-sticky-toolbar { margin: 12px 0; top: 0; }
.right-table { max-height: 56vh; }

@media (max-width: 1023px) {
  .jjwxc-workspace { grid-template-columns: 1fr; }
  .jjwxc-table-scroll { max-height: 52vh; }
}

@media (max-width: 767px) {
  .jjwxc-url-row, .jjwxc-select-form .jjwxc-url-row { grid-template-columns: 1fr; }
  .jjwxc-url-row .btn { width: 100%; }
  .jjwxc-table { min-width: 680px; }
  .jjwxc-table-scroll { max-height: 48vh; }
}

/* JJWXC merged catalog comparison optimization. */
.jjwxc-control-panel { display: grid; gap: 14px; }
.jjwxc-control-grid { display: grid; grid-template-columns: minmax(280px, 1.8fr) minmax(220px, 1.2fr) minmax(150px, .8fr) auto; gap: 12px; align-items: end; }
.jjwxc-control-grid.secondary { grid-template-columns: minmax(260px, 1fr) 180px auto; padding-top: 14px; border-top: 1px solid var(--border); }
.jjwxc-control-actions { display: flex; align-items: end; }
.jjwxc-control-actions .btn { white-space: nowrap; }
.jjwxc-novelid-row { display: flex; align-items: center; min-height: 42px; border: 1px solid var(--border); border-radius: 8px; background: #fff; overflow: hidden; }
.jjwxc-novelid-row input { border: 0; border-radius: 0; padding-left: 8px; min-width: 120px; }
.jjwxc-novelid-row input:focus { outline: none; }
.jjwxc-url-prefix { flex: 0 0 auto; padding: 10px 0 10px 12px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.jjwxc-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.jjwxc-summary-grid strong { display: block; margin-top: 4px; font-size: 20px; line-height: 1.35; }
.jjwxc-merged-panel { min-width: 0; }
.jjwxc-merged-scroll { max-height: 72vh; }
.jjwxc-compare-table { min-width: 980px; }
.jjwxc-compare-table th:nth-child(1), .jjwxc-compare-table td:nth-child(1) { width: 64px; text-align: center; }
.jjwxc-compare-table th:nth-child(2), .jjwxc-compare-table td:nth-child(2) { width: 70px; white-space: nowrap; }
.jjwxc-compare-table th:nth-child(6), .jjwxc-compare-table td:nth-child(6) { width: 96px; }
.jjwxc-compare-table td strong { display: block; line-height: 1.45; }
.jjwxc-compare-table td small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.45; }
.jjwxc-inline-form { margin: 0; }

@media (max-width: 1023px) {
  .jjwxc-control-grid,
  .jjwxc-control-grid.secondary { grid-template-columns: 1fr 1fr; }
  .jjwxc-control-actions { align-items: stretch; }
  .jjwxc-control-actions .btn { width: 100%; }
  .jjwxc-summary-grid { grid-template-columns: 1fr; }
  .jjwxc-compare-table { min-width: 900px; }
}

@media (max-width: 767px) {
  .jjwxc-control-grid,
  .jjwxc-control-grid.secondary { grid-template-columns: 1fr; }
  .jjwxc-url-prefix { display: block; width: 100%; padding: 9px 12px 0; white-space: normal; word-break: break-all; }
  .jjwxc-novelid-row { display: block; }
  .jjwxc-novelid-row input { padding: 8px 12px 10px; }
  .jjwxc-summary-grid strong { font-size: 17px; }
  .jjwxc-merged-scroll { max-height: none; overflow: visible; border: 0; background: transparent; }
  .jjwxc-compare-table,
  .jjwxc-compare-table thead,
  .jjwxc-compare-table tbody,
  .jjwxc-compare-table tr,
  .jjwxc-compare-table th,
  .jjwxc-compare-table td { display: block; width: 100%; min-width: 0; }
  .jjwxc-compare-table { border-collapse: separate; border-spacing: 0; }
  .jjwxc-compare-table thead { display: none; }
  .jjwxc-compare-table tr { margin-bottom: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
  .jjwxc-compare-table tr.changed { background: #f8fbff; }
  .jjwxc-compare-table td { position: relative; padding: 8px 0 8px 88px; border-bottom: 1px dashed var(--border); min-height: 36px; text-align: left !important; }
  .jjwxc-compare-table td:last-child { border-bottom: 0; }
  .jjwxc-compare-table td::before { content: attr(data-label); position: absolute; left: 0; top: 8px; width: 76px; color: var(--muted); font-size: 12px; font-weight: 700; }
  .jjwxc-compare-table td[data-label="替换"] { padding-left: 88px; }
  .jjwxc-compare-table .empty { text-align: left; padding: 8px 0 8px 88px; }
  .jjwxc-sticky-toolbar { position: sticky; top: 0; z-index: 5; align-items: stretch; }
  .jjwxc-sticky-toolbar .btn { flex: 1; }
}

/* EPUB title cleanup release: mobile JJWXC page refinement. */
@media (max-width: 767px) {
  .page-head h1 {
    font-size: 24px;
    line-height: 1.25;
  }

  .jjwxc-control-panel,
  .jjwxc-summary-panel,
  .jjwxc-merged-panel {
    padding: 12px;
    margin: 12px 0;
    border-radius: 12px;
  }

  .jjwxc-control-grid,
  .jjwxc-control-grid.secondary {
    gap: 9px;
  }

  .jjwxc-control-grid .form-label {
    margin-bottom: 0;
    font-size: 13px;
  }

  .jjwxc-novelid-row {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 0;
    border-radius: 10px;
  }

  .jjwxc-url-prefix {
    display: block;
    width: auto;
    padding: 8px 10px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    line-height: 1.35;
    word-break: break-all;
  }

  .jjwxc-novelid-row input,
  .jjwxc-control-grid select,
  .jjwxc-control-grid.secondary select {
    min-height: 42px;
    font-size: 16px;
  }

  .jjwxc-novelid-row input {
    padding: 10px;
  }

  .jjwxc-control-actions,
  .jjwxc-control-actions .btn {
    width: 100%;
  }

  .jjwxc-inline-form .jjwxc-control-grid.secondary {
    padding-top: 10px;
  }

  .jjwxc-summary-grid {
    gap: 10px;
  }

  .jjwxc-summary-grid > div {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
  }

  .jjwxc-summary-grid strong {
    font-size: 16px;
  }

  .jjwxc-merged-panel .section-head h2 {
    margin-bottom: 2px;
    font-size: 20px;
  }

  .jjwxc-sticky-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
    margin: 8px 0 12px;
    border-radius: 12px;
  }

  .jjwxc-sticky-toolbar span {
    grid-column: 1 / -1;
    order: 3;
    margin: 0;
    text-align: center;
    font-size: 12px;
  }

  .jjwxc-sticky-toolbar .btn.primary {
    grid-column: 1 / -1;
    order: 4;
  }

  .jjwxc-compare-table tr {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 14px;
    box-shadow: none;
  }

  .jjwxc-compare-table td {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 8px 0;
    min-height: 0;
    word-break: break-word;
  }

  .jjwxc-compare-table td::before {
    position: static;
    width: auto;
    line-height: 1.45;
  }

  .jjwxc-compare-table td[data-label="替换"],
  .jjwxc-compare-table td[data-label="序号"],
  .jjwxc-compare-table td[data-label="状态"] {
    grid-template-columns: 72px auto;
    align-items: center;
  }

  .jjwxc-compare-table td[data-label="晋江目录"] strong,
  .jjwxc-compare-table td[data-label="本站目录"] strong,
  .jjwxc-compare-table td[data-label="替换后标题"] {
    font-size: 14px;
    line-height: 1.5;
  }

  .jjwxc-compare-table td small {
    font-size: 12px;
    line-height: 1.45;
  }

  .jjwxc-compare-table .badge {
    margin: 0;
    justify-self: start;
  }

  .jjwxc-compare-table .empty {
    padding: 10px;
  }
}

@media (max-width: 390px) {
  .jjwxc-control-panel,
  .jjwxc-summary-panel,
  .jjwxc-merged-panel {
    padding: 10px;
  }

  .jjwxc-compare-table td {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
  }

  .jjwxc-sticky-toolbar {
    grid-template-columns: 1fr;
  }

  .jjwxc-sticky-toolbar span,
  .jjwxc-sticky-toolbar .btn.primary {
    grid-column: auto;
  }
}
@media (max-width: 767px) {
  .jjwxc-compare-table td[data-label="替换"],
  .jjwxc-compare-table td[data-label="序号"],
  .jjwxc-compare-table td[data-label="状态"],
  .jjwxc-compare-table td[data-label="晋江目录"],
  .jjwxc-compare-table td[data-label="本站目录"],
  .jjwxc-compare-table td[data-label="替换后标题"],
  .jjwxc-compare-table td[data-label="内容摘要"],
  .jjwxc-compare-table td[data-label="生成标题"],
  .jjwxc-compare-table td[data-label="晋江标题"],
  .jjwxc-compare-table td[data-label="本站标题"],
  .jjwxc-compare-table td[data-label="字数"] {
    padding: 8px 0;
  }
}

/* Header and novel-detail readability optimization. */
.topbar {
  padding: 0;
}

.topbar-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  flex: 0 0 auto;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: .02em;
}

.nav {
  margin-left: auto;
  gap: 8px;
  align-items: center;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.nav a:hover {
  background: #eff6ff;
}

.nav-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.nav-toggle-icon {
  position: relative;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  position: absolute;
  left: 0;
}

.nav-toggle-icon::before { top: -5px; }
.nav-toggle-icon::after { top: 5px; }

.detail-head {
  align-items: start;
}

.detail-info h1 {
  margin: 0 0 14px;
  line-height: 1.22;
}

.detail-meta {
  display: grid;
  gap: 9px;
}

.detail-meta p {
  margin: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  line-height: 1.55;
}

.detail-meta p > span:first-child {
  color: var(--muted);
  white-space: nowrap;
}

.detail-meta strong {
  font-weight: 500;
  min-width: 0;
}

.detail-tags strong {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.detail-intro,
.detail-actions {
  grid-column: 1 / -1;
}

.detail-intro {
  margin-top: 2px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.detail-intro-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-intro h2 {
  margin: 0;
  font-size: 18px;
}

.intro-text {
  margin: 0;
  color: var(--text);
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-intro.is-expanded .intro-text,
.empty-intro .intro-text {
  display: block;
  overflow: visible;
}

.intro-toggle {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  padding: 6px 2px;
  font-weight: 700;
}

.detail-actions {
  padding-top: 4px;
}

@media (max-width: 767px) {
  .topbar {
    align-items: stretch;
    flex-direction: row;
  }

  .topbar-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: 10px 12px;
  }

  .brand {
    min-width: 0;
    font-size: 19px;
    align-self: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-toggle {
    display: inline-flex;
    align-self: center;
  }

  .nav {
    grid-column: 1 / -1;
    width: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: max-height .22s ease, opacity .16s ease;
  }

  .topbar.nav-open .nav {
    max-height: 240px;
    opacity: 1;
    pointer-events: auto;
    padding-top: 4px;
  }

  .nav a {
    justify-content: center;
    min-height: 36px;
    padding: 7px 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .72);
    border-radius: 10px;
    font-size: 13px;
  }

  .detail-head.detail-has-cover {
    grid-template-columns: 98px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .detail-head.detail-has-cover .detail-cover {
    width: 98px;
    height: 130px;
  }

  .detail-info h1 {
    font-size: 20px;
    margin-bottom: 9px;
  }

  .detail-meta {
    gap: 5px;
  }

  .detail-meta p {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px;
    line-height: 1.45;
    font-size: 14px;
  }

  .detail-tags .badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .detail-intro {
    margin-top: 0;
    padding-top: 12px;
  }

  .detail-intro h2 {
    font-size: 16px;
  }

  .intro-text {
    -webkit-line-clamp: 4;
    line-height: 1.75;
    font-size: 15px;
  }

  .detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .detail-actions .btn,
  .detail-actions form,
  .detail-actions form .btn {
    width: 100%;
  }

  .detail-actions form:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 390px) {
  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .detail-head.detail-has-cover {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .detail-head.detail-has-cover .detail-cover {
    width: 88px;
    height: 118px;
  }

  .detail-meta p {
    grid-template-columns: 34px minmax(0, 1fr);
    font-size: 13px;
  }
}


/* Dashboard compact layout and visual Legado settings. */
.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.dashboard-hero h1 { margin: 0 0 6px; }
.dashboard-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dashboard-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.dashboard-stat-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 86px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.dashboard-stat-card span { color: var(--muted); font-weight: 700; }
.dashboard-stat-card strong { font-size: 30px; line-height: 1; }
.dashboard-section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr);
  gap: 16px;
  align-items: start;
}
.dashboard-panel { margin: 0; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quick-card {
  display: grid;
  gap: 4px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
}
.quick-card.primary { border-color: rgba(37, 99, 235, .35); background: #eff6ff; }
.quick-card strong { font-size: 16px; }
.quick-card span { color: var(--muted); line-height: 1.45; }
.mini-flow { display: grid; gap: 10px; }
.mini-flow div { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.mini-flow b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; background: #eff6ff; color: var(--primary); }
.legado-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .7fr); gap: 16px; align-items: start; }
.legado-config-card, .legado-side-card { margin-top: 0; }
.legado-form label { display: grid; gap: 7px; font-weight: 700; }
.legado-form label small { font-weight: 400; }
.legado-inline-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.inline-actions { justify-content: flex-start; }
.legado-source-box { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; }
.legado-source-box span, .legado-info-list span { color: var(--muted); font-size: 13px; }
.legado-source-box strong, .legado-info-list strong { display: block; word-break: break-all; line-height: 1.45; }
.legado-info-list { display: grid; gap: 10px; margin-top: 14px; }
.legado-info-list div { padding: 10px 0; border-bottom: 1px solid var(--border); }
.legado-info-list div:last-child { border-bottom: 0; }

@media (max-width: 1023px) {
  .dashboard-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-section-grid, .legado-layout { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .dashboard-hero { align-items: stretch; flex-direction: column; margin-bottom: 12px; }
  .dashboard-hero h1 { font-size: 24px; }
  .dashboard-hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .dashboard-hero-actions .btn { width: 100%; }
  .dashboard-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dashboard-stat-card { min-height: 72px; padding: 12px; grid-template-columns: 1fr; gap: 8px; }
  .dashboard-stat-card strong { font-size: 26px; order: -1; }
  .quick-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .quick-card { min-height: 84px; padding: 12px; }
  .quick-card strong { font-size: 15px; }
  .quick-card span { font-size: 13px; }
  .dashboard-guide { display: none; }
  .legado-head .actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .legado-head .btn { width: 100%; }
  .legado-inline-grid { grid-template-columns: 1fr; }
  .inline-actions { display: grid; grid-template-columns: 1fr; }
  .inline-actions .btn { width: 100%; }
}

@media (max-width: 390px) {
  .quick-grid { grid-template-columns: 1fr; }
  .dashboard-hero-actions { grid-template-columns: 1fr; }
}

/* Cover proxy/fallback optimization. */
.cover-img {
  display: block;
  background: #e2e8f0;
}
.cover-fallback {
  border: 1px solid var(--border);
  text-align: center;
  line-height: 1.5;
}
.detail-cover.cover-fallback {
  display: grid;
  place-items: center;
  min-height: 292px;
}
.import-live-notice {
  display: grid;
  gap: 6px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}
.import-job-row.is-terminal,
.import-file-row.is-terminal {
  border-color: #bbf7d0;
}

/* Chapter middle insertion UI. */
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.chapter-manage-list { gap: 10px; }
.chapter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.chapter-list .chapter-row .chapter-link { display: flex; justify-content: space-between; gap: 12px; padding: 0; border: 0; border-radius: 0; background: transparent; min-width: 0; }
.chapter-link strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-link span { color: var(--muted); white-space: nowrap; }
@media (max-width: 767px) {
  .chapter-row { grid-template-columns: 1fr; align-items: stretch; }
  .chapter-list .chapter-row .chapter-link { flex-direction: column; gap: 4px; }
  .chapter-row .btn { width: 100%; }
}

/* Separate public/private novel list pages. */
.novel-list-head { margin-bottom: 12px; }
.novel-list-actions { justify-content: flex-end; }
.list-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 16px;
}
.list-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
}
.list-tab span { font-weight: 700; }
.list-tab strong {
  display: inline-flex;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}
.list-tab.active {
  border-color: #2563eb;
  background: #eff6ff;
}
.list-tab.active strong {
  background: #2563eb;
  color: #fff;
}
@media (max-width: 767px) {
  .list-tabs { gap: 8px; }
  .list-tab { padding: 12px; border-radius: 12px; }
  .novel-list-actions .btn { width: 100%; }
}

/* Import reliability controls. */
.import-job-actions {
  justify-content: flex-start;
  gap: 8px;
}
.import-job-log {
  grid-column: 1 / -1;
  margin-top: 6px;
  font-size: 13px;
}
.import-job-log summary {
  cursor: pointer;
  color: var(--muted);
}
.import-job-log pre {
  max-height: 180px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Mobile overflow fix for add/insert chapter sheet. */
html, body { max-width: 100%; overflow-x: hidden; }
img, video, canvas, svg { max-width: 100%; }
.btn, button, input, textarea, select { max-width: 100%; min-width: 0; }
.sheet, .sheet * { min-width: 0; }
.sheet-panel { max-width: 100vw; overflow-x: hidden; }
.sheet-form, .sheet-form label { min-width: 0; max-width: 100%; }
.sheet-form input, .sheet-form textarea, .sheet-form select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.chapter-insert-select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chapter-row, .chapter-link, .chapter-link strong { min-width: 0; }
.chapter-row .btn.small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 767px) {
  .sheet-panel,
  .sheet-panel.wide {
    width: 100vw;
    max-width: 100vw;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .sheet-head {
    gap: 10px;
  }
  .sheet-head h2 {
    font-size: 20px;
    line-height: 1.25;
  }
  .sheet-head p {
    font-size: 13px;
    line-height: 1.45;
  }
  .sheet-close {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
  }
  .sheet-form textarea[name="content"] {
    min-height: 34vh;
    max-height: 48vh;
  }
  .btn,
  button {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .chapter-row .btn.small {
    white-space: normal;
  }
  .detail-actions,
  .section-head .btn {
    max-width: 100%;
  }
}

/* System maintenance module. */
.system-stat-grid { margin: 18px 0; }
.mini-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.mini-stat-grid > div { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.mini-stat-grid strong { display: block; font-size: 24px; }
.mini-stat-grid span { color: var(--muted); font-size: 13px; }
.maintenance-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.maintenance-actions form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.danger-confirm { color: var(--danger); }
.issue-counts { margin: 12px 0; }
.issue-list { display: grid; gap: 10px; margin-top: 12px; }
.issue-item { padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.issue-item.warning { border-color: #f59e0b; background: #fffbeb; }
.issue-item.error { border-color: #fecaca; background: #fef2f2; }
.issue-item p { margin: 6px 0; line-height: 1.6; }
.issue-item small { display: block; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.maintenance-log-row { grid-template-columns: .8fr .35fr 1.6fr; }
.btn.secondary { background: #f8fafc; }

@media (max-width: 1023px) {
  .mini-stat-grid { grid-template-columns: repeat(3, 1fr); }
  .maintenance-log-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 767px) {
  .mini-stat-grid { grid-template-columns: 1fr 1fr; }
  .maintenance-actions, .maintenance-actions form { align-items: stretch; flex-direction: column; width: 100%; }
  .maintenance-actions .btn { width: 100%; }
  .maintenance-log-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .mini-stat-grid { grid-template-columns: 1fr; }
}

/* v3.7.1 mobile UI compaction and overflow fixes. */
:root {
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.55;
}

.panel,
.card,
.auth-card,
.novel-card,
.stat-card,
.table-row,
.quick-card,
.list-tab,
.guide-grid > div,
.mini-stat-grid > div {
  box-shadow: var(--shadow-soft);
}

.panel > h2,
.card > h2,
.compact-panel > h2 {
  margin-top: 0;
}

.row-main,
.row-main strong,
.row-main span,
.table-row,
.table-row > *,
.chapter-row,
.chapter-link,
.chapter-link strong,
.chapter-preview-main,
.chapter-preview-main strong {
  min-width: 0;
}

.row-main strong,
.table-row strong,
.chapter-link strong,
.chapter-preview-main strong {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chapter-list .chapter-row .chapter-link {
  align-items: flex-start;
}

.chapter-link strong {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.45;
}

.chapter-link span {
  flex: 0 0 auto;
  font-size: 13px;
}

.chapter-preview-main strong,
.chapter-preview-main em {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 767px) {
  body {
    font-size: 15px;
    background: #f6f8fc;
  }

  .topbar-inner {
    padding: 9px 12px;
  }

  .brand {
    font-size: 18px;
  }

  .container {
    padding: 12px 10px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .page-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    align-items: start;
    margin-bottom: 10px;
  }

  .page-head > div {
    min-width: 0;
  }

  .page-head h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
    letter-spacing: 0;
  }

  .page-head .page-desc {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .page-head > .btn {
    align-self: start;
    width: auto;
    min-width: 0;
    min-height: 34px;
    padding: 6px 11px;
    font-size: 14px;
    white-space: nowrap;
  }

  .panel,
  .card,
  .compact-panel {
    margin: 10px 0;
    padding: 12px;
    border-radius: 12px;
  }

  .panel > h2,
  .card > h2,
  .compact-panel > h2,
  .section-head h2 {
    margin: 0 0 8px;
    font-size: 19px;
    line-height: 1.3;
  }

  .section-head {
    gap: 8px;
    margin-bottom: 10px;
  }

  .section-head .page-desc {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.5;
  }

  .table-list,
  .clean-list {
    gap: 8px;
  }

  .table-row,
  .category-row,
  .tag-row,
  .token-row,
  .import-file-row,
  .import-job-row,
  .maintenance-log-row {
    gap: 6px 8px;
    padding: 9px 10px;
    border-radius: 10px;
    box-shadow: none;
  }

  .category-row,
  .tag-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .category-row .row-main,
  .tag-row .row-main {
    grid-column: 1 / -1;
    gap: 2px;
  }

  .category-row > span,
  .tag-row > span,
  .token-row > span,
  .import-file-row > .muted,
  .import-job-row > .muted,
  .maintenance-log-row > span {
    font-size: 13px;
    line-height: 1.4;
  }

  .row-main strong {
    font-size: 15px;
    line-height: 1.35;
    white-space: normal;
  }

  .row-main span {
    font-size: 13px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
  }

  .row-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .category-row .row-actions,
  .tag-row .row-actions {
    grid-column: 1 / -1;
  }

  .token-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .token-row .row-main {
    grid-column: 1 / -1;
    gap: 2px;
  }

  .token-row form {
    grid-column: 1 / -1;
  }

  .token-row form .btn,
  .row-actions .btn,
  .row-actions form .btn {
    width: auto;
  }

  .btn,
  button {
    min-height: 34px;
    padding: 6px 11px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.25;
  }

  .btn.small {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
  }

  input,
  textarea,
  select {
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 16px;
  }

  .badge {
    margin: 1px 3px 1px 0;
    padding: 2px 7px;
    font-size: 11px;
    line-height: 1.45;
  }

  .chapter-manage-list {
    gap: 8px;
  }

  .chapter-row {
    grid-template-columns: minmax(0, 1fr);
    padding: 9px 10px;
  }

  .chapter-list .chapter-row .chapter-link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
  }

  .chapter-link strong {
    font-size: 14px;
    line-height: 1.45;
  }

  .chapter-link span {
    padding-top: 1px;
    font-size: 12px;
  }

  .chapter-row .btn.small {
    justify-self: start;
    width: auto;
    max-width: 100%;
  }

  .chapter-select-toolbar {
    gap: 7px;
    padding: 9px;
    border-radius: 10px;
  }

  .chapter-preview-list {
    gap: 7px;
    max-height: 48vh;
  }

  .chapter-preview-item {
    gap: 8px;
    padding: 9px 10px;
    border-radius: 10px;
  }

  .token-box,
  .import-job-log pre {
    font-size: 12px;
    line-height: 1.55;
  }

  .guide-grid > div,
  .mini-stat-grid > div,
  .quick-card,
  .list-tab {
    padding: 10px;
    border-radius: 11px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-card strong {
    font-size: 24px;
  }

  .sheet-panel,
  .sheet-panel.wide {
    height: min(86vh, 720px);
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
  }

  .sheet-head {
    padding-bottom: 10px;
    margin-bottom: 12px;
  }

  .sheet-head h2 {
    font-size: 19px;
  }

  .sheet-actions {
    gap: 8px;
  }
}

@media (max-width: 390px) {
  .page-head {
    grid-template-columns: 1fr;
  }

  .page-head > .btn {
    justify-self: start;
  }

  .chapter-list .chapter-row .chapter-link {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}



/* v3.7.2 mobile two-column management cards. */
@media (max-width: 767px) {
  .mobile-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
  }

  .mobile-card-grid .empty {
    grid-column: 1 / -1;
  }

  .mobile-card-grid .table-row,
  .mobile-card-grid .category-row,
  .mobile-card-grid .tag-row,
  .mobile-card-grid .token-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 5px;
    min-width: 0;
    min-height: 0;
    padding: 8px;
    border-radius: 10px;
  }

  .mobile-card-grid .row-main {
    grid-column: auto;
    gap: 1px;
  }

  .mobile-card-grid .row-main strong {
    font-size: 14px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .mobile-card-grid .row-main span {
    font-size: 12px;
    line-height: 1.35;
    -webkit-line-clamp: 1;
  }

  .mobile-card-grid .category-row > span,
  .mobile-card-grid .tag-row > span,
  .mobile-card-grid .token-row > span {
    font-size: 12px;
    line-height: 1.35;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .mobile-card-grid .category-row > span:nth-of-type(1),
  .mobile-card-grid .category-row > span:nth-of-type(2),
  .mobile-card-grid .tag-row > span:nth-of-type(1) {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
  }

  .mobile-card-grid .badge,
  .mobile-card-grid .muted {
    font-size: 11px;
  }

  .mobile-card-grid .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .mobile-card-grid .row-actions form,
  .mobile-card-grid .token-row form {
    width: 100%;
    min-width: 0;
  }

  .mobile-card-grid .row-actions .btn,
  .mobile-card-grid .row-actions form .btn,
  .mobile-card-grid .token-row form .btn {
    width: 100%;
    min-height: 30px;
    padding: 5px 7px;
    font-size: 12px;
    border-radius: 8px;
  }

  .mobile-card-grid .token-row form {
    grid-column: auto;
    margin-top: 1px;
  }

  .mobile-card-grid .token-row > span:nth-of-type(2) {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* v3.7.4 site display customization and upload support. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.10);
}

.brand-text {
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-footer {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, .72);
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 13px;
}

.footer-version {
  white-space: nowrap;
}

.form-help {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.site-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 16px;
  align-items: start;
}

.site-settings-form code,
.site-preview-panel code {
  padding: 1px 5px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #334155;
  font-size: .92em;
}

.site-form-section {
  margin-top: 20px;
}

.site-settings-actions {
  margin-top: 12px;
}

.site-preview-card {
  display: grid;
  gap: 14px;
}

.site-preview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.site-preview-header img,
.site-preview-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  flex: 0 0 auto;
}

.site-preview-icon {
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: var(--primary);
  font-weight: 800;
}

.site-preview-header div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.site-preview-header strong,
.browser-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-preview-header span,
.site-preview-browser small {
  color: var(--muted);
}

.site-preview-browser {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
}

.browser-dot-row {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
}

.browser-dot-row i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #cbd5e1;
}

.browser-title {
  margin: 0 0 4px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .site-settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 7px;
  }

  .site-footer-inner {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
  }

  .site-settings-grid {
    gap: 10px;
  }

  .site-preview-header,
  .site-preview-browser {
    padding: 10px;
    border-radius: 12px;
  }
}

/* v3.8.0 API 请求日志与后端服务化页面 */
.api-log-filter-card { overflow: visible; }
.api-log-filter-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.api-log-filter-form label { display: grid; gap: 6px; min-width: 0; font-size: 13px; color: var(--muted); }
.api-log-filter-form input, .api-log-filter-form select { width: 100%; min-width: 0; }
.api-log-filter-actions { display: flex; gap: 8px; align-items: center; }
.api-log-list { display: grid; gap: 10px; }
.api-log-card { border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 12px; display: grid; gap: 10px; }
.api-log-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.api-log-title strong { overflow-wrap: anywhere; word-break: break-word; }
.api-log-path { margin: 6px 0 0; color: #334155; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; word-break: break-all; }
.api-log-meta { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; color: var(--muted); font-size: 13px; }
.api-log-meta span { min-width: 0; overflow-wrap: anywhere; }
.api-log-detail { border-top: 1px dashed var(--border); padding-top: 8px; }
.api-log-detail summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.api-log-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.api-log-detail-grid div { min-width: 0; display: grid; gap: 4px; }
.api-log-detail-grid strong { color: #334155; font-size: 13px; }
.api-log-detail-grid span, .api-log-detail-grid pre { min-width: 0; margin: 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.api-log-pagination { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }
.method-badge { background: #eef2ff; color: #3730a3; }

@media (max-width: 1023px) {
  .api-log-filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .api-log-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .api-log-filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .api-log-filter-actions { grid-column: 1 / -1; }
  .api-log-card { padding: 10px; border-radius: 10px; }
  .api-log-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; font-size: 12px; }
  .api-log-detail-grid { grid-template-columns: 1fr; }
  .api-log-pagination { justify-content: space-between; }
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 767px) { .page-actions { width: 100%; justify-content: flex-start; } }

/* v3.8.1 API 日志半模态筛选 / 详情与站点页限流设置。 */
.api-log-head .page-actions {
  align-items: center;
}

.api-log-summary-card {
  margin-top: 14px;
}

.api-log-active-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.api-log-card-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.sheet-detail-grid .detail-wide {
  grid-column: 1 / -1;
}

.api-log-filter-form.sheet-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.api-log-filter-form.sheet-form label {
  font-weight: 700;
  color: var(--text);
}

.api-log-filter-form.sheet-form .api-log-filter-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.rate-limit-settings {
  display: grid;
  gap: 12px;
}

.rate-limit-switch {
  justify-content: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.rate-limit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.rate-limit-grid label {
  display: grid;
  gap: 7px;
  min-width: 0;
  font-weight: 700;
}

.site-rate-limit-preview {
  display: grid;
  gap: 6px;
}

.site-rate-limit-preview strong {
  display: block;
  color: var(--text);
}

.site-rate-limit-preview span {
  color: var(--muted);
}

@media (max-width: 767px) {
  .api-log-summary-card .section-head > .btn {
    width: 100%;
  }

  .api-log-card-actions {
    justify-content: stretch;
  }

  .api-log-card-actions .btn {
    width: 100%;
  }

  .api-log-filter-form.sheet-form,
  .rate-limit-grid {
    grid-template-columns: 1fr;
  }

  .api-log-filter-form.sheet-form .api-log-filter-actions {
    justify-content: stretch;
  }
}

.radio-card-list {
  display: grid;
  gap: 10px;
}
.radio-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.radio-card input { margin-top: 3px; }
.radio-card span { display: grid; gap: 3px; }
.radio-card small { color: var(--muted); line-height: 1.5; }
.danger-radio { border-color: rgba(220, 38, 38, .28); }
.access-log-settings { margin-bottom: 12px; }
@media (max-width: 767px) {
  .radio-card { padding: 10px; border-radius: 12px; }
}

/* v3.8.3 UI refinement: compact navigation and reduced management-page noise. */
.nav-refactor {
  gap: 6px;
  flex-wrap: nowrap;
}

.nav-refactor .nav-link,
.nav-refactor .nav-group > summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

.nav-refactor .nav-group > summary::-webkit-details-marker {
  display: none;
}

.nav-refactor .nav-group > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}

.nav-refactor .nav-link:hover,
.nav-refactor .nav-group > summary:hover,
.nav-refactor .nav-group[open] > summary {
  color: var(--primary);
  background: #eff6ff;
}

.nav-refactor .nav-group {
  position: relative;
}

.nav-refactor .nav-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 80;
  min-width: 148px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .14);
}

.nav-refactor .nav-menu a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
}

.nav-refactor .nav-menu a:hover {
  color: var(--primary);
  background: #eff6ff;
}

.dashboard-stat-grid {
  margin-top: 12px;
}

.dashboard-hero {
  align-items: center;
}

.dashboard-hero h1,
.page-head h1 {
  letter-spacing: -.02em;
}

.page-head {
  margin-bottom: 14px;
}

.page-desc.compact-desc,
.section-head .page-desc.compact-desc {
  margin-top: 0;
}

.compact-section-head {
  margin-bottom: 8px;
}

.table-row .row-main span:empty {
  display: none;
}

.site-settings-form .section-head,
.api-log-summary-card .section-head,
.compact-panel .section-head {
  margin-bottom: 10px;
}

.legado-layout,
.site-settings-grid {
  align-items: start;
}

@media (min-width: 768px) {
  .nav-refactor .nav-group:not([open]) .nav-menu {
    display: none;
  }
}

@media (max-width: 767px) {
  .nav-refactor {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .topbar.nav-open .nav-refactor {
    max-height: 320px;
  }

  .nav-refactor .nav-link,
  .nav-refactor .nav-group > summary {
    justify-content: center;
    width: 100%;
    min-height: 34px;
    padding: 7px 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,.72);
    color: var(--text);
    font-size: 13px;
  }

  .nav-refactor .nav-group {
    min-width: 0;
  }

  .nav-refactor .nav-menu {
    position: static;
    min-width: 0;
    margin-top: 6px;
    padding: 6px;
    border-radius: 10px;
    box-shadow: none;
  }

  .nav-refactor .nav-menu a {
    justify-content: center;
    min-height: 32px;
    padding: 7px 6px;
    font-size: 12px;
  }

  .dashboard-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-hero {
    margin-bottom: 8px;
  }

  .dashboard-hero h1 {
    font-size: 22px;
  }

  .page-head {
    margin-bottom: 8px;
  }

  .page-head h1 {
    font-size: 21px;
  }

  .compact-panel > h2,
  .section-head h2 {
    margin-bottom: 0;
  }
}

/* v3.8.4 page-head actions and mobile side drawer navigation. */
.nav-drawer-head,
.nav-backdrop {
  display: none;
}

.page-head,
.legado-head,
.novel-list-head,
.api-log-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px 14px;
}

.page-head > div:first-child,
.legado-head > div:first-child,
.novel-list-head > div:first-child,
.api-log-head > div:first-child {
  min-width: 0;
  grid-column: 1;
}

.page-head h1,
.legado-head h1,
.novel-list-head h1,
.api-log-head h1 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.page-head > .btn,
.page-head > .actions,
.page-head > .page-actions,
.legado-head > .actions,
.novel-list-head > .actions,
.api-log-head > .page-actions {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: start;
  width: auto;
  max-width: 100%;
}

.page-head > .actions,
.page-head > .page-actions,
.legado-head > .actions,
.novel-list-head > .actions,
.api-log-head > .page-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.page-head > .actions .btn,
.page-head > .page-actions .btn,
.legado-head > .actions .btn,
.novel-list-head > .actions .btn,
.api-log-head > .page-actions .btn {
  white-space: nowrap;
}

@media (max-width: 767px) {
  body.nav-locked {
    overflow: hidden;
  }

  .topbar {
    align-items: stretch;
    flex-direction: row;
  }

  .topbar-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .nav-toggle {
    display: inline-flex;
    position: relative;
    z-index: 1202;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1190;
    display: block;
    background: rgba(15, 23, 42, .46);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .topbar.nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .nav-refactor,
  .topbar.nav-open .nav-refactor {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    z-index: 1201;
    width: min(82vw, 324px);
    max-height: none;
    height: 100vh;
    margin: 0;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 14px calc(18px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: rgba(255, 255, 255, .98);
    box-shadow: -18px 0 42px rgba(15, 23, 42, .22);
    opacity: 1;
    pointer-events: auto;
    transform: translateX(105%);
    transition: transform .22s ease;
  }

  .topbar.nav-open .nav-refactor {
    transform: translateX(0);
  }

  .nav-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 2px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }

  .nav-drawer-head strong {
    font-size: 17px;
  }

  .nav-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    font-size: 22px;
    line-height: 1;
  }

  .nav-refactor .nav-link,
  .nav-refactor .nav-group > summary {
    justify-content: flex-start;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-size: 15px;
  }

  .nav-refactor .nav-link:hover,
  .nav-refactor .nav-group > summary:hover,
  .nav-refactor .nav-group[open] > summary {
    border-color: rgba(37, 99, 235, .18);
    background: #eff6ff;
  }

  .nav-refactor .nav-group {
    width: 100%;
    min-width: 0;
  }

  .nav-refactor .nav-menu {
    position: static;
    display: none;
    min-width: 0;
    margin: 6px 0 2px;
    padding: 6px;
    border-radius: 12px;
    box-shadow: none;
    background: #f8fafc;
  }

  .nav-refactor .nav-group[open] .nav-menu {
    display: grid;
  }

  .nav-refactor .nav-menu a {
    justify-content: flex-start;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .page-head,
  .legado-head,
  .novel-list-head,
  .api-log-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px 10px;
  }

  .page-head > .btn,
  .page-head > .actions,
  .page-head > .page-actions,
  .legado-head > .actions,
  .novel-list-head > .actions,
  .api-log-head > .page-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    width: auto;
  }

  .page-head > .actions,
  .page-head > .page-actions,
  .legado-head > .actions,
  .novel-list-head > .actions,
  .api-log-head > .page-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .page-head > .btn,
  .page-head > .actions .btn,
  .page-head > .page-actions .btn,
  .legado-head > .actions .btn,
  .novel-list-head > .actions .btn,
  .api-log-head > .page-actions .btn {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 10px;
    white-space: nowrap;
  }

  .api-log-head > .page-actions .btn {
    padding-inline: 8px;
  }
}

@media (max-width: 390px) {
  .page-head,
  .legado-head,
  .novel-list-head,
  .api-log-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .page-head h1,
  .legado-head h1,
  .novel-list-head h1,
  .api-log-head h1 {
    font-size: 20px;
  }

  .page-head > .btn,
  .page-head > .actions .btn,
  .page-head > .page-actions .btn,
  .legado-head > .actions .btn,
  .novel-list-head > .actions .btn,
  .api-log-head > .page-actions .btn {
    padding-inline: 8px;
    font-size: 12px;
  }
}

/* v3.8.5 switch controls and sheet action layout. */
.switch-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 44px;
  padding: 10px 0;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.sheet-form .switch-row,
.form-stack .switch-row {
  display: flex !important;
  grid-template-columns: none;
}
.switch-label {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.switch-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0;
  pointer-events: none;
}
.switch-control {
  position: relative;
  flex: 0 0 46px;
  width: 46px;
  height: 26px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #e5e7eb;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.switch-control::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .24);
  transition: transform .18s ease;
}
.switch-input:checked + .switch-control {
  border-color: var(--primary);
  background: var(--primary);
}
.switch-input:checked + .switch-control::after {
  transform: translateX(20px);
}
.switch-input:focus-visible + .switch-control {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
.sheet-panel .sheet-actions {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  gap: 10px;
}
.sheet-panel .sheet-actions > .btn,
.sheet-panel .sheet-actions > a.btn,
.sheet-panel .sheet-actions > button.btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}
@media (max-width: 767px) {
  .switch-row {
    min-height: 40px;
    padding: 8px 0;
  }
  .switch-control {
    flex-basis: 44px;
    width: 44px;
    height: 24px;
  }
  .switch-control::after {
    width: 18px;
    height: 18px;
  }
  .switch-input:checked + .switch-control::after {
    transform: translateX(20px);
  }
  .sheet-panel .sheet-actions {
    flex-direction: row;
    gap: 8px;
  }
  .sheet-panel .sheet-actions > .btn,
  .sheet-panel .sheet-actions > a.btn,
  .sheet-panel .sheet-actions > button.btn {
    width: auto !important;
    flex: 1 1 0;
    min-height: 38px;
    padding-inline: 10px;
  }
}

/* v3.8.6 mobile drawer blank-area fix. */
@media (max-width: 767px) {
  .nav-backdrop {
    background: rgba(15, 23, 42, .42);
    backdrop-filter: blur(2px);
  }

  .nav-refactor,
  .topbar.nav-open .nav-refactor {
    top: max(10px, env(safe-area-inset-top, 0px));
    right: 0;
    bottom: auto;
    left: auto;
    width: min(74vw, 292px);
    height: auto;
    min-height: 0;
    max-height: calc(100vh - 20px - env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0px));
    padding: 14px;
    border: 1px solid rgba(226, 232, 240, .96);
    border-radius: 20px 0 0 20px;
    box-shadow: -16px 18px 42px rgba(15, 23, 42, .22);
    overflow-y: auto;
    overscroll-behavior: contain;
    visibility: hidden;
    transform: translateX(calc(100% + 14px));
  }

  .topbar.nav-open .nav-refactor {
    visibility: visible;
    transform: translateX(0);
  }

  .nav-drawer-head {
    flex: 0 0 auto;
  }

  .nav-refactor .nav-link,
  .nav-refactor .nav-group > summary {
    min-height: 40px;
  }
}

/* v3.8.7 mobile viewport height adaptation fix. */
:root {
  --app-height: 100vh;
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-safe-top: env(safe-area-inset-top, 0px);
}

html,
body {
  min-height: var(--app-height);
}

body {
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 auto;
}

.container {
  flex: 1 0 auto;
  width: 100%;
}

.site-footer {
  flex: 0 0 auto;
}

@media (max-width: 767px) {
  body.nav-locked {
    width: 100%;
    min-height: var(--app-height);
    overflow: hidden;
    overscroll-behavior: contain;
  }

  .nav-backdrop {
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    height: var(--app-height);
    min-height: var(--app-height);
  }

  .nav-refactor,
  .topbar.nav-open .nav-refactor {
    top: max(10px, var(--app-safe-top));
    right: 0;
    bottom: auto;
    width: min(78vw, 310px);
    height: calc(var(--app-height) - 20px - var(--app-safe-top) - var(--app-safe-bottom));
    max-height: calc(var(--app-height) - 20px - var(--app-safe-top) - var(--app-safe-bottom));
    min-height: min(420px, calc(var(--app-height) - 20px - var(--app-safe-top) - var(--app-safe-bottom)));
    padding: 14px 14px calc(14px + var(--app-safe-bottom));
    border-radius: 20px 0 0 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .nav-drawer-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(255, 255, 255, .98);
  }

  .sheet,
  .sheet-backdrop {
    min-height: var(--app-height);
  }

  .sheet-panel,
  .sheet-panel.wide {
    max-height: calc(var(--app-height) - 10px - var(--app-safe-top));
  }
}


/* v3.8.8 dashboard charts and compact system status. */
.dashboard-hero-compact {
  margin-bottom: 10px;
}

.dashboard-chart-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.chart-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-soft, var(--shadow));
  overflow: hidden;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.chart-head h2 {
  margin: 0 0 3px;
  font-size: 17px;
  letter-spacing: -.02em;
}

.chart-head span,
.scale-main span,
.scale-side span,
.bar-chart-row span {
  color: var(--muted);
  font-size: 13px;
}

.donut-layout {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.donut-chart {
  position: relative;
  display: grid;
  place-items: center;
  width: 108px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0 var(--public-pct), #7c3aed var(--public-pct) 100%);
}

.donut-chart.is-empty {
  background: #e5e7eb;
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: inset 0 0 0 1px rgba(226, 232, 240, .88);
}

.donut-chart span {
  position: relative;
  z-index: 1;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.03em;
}

.chart-legend {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.chart-legend a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot-primary { background: var(--primary); }
.dot-purple { background: #7c3aed; }

.bar-chart-list {
  display: grid;
  gap: 10px;
  align-content: center;
}

.bar-chart-row {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.bar-chart-row div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.bar-chart-row strong {
  font-size: 18px;
}

.bar-chart-row b {
  display: block;
  height: 9px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.bar-chart-row i {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}

.scale-chart {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .86fr);
  gap: 12px;
  align-items: stretch;
}

.scale-main,
.scale-side > div {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
}

.scale-main strong {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  letter-spacing: -.04em;
}

.scale-side {
  display: grid;
  gap: 10px;
}

.scale-side strong {
  font-size: 22px;
  line-height: 1.05;
}

.system-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.system-summary-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-soft, var(--shadow));
}

.system-summary-card span,
.system-run-grid span {
  color: var(--muted);
  font-size: 12px;
}

.system-summary-card strong {
  min-width: 0;
  font-size: clamp(19px, 2.4vw, 28px);
  line-height: 1.08;
  letter-spacing: -.03em;
  overflow-wrap: anywhere;
}

.system-summary-card.is-ok strong { color: #047857; }
.system-summary-card.is-error strong { color: var(--danger); }

.system-run-panel {
  margin-top: 0;
}

.system-run-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.system-run-grid > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.system-run-grid strong {
  min-width: 0;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.system-run-wide {
  grid-column: span 4;
}

@media (max-width: 1180px) {
  .dashboard-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .system-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .dashboard-chart-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .chart-card {
    padding: 12px;
    border-radius: 14px;
    gap: 10px;
  }

  .chart-head h2 {
    font-size: 15px;
  }

  .donut-layout {
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
  }

  .donut-chart {
    width: 86px;
  }

  .donut-chart::after {
    inset: 14px;
  }

  .donut-chart span {
    font-size: 20px;
  }

  .bar-chart-list {
    gap: 8px;
  }

  .bar-chart-row strong {
    font-size: 16px;
  }

  .scale-chart {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .scale-main,
  .scale-side > div {
    padding: 10px;
    border-radius: 12px;
  }

  .scale-main strong {
    font-size: 28px;
  }

  .scale-side strong {
    font-size: 18px;
  }

  .system-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0 12px;
  }

  .system-summary-card {
    min-height: 68px;
    padding: 10px;
    border-radius: 12px;
  }

  .system-summary-card strong {
    font-size: 21px;
  }

  .system-run-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .system-run-grid > div {
    padding: 8px;
    border-radius: 10px;
  }

  .system-run-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 390px) {
  .system-summary-card strong {
    font-size: 19px;
  }

  .chart-legend a {
    padding-inline: 7px;
  }
}

/* v3.8.9 form action width and novel detail action layout fix. */
.form-actions {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  gap: 10px;
  flex-wrap: nowrap;
  width: 100%;
}
.form-actions > .btn,
.form-actions > a.btn,
.form-actions > button.btn,
.form-actions > form,
.form-actions > form > .btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}
.form-actions.two-actions > .btn,
.form-actions.two-actions > a.btn,
.form-actions.two-actions > button.btn {
  flex-basis: 50%;
}
.chapter-edit-actions > .btn,
.chapter-edit-actions > a.btn,
.chapter-edit-actions > button.btn {
  flex: 1 1 0;
}
.detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
  width: 100%;
}
.detail-actions > .btn,
.detail-actions > form,
.detail-actions > form > .btn {
  width: 100%;
  min-width: 0;
}
.detail-actions > form,
.detail-actions form:last-child {
  grid-column: auto !important;
  display: flex;
}
.detail-actions > form > .btn {
  flex: 1 1 auto;
}
.sheet-panel .sheet-actions,
.sheet-actions {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  gap: 10px;
  flex-direction: row;
  width: 100%;
}
.sheet-panel .sheet-actions > .btn,
.sheet-panel .sheet-actions > a.btn,
.sheet-panel .sheet-actions > button.btn,
.sheet-actions > .btn,
.sheet-actions > a.btn,
.sheet-actions > button.btn {
  flex: 1 1 0;
  width: auto !important;
  min-width: 0;
}
@media (max-width: 767px) {
  .form-actions,
  .detail-actions,
  .sheet-actions {
    gap: 8px;
  }
  .form-actions > .btn,
  .form-actions > a.btn,
  .form-actions > button.btn,
  .chapter-edit-actions > .btn,
  .chapter-edit-actions > a.btn,
  .chapter-edit-actions > button.btn,
  .detail-actions > .btn,
  .detail-actions > form > .btn,
  .sheet-actions > .btn,
  .sheet-actions > a.btn,
  .sheet-actions > button.btn {
    min-height: 40px;
    padding-inline: 10px;
    white-space: nowrap;
  }
}
@media (max-width: 360px) {
  .chapter-edit-actions {
    flex-wrap: wrap;
  }
  .chapter-edit-actions > .btn,
  .chapter-edit-actions > a.btn,
  .chapter-edit-actions > button.btn {
    flex-basis: calc(50% - 4px);
  }
  .chapter-edit-actions > button.btn.danger {
    flex-basis: 100%;
  }
}

/* v3.8.10 novel detail performance and chapter row layout. */
.detail-cover.cover-img {
  content-visibility: auto;
}
.chapter-row.chapter-row-compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: stretch;
  padding: 10px 10px 10px 12px;
}
.chapter-row-compact .chapter-main,
.chapter-list .chapter-row-compact .chapter-link {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  align-content: center;
  min-width: 0;
}
.chapter-row-compact .chapter-main strong {
  display: block;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}
.chapter-row-compact .chapter-main span {
  justify-self: start;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}
.chapter-row-compact .chapter-insert-btn {
  display: grid;
  place-items: center;
  align-self: stretch;
  justify-self: stretch;
  width: 44px;
  min-width: 44px;
  min-height: 68px;
  padding: 8px 0;
  line-height: 1.1;
  writing-mode: vertical-rl;
  text-orientation: upright;
  white-space: nowrap;
}
.chapter-insert-display[readonly] {
  cursor: default;
  color: var(--muted);
  background: #f8fafc;
}
@media (max-width: 767px) {
  .chapter-row.chapter-row-compact {
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    padding: 9px 9px 9px 10px;
  }
  .chapter-row-compact .chapter-insert-btn {
    width: 42px;
    min-width: 42px;
    min-height: 64px;
    padding: 7px 0;
  }
  .chapter-row-compact .chapter-main strong {
    font-size: 14px;
  }
  .chapter-row-compact .chapter-main span {
    font-size: 12px;
  }
}
.chapter-row.chapter-row-compact .btn.small.chapter-insert-btn {
  justify-self: stretch;
  width: 44px;
  max-width: 44px;
}
@media (max-width: 767px) {
  .chapter-row.chapter-row-compact .btn.small.chapter-insert-btn {
    justify-self: stretch;
    width: 42px;
    max-width: 42px;
  }
}
.chapter-row-compact {
  content-visibility: auto;
  contain-intrinsic-size: 84px;
}

/* v3.8.11 chapter insert picker and selectable search controls. */
.chapter-row-compact .chapter-insert-btn,
.chapter-row.chapter-row-compact .btn.small.chapter-insert-btn {
  width: 54px;
  max-width: 54px;
  min-width: 54px;
  min-height: 64px;
  padding: 6px 8px;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  white-space: nowrap;
  line-height: 1.2;
  overflow: visible;
}
@media (max-width: 767px) {
  .chapter-row.chapter-row-compact {
    grid-template-columns: minmax(0, 1fr) 54px;
  }
  .chapter-row-compact .chapter-insert-btn,
  .chapter-row.chapter-row-compact .btn.small.chapter-insert-btn {
    width: 54px;
    max-width: 54px;
    min-width: 54px;
    min-height: 62px;
  }
}
.chapter-position-picker,
.searchable-select-field {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}
.picker-current {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #f8fafc;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.picker-search,
.select-search-input {
  width: 100%;
}
.picker-results {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}
.picker-option {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  justify-items: start;
  text-align: left;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}
.picker-option strong {
  min-width: 0;
  max-width: 100%;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.picker-option span {
  color: var(--muted);
  font-size: 12px;
}
.picker-option.is-selected {
  border-color: var(--primary);
  background: #eff6ff;
  color: #1d4ed8;
}
.picker-empty {
  margin: 4px;
  padding: 8px;
}
@media (max-width: 767px) {
  .picker-results {
    max-height: 220px;
  }
  .picker-current,
  .picker-option {
    font-size: 14px;
  }
}

/* v3.8.12 compact picker rows: search/current value on the left, native select button on the right. */
.chapter-row.chapter-row-compact {
  grid-template-columns: minmax(0, 1fr) 64px;
}
.chapter-row-compact .chapter-insert-btn,
.chapter-row.chapter-row-compact .btn.small.chapter-insert-btn {
  width: 64px !important;
  max-width: 64px !important;
  min-width: 64px !important;
  min-height: 58px;
  writing-mode: horizontal-tb !important;
  text-orientation: mixed !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-align: center;
  padding: 6px 8px;
}
.picker-combo-row,
.search-select-combo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}
.picker-combo-input,
.search-select-input,
.picker-search.picker-combo-input,
.select-search-input.search-select-input {
  width: 100%;
  min-width: 0;
  height: 42px;
}
.picker-select-wrap {
  position: relative;
  display: block;
  min-width: 0;
  height: 42px;
}
.picker-select-visual,
.picker-select-wrap > .btn.picker-select-visual {
  width: 100%;
  height: 100%;
  min-height: 42px;
  padding: 0 10px;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.picker-native-select,
.native-search-select,
.picker-select-wrap > select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.chapter-position-picker .picker-current,
.chapter-position-picker .picker-results {
  display: none !important;
}
.searchable-select-field > select,
.searchable-select-field > .select-search-input:not(.search-select-input) {
  width: 100%;
}
@media (max-width: 767px) {
  .chapter-row.chapter-row-compact {
    grid-template-columns: minmax(0, 1fr) 60px;
  }
  .chapter-row-compact .chapter-insert-btn,
  .chapter-row.chapter-row-compact .btn.small.chapter-insert-btn {
    width: 60px !important;
    max-width: 60px !important;
    min-width: 60px !important;
    min-height: 56px;
    font-size: 13px;
  }
  .picker-combo-row,
  .search-select-combo {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 7px;
  }
  .picker-combo-input,
  .search-select-input,
  .picker-search.picker-combo-input,
  .select-search-input.search-select-input,
  .picker-select-wrap,
  .picker-select-visual,
  .picker-select-wrap > .btn.picker-select-visual {
    height: 40px;
    min-height: 40px;
  }
}

/* v3.8.13 enter-to-search compact picker behavior. */
.chapter-position-picker,
.searchable-select-field {
  position: relative;
}
.picker-select-visual,
.picker-select-wrap > .btn.picker-select-visual {
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 3;
}
.picker-native-select,
.native-search-select,
.picker-select-wrap > select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  clip-path: inset(50%);
}

/* v3.8.14 use browser native select lists instead of handmade popups. */
.picker-select-wrap {
  height: 42px;
}
.picker-select-visual,
.picker-select-wrap > .btn.picker-select-visual {
  display: none !important;
}
.picker-native-select,
.native-search-select,
.picker-select-wrap > select {
  position: static !important;
  inset: auto !important;
  width: 100% !important;
  height: 42px !important;
  min-height: 42px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  overflow: visible !important;
  clip-path: none !important;
  cursor: pointer;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  appearance: auto;
}
@media (max-width: 767px) {
  .picker-select-wrap,
  .picker-native-select,
  .native-search-select,
  .picker-select-wrap > select {
    height: 40px !important;
    min-height: 40px !important;
  }
}


/* v3.8.15 mobile picker layout: stack search/current input above native select. */
@media (max-width: 767px) {
  .picker-combo-row,
  .search-select-combo {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  .picker-combo-input,
  .search-select-input,
  .picker-search.picker-combo-input,
  .select-search-input.search-select-input,
  .picker-select-wrap,
  .picker-native-select,
  .native-search-select,
  .picker-select-wrap > select {
    width: 100% !important;
  }
}

/* v3.8.17 mobile hamburger menu and persistent picker clear buttons. */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.hamburger-toggle {
  justify-content: center;
}
.hamburger-lines,
.hamburger-lines::before,
.hamburger-lines::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}
.hamburger-lines {
  position: relative;
}
.hamburger-lines::before,
.hamburger-lines::after {
  position: absolute;
  left: 0;
}
.hamburger-lines::before { top: -6px; }
.hamburger-lines::after { top: 6px; }
@media (max-width: 767px) {
  .nav-toggle.hamburger-toggle {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 12px;
  }
}
.picker-input-wrap {
  position: relative;
  min-width: 0;
  width: 100%;
  height: 42px;
}
.picker-input-wrap > .picker-combo-input,
.picker-input-wrap > .search-select-input,
.picker-input-wrap > input[type="search"] {
  width: 100% !important;
  height: 100% !important;
  min-height: 42px;
  padding-right: 42px;
}
.picker-clear-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transform: translateY(-50%);
  cursor: pointer;
}
.picker-clear-btn:hover,
.picker-clear-btn:focus-visible {
  border-color: rgba(37, 99, 235, .24);
  background: #e0ecff;
  color: var(--primary);
  outline: none;
}
@media (max-width: 767px) {
  .picker-input-wrap {
    height: 40px;
  }
  .picker-input-wrap > .picker-combo-input,
  .picker-input-wrap > .search-select-input,
  .picker-input-wrap > input[type="search"] {
    min-height: 40px;
    padding-right: 40px;
  }
  .picker-clear-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    right: 6px;
    font-size: 19px;
  }
}

/* v3.8.19 OpenAPI page. */
.openapi-summary-grid .system-summary-card strong {
  font-size: 18px;
  line-height: 1.25;
  word-break: break-word;
}
.openapi-tool-panel .openapi-doc-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.openapi-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.openapi-group-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
.openapi-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.openapi-group-title strong {
  min-width: 0;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.openapi-group-title span {
  flex: none;
  color: var(--muted);
  font-size: 12px;
}
.openapi-group-bar {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: #eef2ff;
  overflow: hidden;
}
.openapi-group-bar span {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: var(--primary);
}
.openapi-operation-groups {
  display: grid;
  gap: 14px;
}
.openapi-operation-list {
  display: grid;
  gap: 10px;
}
.openapi-operation-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
.openapi-operation-main {
  min-width: 0;
}
.openapi-operation-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.openapi-operation-line code {
  min-width: 0;
  color: #334155;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.openapi-method {
  flex: none;
  min-width: 52px;
  padding: 3px 8px;
  border-radius: 999px;
  text-align: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}
.openapi-method-get { background: #2563eb; }
.openapi-method-post { background: #059669; }
.openapi-method-put,
.openapi-method-patch { background: #d97706; }
.openapi-method-delete { background: #dc2626; }
.openapi-method-options,
.openapi-method-head { background: #64748b; }
.openapi-operation-meta {
  display: grid;
  gap: 3px;
  margin-top: 8px;
}
.openapi-operation-meta strong {
  font-size: 14px;
}
.openapi-operation-meta span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.openapi-operation-flags {
  margin-top: 8px;
}
.badge.warn {
  background: #fffbeb;
  color: #b45309;
}
.openapi-operation-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 96px;
}
.openapi-operation-actions .btn {
  justify-content: center;
}
@media (max-width: 767px) {
  .openapi-head .page-actions {
    justify-content: flex-end;
  }
  .openapi-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .openapi-summary-grid .system-summary-card:first-child {
    grid-column: 1 / -1;
  }
  .openapi-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .openapi-group-card {
    padding: 10px;
    border-radius: 12px;
  }
  .openapi-group-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
  .openapi-operation-card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
  }
  .openapi-operation-line {
    align-items: flex-start;
  }
  .openapi-operation-line code {
    white-space: normal;
    word-break: break-all;
  }
  .openapi-operation-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }
}

/* v3.8.20 OpenAPI auto generation and detail sheets. */
.openapi-operation-clickable {
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.openapi-operation-clickable:hover,
.openapi-operation-clickable:focus-visible {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  outline: none;
}
.openapi-detail-grid {
  margin-bottom: 14px;
}
.openapi-detail-section {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.openapi-detail-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}
.openapi-detail-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.openapi-detail-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-size: 13px;
}
.openapi-detail-table th,
.openapi-detail-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.openapi-detail-table th {
  background: rgba(15, 23, 42, 0.035);
  color: var(--muted);
  font-weight: 700;
}
.openapi-detail-table tr:last-child td {
  border-bottom: 0;
}
.openapi-copy-block {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: #0f172a;
  color: #e5e7eb;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
}
@media (max-width: 767px) {
  .openapi-detail-table {
    min-width: 440px;
  }
  .openapi-operation-clickable:hover {
    transform: none;
  }
}

/* v3.8.22 layout and interaction refinements. */
html {
  scroll-behavior: smooth;
}
body.sheet-locked {
  position: fixed;
  inset-inline: 0;
  width: 100%;
  overflow: hidden !important;
  overscroll-behavior: none;
}
.sheet.is-open,
.sheet.is-open .sheet-backdrop,
.sheet.is-open .sheet-panel {
  overscroll-behavior: contain;
}
.sheet.is-open .sheet-panel {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* All devices: stack search/current input above the native select. */
.picker-combo-row,
.search-select-combo {
  grid-template-columns: 1fr !important;
  gap: 8px !important;
}
.picker-input-wrap,
.search-input-wrap,
.picker-select-wrap,
.search-select-wrap,
.picker-native-select,
.native-search-select,
.picker-select-wrap > select {
  width: 100% !important;
}

/* PC and tablet: chapter management list uses two ordered columns. */
@media (min-width: 768px) {
  .chapter-list.chapter-manage-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
  .chapter-row.chapter-row-compact {
    height: 100%;
  }
}
@media (max-width: 767px) {
  .chapter-list.chapter-manage-list {
    grid-template-columns: 1fr;
  }
}

/* Moderate motion for page rendering, cards and controls. */
@media (prefers-reduced-motion: no-preference) {
  body {
    animation: pageFadeIn .18s ease-out both;
  }
  main > *,
  .panel,
  .card,
  .compact-panel,
  .chapter-row,
  .openapi-operation-card,
  .system-summary-card,
  .novel-card,
  .resource-card,
  .token-card,
  .category-card,
  .tag-card {
    animation: itemRiseIn .20s ease-out both;
  }
  .btn,
  .nav a,
  .chapter-row,
  .openapi-operation-card,
  .sheet-close,
  input,
  select,
  textarea {
    transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease, opacity .16s ease;
  }
  .btn:active,
  .openapi-operation-card:active,
  .chapter-row:active {
    transform: translateY(1px);
  }
  .sheet.is-open .sheet-backdrop {
    animation: sheetBackdropIn .18s ease-out both;
  }
}
@keyframes pageFadeIn {
  from { opacity: .86; }
  to { opacity: 1; }
}
@keyframes itemRiseIn {
  from { opacity: .88; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sheetBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* v3.8.25: sheet overlays must stay viewport-fixed and must not inherit page/card transform animations. */
.sheet,
main > .sheet {
  animation: none !important;
  transform: none !important;
}

/* v3.8.23 OpenAPI mobile detail and Markdown export refinements. */
.openapi-tool-panel .section-head {
  align-items: center;
}
@media (max-width: 767px) {
  .openapi-head .page-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .openapi-head .page-actions .btn {
    min-width: 0;
    justify-content: center;
  }
  .openapi-detail-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  .openapi-detail-grid div {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(248, 250, 252, .72);
  }
  .openapi-detail-section {
    margin-top: 12px;
    padding-top: 12px;
  }
  .openapi-detail-section h3 {
    font-size: 14px;
  }
  .openapi-detail-table-wrap {
    overflow-x: visible;
    border: 0;
    border-radius: 0;
  }
  .openapi-detail-table {
    min-width: 0 !important;
    font-size: 12px;
  }
  .openapi-detail-table thead {
    display: none;
  }
  .openapi-detail-table,
  .openapi-detail-table tbody,
  .openapi-detail-table tr,
  .openapi-detail-table td {
    display: block;
    width: 100%;
  }
  .openapi-detail-table tr {
    padding: 9px 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
  }
  .openapi-detail-table td {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
    padding: 3px 0;
    border: 0;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .openapi-detail-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }
  .openapi-copy-block {
    max-height: 220px;
    padding: 10px;
    font-size: 11px;
    line-height: 1.55;
  }
}



/* v3.8.26 OpenAPI unified sheet and group jump fixes. */
.openapi-group-card {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.openapi-group-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .22);
  outline-offset: 3px;
}
.openapi-operation-group {
  scroll-margin-top: 92px;
}
@media (max-width: 767px) {
  .openapi-operation-group {
    scroll-margin-top: 76px;
  }
}

/* v3.8.27 OpenAPI sheet close scroll-jump fix. */
html.sheet-scroll-restoring {
  scroll-behavior: auto !important;
}
body.sheet-locked {
  left: 0;
  right: 0;
  touch-action: none;
}
.sheet.is-open {
  touch-action: none;
}
.sheet.is-open .sheet-panel {
  touch-action: pan-y;
}
