/* ==========================================================================
   公版晨读 · 移动端网页版
   --------------------------------------------------------------------------
   样式来源：小程序 app.wxss 的 1:1 转译（rpx ÷ 2 = px，375 基准）。
   刻意不做「H5 再设计一版」——两端口径不一致，以后改配色就要改两处且容易漂移。

   与小程序的三处必要差异（都是载体决定，不是审美偏好）：
     1. 小程序有原生导航栏与 tabBar，H5 必须自己画 → .appbar / .tabbar
     2. 小程序有 safe-area 自动处理，H5 要显式 env(safe-area-inset-*)
     3. 小程序页面整体滚动，H5 用 .appbar/.tabbar 固定 + main 内部滚动
   ========================================================================== */

:root {
  --bg: #F7F8F6;
  --ink: #1C2430;
  --ink-2: #6B7684;
  --line: #E3E8E5;
  --brand: #2F6F5E;
  --brand-soft: #EEF3F1;
  --brand-pale: #EAF3EF;
  --gold: #B7791F;
  --gold-soft: #FAEEDA;
  --warn: #A63A2F;
  --warn-soft: #FBEAE5;
  --white: #FFFFFF;
  --radius: 10px;
  --appbar-h: 48px;
  --tabbar-h: 56px;
}

* { box-sizing: border-box; }

/* 关键：.appbar-back / .tabbar 都设了 display:flex，作者样式的特异性
   与 [hidden] 相同但优先级更高，会把 hidden 的 display:none 覆盖掉 ——
   表现为首页冒出返回箭头、精读页底部还挂着 tabbar。必须 !important 兜住。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body { overscroll-behavior-y: none; }

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---------------------------------------------------------------- 外壳 */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.appbar {
  flex: 0 0 auto;
  height: var(--appbar-h);
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  padding-right: 12px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.appbar-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 有返回键时标题不居中于整条，避免和被挤到左边 */
.appbar.has-back .appbar-title { text-align: left; }

.appbar-back {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.appbar-spacer { width: 32px; flex: 0 0 auto; }

main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
}

main.no-tabbar { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }

/* ---------------------------------------------------------------- 底栏 */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  position: sticky;
  bottom: 0;
  z-index: 20;
}

.tabbar a {
  flex: 1;
  text-align: center;
  padding: 8px 0 7px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 11px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tabbar a.on { color: var(--brand); font-weight: 600; }
.tabbar svg { width: 22px; height: 22px; display: block; }

/* ---------------------------------------------------------------- 通用 */
.wrap { padding: 12px 12px 24px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.card.accent-border { border: 2px solid var(--brand); }

.h1 { font-size: 20px; font-weight: 600; line-height: 1.4; }
.h2 { font-size: 15px; font-weight: 600; display: block; margin-bottom: 6px; }
.h3 { font-size: 13.5px; font-weight: 600; }
.muted { color: var(--ink-2); font-size: 12px; }
.accent { color: var(--brand); }
.gold { color: var(--gold); }
.warn { color: var(--warn); }

.para { display: block; margin-bottom: 7px; }
.para:last-child { margin-bottom: 0; }

.divider { height: 1px; background: var(--line); margin: 10px 0; }

.quote { font-size: 17px; line-height: 1.9; color: var(--ink); display: block; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chip {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  margin-right: 5px;
  white-space: nowrap;
}
.chip-ai { background: var(--gold-soft); color: var(--gold); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }

.btn {
  display: block;
  width: 100%;
  background: var(--brand);
  color: var(--white);
  border: 0;
  border-radius: 7px;
  font-size: 14px;
  padding: 10px 12px;
  margin-top: 8px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:active { opacity: .82; }
.btn[disabled] { opacity: .5; cursor: default; }

.btn-ghost {
  display: block;
  width: 100%;
  background: var(--white);
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 7px;
  font-size: 13.5px;
  padding: 9px 12px;
  margin-top: 6px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-ghost:active { opacity: .7; }
.btn-ghost[disabled] { opacity: .5; cursor: default; }

.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

.input, .textarea {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  margin: 6px 0;
  width: 100%;
  font-size: 13.5px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .textarea:focus { border-color: var(--brand); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.65; }

.notice {
  background: #F3F6F4;
  border-left: 3px solid var(--brand);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 10px;
}

.empty { padding: 30px 0; text-align: center; color: var(--ink-2); font-size: 13px; }

.bar { height: 6px; background: var(--brand-soft); border-radius: 3px; overflow: hidden; margin: 5px 0; }
.bar-in { height: 100%; background: var(--brand); transition: width .3s; }

/* 可点的句子 */
.sent {
  display: block;
  padding: 5px 6px;
  border-radius: 5px;
  margin: 3px 0;
  font-size: 16px;
  line-height: 1.85;
  cursor: pointer;
}
.sent-on { background: var(--brand-pale); color: var(--brand); }

/* 长按选中时不要盖住高亮 */
.sent::selection { background: #CFE3DA; }

/* 列表项可点 */
.tapable { cursor: pointer; }
.tapable:active { background: #FAFBFA; }

/* ---------------------------------------------------------------- 弹窗 */
.mask {
  position: fixed;
  inset: 0;
  background: var(--ink);
  opacity: .45;
  z-index: 40;
}

.dialog {
  position: fixed;
  left: 20px;
  right: 20px;
  top: 14%;
  max-width: 440px;
  margin: 0 auto;
  z-index: 41;
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
}
.dialog .h2 { font-size: 16px; }
.dialog-body {
  overflow-y: auto;
  margin: 8px 0;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* ---------------------------------------------------------------- 组件 */
.loading, .fatal {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
}
.fatal { color: var(--warn); }

.dim { opacity: .55; }

/* 打印/桌面宽屏：不撑满，交给 #app 的 max-width */
@media (min-width: 520px) {
  html, body { background: #EDEFEC; }
  #app { box-shadow: 0 0 0 1px var(--line); }
}
