/* 拾忆 — 移动端优先，深浅色自适应 */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c1e21;
  --text2: #5a6270;
  --text3: #9aa1ac;
  --accent: #1e3a5f;
  --accent2: #2f6bb0;
  --border: #e4e7ec;
  --danger: #d64545;
  --ok: #2e8b57;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --card: #1c1f24;
    --text: #e8eaed;
    --text2: #a8b0bc;
    --text3: #6b7280;
    --border: #2c3138;
    --accent: #6fa8dc;
    --accent2: #4a90d9;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
}

body {
  padding-bottom: 66px; /* tabbar 高度 */
  overscroll-behavior-y: none;
}

/* ---- 顶部 ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
}
.brand-name { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }

.icon-btn {
  border: none;
  background: var(--card);
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 17px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* ---- 底部导航 ---- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text3);
  cursor: pointer;
}
.tab span { font-size: 27px; }
.tab em { font-style: normal; font-size: 12.5px; font-weight: 500; }
.tab.active { color: var(--accent2); }
.tab.active em { font-weight: 600; }

/* ---- 视图 ---- */
.view { padding: 14px 16px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin: 18px 4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- 分类网格 ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.grid-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  border: none;
  color: var(--text);
}
.grid-item .gi-icon { font-size: 24px; }
.grid-item .gi-name { font-size: 13px; font-weight: 600; margin-top: 4px; }
.grid-item .gi-count { font-size: 11px; color: var(--text3); }

/* ---- 条目列表 ---- */
.entry-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.entry-item .ei-head { display: flex; align-items: center; gap: 8px; }
.entry-item .ei-title { font-weight: 600; flex: 1; }
.entry-item .ei-type { font-size: 10px; color: var(--text3); }
.entry-item .ei-summary {
  font-size: 13px; color: var(--text2);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-item .ei-meta {
  font-size: 11px; color: var(--text3);
  margin-top: 6px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.entry-item .ei-tag {
  background: var(--bg);
  border-radius: 6px;
  padding: 1px 6px;
}

/* ---- 按钮 ---- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;   /* 消除 iOS 双击缩放延迟 */
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--card); color: var(--accent2); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

/* ---- 录音 ---- */
.record-area { text-align: center; padding: 30px 0 10px; }
.record-ring {
  width: 150px; height: 150px;
  border-radius: 50%;
  margin: 0 auto;
  display: grid; place-items: center;
  background: var(--card);
  box-shadow: var(--shadow);
  border: 3px solid var(--border);
  cursor: pointer;
  transition: transform .15s;
}
.record-ring.recording {
  border-color: var(--danger);
  animation: pulse 1.2s infinite;
}
.record-ring .mic { font-size: 46px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(214,69,69,.35); }
  70% { box-shadow: 0 0 0 22px rgba(214,69,69,0); }
  100% { box-shadow: 0 0 0 0 rgba(214,69,69,0); }
}
.record-timer { font-size: 28px; font-weight: 700; margin-top: 14px; font-variant-numeric: tabular-nums; }
.record-status { font-size: 13px; color: var(--text2); margin-top: 4px; }
.transcript {
  margin-top: 16px;
  text-align: left;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.7;
  min-height: 60px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.transcript .interim { color: var(--text3); }

/* ---- 表单 ---- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; font-weight: 600; }
.input, .textarea, select.input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }

/* ---- 搜索 ---- */
.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-box .input { flex: 1; }
.search-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.search-tabs button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text2);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.search-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- 问答 ---- */
.qa-answer {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}
.qa-cite { margin-top: 12px; }
.qa-cite .qc-item {
  font-size: 12px;
  color: var(--text2);
  padding: 6px 0;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.qa-cite .qc-item b { color: var(--accent2); }

/* ---- 提醒 ---- */
.reminder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.reminder-item .ri-icon { font-size: 22px; }
.reminder-item .ri-main { flex: 1; }
.reminder-item .ri-title { font-weight: 600; font-size: 14px; }
.reminder-item .ri-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }
.reminder-item.expired { opacity: .6; }
.reminder-item.done .ri-title { text-decoration: line-through; color: var(--text3); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text2);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 12px;
  cursor: pointer;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- 详情 ---- */
.detail-title { font-size: 19px; font-weight: 700; margin: 4px 0 10px; line-height: 1.4; }
.detail-content {
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.entity-section { margin-top: 16px; }
.entity-chip {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 9px;
  margin: 0 6px 6px 0;
  font-size: 12px;
}
.entity-chip .ec-label { color: var(--text3); font-size: 10px; margin-right: 3px; }

/* ---- 弹层 ---- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: var(--bg);
  width: 100%;
  max-width: 640px;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

/* ---- 横幅 ---- */
.banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--accent2);
  color: #fff;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  font-size: 14px;
  transform: translateY(-110%);
  transition: transform .3s;
}
.banner.show { transform: translateY(0); }
.banner span { opacity: .85; margin-left: 8px; }

/* ---- 详情页吸底操作栏（fixed，与底部导航同机制，iOS 点击可靠） ---- */
.detail-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(56px + env(safe-area-inset-bottom));
  z-index: 50;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-actions .btn { flex: 1; min-width: 90px; touch-action: manipulation; }
.detail-actions-spacer { height: 80px; }

/* ---- 杂项 ---- */
.empty {
  text-align: center;
  color: var(--text3);
  padding: 48px 20px;
  font-size: 14px;
}
.empty .empty-icon { font-size: 44px; margin-bottom: 10px; }
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.row { display: flex; align-items: center; gap: 8px; }
.row .grow { flex: 1; }
.muted { color: var(--text3); font-size: 12px; }
.err { color: var(--danger); font-size: 13px; margin-top: 6px; }
.ok { color: var(--ok); font-size: 13px; margin-top: 6px; }
.hidden { display: none !important; }
