:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --line: #2b303b;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #4ade80;
  --accent-2: #60a5fa;
  --warn: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
  max-width: 760px;
  margin: 0 auto;
}

header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
h1 { font-size: 19px; margin: 0; letter-spacing: .3px; }
.who { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.card h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.badge {
  font-size: 11px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 20px; padding: 2px 9px;
}
.desc { font-size: 12px; color: var(--muted); margin: -4px 0 12px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

input[type="date"], input[type="number"], input[type="text"], select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); padding: 11px 12px;
  font-size: 16px; font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent-2); }
input[type="date"] { -webkit-appearance: none; appearance: none; }
select { appearance: none; background-image: none; }

button {
  font-family: inherit; font-size: 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); padding: 11px 14px; cursor: pointer;
}
button.primary { background: var(--accent); color: #08130c; border-color: transparent; font-weight: 600; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
.submit { width: 100%; margin-top: 12px; padding: 13px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 16px; }
.hint.err { color: #f87171; }
.hint.ok { color: var(--accent); }

.seg { display: flex; background: var(--panel-2); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button {
  flex: 1; border: none; background: transparent; font-size: 13px;
  padding: 8px; color: var(--muted);
}
.seg button.on { background: #303643; color: var(--text); font-weight: 600; }

.toggle-row { margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); margin: 0; }
.check input { width: auto; accent-color: var(--accent); }

.chart-wrap { position: relative; height: 260px; }
.chart-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.stat {
  flex: 1 1 30%; background: var(--panel-2); border-radius: 10px;
  padding: 9px 10px; display: flex; flex-direction: column; gap: 2px;
}
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 15px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 4px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: none; }

.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.pos { color: var(--accent); }
.neg { color: #f87171; }
.bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-top: 5px; min-width: 60px; }
.bar > i { display: block; height: 100%; border-radius: 3px; }

.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; margin: 0; }
.foot { color: var(--muted); font-size: 11px; text-align: center; margin-top: 18px; }
.link-btn {
  background: none; border: none; color: var(--muted); font-size: 12px;
  padding: 0; text-decoration: underline; cursor: pointer;
}

.setup { display: none; }
.setup.show { display: block; }

.review { font-size: 14px; line-height: 1.65; }
.review h3 { font-size: 14px; margin: 14px 0 6px; color: var(--accent); }
.review h4 { font-size: 13px; margin: 12px 0 4px; color: var(--text); }
.review h5, .review h6 { font-size: 13px; margin: 10px 0 4px; color: var(--muted); }
.review p { margin: 7px 0; }
.review ul, .review ol { margin: 7px 0; padding-left: 20px; }
.review li { margin: 3px 0; }
.review code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.review strong { color: var(--text); font-weight: 600; }
.review > :first-child { margin-top: 0; }

@media (max-width: 380px) {
  .row { flex-wrap: wrap; }
  .row > * { flex: 1 1 46%; }
  .stat { flex: 1 1 45%; }
}

.chat-entry {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  text-decoration: none; color: var(--text);
}
.chat-entry .t { font-size: 14px; font-weight: 600; }
.chat-entry .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chat-entry .arrow { color: var(--muted); font-size: 18px; }

.diary-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.diary-row:last-child { border-bottom: none; }
.diary-icon {
  flex: 0 0 24px; height: 24px; border-radius: 7px; display: flex;
  align-items: center; justify-content: center; font-size: 11px;
  background: var(--panel-2); color: var(--muted);
}
.diary-icon.k-meal { background: #24301f; color: #a3e635; }
.diary-icon.k-workout { background: #1f2a38; color: #60a5fa; }
.diary-icon.k-mood { background: #332435; color: #f472b6; }
.diary-main { min-width: 0; flex: 1; }
.diary-meta { font-size: 11px; color: var(--muted); }
.diary-text { font-size: 13px; word-break: break-word; }
