:root {
  --bg: #f7f6f3;
  --card: #fff;
  --ink: #2f2d2a;
  --sub: #8b8781;
  --line: #e8e5df;
  --accent: #b8776a;
  --accent-soft: #f6e7e2;
  --user: #e9efe8;
  --yan: #fff;
}

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

/* hidden 属性靠的是浏览器默认样式，优先级最低——
   下面 .ctx-panel 写了 display:flex 就会把它覆盖掉，浮层永远关不上。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 0 40px;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(247, 246, 243, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { flex: 1; text-align: center; font-weight: 600; letter-spacing: .04em; }
.linkbtn {
  color: var(--sub); text-decoration: none; font-size: 14px;
  padding: 4px 6px; border-radius: 8px; white-space: nowrap;
}
.linkbtn:active { background: var(--line); }
.linkbtn.right { text-align: right; }

/* ---------- 搜索框 ---------- */
.searchwrap { padding: 12px 14px 6px; }
.searchbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 12px;
}
.searchbar .mag { font-size: 14px; opacity: .5; }
.searchbar input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 16px; color: var(--ink); min-width: 0;
}
.searchbar input::-webkit-search-cancel-button { display: none; }
.clear {
  border: 0; background: var(--line); color: var(--sub);
  width: 20px; height: 20px; border-radius: 50%; font-size: 14px;
  line-height: 1; cursor: pointer; flex: none;
}

/* ---------- tab ---------- */
.tabs { display: flex; gap: 6px; padding: 4px 14px 10px; }
.tab {
  border: 0; background: transparent; color: var(--sub);
  font-size: 14px; padding: 6px 14px; border-radius: 20px; cursor: pointer;
}
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.stat { padding: 0 16px 6px; color: var(--sub); font-size: 13px; }
.hint { padding: 40px 24px; text-align: center; color: var(--sub); font-size: 14px; line-height: 1.9; }

/* ---------- 搜索结果 ---------- */
.results { padding: 0 14px; }
.hit {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px; margin-bottom: 8px; cursor: pointer;
}
.hit:active { background: #faf9f7; }
.hit-head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; color: var(--sub); margin-bottom: 4px;
}
.hit-who { font-weight: 600; }
.hit-who.user { color: #6b8f68; }
.hit-who.yan { color: var(--accent); }
.hit-text { font-size: 14.5px; word-break: break-word; }
.hit-text mark { background: #ffe9a8; color: inherit; border-radius: 3px; padding: 0 1px; }
.tagchip {
  display: inline-block; font-size: 11px; color: var(--sub);
  border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-right: 5px;
}

.more { padding: 6px 14px 20px; text-align: center; }
.more button {
  border: 1px solid var(--line); background: var(--card); color: var(--sub);
  border-radius: 20px; padding: 8px 22px; font-size: 14px; cursor: pointer;
}

/* ---------- 日期列表 ---------- */
.dates { padding: 0 14px; }
.dmonth {
  font-size: 12.5px; color: var(--sub); letter-spacing: .08em;
  padding: 14px 2px 6px; font-weight: 600;
}
.drow {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; margin-bottom: 6px; cursor: pointer;
}
.drow:active { background: #faf9f7; }
.drow .d-date { font-size: 14.5px; }
.drow .d-wd { color: var(--sub); font-size: 12.5px; margin-left: 8px; }
.drow .d-n { color: var(--sub); font-size: 12.5px; }

/* ---------- 上下文浮层 ---------- */
.ctx-mask {
  position: fixed; inset: 0; background: rgba(40, 38, 35, .38);
  z-index: 40; backdrop-filter: blur(2px);
}
.ctx-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  height: 86vh; background: var(--bg);
  border-radius: 16px 16px 0 0; display: flex; flex-direction: column;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .12);
}
.ctx-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line);
}
.ctx-title { flex: 1; font-size: 14px; color: var(--sub); }
.ctx-close {
  border: 0; background: var(--line); color: var(--ink);
  width: 26px; height: 26px; border-radius: 50%; font-size: 16px; line-height: 1; cursor: pointer;
}
.ctx-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(env(safe-area-inset-bottom) + 24px);
}

/* 气泡 */
.day-sep { text-align: center; color: var(--sub); font-size: 12px; margin: 14px 0 10px; }
.bub-row { display: flex; margin-bottom: 8px; }
.bub-row.me { justify-content: flex-end; }
.bub {
  max-width: 78%; padding: 9px 12px; border-radius: 13px;
  font-size: 14.5px; word-break: break-word; white-space: pre-wrap;
  background: var(--yan); border: 1px solid var(--line);
}
.bub-row.me .bub { background: var(--user); border-color: #dbe4d9; }
.bub-time { font-size: 11px; color: var(--sub); margin: 0 6px; align-self: flex-end; }
.bub.focus { box-shadow: 0 0 0 2px var(--accent); }
.bub mark { background: #ffe9a8; border-radius: 3px; padding: 0 1px; }
