/* 底稿 — 个人记录与复盘系统 */

*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --text: #1b1b19;
  --muted: #85857d;
  --faint: #a9a9a1;
  --line: #e7e6e0;
  --line-strong: #d8d7d0;
  --accent: #2f6b4f;
  --accent-soft: #e7f1eb;
  --accent-ink: #ffffff;
  --warn: #a94a22;
  --warn-soft: #fbeade;
  --idea: #a8752a;
  --idea-soft: #f8efdf;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 15, .04), 0 6px 20px rgba(20, 20, 15, .05);
  --topbar-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111211;
    --panel: #1b1c1a;
    --panel-2: #212220;
    --text: #eceae4;
    --muted: #8e908a;
    --faint: #6f716c;
    --line: #2b2d2a;
    --line-strong: #3a3c38;
    --accent: #74c39a;
    --accent-soft: #1d2b24;
    --accent-ink: #0c1a12;
    --warn: #e08b6b;
    --warn-soft: #2b1d16;
    --idea: #d8a75c;
    --idea-soft: #2a2318;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

a { color: var(--accent); }

.hide { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar .title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  flex: none;
}

.icon-btn:active { background: var(--line); }

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

.section-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .08em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 22px 2px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .count {
  font-weight: 500;
  letter-spacing: 0;
  color: var(--faint);
}

/* ---------- 快记 ---------- */
.composer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 10px 8px;
  margin-bottom: 6px;
}

.seg {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 8px;
  width: fit-content;
}

.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 5px 13px;
  border-radius: 999px;
  line-height: 1.2;
}

.seg button[aria-pressed="true"] {
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.composer__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#composerText {
  flex: 1;
  min-height: 46px;
  max-height: 180px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  padding: 8px 4px;
  font-size: 16px;
  line-height: 1.5;
  overflow-y: auto;
}

#composerText::placeholder { color: var(--faint); }

.send {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 18px;
  display: grid;
  place-items: center;
  transition: transform .12s ease, opacity .12s;
}

.send:active { transform: scale(.92); }
.send[disabled] { opacity: .35; }

.composer__hint {
  font-size: 11.5px;
  color: var(--faint);
  padding: 2px 4px 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* ---------- 日期导航 ---------- */
.datenav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 0 4px;
}

.datenav__label {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.datenav__label small { color: var(--muted); font-weight: 400; font-size: 12px; }

.datenav__btns { display: flex; gap: 4px; }

.datenav__btns button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 8px;
  width: 32px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 13px;
}

/* ---------- 流水条目 ---------- */
.entries { display: flex; flex-direction: column; }

.entry {
  display: flex;
  gap: 10px;
  padding: 10px 2px 10px 0;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.entry:last-child { border-bottom: none; }

.entry__time {
  flex: none;
  width: 42px;
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
  text-align: right;
}

.entry__body { flex: 1; min-width: 0; }

.entry__text {
  font-size: 15.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.entry[data-type="idea"] .entry__text { color: var(--text); }

.entry__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.tag {
  font-size: 11.5px;
  line-height: 1.5;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.tag--idea { background: var(--idea-soft); border-color: transparent; color: var(--idea); }
.tag--person { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---------- 待办 ---------- */
.todo {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
}

.todo:last-child { border-bottom: none; }

.todo__check {
  flex: none;
  width: 21px;
  height: 21px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: transparent;
}

.todo[data-done="1"] .todo__check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.todo[data-done="1"] .todo__text {
  color: var(--faint);
  text-decoration: line-through;
}

.todo__text { flex: 1; font-size: 15px; word-break: break-word; }
.todo__text .who { color: var(--muted); font-size: 12.5px; display: block; }
.todo__due { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.todo__due.overdue { color: var(--warn); }

/* ---------- 通用卡片 / 面板 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.panel + .panel { margin-top: 10px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spread { justify-content: space-between; }

.muted { color: var(--muted); font-size: 13px; }
.faint { color: var(--faint); font-size: 12px; }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:active { background: var(--panel-2); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn--danger { color: var(--warn); border-color: var(--line-strong); }

.wide { width: 100%; justify-content: center; }

/* ---------- 经验卡 ---------- */
.card-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  position: relative;
}

.card-item__scene {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.45;
  margin: 0 0 8px;
  word-break: break-word;
}

.card-item__next {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-s);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-item__next b { color: var(--accent); font-weight: 650; }

.card-item details { margin: 0; }

.card-item summary {
  font-size: 12.5px;
  color: var(--muted);
  list-style: none;
  cursor: pointer;
  padding: 3px 0;
  user-select: none;
}

.card-item summary::-webkit-details-marker { display: none; }
.card-item summary::before { content: "▸ "; color: var(--faint); }
.card-item details[open] summary::before { content: "▾ "; }

.entry__time--wide { width: 62px; }

.card-item__detail {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  padding: 6px 0 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-item__detail b { color: var(--text); font-weight: 600; display: block; font-size: 12px; letter-spacing: .05em; margin-bottom: 1px; }

.card-item__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.card-item__foot .grow { flex: 1; }

/* ---------- 人 ---------- */
.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.person-row:last-child { border-bottom: none; }

.avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
}

.person-row__main { flex: 1; min-width: 0; }
.person-row__name { font-size: 15.5px; font-weight: 600; }
.person-row__meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.person-row__meta .warn { color: var(--warn); }

.badge {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  white-space: nowrap;
}

/* ---------- 输入 ---------- */
.field { margin-bottom: 12px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 5px;
}

.input, .textarea, select.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  border-radius: var(--radius-s);
  padding: 10px 11px;
  font-size: 15.5px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus, .textarea:focus { border-color: var(--accent); background: var(--panel); }

.textarea { resize: vertical; min-height: 68px; line-height: 1.6; }

.search-wrap { position: relative; margin-bottom: 10px; }

.search-wrap .input { padding-left: 33px; border-radius: 999px; }

/* ---------- 搜索结果行 ---------- */
.srow {
  padding: 11px 2px 11px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.srow:last-child { border-bottom: none; }

.srow__meta {
  font-size: 11.5px;
  color: var(--faint);
  margin-bottom: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.srow__title {
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

.srow__sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.5;
  word-break: break-word;
}

mark.hl {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
  font-weight: 600;
}

.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 16px;
}

/* ---------- 复盘 ---------- */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.week-nav__label { font-size: 14px; font-weight: 600; }

.review-day {
  border-left: 2px solid var(--line);
  padding: 0 0 14px 14px;
  position: relative;
}

.review-day::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
}

.review-day__head {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.review-day__item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 4px 0;
  font-size: 14.5px;
  line-height: 1.5;
}

.review-day__item span { flex: 1; word-break: break-word; }

.mini-link {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  padding: 0 2px;
  white-space: nowrap;
  flex: none;
  opacity: .85;
}

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 640px;
  z-index: 40;
  display: flex;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--faint);
  padding: 8px 0 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10.5px;
  letter-spacing: .02em;
}

.tabbar button .ico { font-size: 19px; line-height: 1.2; }
.tabbar button[aria-current="true"] { color: var(--accent); font-weight: 600; }

/* ---------- 底部弹层 ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 8, .42);
  z-index: 50;
  opacity: 0;
  transition: opacity .18s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop.open { opacity: 1; }

.sheet {
  width: 100%;
  max-width: 640px;
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  padding: 6px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh;
  overflow-y: auto;
  transform: translateY(14px);
  transition: transform .2s cubic-bezier(.2, .8, .3, 1);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .18);
}

.sheet-backdrop.open .sheet { transform: translateY(0); }

.sheet__grab {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-strong);
  margin: 6px auto 10px;
}

.sheet__title {
  font-size: 16px;
  font-weight: 650;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet__actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet__actions .btn { flex: 1; justify-content: center; }

.menu-list { display: flex; flex-direction: column; }

.menu-list button {
  border: none;
  background: transparent;
  text-align: left;
  padding: 14px 4px;
  font-size: 15.5px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.menu-list button:last-child { border-bottom: none; }
.menu-list button.danger { color: var(--warn); }
.menu-list button small { color: var(--faint); font-size: 12px; }

/* ---------- 登录 ---------- */
.auth {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px));
}

.auth__inner { width: 100%; max-width: 340px; }

.auth__brand {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .08em;
  margin-bottom: 6px;
}

.auth__lede {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 20px;
}

.auth__field { display: block; margin-bottom: 12px; }

.auth__field span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.auth__err {
  color: var(--warn);
  font-size: 13px;
  min-height: 20px;
  line-height: 1.5;
  margin-bottom: 8px;
  word-break: break-word;
}

#authGo { margin-bottom: 6px; }

/* ---------- 同步状态 ---------- */
.sync-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  margin-right: 6px;
  vertical-align: 1px;
}

.sync-dot.ok { background: var(--accent); }
.sync-dot.warn { background: #c98a2e; }
.sync-dot.err { background: var(--warn); }

/* ---------- 提示 / 空态 ---------- */
.empty {
  text-align: center;
  padding: 34px 20px;
  color: var(--faint);
  font-size: 14px;
  line-height: 1.7;
}

.empty b { color: var(--muted); font-weight: 600; display: block; margin-bottom: 6px; font-size: 15px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 10px);
  background: #26261f;
  color: #f4f2ea;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 80vw;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .toast { background: #f0eee7; color: #1a1a16; }
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.banner button {
  border: none;
  background: transparent;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  padding: 0;
  flex: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.stat-grid div {
  background: var(--panel-2);
  border-radius: var(--radius-s);
  padding: 10px 4px;
}

.stat-grid b { display: block; font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-grid small { font-size: 11.5px; color: var(--muted); }

@media (min-width: 700px) {
  body { font-size: 16px; }
  .view { padding-top: 20px; }
}
