:root {
  color-scheme: light;
  --bg: #f4f7f7;
  --surface: rgba(255,255,255,.9);
  --surface-solid: #fff;
  --text: #13201f;
  --muted: #6a7b79;
  --line: #dfe9e7;
  --primary: #0f766e;
  --primary-2: #14b8a6;
  --danger: #dc2626;
  --shadow: 0 18px 46px rgba(15,118,110,.1);
  --radius: 24px;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(20,184,166,.2), transparent 34%),
    radial-gradient(circle at 95% 5%, rgba(59,130,246,.1), transparent 28%),
    var(--bg);
}
button,input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.app {
  width: min(100%,760px);
  margin: 0 auto;
  padding: max(20px,env(safe-area-inset-top)) 16px calc(108px + env(safe-area-inset-bottom));
}
.topbar,.chart-head,.history-head,.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar { margin-bottom: 18px; }
.title-wrap { min-width:0; }
.title-wrap h1 { margin: 0; font-size: clamp(25px,6vw,34px); letter-spacing: -.04em; }
.title-wrap p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.top-actions { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.sync-status { color: var(--muted); font-size:12px; }
.sync-status.syncing { color: var(--primary); }
.sync-status.error { color: var(--danger); }
.icon-btn {
  width:44px; height:44px; flex:0 0 44px; padding:0; overflow:hidden;
  display:grid; place-items:center; line-height:0;
  border:1px solid rgba(15,118,110,.12); border-radius:15px;
  background:var(--surface); box-shadow:0 8px 24px rgba(0,0,0,.04); color:var(--primary); cursor:pointer;
}
.more-icon { width:22px; height:22px; display:block; fill:currentColor; }
.card {
  background: var(--surface); border: 1px solid rgba(255,255,255,.85); backdrop-filter: blur(18px);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.summary { padding:22px; display:grid; grid-template-columns:1.4fr 1fr 1fr; gap:12px; align-items:end; }
.label { color: var(--muted); font-size:13px; margin-bottom:8px; }
.current { font-size:clamp(38px,10vw,60px); line-height:.95; font-weight:780; letter-spacing:-.06em; }
.current small { font-size:18px; color:var(--muted); font-weight:650; letter-spacing:0; }
.metric strong { display:block; font-size:22px; letter-spacing:-.03em; }
.metric span { color:var(--muted); font-size:13px; }
.positive { color:#b45309; }
.negative { color:#047857; }
.neutral { color:var(--muted); }
.chart-card { margin-top:16px; padding:18px 14px 12px; }
.chart-head { padding:0 6px 12px; }
.chart-head h2,.history-head h2 { margin:0; font-size:18px; letter-spacing:-.025em; }
.range-tabs { display:flex; gap:6px; overflow-x:auto; padding:2px; }
.range-tabs button { border:0; border-radius:999px; padding:8px 11px; background:transparent; color:var(--muted); cursor:pointer; white-space:nowrap; font-size:13px; }
.range-tabs button.active { color:white; background:var(--primary); box-shadow:0 6px 18px rgba(15,118,110,.22); }
.chart-wrap { position:relative; min-height:280px; overflow:hidden; border-radius:18px; background:linear-gradient(180deg,rgba(240,253,250,.76),rgba(255,255,255,.38)); }
#chart { width:100%; height:300px; display:block; }
.empty { min-height:280px; display:grid; place-items:center; text-align:center; color:var(--muted); padding:30px; }
.empty strong { color:var(--text); display:block; margin-bottom:6px; }
.history { margin-top:16px; padding:18px; }
.history-head { margin-bottom:10px; }
.history-count { font-size:13px; color:var(--muted); }
.records { display:grid; gap:9px; }
.record { display:grid; grid-template-columns:1fr auto; gap:12px; padding:13px 14px; border:1px solid var(--line); border-radius:17px; background:rgba(255,255,255,.72); }
.record-main { display:flex; align-items:center; gap:12px; min-width:0; }
.dot { width:10px; height:10px; border-radius:50%; background:var(--primary-2); box-shadow:0 0 0 5px rgba(20,184,166,.1); flex:0 0 auto; }
.record strong { font-size:19px; display:block; }
.record time { display:block; margin-top:3px; color:var(--muted); font-size:13px; }
.record-actions { display:flex; align-items:center; gap:6px; }
.mini-btn { border:0; background:transparent; color:var(--muted); padding:8px; border-radius:10px; cursor:pointer; }
.mini-btn:hover { background:#eef6f5; color:var(--primary); }
.mini-btn.danger:hover { background:#fef2f2; color:var(--danger); }
.fab { position:fixed; z-index:20; left:50%; bottom:calc(22px + env(safe-area-inset-bottom)); transform:translateX(-50%); width:min(calc(100% - 32px),728px); border:0; border-radius:20px; padding:17px 22px; color:white; background:linear-gradient(135deg,var(--primary),var(--primary-2)); box-shadow:0 18px 42px rgba(15,118,110,.32); font-size:17px; font-weight:750; cursor:pointer; }
dialog { width:min(calc(100% - 28px),520px); border:0; border-radius:26px; padding:0; background:var(--surface-solid); color:var(--text); box-shadow:0 30px 90px rgba(0,0,0,.24); }
dialog::backdrop { background:rgba(6,24,22,.5); backdrop-filter:blur(5px); }
.dialog-body { padding:22px; }
.dialog-head h3 { margin:0; font-size:22px; }
.dialog-copy { color:var(--muted); margin:0 0 16px; }
.close-btn { border:0; width:38px; height:38px; border-radius:12px; background:#f1f5f4; cursor:pointer; color:var(--muted); }
.field { margin-top:14px; }
.field label { display:block; font-size:13px; color:var(--muted); margin-bottom:7px; }
.field input,.gate input { width:100%; border:1px solid var(--line); border-radius:16px; padding:14px 15px; background:#fbfdfd; outline:none; color:var(--text); }
.field input:focus,.gate input:focus { border-color:rgba(15,118,110,.55); box-shadow:0 0 0 4px rgba(20,184,166,.1); }
.weight-input { position:relative; }
.weight-input input { font-size:32px; font-weight:760; padding-right:56px; }
.weight-input span { position:absolute; right:16px; top:50%; transform:translateY(-50%); color:var(--muted); font-weight:700; }
.dialog-actions { display:grid; grid-template-columns:1fr 1.7fr; gap:10px; margin-top:20px; }
.btn { border:0; border-radius:15px; padding:14px 16px; font-weight:700; cursor:pointer; }
.btn-secondary { background:#edf3f2; color:var(--text); }
.btn-primary { background:var(--primary); color:white; }

.install-primary { width:100%; margin-top:2px; }
.install-guide { margin-top:16px; padding:14px 15px; border:1px solid var(--line); border-radius:16px; background:rgba(244,247,247,.72); }
.install-guide strong { display:block; margin-bottom:7px; }
.install-guide p { margin:6px 0; color:var(--muted); font-size:13px; line-height:1.65; }
.install-menu-item { color:var(--primary); font-weight:700; }

.choice-list { display:grid; gap:10px; }
.choice { border:1px solid var(--line); border-radius:16px; padding:15px; text-align:left; background:#fbfdfd; cursor:pointer; color:var(--text); }
.choice strong { display:block; margin-bottom:4px; }
.choice span { display:block; color:var(--muted); font-size:13px; line-height:1.5; }
.menu { position:fixed; inset:0; z-index:40; display:none; background:rgba(6,24,22,.42); padding:max(16px,env(safe-area-inset-top)) 16px 16px; align-items:flex-start; justify-content:center; }
.menu.open { display:flex; }
.menu-panel { width:min(100%,520px); background:white; border-radius:24px; padding:16px; margin-top:64px; box-shadow:0 28px 80px rgba(0,0,0,.22); }
.menu-panel h3 { margin:4px 6px 12px; }
.menu-item { width:100%; border:0; background:transparent; padding:13px 12px; border-radius:13px; text-align:left; cursor:pointer; color:var(--text); }
.menu-item:hover { background:#f1f7f6; }
.toast { position:fixed; z-index:80; left:50%; bottom:calc(92px + env(safe-area-inset-bottom)); transform:translate(-50%,20px); opacity:0; pointer-events:none; background:#13201f; color:white; padding:11px 16px; border-radius:999px; font-size:14px; transition:.22s ease; box-shadow:0 12px 30px rgba(0,0,0,.2); }
.toast.show { opacity:1; transform:translate(-50%,0); }
.gate { min-height:100vh; display:grid; place-items:center; padding:24px; }
.gate-card { width:min(100%,460px); background:var(--surface); border:1px solid rgba(255,255,255,.85); border-radius:28px; padding:28px; box-shadow:var(--shadow); text-align:center; }
.gate-icon { width:58px; height:58px; margin:0 auto 14px; display:grid; place-items:center; border-radius:18px; background:linear-gradient(135deg,var(--primary),var(--primary-2)); color:white; font-size:28px; }
.gate h1 { margin:0; font-size:25px; }
.gate p { color:var(--muted); line-height:1.7; }
.gate input { margin:4px 0 10px; text-align:left; }
.gate .btn { width:100%; }
.gate-tip { font-size:12px; }
.chart-label { font-size:11px; fill:#70817f; }
.chart-grid { stroke:rgba(118,145,141,.16); stroke-width:1; }
.chart-line { fill:none; stroke:#0f766e; stroke-width:3.5; stroke-linecap:round; stroke-linejoin:round; }
.chart-area { fill:url(#areaGradient); }
.chart-point { fill:white; stroke:#14b8a6; stroke-width:3; }
@media (max-width:560px) {
  .summary { grid-template-columns:1.35fr 1fr; }
  .summary .metric:last-child { display:none; }
  .chart-head { align-items:flex-start; flex-direction:column; }
  .sync-status { display:none; }
  .topbar { align-items:flex-start; }
  .icon-btn { margin-top:2px; }
}
@media (prefers-color-scheme:dark) {
  :root { color-scheme:dark; --bg:#07110f; --surface:rgba(14,31,28,.88); --surface-solid:#0e1f1c; --text:#edf8f6; --muted:#91a6a2; --line:#243c37; --shadow:0 18px 46px rgba(0,0,0,.24); }
  body { background:radial-gradient(circle at 10% -10%,rgba(20,184,166,.16),transparent 34%),radial-gradient(circle at 95% 5%,rgba(59,130,246,.09),transparent 28%),var(--bg); }
  .record,.field input,.gate input,.choice { background:rgba(12,28,25,.78); }
  .install-guide { background:rgba(12,28,25,.62); }
  .chart-wrap { background:linear-gradient(180deg,rgba(13,47,42,.68),rgba(8,23,20,.35)); }
  .icon-btn,.card,.gate-card { border-color:rgba(255,255,255,.06); }
  .mini-btn:hover,.menu-item:hover { background:#17332e; }
  .mini-btn.danger:hover { background:#3a1919; }
  .btn-secondary,.close-btn { background:#1b3530; color:var(--text); }
  .menu-panel { background:#0e1f1c; }
}
