:root {
  --primary: #4f7cff;
  --primary-dark: #3a63e0;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e8eaf0;
  --danger: #e5484d;
  --ok: #2f9e6f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 25, 40, .04), 0 8px 24px rgba(20, 25, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* hidden 属性必须压过组件自身的 display：
   .modal / .tabbar 自带 display:flex，会盖掉浏览器默认的 [hidden]{display:none}，
   导致隐藏的全屏遮罩和底部栏仍然可见并拦截点击。 */
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 760px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-weight: 700; letter-spacing: .5px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.me { color: var(--muted); font-size: 13px; }

/* ---------- 布局 ---------- */
.main { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card-title { font-weight: 600; margin: 0 0 12px; font-size: 15px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; transition: .15s;
}
.btn:hover { border-color: #cfd4e0; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f0f1f6; color: var(--text); }
.btn-danger { color: var(--danger); border-color: #f3d4d5; }
.btn-danger:hover { background: #fdf2f2; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; outline: none; transition: .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 124, 255, .12); }
.textarea { min-height: 92px; resize: vertical; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.row-auto > * { flex: 0 0 auto; }

/* ---------- 概览条 ---------- */
.overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px; text-align: center;
}
.stat-num { font-size: 19px; font-weight: 700; line-height: 1.2; }
.stat-num.flash { animation: pop .45s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.22); color: var(--primary); } 100% { transform: scale(1); } }
.stat-label { font-size: 12px; color: var(--muted); }

/* ---------- 录入卡 ---------- */
.compose-top { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.compose-top .select { width: auto; min-width: 130px; flex: 0 0 auto; }
.compose-top .date { width: auto; flex: 0 0 auto; padding: 9px 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.chip {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 13px;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.hint { font-size: 12px; color: var(--muted); }

/* ---------- 时间线 ---------- */
.day-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 16px 4px 8px; font-size: 13px; color: var(--muted);
}
.day-head b { color: var(--text); font-size: 14px; }
.entry {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; display: flex; gap: 10px;
}
.entry-bar { width: 4px; border-radius: 3px; flex: 0 0 4px; background: var(--line); }
.entry-main { flex: 1 1 auto; min-width: 0; }
.entry-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.topic-tag { padding: 1px 8px; border-radius: 999px; font-size: 12px; color: #fff; }
.entry-content { white-space: pre-wrap; word-break: break-word; }
.entry-actions { display: flex; gap: 4px; opacity: .55; }
.entry:hover .entry-actions { opacity: 1; }

/* ---------- 统计 ---------- */
.heatmap-wrap { overflow-x: auto; padding-bottom: 6px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 5px 14px; border: none; background: #fff; cursor: pointer; }
.seg button.active { background: var(--primary); color: #fff; }
.bar-row { display: flex; align-items: flex-end; gap: 6px; height: 170px; }
.bar-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bar { width: 100%; min-height: 2px; background: var(--primary); border-radius: 4px 4px 0 0; opacity: .85; }
.bar-val { font-size: 11px; color: var(--muted); }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.topic-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.topic-line .nm { flex: 0 0 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-line .track { flex: 1 1 auto; height: 8px; background: #eef0f6; border-radius: 5px; overflow: hidden; }
.topic-line .fill { height: 100%; border-radius: 5px; }
.topic-line .vv { flex: 0 0 auto; color: var(--muted); font-size: 12px; }

/* ---------- 设置 ---------- */
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.swatch { width: 18px; height: 18px; border-radius: 5px; flex: 0 0 18px; }
.grow { flex: 1 1 auto; min-width: 0; }
.notice {
  background: #fff8e6; border: 1px solid #f3e2b8; color: #8a6314;
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
}

/* ---------- 登录页 ---------- */
.auth-wrap { max-width: 380px; margin: 8vh auto 0; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.auth-tabs button {
  flex: 1; padding: 10px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; cursor: pointer;
}
.auth-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.captcha-row { display: flex; gap: 8px; align-items: center; }
.captcha-row .input { flex: 1 1 auto; }
.captcha-img { height: 44px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; background: #fff; }
.hero { text-align: center; margin-bottom: 18px; }
.hero h1 { font-size: 22px; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14px; }

/* ---------- 底部 tab ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; padding: 8px 0 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 12px;
}
.tab.active { color: var(--primary); font-weight: 600; }
.tab-ico { font-size: 18px; line-height: 1; }

/* ---------- toast / modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 60; box-shadow: var(--shadow); max-width: 86vw; text-align: center;
}
.toast.err { background: var(--danger); }
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 25, 40, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card { background: #fff; border-radius: var(--radius); padding: 18px; width: 100%; max-width: 420px; }
.modal-title { font-weight: 600; margin: 0 0 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

@media (max-width: 480px) {
  .main { padding: 12px 12px 96px; }
  .overview { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 14px; }
}
