/* 问世界 —— 观星者的笔记本：冷调纸张 + 墨蓝 + 黄铜色（望远镜） + 青色（连接线） */
:root {
  --bg: #f2f4f8;
  --paper: #ffffff;
  --ink: #18203a;
  --muted: #646d86;
  --line: #dde2ec;
  --brass: #b4741a;
  --brass-soft: #f6ead6;
  --teal: #1d7a76;
  --teal-soft: #dff0ee;
  --sprout: #4f8a3a;
  --danger: #b23a3a;
  --shadow: 0 1px 2px rgba(24, 32, 58, .06), 0 4px 16px rgba(24, 32, 58, .05);
  --font-display: "Noto Serif SC", "Songti SC", "STSong", serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Hiragino Sans", "Microsoft YaHei", system-ui, sans-serif;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1322;
    --paper: #161d31;
    --ink: #e7ebf5;
    --muted: #8f99b5;
    --line: #283150;
    --brass: #e5a640;
    --brass-soft: #3a2f1c;
    --teal: #4fb8b1;
    --teal-soft: #17343a;
    --sprout: #86c06c;
    --danger: #e57070;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--teal); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ---------- 顶部 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); }
.brand b { font-family: var(--font-display); font-weight: 900; font-size: 22px; letter-spacing: .04em; }
.brand small { color: var(--muted); font-size: 12px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 999px;
  font-size: 14px; white-space: nowrap;
}
.nav a.on { color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }

/* ---------- 记录框 ---------- */
.hero { padding: 22px 0 6px; }
.hero h1 {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 5vw, 28px);
  margin: 0 0 4px; text-wrap: balance;
}
.hero .deco { font-size: 20px; letter-spacing: 6px; opacity: .85; }
.capture {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 12px; margin: 14px 0 8px;
}
.capture textarea {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent;
  font-size: 17px; min-height: 52px; padding: 2px 4px;
}
.capture .ctx { width: 100%; border: 0; border-top: 1px dashed var(--line); background: transparent; padding: 8px 4px 2px; outline: 0; font-size: 14px; color: var(--muted); }
.capture .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.capture .hint { color: var(--muted); font-size: 13px; }

/* ---------- 按钮 / 标签 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .08s ease, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 500; }
.btn.brass { background: var(--brass); color: #fff; border-color: var(--brass); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; line-height: 1;
  padding: 5px 9px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line);
  color: var(--ink); white-space: nowrap; cursor: pointer;
}
.chip.topic { background: var(--teal-soft); border-color: transparent; color: var(--teal); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.on .n { color: inherit; opacity: .7; }
.copy-tag {
  font-size: 12px; color: var(--muted); border: 1px dashed var(--line); background: transparent;
  border-radius: 6px; padding: 2px 8px; cursor: pointer;
}

.filters { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }

/* ---------- 时间线 ---------- */
.day { margin: 22px 0 8px; display: flex; align-items: baseline; gap: 10px; }
.day h2 { font-family: var(--font-display); font-size: 16px; margin: 0; font-weight: 600; }
.day span { color: var(--muted); font-size: 13px; }
.list { display: grid; gap: 10px; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow); position: relative;
}
.card.open::before {
  content: ""; position: absolute; left: -1px; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--sprout);
}
.card .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card .meta .time { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.card h3 { margin: 8px 0 4px; font-size: 16.5px; font-weight: 500; line-height: 1.5; }
.card .from { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.card .ans { color: var(--muted); font-size: 14px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .ans.none { color: var(--sprout); }
.card .foot { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }

.suggest {
  margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--brass-soft);
  font-size: 13.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
}
.suggest .who { color: var(--brass); font-weight: 500; }
.suggest .acts { margin-left: auto; display: flex; gap: 6px; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- 详情页（底部弹出） ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 14, 28, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 94vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@media (min-width: 760px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; max-height: 88vh; } }
.sheet-head { position: sticky; top: 0; background: var(--bg); display: flex; justify-content: space-between; align-items: center; padding: 12px 0; z-index: 2; }
.field { margin: 14px 0; }
.field > label, .label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }
.q-edit {
  width: 100%; font-family: var(--font-display); font-weight: 600; font-size: 21px; line-height: 1.45;
  border: 0; background: transparent; resize: none; outline: 0; padding: 0;
}
.input, .textarea, select.input {
  width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; outline: 0;
}
.textarea { resize: vertical; min-height: 140px; line-height: 1.7; }
.input:focus, .textarea:focus { border-color: var(--brass); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bar.space { justify-content: space-between; }
.src { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.src .chip.on { background: var(--brass); border-color: var(--brass); color: #fff; }
.verify { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--muted); margin-left: auto; }
.verify input { accent-color: var(--sprout); width: 16px; height: 16px; }
.section-t { font-family: var(--font-display); font-size: 16px; margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; }
.ideas { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.idea { text-align: left; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 10px; padding: 7px 10px; cursor: pointer; font-size: 14px; }
.idea:hover { color: var(--ink); border-color: var(--brass); }
.mini { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 14.5px; display: flex; gap: 8px; align-items: baseline; }
.mini small { color: var(--muted); margin-left: auto; white-space: nowrap; font-size: 12px; }
.badge-ai { font-size: 11px; color: var(--brass); border: 1px solid var(--brass); border-radius: 4px; padding: 0 4px; }

/* ---------- 分类 ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; box-shadow: var(--shadow); position: relative; }
.tile .e { font-size: 30px; line-height: 1.2; }
.tile .nm { font-weight: 500; margin-top: 4px; }
.tile .ct { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tile .ed { position: absolute; top: 8px; right: 8px; }
.tile.add { border-style: dashed; box-shadow: none; display: grid; place-items: center; color: var(--muted); min-height: 104px; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.emoji-pick button { border: 0; background: transparent; font-size: 22px; cursor: pointer; border-radius: 8px; padding: 2px 4px; }
.emoji-pick button.on { background: var(--brass-soft); }
.form-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-top: 14px; display: grid; gap: 10px; }
.form-card .emo { width: 64px; text-align: center; font-size: 22px; }

/* ---------- 课题 ---------- */
.topic-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; box-shadow: var(--shadow); display: grid; gap: 6px; }
.topic-card .hd { display: flex; align-items: center; gap: 10px; }
.topic-card .hd .e { font-size: 26px; }
.topic-card .hd b { font-size: 17px; }
.topic-card .goal { color: var(--muted); font-size: 14px; margin: 0; }
.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--teal); border-radius: 99px; }
.topic-card .st { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; }
.done-tag { font-size: 12px; color: var(--teal); }

.journey { position: relative; margin: 18px 0 0 10px; padding-left: 22px; border-left: 2px solid var(--teal-soft); display: grid; gap: 14px; }
.step { position: relative; }
.step::before {
  content: ""; position: absolute; left: -29px; top: 16px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--teal);
}
.step.done::before { background: var(--teal); }
.step .when { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.step.child { margin-left: 18px; }

/* ---------- 回顾 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
@media (max-width: 480px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { font-family: var(--font-display); font-size: 24px; display: block; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); }
.graph-box { position: relative; margin-top: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; height: min(70vh, 520px); touch-action: none; }
.graph-box canvas { display: block; width: 100%; height: 100%; }
.graph-tip { position: absolute; left: 10px; right: 10px; bottom: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; display: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 22px; height: 0; vertical-align: middle; margin-right: 4px; border-top: 2px solid var(--brass); }
.legend i.dash { border-top: 2px dashed var(--teal); }
.legend i.faint { border-top: 2px solid var(--line); }

/* ---------- 设置 / 登录 ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-top: 14px; }
.panel h3 { margin: 0 0 6px; font-size: 16px; }
.panel p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.panel ul { margin: 0; padding-left: 18px; font-size: 14px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 340px; text-align: center; display: grid; gap: 12px; }
.login .big { font-size: 56px; }
.login h1 { font-family: var(--font-display); margin: 0; font-size: 28px; }
.err { color: var(--danger); font-size: 14px; min-height: 1em; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }

/* 手机上：标题一行、导航一行 */
.brand { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 560px) {
  .top .wrap { flex-direction: column; align-items: stretch; height: auto; gap: 0; padding-top: 8px; }
  .brand small { display: none; }
  .nav { justify-content: space-between; padding: 6px 0 8px; }
  .nav a { padding: 5px 9px; }
}

/* 记录框里的分类选择 */
.pick-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pick-row .chip.on { background: var(--brass); border-color: var(--brass); color: #fff; }
.pick-row .add-cat { border-style: dashed; color: var(--muted); background: transparent; }
.newcat-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.newcat-row .emo { width: 56px; text-align: center; }
