/* =========================================================
   base.css — 变量 / 重置 / 基础排版
   ========================================================= */

:root {
  /* 中性色 */
  --c-bg:        #f6f7f9;
  --c-surface:   #ffffff;
  --c-surface-2: #f0f2f5;
  --c-border:    #e3e6ea;
  --c-border-2:  #d3d7dd;

  /* 文字 */
  --c-text:      #1b1d21;
  --c-text-2:    #5a6069;
  --c-text-3:    #8a9099;

  /* 品牌：三一红，只做点缀 */
  --c-accent:    #c8102e;
  --c-accent-bg: #fdeef1;

  /* 对话双角色（还原原书蓝/粉气泡） */
  --c-a:         #378add;
  --c-a-bg:      #e6f1fb;
  --c-b:         #d4537e;
  --c-b-bg:      #fbeaf0;

  /* 尺寸 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --hdr-h: 54px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* 深色模式：跟随系统，不提供手动开关。
   只覆盖变量，页面样式一律走变量，故无需逐条改组件。 */
@media (prefers-color-scheme: dark) {
  :root {
    --c-bg:        #14161a;
    --c-surface:   #1c1f24;
    --c-surface-2: #262a31;
    --c-border:    #2f343c;
    --c-border-2:  #3d434c;

    --c-text:      #e8eaed;
    --c-text-2:    #a9b0b9;
    --c-text-3:    #767d87;

    --c-accent:    #ff4d63;
    --c-accent-bg: #3a1620;

    --c-a:         #5aa9f0;
    --c-a-bg:      #17293b;
    --c-b:         #e8749a;
    --c-b-bg:      #341c28;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

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

/* ---------- 顶栏 ---------- */
/* iPhone 17 等灵动岛机型：viewport-fit=cover 会让内容延伸到安全区，
   必须用 env(safe-area-inset-top) 把顶栏内容推离刘海/灵动岛。
   无安全区的设备（传统屏/桌面）env() 返回 0，不影响。 */
.hdr {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding-top: env(safe-area-inset-top);
}

.hdr-in {
  max-width: 960px;
  margin: 0 auto;
  height: var(--hdr-h);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--c-accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-txt {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

/* ---------- 搜索框 ---------- */
.srch {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex: 1;
  max-width: 340px;
}

.srch input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  /* iOS Safari 会给 input 加默认内阴影与圆角，必须清掉才能保持设计一致 */
  -webkit-appearance: none;
  appearance: none;
  /* iOS Safari 铁律：输入框字号 < 16px 时，聚焦会强制放大整页。
     要维持 32px 的视觉高度又不能缩字号，就用 16px 字号 + 缩放补偿不可行，
     故此处直接给 16px（高度随之改为 34px 以容纳）。 */
  font-size: 16px;
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  outline: none;
}

.srch input:focus {
  border-color: var(--c-accent);
}

.srch button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text-2);
  cursor: pointer;
  white-space: nowrap;
}

.srch button:hover {
  background: var(--c-surface-2);
}

/* ---------- 主区 ---------- */
/* 底部留出 Home Indicator 高度（iPhone 约 34px），否则最后一行会被手势条压住 */
.view {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 14px 60px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

/* ---------- 页脚 ---------- */
.ftr {
  padding: 16px 14px 28px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--c-text-3);
  font-size: 13px;
}

/* ---------- 通用小件 ---------- */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--c-surface-2);
  color: var(--c-text-2);
  font-size: 12px;
  line-height: 1.7;
}

.tag-accent {
  background: var(--c-accent-bg);
  color: var(--c-accent);
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--c-text-3);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
