/* ─────────────────────────────────────────────────────────────
   自由 · 私人财富终端
   设计基调：侘寂（wabi-sabi）——留白、素色、不完美之美
   四套切换主题：宣纸 / 夜墨 / 苔庭 / 素瓷
   ───────────────────────────────────────────────────────────── */

:root {
  --paper:      #F4F1EA;
  --paper-2:    #EDE8DE;
  --paper-3:    #E4DED2;
  --ink:        #2A2724;
  --ink-2:      #4C463E;
  --muted:      #8B8378;
  --faint:      #ADA598;
  --line:       rgba(42, 39, 36, .10);
  --line-soft:  rgba(42, 39, 36, .055);
  --accent:     #6E7A5E;   /* 苔 */
  --warm:       #A9714E;   /* 柿 */
  --cool:       #6E8093;   /* 雾 */
  --danger:     #9E5544;
  --shadow:     0 1px 2px rgba(42,39,36,.03), 0 8px 28px -18px rgba(42,39,36,.18);

  --r-sm: 3px;
  --r-md: 6px;
  --r-lg: 10px;

  --font-display: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif CN", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-num: "New York", "Iowan Old Style", "Songti SC", Georgia, serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --ease: cubic-bezier(.22,.68,.16,1);
  --slow: 720ms;
  --mid: 420ms;
}

/* ── 夜墨 ───────────────────────────────────────────── */
html[data-theme="ink"] {
  --paper:      #17161A;
  --paper-2:    #1E1D22;
  --paper-3:    #26252B;
  --ink:        #E9E3D7;
  --ink-2:      #C4BDB0;
  --muted:      #8B857A;
  --faint:      #635E56;
  --line:       rgba(233, 227, 215, .12);
  --line-soft:  rgba(233, 227, 215, .06);
  --accent:     #93A47E;
  --warm:       #C08A63;
  --cool:       #8DA0B4;
  --danger:     #C0735E;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 18px 50px -30px rgba(0,0,0,.9);
}

/* ── 苔庭 ───────────────────────────────────────────── */
html[data-theme="moss"] {
  --paper:      #EFF1E8;
  --paper-2:    #E6E9DC;
  --paper-3:    #DBDFCE;
  --ink:        #2A2E26;
  --ink-2:      #474D40;
  --muted:      #7E8574;
  --faint:      #A3A995;
  --line:       rgba(42, 46, 38, .10);
  --line-soft:  rgba(42, 46, 38, .05);
  --accent:     #5F7350;
  --warm:       #9E7550;
  --cool:       #6B8090;
  --danger:     #96543F;
}

/* ── 素瓷 ───────────────────────────────────────────── */
html[data-theme="porcelain"] {
  --paper:      #F3F4F5;
  --paper-2:    #EAECEE;
  --paper-3:    #DFE2E5;
  --ink:        #23262A;
  --ink-2:      #464B51;
  --muted:      #7F868D;
  --faint:      #A7ADB3;
  --line:       rgba(35, 38, 42, .10);
  --line-soft:  rgba(35, 38, 42, .05);
  --accent:     #5C7A6E;
  --warm:       #A2684C;
  --cool:       #58718C;
  --danger:     #94513F;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--slow) var(--ease), color var(--slow) var(--ease);
}

/* 纸纹与光晕：极淡，只为「质感」，不为装饰 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background:
    radial-gradient(120% 80% at 12% 0%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, rgba(0,0,0,.045), transparent 62%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .035;
  mix-blend-mode: multiply;
  background-image:
    repeating-linear-gradient(0deg, rgba(0,0,0,.9) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.6) 0 1px, transparent 1px 4px);
}
html[data-theme="ink"] body::before { opacity: .35; }
html[data-theme="ink"] body::after  { mix-blend-mode: screen; opacity: .03; }

.app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 22px 132px;
  min-height: 100vh;
}

/* ── 排版 ───────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: .01em; margin: 0; }
h1 { font-size: 27px; line-height: 1.5; }
h2 { font-size: 20px; line-height: 1.6; color: var(--ink-2); }
h3 { font-size: 16px; line-height: 1.6; color: var(--muted); font-family: var(--font-body); }
p  { margin: 0 0 14px; color: var(--ink-2); }
a  { color: inherit; }

.serif { font-family: var(--font-display); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: .005em; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: .01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; line-height: 1.7; }
.tiny  { font-size: 12px; line-height: 1.65; }
.up    { color: var(--accent); }
.down  { color: var(--danger); }
.flat  { color: var(--muted); }
.right { text-align: right; }
.center{ text-align: center; }
.nowrap{ white-space: nowrap; }

/* ── 顶栏 ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px;
  padding: 22px 0 14px;
  background: linear-gradient(var(--paper) 62%, transparent);
  backdrop-filter: saturate(1.1) blur(6px);
}
.topbar .brand {
  font-family: var(--font-display);
  font-size: 17px; letter-spacing: .18em;
  color: var(--ink); text-decoration: none;
}
.topbar .stamp {
  font-size: 11px; letter-spacing: .22em; color: var(--faint);
  writing-mode: horizontal-tb;
}
.topbar-actions { display: flex; gap: 14px; align-items: center; }
.icon-btn {
  appearance: none; background: none; border: 0; cursor: pointer;
  color: var(--muted); padding: 4px; line-height: 1;
  font-size: 15px; border-radius: var(--r-sm);
  transition: color var(--mid) var(--ease);
}
.icon-btn:hover { color: var(--ink); }

/* ── 卡片与分割 ─────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.42), rgba(255,255,255,.16));
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 20px 20px 18px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
}
html[data-theme="ink"] .card { background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012)); }
.card.plain { background: none; box-shadow: none; border-color: var(--line); }
.card.flush { padding: 0; }

.rule { height: 1px; background: var(--line); border: 0; margin: 20px 0; }
.rule.soft { background: var(--line-soft); }

.row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.row + .row { margin-top: 12px; }
.row.tight + .row.tight { margin-top: 8px; }
.row .k { color: var(--muted); font-size: 13px; }
.row .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

.label {
  font-size: 11px; letter-spacing: .2em; color: var(--faint);
  text-transform: uppercase; margin: 0 0 10px;
}

/* ── 首页：主叙述 ───────────────────────────────────── */
.hero { padding: 26px 0 6px; }
.hero .depth {
  font-family: var(--font-display);
  font-size: 25px; line-height: 1.55; color: var(--ink);
  margin: 0 0 12px;
  animation: rise var(--slow) var(--ease) both;
}
.hero .sub { font-size: 14px; color: var(--muted); animation: rise var(--slow) var(--ease) 80ms both; }

.distance { margin: 34px 0 8px; animation: rise var(--slow) var(--ease) 140ms both; }
.distance .label { margin-bottom: 14px; }
.distance .pair { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.distance .now { font-family: var(--font-num); font-size: 40px; line-height: 1.1; letter-spacing: -.01em; }
.distance .of  { font-family: var(--font-num); font-size: 16px; color: var(--faint); }
.distance .pct { color: var(--muted); font-size: 13px; margin-top: 10px; }

.pool { position: relative; height: 2px; background: var(--line); margin: 20px 0 6px; border-radius: 2px; overflow: hidden; }
.pool > i {
  position: absolute; inset: 0 auto 0 0; display: block;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent));
  transition: width 1.2s var(--ease);
}

.eta { margin: 30px 0 0; animation: rise var(--slow) var(--ease) 200ms both; }
.eta .big { font-family: var(--font-display); font-size: 31px; line-height: 1.5; }
.eta .big em { font-style: normal; color: var(--faint); font-size: 17px; }
.conf { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.conf .dots { display: inline-flex; gap: 3px; }
.conf .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--line); border: 1px solid var(--muted); }
.conf .dots i.on { background: var(--accent); border-color: var(--accent); }

.speed-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 6px; }
.speed-split .cell .k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.speed-split .cell .v { font-family: var(--font-num); font-size: 17px; }
@media (max-width: 560px) { .speed-split { grid-template-columns: 1fr 1fr; } }

/* 值得注意的事 */
.note {
  border-left: 2px solid var(--line);
  padding: 2px 0 2px 16px;
  margin: 0 0 18px;
  animation: rise var(--mid) var(--ease) both;
}
.note.warm  { border-left-color: var(--warm); }
.note.good  { border-left-color: var(--accent); }
.note.cool  { border-left-color: var(--cool); }
.note .t { font-family: var(--font-display); font-size: 16px; margin-bottom: 4px; }
.note .d { font-size: 13px; color: var(--muted); }

/* ── 表单 ───────────────────────────────────────────── */
input, select, textarea, button { font: inherit; color: inherit; }
.field { margin: 0 0 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 2px;
  outline: none;
  transition: border-color var(--mid) var(--ease);
  border-radius: 0;
}
input:focus, select:focus, textarea:focus { border-bottom-color: var(--ink); }
select { appearance: none; }
textarea { resize: vertical; min-height: 76px; line-height: 1.8; }

.btn {
  appearance: none; cursor: pointer;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--r-sm);
  padding: 10px 20px;
  font-size: 14px; letter-spacing: .06em;
  transition: opacity var(--mid) var(--ease), transform var(--mid) var(--ease);
}
.btn:hover { opacity: .88; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: none; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.quiet { background: none; border: 0; color: var(--muted); padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; }
.btn.quiet:hover { color: var(--ink); }
.btn.sm { padding: 6px 13px; font-size: 13px; }
.btn:disabled { opacity: .35; cursor: default; }

.capture {
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,.2));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px 14px;
}
html[data-theme="ink"] .capture { background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02)); }
.capture textarea {
  border: 0; padding: 0; min-height: 52px;
  font-family: var(--font-display); font-size: 19px; line-height: 1.7;
}
.capture textarea::placeholder { color: var(--faint); }
.capture .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 12px; }
.capture .hint { font-size: 12px; color: var(--faint); }

/* ── 时间线 ─────────────────────────────────────────── */
.day { margin: 0 0 26px; }
.day .date { font-size: 12px; color: var(--faint); letter-spacing: .16em; margin-bottom: 12px; }
.ev { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.ev:last-child { border-bottom: 0; }
.ev .what { display: flex; flex-direction: column; min-width: 0; }
.ev .what .t { font-size: 14px; }
.ev .what .s { font-size: 12px; color: var(--faint); }
.ev .amt { font-family: var(--font-num); font-size: 15px; white-space: nowrap; }
.ev .amt.income { color: var(--accent); }

/* ── 表格化列表 ─────────────────────────────────────── */
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.list li:last-child { border-bottom: 0; }
.list .name { min-width: 0; }
.list .name .n { font-size: 14px; }
.list .name .m { font-size: 12px; color: var(--faint); }
.list .val { font-family: var(--font-num); white-space: nowrap; }

.group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 0 6px; border-bottom: 1px solid var(--line);
}
.group-head .g { font-size: 12px; letter-spacing: .18em; color: var(--muted); }
.group-head .s { font-family: var(--font-num); font-size: 13px; color: var(--muted); }

/* ── 图表 ───────────────────────────────────────────── */
.chart { width: 100%; height: 168px; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.goal { stroke: var(--faint); stroke-dasharray: 3 5; stroke-width: 1; }
.chart .line.faint-line { stroke: var(--faint); stroke-dasharray: 4 4; stroke-width: 1.2; }
.chart .area { fill: color-mix(in srgb, var(--accent) 12%, transparent); }
.chart .bar { fill: color-mix(in srgb, var(--accent) 55%, transparent); }
.chart .bar.neg { fill: color-mix(in srgb, var(--danger) 55%, transparent); }
.chart .bar.mkt { fill: color-mix(in srgb, var(--cool) 55%, transparent); }
.chart .dot { fill: var(--paper); stroke: var(--accent); stroke-width: 1.6; }
.chart text { font-family: var(--font-body); font-size: 10px; fill: var(--faint); }

/* ── 分段控件 ───────────────────────────────────────── */
.seg { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }
.seg button {
  appearance: none; background: none; border: 0; cursor: pointer;
  padding: 5px 12px; font-size: 12px; color: var(--muted); border-radius: 2px;
  transition: background var(--mid) var(--ease), color var(--mid) var(--ease);
}
.seg button.on { background: var(--ink); color: var(--paper); }

/* ── 底部导航 ───────────────────────────────────────── */
.nav {
  position: fixed; z-index: 30;
  left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-top: 1px solid var(--line-soft);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
.nav-inner { display: flex; gap: 4px; max-width: 720px; width: 100%; justify-content: space-around; }
.nav a {
  flex: 1; text-decoration: none; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; border-radius: var(--r-sm);
  transition: color var(--mid) var(--ease);
}
.nav a .g { font-family: var(--font-display); font-size: 15px; }
.nav a .l { font-size: 10px; letter-spacing: .14em; }
.nav a.on { color: var(--ink); }

/* ── 锁屏 ───────────────────────────────────────────── */
.lock { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; max-width: 380px; margin: 0 auto; padding: 60px 0 90px; }
.lock .seal {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); display: grid; place-items: center;
  font-family: var(--font-display); font-size: 20px; color: var(--ink);
  margin-bottom: 26px;
}
.lock h1 { font-size: 22px; margin-bottom: 8px; }
.lock .lede { font-size: 13px; color: var(--muted); margin-bottom: 34px; line-height: 1.9; }
.lock .err { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 10px; }

/* ── 浮层 ───────────────────────────────────────────── */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--ink) 26%, transparent);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade var(--mid) var(--ease) both;
}
@media (min-width: 640px) { .modal-mask { align-items: center; } }
.modal {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  padding: 26px 24px calc(26px + env(safe-area-inset-bottom));
  animation: sheet var(--mid) var(--ease) both;
}
@media (min-width: 640px) { .modal { border-radius: var(--r-lg); } }
.modal h2 { margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.toast-root { position: fixed; z-index: 80; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--paper);
  padding: 9px 18px; border-radius: 40px; font-size: 13px;
  animation: rise var(--mid) var(--ease) both;
  box-shadow: var(--shadow); max-width: 90vw;
}

/* ── 展开细节 ───────────────────────────────────────── */
details.more { margin-top: 14px; }
details.more > summary {
  cursor: pointer; list-style: none; font-size: 12px; color: var(--muted);
  letter-spacing: .1em;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "＋ "; }
details.more[open] > summary::before { content: "－ "; }
details.more .body { padding-top: 14px; }

/* ── 动态 ───────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.view > * { animation: rise var(--mid) var(--ease) both; }
.view > *:nth-child(2) { animation-delay: 40ms; }
.view > *:nth-child(3) { animation-delay: 80ms; }
.view > *:nth-child(4) { animation-delay: 120ms; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── 桌面端：导航移到左侧竖排 ───────────────────────── */
@media (min-width: 1024px) {
  .app { max-width: 760px; padding-bottom: 80px; }
  .nav {
    left: 0; right: auto; top: 0; bottom: 0; width: 84px;
    border-top: 0; border-right: 1px solid var(--line-soft);
    flex-direction: column; justify-content: center; padding: 0;
  }
  .nav-inner { flex-direction: column; gap: 10px; padding: 0 8px; }
  .nav a { padding: 10px 4px; }
  .toast-root { bottom: 32px; }
}
