/* 裁判文书查询助手 H5 —— 零依赖样式，主题色由渠道配置注入 CSS 变量 */

:root {
  --primary: #1A6BDE;
  --primary-light: #E8F0FC;
  --primary-soft: #B9D2F6;
  --primary-dark: #154FA6;
  --nav-bg: #FFFFFF;
  --nav-color: #1F2430;
  --text-main: #1F2430;
  --text-sub: #6B7280;
  --text-weak: #9CA3AF;
  --line: #EEF1F5;
  --bg: #F5F7FA;
  --radius: 12px;
  --tabbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-main);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a { color: var(--primary); text-decoration: none; }
button { font: inherit; }
mark { background: #FFE9A8; color: inherit; padding: 0 2px; border-radius: 3px; }

/* ------------------------------- 顶部与页签 ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 12px;
  background: var(--nav-bg);
  color: var(--nav-color);
  border-bottom: 1px solid var(--line);
}

.topbar-back {
  border: 0;
  background: transparent;
  color: var(--nav-color);
  font-size: 26px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid var(--line);
}

.tabbar-item {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  font-size: 14px;
}

.tabbar-item.active { color: var(--primary); font-weight: 600; }

/* --------------------------------- 布局 --------------------------------- */

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 12px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card + .card { margin-top: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-sub); }
.weak { color: var(--text-weak); font-size: 13px; }
.ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 4px 10px;
  font-size: 15px;
  font-weight: 600;
}

.skeleton { padding: 40px 0; text-align: center; color: var(--text-weak); }

/* -------------------------------- 搜索框 -------------------------------- */

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--text-weak);
  cursor: pointer;
}

.searchbar input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--text-main);
  min-width: 0;
}

/* --------------------------------- 分类 --------------------------------- */

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.category-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
  color: var(--text-main);
  cursor: pointer;
}

.category-item b { display: block; font-size: 15px; font-weight: 600; }
.category-item span { color: var(--text-weak); font-size: 12px; }

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 10px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-sub);
  cursor: pointer;
}

.tab.active {
  background: var(--primary-light);
  border-color: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* --------------------------------- 卡片 --------------------------------- */

.qa-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
}

.qa-card h3 { margin: 0 0 6px; font-size: 16px; line-height: 1.5; }
.qa-card p { margin: 0 0 8px; color: var(--text-sub); font-size: 14px; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
}

/* --------------------------------- 按钮 --------------------------------- */

.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.btn[disabled] { opacity: .6; cursor: default; }

.btn-ghost {
  background: #fff;
  color: var(--text-main);
  border: 1px solid var(--line);
}

.btn-sm { width: auto; padding: 8px 16px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; }

/* --------------------------------- 详情 --------------------------------- */

.article-title { font-size: 21px; font-weight: 700; line-height: 1.45; margin: 0 0 10px; }
.article-meta { color: var(--text-weak); font-size: 13px; margin-bottom: 14px; }

.article-body { font-size: 16px; line-height: 1.85; }
.article-body h3 { font-size: 16px; margin: 20px 0 8px; }
.article-body p { margin: 0 0 12px; }
.article-body ul { margin: 0 0 12px; padding-left: 20px; }
.article-body li { margin-bottom: 6px; }

.related-item {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text-main);
}

.related-item:last-child { border-bottom: 0; }

/* --------------------------------- 跳转 --------------------------------- */

.qr-box { text-align: center; padding: 8px 0 4px; }
.qr-box img {
  width: 220px;
  height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.notice {
  background: #FFF9E8;
  border: 1px solid #FFE9A8;
  color: #8A6100;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
}

/* --------------------------------- 表单 --------------------------------- */

textarea, input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  outline: none;
}

textarea { min-height: 130px; resize: vertical; }

.field-label { display: block; margin: 12px 0 6px; color: var(--text-sub); font-size: 14px; }

/* --------------------------------- 提示 --------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 28px);
  transform: translateX(-50%);
  max-width: 80%;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(31, 36, 48, .9);
  color: #fff;
  font-size: 14px;
  z-index: 50;
}

.empty { padding: 48px 16px; text-align: center; color: var(--text-weak); }
.loading-more { padding: 18px; text-align: center; color: var(--text-weak); font-size: 13px; }

/* --------------------------------- 工具 --------------------------------- */

.tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-cell {
  width: calc((100% - 16px) / 3);
  padding: 14px 2px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
}

.tool-cell-primary {
  background: var(--primary-light);
  border-color: var(--primary-soft);
}

.tool-cell-primary .tool-cell-name {
  color: var(--primary-dark);
  font-weight: 600;
}

.tool-cell-icon { font-size: 20px; line-height: 1.2; }
.tool-cell-name { margin-top: 4px; font-size: 12px; color: var(--text-main); }

.tool-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.tool-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 10px;
  background: var(--primary-light);
}

.tool-main { flex: 1; min-width: 0; }
.tool-name { font-size: 15px; font-weight: 600; }
.tool-desc { margin-top: 2px; font-size: 12px; color: var(--text-sub); }
.tool-arrow { flex: 0 0 auto; color: var(--text-weak); font-size: 18px; }

.field { margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--text-sub); }
.required { color: #E5484D; }

.input, .textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  outline: none;
}

.textarea { min-height: 110px; resize: vertical; }
.field-hint { margin-top: 4px; font-size: 12px; color: var(--text-weak); line-height: 1.5; }

.error-tip {
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: #FEF3F2;
  color: #B42318;
  font-size: 13px;
}

.result-card { border-color: var(--primary-soft); background: var(--primary-light); }
.result-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, .05);
  font-size: 14px;
}
.result-row:last-of-type { border-bottom: 0; }
.result-strong { font-weight: 700; color: var(--primary-dark); font-size: 16px; }
.result-text {
  margin: 10px 0 0;
  padding: 12px;
  max-height: 320px;
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}
.result-notes { margin: 12px 0; }
.result-note { font-size: 12px; color: var(--text-sub); line-height: 1.7; }
.tone-urgent { background: #FFF9E8; border-color: #FFE9A8; }
.tone-expired { background: #FEF3F2; border-color: #FDA29B; }
