/* 申论素材库 · 仿APP界面 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --red: #C8102E; --red-deep: #9E0B22; --red-soft: #FFF1F2;
  --blue: #1266B0; --blue-soft: #EDF4FB;
  --ink: #262626; --ink-2: #595959; --ink-3: #8C8C8C;
  --gold: #D4880F; --gold-soft: #FFF8E8;
  --bg: #F6F4F0; --card: #FFFFFF; --line: #EDE9E3;
  --green: #2E7D32;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(60,40,20,.06), 0 4px 14px rgba(60,40,20,.05);
}

/* ===== 夜间模式 ===== */
body.dark {
  --bg: #16161a; --card: #232329; --line: #33333c;
  --ink: #e6e6ea; --ink-2: #b4b4bd; --ink-3: #84848f;
  --red-soft: #3a1a20; --blue-soft: #16222e; --gold-soft: #3a3013;
  --shadow: 0 1px 3px rgba(0,0,0,.45), 0 4px 14px rgba(0,0,0,.35);
}
body.dark .topbar { background: linear-gradient(135deg, #7a0d1f, #b0112c); }
body.dark .tabbar { background: rgba(35,35,41,.96); }
body.dark .reader { background: var(--bg); }
body.dark .reader-top { background: rgba(22,22,26,.95); }
body.dark .reader-content { color: #d6d6da; }
body.dark .searchbar input, body.dark .form-row input { background: #2a2a31; color: var(--ink); border-color: var(--line); }
body.dark .fchip { background: var(--card); color: var(--ink-2); }
body.dark .seg { background: #1e1e24; }
body.dark .mini-btn, body.dark .btn-ghost { color: var(--ink-2); }
body.dark .empty, body.dark .loading { color: var(--ink-3); }

html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink);
  max-width: 520px; margin: 0 auto;
  overscroll-behavior-y: none;
}

/* ===== 顶部栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(135deg, var(--red-deep), var(--red));
  color: #fff; padding: 14px 18px 12px;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 2px 10px rgba(158,11,34,.25);
}
.topbar .row { display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: 1px; display:flex; align-items:center; gap:8px; }
.topbar h1 svg { width: 22px; height: 22px; }
.topbar .sub { font-size: 11px; opacity: .85; margin-top: 3px; }

/* 每日一句 */
.quote {
  margin: 12px 16px 0; padding: 12px 14px;
  background: var(--gold-soft); border-left: 3px solid var(--gold);
  border-radius: 10px; font-size: 13px; line-height: 1.7; color: #7A5A12;
}
.quote .from { display: block; margin-top: 4px; font-size: 11px; color: var(--ink-3); }

/* ===== 主内容区 ===== */
.page { padding: 14px 16px 90px; display: none; }
.page.active { display: block; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.date-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--red); background: var(--red-soft);
  padding: 4px 12px; border-radius: 99px; margin-bottom: 12px; font-weight: 600;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
  cursor: pointer; transition: transform .12s ease;
  border: 1px solid rgba(0,0,0,.02);
}
.card:active { transform: scale(.985); }
.card .meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 6px; letter-spacing: .5px;
}
.badge.rmrb { background: var(--red-soft); color: var(--red); }
.badge.byt { background: var(--blue-soft); color: var(--blue); }
.card .col { font-size: 11px; color: var(--ink-3); }
.card h3 { font-size: 16px; line-height: 1.5; font-weight: 650; margin-bottom: 6px; }
.card .abs {
  font-size: 13px; color: var(--ink-2); line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .gold-preview {
  margin-top: 8px; padding: 8px 10px; background: var(--gold-soft);
  border-left: 2px solid var(--gold); border-radius: 6px;
  font-size: 12.5px; color: #7A5A12; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chips { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.chip {
  font-size: 10.5px; color: var(--ink-2); background: var(--bg);
  padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line);
}
/* 卡片适用主题提示 */
.app-tag {
  margin-top: 8px; font-size: 11px; color: var(--blue);
  background: var(--blue-soft); border-radius: 8px; padding: 5px 9px;
  line-height: 1.5; word-break: break-all;
}

/* ===== 底部TabBar ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 50;
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; color: var(--ink-3); cursor: pointer; padding: 4px 0; user-select: none;
}
.tab svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tab.active { color: var(--red); font-weight: 600; }

/* ===== 搜索栏 ===== */
.searchbar {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.searchbar input {
  flex: 1; border: none; outline: none; background: var(--card);
  border-radius: 12px; padding: 11px 14px; font-size: 14px;
  box-shadow: var(--shadow); color: var(--ink);
}
.searchbar input::placeholder { color: var(--ink-3); }
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 2px; }
.fchip {
  flex-shrink: 0; font-size: 12px; padding: 6px 14px; border-radius: 99px;
  background: var(--card); color: var(--ink-2); border: 1px solid var(--line); cursor: pointer;
}
.fchip.on { background: var(--red); color: #fff; border-color: var(--red); font-weight: 600; }

.loadmore {
  display: block; width: 100%; padding: 11px; margin-top: 4px;
  border: none; border-radius: 12px; background: var(--card);
  color: var(--ink-2); font-size: 13px; box-shadow: var(--shadow); cursor: pointer;
}

/* ===== 分类宫格（申论分类导航模板体系） ===== */
.tag-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cat-cell {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 14px; cursor: pointer; text-align: left;
  border-left: 3px solid var(--red);
}
.cat-cell:active { transform: scale(.97); }
.cat-cell .t { font-size: 15px; font-weight: 750; color: var(--ink); }
.cat-cell .d { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
.cat-cell .n { font-size: 11px; color: var(--red); margin-top: 6px; }
.sub-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.sub-cell {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  padding: 12px 10px; cursor: pointer; text-align: left;
  border: 1px solid var(--line);
}
.sub-cell:active { transform: scale(.97); }
.sub-cell .t { font-size: 13px; font-weight: 700; color: var(--ink); }
.sub-cell .d { font-size: 11px; color: var(--ink-3); margin-top: 3px; line-height: 1.4; }
.tag-cell {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 8px; text-align: center; cursor: pointer;
}
.tag-cell:active { transform: scale(.96); }
.tag-cell .n { font-size: 20px; font-weight: 750; color: var(--red); }
.tag-cell .t { font-size: 12px; color: var(--ink-2); margin-top: 3px; }

/* ===== 我的 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-cell { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 6px; text-align: center; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.stat-cell:active { transform: scale(.96); }
.stat-cell .n { font-size: 22px; font-weight: 750; color: var(--ink); }
.stat-cell .t { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.panel h4 { font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.kv { display: flex; justify-content: space-between; font-size: 13px; padding: 7px 0; border-bottom: 1px dashed var(--line); color: var(--ink-2); }
.kv:last-child { border-bottom: none; }
.kv b { color: var(--ink); font-weight: 600; }
.btn-main {
  display: block; width: 100%; padding: 12px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--red-deep), var(--red)); color: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; letter-spacing: 1px;
}
.btn-main:disabled { opacity: .6; }
.btn-ghost {
  display: block; width: 100%; padding: 11px; border-radius: 12px; margin-top: 10px;
  background: none; border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; cursor: pointer;
}
.hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.7; }

/* ===== AI 配置表单 ===== */
.ai-state {
  font-size: 12.5px; padding: 8px 12px; border-radius: 10px; margin-bottom: 12px;
  background: var(--bg); color: var(--ink-2); line-height: 1.6;
}
.ai-state.on { background: #EAF5EA; color: var(--green); }
.ai-state.off { background: var(--gold-soft); color: #7A5A12; }

.mini-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 14px;
  padding: 4px 12px; cursor: pointer; font-size: 12px; color: var(--ink-2);
  transition: background .15s, border-color .15s, color .15s;
}
.mini-btn:hover { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.mini-btn:active { transform: scale(.96); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.form-row input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; outline: none;
  padding: 10px 12px; font-size: 13.5px; background: #fff; color: var(--ink);
}
.form-row input:focus { border-color: var(--red); }
.chip-btn { cursor: pointer; background: #fff; }
.chip-btn:active { background: var(--red-soft); color: var(--red); }
#testResult.ok { color: var(--green); }
#testResult.err { color: var(--red); }

/* 接口格式分段选择器 */
.seg {
  display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px;
}
.seg-item {
  flex: 1; text-align: center; font-size: 12px; padding: 8px 2px;
  border-radius: 8px; color: var(--ink-2); cursor: pointer; user-select: none;
  transition: all .12s;
}
.seg-item.on {
  background: #fff; color: var(--red); font-weight: 650;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ===== 阅读页（全屏浮层） ===== */
.reader {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 100; background: var(--bg);
  max-width: 520px; margin: 0 auto; overflow-y: auto;
  transform: translateX(100%); visibility: hidden;
  /* 关闭时先播完滑出动画再隐藏：宽屏下 translateX(100%) 滑不出屏幕，必须靠 visibility 兜底 */
  transition: transform .22s ease, visibility 0s linear .22s;
}
.reader.open {
  transform: translateX(0); visibility: visible;
  transition: transform .22s ease;
}
.reader-top {
  position: sticky; top: 0; z-index: 10; background: rgba(246,244,240,.95);
  backdrop-filter: blur(10px); display: flex; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.reader-top .back { cursor: pointer; display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--ink-2); }
.reader-body { padding: 20px 18px 110px; }
.reader-body h2 { font-size: 21px; line-height: 1.55; font-weight: 700; margin-bottom: 10px;
  font-family: "Songti SC", SimSun, serif; }
.reader-meta { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.reader-content {
  font-size: var(--reader-font, 16px); line-height: 1.95; color: #333; margin-top: 14px;
  font-family: "Songti SC", SimSun, serif; text-align: justify;
}
.reader-content p { margin-bottom: 14px; text-indent: 2em; }

.ai-sec { margin-top: 22px; }
.ai-sec h5 {
  font-size: 13px; color: var(--red); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px; font-weight: 700;
}
.ai-sec h5::before { content: ""; width: 4px; height: 14px; background: var(--red); border-radius: 2px; }
.ai-card {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 13px 14px; margin-bottom: 8px; font-size: 14px; line-height: 1.75;
}
.ai-card.gold { background: var(--gold-soft); border-left: 3px solid var(--gold); display: flex; align-items: flex-start; gap: 8px; }
.ai-card.gold .gold-txt { flex: 1; }
.ai-card .gold-copy { flex-shrink: 0; margin-top: 2px; padding: 2px 10px; }
.ai-card.plain { color: var(--ink-2); }
.ai-sec h5 .mini-btn { margin-left: auto; font-weight: 400; }

.reader-favbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; padding: 10px 18px max(10px, env(safe-area-inset-bottom));
  background: rgba(255,255,255,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  display: none; gap: 10px; z-index: 110;
}
/* 跟随紧邻的 .reader 开合状态显示 */
.reader.open + .reader-favbar { display: flex; }
.reader-favbar button {
  flex: 1; padding: 11px; border-radius: 12px; border: none; font-size: 14px; cursor: pointer;
}
.fav-btn { background: var(--red-soft); color: var(--red); font-weight: 600; }
.src-btn { background: var(--bg); color: var(--ink-2); font-size: 13px !important; }

/* 阅读页上一篇/下一篇 */
.reader-nav {
  display: flex; gap: 8px; margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--line);
}
.reader-nav .mini-btn {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--card); padding: 10px 8px;
}

/* 访问口令锁定层 */
.lock-screen {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.lock-box {
  width: 100%; max-width: 320px; background: var(--card); border-radius: 16px;
  box-shadow: var(--shadow); padding: 28px 22px; text-align: center;
}
.lock-box h3 { font-size: 18px; color: var(--ink); }
.lock-box input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-size: 14px; background: #fff; color: var(--ink); outline: none;
}
.lock-box input:focus { border-color: var(--red); }

/* 空状态 / 加载 */
.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); font-size: 13px; }
.empty svg { width: 54px; height: 54px; margin-bottom: 12px; opacity: .4; }
.loading { text-align: center; padding: 30px; color: var(--ink-3); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: rgba(38,38,38,.88); color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 99px; z-index: 999; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: 80%;
}
.toast.show { opacity: 1; }

.spin {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
