/* =========================================================
   每日记录 · 时间账本
   中性的纸墨底色 + 分类自己的颜色。界面本身几乎不用彩色，
   让「时间花在了哪里」成为页面上唯一的色彩。
   ========================================================= */

:root {
  --page: #f4f3ef;
  --surface: #fcfcfb;
  --sunken: #efeee9;
  --hover: #e8e6e0;
  --ink: #1b1b19;
  --ink-2: #52514e;
  --ink-3: #898781;
  --line: #e4e2db;
  --line-2: #d3d1c9;
  --accent: #1b1b19;
  --on-accent: #fcfcfb;
  --live: #d93a32;
  --live-soft: #fbeae8;
  --danger: #c4372f;
  --focus: #2a78d6;
  --good: #0ca30c;
  --warning: #fab219;
  --neutral-chip: #a3a199;
  --mark: #fde6a0;

  --r-lg: 18px;
  --r: 14px;
  --r-sm: 10px;
  --shadow-sm: 0 1px 2px rgb(27 27 25 / 4%), 0 1px 1px rgb(27 27 25 / 2%);
  --shadow-lg: 0 18px 50px rgb(27 27 25 / 16%), 0 2px 6px rgb(27 27 25 / 6%);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --content: 680px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0f0f0e;
    --surface: #1a1a19;
    --sunken: #232321;
    --hover: #2c2c2a;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --line: #2c2c2a;
    --line-2: #3a3a37;
    --accent: #f0efec;
    --on-accent: #1a1a19;
    --live: #f0605a;
    --live-soft: #3a1f1d;
    --danger: #f07a73;
    --focus: #6da7ec;
    --neutral-chip: #6f6d66;
    --mark: #5a4710;
    --shadow-sm: none;
    --shadow-lg: 0 18px 50px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}

/* 分类颜色：JS 在元素上写 --chip-l（浅色）和 --chip-d（深色），这里统一成 --chip */
* { --chip: var(--chip-l, var(--neutral-chip)); }
@media (prefers-color-scheme: dark) {
  * { --chip: var(--chip-d, var(--chip-l, var(--neutral-chip))); }
}

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
::selection { background: color-mix(in srgb, var(--focus) 26%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon .fill { fill: currentColor; stroke: none; }

/* 表单控件（:where 让后面的组件样式可以轻松覆盖） */
:where(input:not([type="color"], [type="hidden"], [type="checkbox"], [type="radio"]), select, textarea) {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px; /* 小于 16px 时 iOS 聚焦会自动放大页面 */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
:where(input, textarea)::placeholder { color: var(--ink-3); }
:where(input, select, textarea):focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
:where(textarea) { resize: vertical; line-height: 1.55; }
:where(select) {
  padding-right: 34px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
}
:where(input[type="date"], input[type="time"], input[type="month"]) { min-width: 0; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 84%, var(--page)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunken); color: var(--ink); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { color: var(--danger); background: var(--live-soft); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 48px; font-size: 15px; }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; }
.btn-stop { background: var(--live); border-color: var(--live); color: #fff; }
.btn-stop:hover { background: color-mix(in srgb, var(--live) 86%, #000); }
.btn-stop .icon { width: 16px; height: 16px; }

/* ---------- 启动 / 登录 ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; grid-auto-flow: column; gap: 10px; color: var(--ink-3); font-size: 14px; }
.boot-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); animation: breathe 1.2s ease-in-out infinite; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(360px, 100%);
  display: grid; gap: 18px;
  padding: 32px 24px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.login-card .field { text-align: left; }
.login-logo { width: 56px; height: 56px; margin: 0 auto; border-radius: 15px; }
.login-title { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.login-sub { margin: 4px 0 0; color: var(--ink-3); font-size: 14px; }

/* ---------- 外框 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 10px;
}
.topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--page) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  backdrop-filter: saturate(1.5) blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.brand img { border-radius: 7px; }

.sync {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--sunken); color: var(--ink-3);
  font-size: 12px; font-weight: 550;
}
.sync::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.sync[data-state="live"]::before { background: var(--good); }
.sync[data-state="offline"] { color: var(--danger); }
.sync[data-state="offline"]::before { background: var(--danger); }

/* 手机：底部悬浮导航 */
.nav {
  position: fixed; z-index: 40;
  left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px);
  max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 5px;
  border: 1px solid var(--line); border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(18px);
  backdrop-filter: saturate(1.5) blur(18px);
  box-shadow: 0 8px 30px rgb(0 0 0 / 10%);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0 5px; border-radius: 17px;
  color: var(--ink-3); font-size: 11px; font-weight: 600;
  transition: color .15s, background .15s;
}
.nav .icon { width: 22px; height: 22px; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--sunken); }

.main {
  max-width: var(--content); margin: 0 auto;
  padding: 4px 16px calc(env(safe-area-inset-bottom) + 112px);
}

/* 电脑：导航放进顶栏 */
@media (min-width: 760px) {
  .topbar { padding: 14px 28px; }
  .nav {
    position: static; max-width: none; margin: 0 auto;
    display: flex; gap: 2px; padding: 4px;
    border: 0; border-radius: 999px;
    background: var(--sunken); box-shadow: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .nav a { flex-direction: row; gap: 6px; padding: 6px 14px; border-radius: 999px; font-size: 13.5px; }
  .nav .icon { width: 17px; height: 17px; }
  .nav a:hover { color: var(--ink); }
  .nav a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
  .sync { margin-left: 0; }
  .main { padding: 16px 24px 72px; }
}

/* ---------- 页面通用 ---------- */
.view { display: grid; gap: 16px; }
.view.is-entering { animation: rise .22s ease-out; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 10px 2px 2px; }
.hero-text { min-width: 0; }
.eyebrow { margin: 0 0 4px; color: var(--ink-3); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.hero-title { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 750; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.hero-nav { display: flex; align-items: center; gap: 2px; flex: none; }
.hero-nav .btn-icon { border-color: transparent; background: transparent; color: var(--ink-2); }
.hero-nav .btn-icon:hover { background: var(--sunken); color: var(--ink); }

.date-picker { position: relative; display: inline-flex; cursor: pointer; }
.date-picker:hover > span { text-decoration: underline dotted var(--ink-3) 2px; text-underline-offset: 7px; }
.date-picker input {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0;
  padding: 0; border: 0; opacity: 0; cursor: pointer;
}

.card {
  padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head .section-label { margin: 0; }
.section-label { margin: 0 0 12px; color: var(--ink-2); font-size: 13px; font-weight: 650; letter-spacing: .02em; }
.section-label a:hover { color: var(--ink); }
.section-label-gap { margin-top: 18px; }
.axis-note { color: var(--ink-3); font-size: 12px; }
.footnote { margin: 0 2px; color: var(--ink-3); font-size: 12.5px; line-height: 1.7; }
.link-arrow { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.link-arrow .icon { width: 15px; height: 15px; }
.spacer { flex: 1; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stack-form { display: grid; gap: 10px; max-width: 380px; }

.empty { padding: 28px 18px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty-title { margin: 0; color: var(--ink-2); font-weight: 650; }
.empty-hint { margin: 6px auto 0; max-width: 320px; color: var(--ink-3); font-size: 13.5px; line-height: 1.65; }

.field { display: grid; gap: 6px; min-width: 0; }
.field-label { color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 10px; }
.field-hint { margin: -6px 0 0; color: var(--ink-3); font-size: 12px; }
.form-error { margin: 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--live-soft); color: var(--danger); font-size: 13.5px; text-align: left; }

/* ---------- 指标 ---------- */
.metric { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric-value { font-size: 22px; font-weight: 750; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric-value small { margin-left: 1px; color: var(--ink-3); font-size: 14px; font-weight: 600; }
.metric-label { color: var(--ink-3); font-size: 12.5px; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metrics .metric { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.metrics-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metrics-5 .metric-hero { grid-column: 1 / -1; }
.metric-hero .metric-value { font-size: 34px; }
@media (min-width: 600px) {
  .metrics-5 { grid-template-columns: 1.5fr repeat(4, minmax(0, 1fr)); }
  .metrics-5 .metric-hero { grid-column: auto; }
  .metric-hero .metric-value { font-size: 26px; }
}

/* 堆叠条（今天概览 / 日历格子） */
.stack { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; }
.stack-seg { flex: 1 1 0; min-width: 3px; background: var(--chip); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 0; padding: 0; color: var(--ink-2); font-size: 12.5px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- 今天 ---------- */
.now-list { display: grid; gap: 10px; }
.now-card {
  position: relative; overflow: hidden;
  padding: 16px 16px 14px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.now-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--chip); }
.now-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.live-badge { display: inline-flex; align-items: center; gap: 7px; color: var(--live); font-size: 12.5px; font-weight: 700; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 1.8s ease-out infinite; }
.now-content { margin: 10px 0 14px; font-size: 18px; font-weight: 650; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.now-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.now-clock { display: block; font-size: 34px; font-weight: 750; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.now-since { display: block; margin-top: 6px; color: var(--ink-3); font-size: 12.5px; }

.composer { padding: 14px 14px 12px; }
.composer-input {
  min-height: 44px; padding: 6px 4px;
  border: 0; border-radius: 8px; background: transparent;
  font-size: 18px; font-weight: 600;
}
.composer-input:focus { box-shadow: none; }
.composer-cats { margin: 8px 0 12px; }
.composer-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.composer-actions .btn-ghost { margin-right: auto; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }

.overview-head { display: flex; gap: 32px; margin-bottom: 14px; }

/* 时间线 */
.timeline { list-style: none; margin: 0; padding: 0; }
.entry { position: relative; display: grid; grid-template-columns: 46px 18px minmax(0, 1fr); column-gap: 8px; cursor: pointer; }
.entry-time {
  display: flex; flex-direction: column; align-items: flex-end;
  padding-top: 13px; line-height: 1.35;
  color: var(--ink); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.t-end, .t-none { color: var(--ink-3); font-weight: 500; }
.t-live { color: var(--live); font-size: 11.5px; font-weight: 650; }
.entry-rail { position: relative; display: flex; justify-content: center; }
.entry-rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line); }
.entry:first-child .entry-rail::before { top: 20px; }
.entry:last-child .entry-rail::before { bottom: calc(100% - 20px); }
.entry-dot { position: relative; margin-top: 15px; width: 12px; height: 12px; border-radius: 50%; background: var(--chip); box-shadow: 0 0 0 3px var(--page); }
.entry.is-running .entry-dot { animation: pulse 1.8s ease-out infinite; }
.entry-body {
  margin: 0 0 8px; padding: 10px 14px 11px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s;
}
.entry:hover .entry-body { border-color: var(--line-2); }
.entry.is-running .entry-body { border-color: color-mix(in srgb, var(--live) 45%, var(--line)); }
.entry-content { margin: 0; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; color: var(--ink-3); font-size: 12.5px; }
.entry-duration { font-variant-numeric: tabular-nums; }
.cat-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-weight: 600; }
.cat-dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--chip); }
.tag { color: var(--ink-3); }
.tag:hover { color: var(--ink); }

/* 心情 / 精力 */
.reflect { display: grid; gap: 12px; }
.reflect .section-label { margin: 0; }
.reflect-row { display: grid; grid-template-columns: 36px auto 1fr; align-items: center; gap: 10px; }
.reflect-label { color: var(--ink-2); font-size: 14px; }
.rating { display: flex; gap: 6px; }
.rating-caption { color: var(--ink-3); font-size: 12.5px; text-align: right; }
.rating-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.rating-btn:hover { background: var(--sunken); }
.rating-btn:active { transform: scale(.94); }
.rating-mood .emoji { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .5; transition: filter .15s, opacity .15s, transform .15s; }
.rating-mood .rating-btn:hover .emoji { filter: none; opacity: 1; }
.rating-mood .rating-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--sunken); }
.rating-mood .rating-btn[aria-pressed="true"] .emoji { filter: none; opacity: 1; transform: scale(1.12); }

.rating-energy { align-items: flex-end; gap: 4px; }
.rating-energy .rating-btn { width: 30px; place-items: end center; padding-bottom: 6px; border-color: transparent; background: transparent; border-radius: 8px; }
.rating-energy .rating-btn:hover { background: var(--sunken); }
.energy-bar { display: block; width: 14px; height: calc(4px + var(--level) * 5px); border-radius: 3px; background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line-2); transition: background .15s; }
.rating-energy[data-level="1"] .rating-btn:nth-child(-n+1) .energy-bar,
.rating-energy[data-level="2"] .rating-btn:nth-child(-n+2) .energy-bar,
.rating-energy[data-level="3"] .rating-btn:nth-child(-n+3) .energy-bar,
.rating-energy[data-level="4"] .rating-btn:nth-child(-n+4) .energy-bar,
.rating-energy[data-level="5"] .rating-btn:nth-child(-n+5) .energy-bar { background: var(--ink); box-shadow: none; }
.reflect-note { min-height: 64px; }

/* ---------- 分类选择器 ---------- */
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px 0 11px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.cat-chip:hover { background: var(--sunken); color: var(--ink); }
.cat-chip[aria-checked="true"] {
  border-color: var(--chip); color: var(--ink);
  background: color-mix(in srgb, var(--chip) 15%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--chip);
}
.cat-chip-add { border-style: dashed; color: var(--ink-3); }
.cat-chip-add[aria-expanded="true"] { border-style: solid; background: var(--sunken); color: var(--ink); }

.cat-new { --ring-gap: var(--sunken); display: grid; gap: 12px; margin-top: 10px; padding: 12px; border-radius: var(--r); background: var(--sunken); }
.cat-new-row { display: flex; align-items: center; gap: 10px; }
.cat-new-row input { background: var(--surface); }
.cat-new-preview { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--chip); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line-2); }
.cat-new-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* 色板 */
.swatch-group { display: grid; gap: 6px; }
.swatch-group + .swatch-group { margin-top: 10px; }
.swatch-label { color: var(--ink-3); font-size: 12px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative; display: inline-block;
  width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 50%; background: var(--chip);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 10%);
  cursor: pointer; transition: transform .12s;
}
.swatch:hover { transform: scale(1.1); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ring-gap, var(--surface)), 0 0 0 4px var(--chip); }
.swatch-custom {
  overflow: hidden;
  background: conic-gradient(from 210deg, #e34948, #eda100, #1baf7a, #2a78d6, #6250d6, #e87ba4, #e34948);
}
.swatch-custom[aria-pressed="true"] { background: var(--chip); }
.swatch-custom input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }

/* ---------- 日历 ---------- */
.calendar { padding: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-weekhead { margin: 2px 0 6px; }
.cal-weekhead span { color: var(--ink-3); font-size: 12px; font-weight: 600; text-align: center; }
.cal-cell {
  display: flex; flex-direction: column; gap: 3px;
  min-height: 66px; padding: 6px 6px 7px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink) calc(var(--intensity, 0) * 13%), var(--sunken));
  transition: box-shadow .15s;
}
.cal-cell:hover { box-shadow: inset 0 0 0 1px var(--line-2); }
.cal-cell.is-blank { background: transparent; }
.cal-cell.is-future { opacity: .5; }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 2px; }
.cal-day { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-cell:not(.has-data) .cal-day { color: var(--ink-3); font-weight: 500; }
.cal-mood { font-size: 12px; line-height: 1.1; }
.cal-hours { margin-top: auto; color: var(--ink-2); font-size: 11px; font-weight: 550; font-variant-numeric: tabular-nums; }
.stack-mini { height: 4px; gap: 1px; border-radius: 2px; }
@media (min-width: 600px) {
  .calendar { padding: 14px; }
  .cal-grid { gap: 6px; }
  .cal-cell { min-height: 86px; padding: 8px; }
  .cal-hours { font-size: 12px; }
  .stack-mini { height: 5px; }
}

/* ---------- 统计 ---------- */
.segmented { justify-self: start; display: inline-flex; padding: 3px; border-radius: 999px; background: var(--sunken); }
.segmented a { padding: 6px 18px; border-radius: 999px; color: var(--ink-3); font-size: 13.5px; font-weight: 600; }
.segmented a[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }

.bars { list-style: none; display: grid; gap: 12px; margin: 0; padding: 0; }
.bar-row { display: grid; grid-template-columns: minmax(64px, 7em) minmax(0, 1fr) auto; align-items: center; gap: 12px; font-size: 14px; }
.bar-name { display: flex; align-items: center; gap: 7px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar-track { height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 3px; border-radius: 0 4px 4px 0; background: var(--chip); }
.bar-value { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; min-width: 88px; font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.bar-value small { min-width: 2.8em; color: var(--ink-3); font-size: 12px; font-weight: 500; text-align: right; }

.cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; height: 190px; margin-top: 14px; }
.cols-month { gap: 2px; }
.col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.col-value { height: 16px; color: var(--ink-2); font-size: 11px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-plot { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; border-radius: 5px; background: color-mix(in srgb, var(--sunken) 70%, transparent); transition: background .15s; }
.col:hover .col-plot { background: var(--hover); }
.col-seg { display: block; flex: none; width: 100%; background: var(--chip); }
.col-seg:last-child { border-radius: 4px 4px 0 0; }
.col-label { color: var(--ink-3); font-size: 11.5px; text-align: center; font-variant-numeric: tabular-nums; }
.col.is-today .col-label { color: var(--ink); font-weight: 700; }
.cols-month .col-label { font-size: 10px; }
.cols-month .col:not(:nth-child(5n + 1)) .col-label { visibility: hidden; }

.rating-chart, .rc-axis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.rating-chart { height: 44px; }
.rc-col { display: flex; }
.rc-plot { flex: 1; display: flex; align-items: flex-end; justify-content: center; border-radius: 4px; background: color-mix(in srgb, var(--sunken) 70%, transparent); }
.rc-bar { display: block; width: min(100%, 14px); border-radius: 4px 4px 0 0; background: var(--ink-3); }
.rc-axis { margin-top: 6px; color: var(--ink-3); font-size: 10.5px; text-align: center; white-space: nowrap; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud .tag { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 11px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); font-size: 13px; }
.tag-cloud small { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 搜索 ---------- */
.search { display: grid; gap: 12px; }
.search-box { position: relative; display: block; }
.search-box .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search-box input { min-height: 48px; padding-left: 42px; border-radius: 999px; background: var(--sunken); border-color: transparent; }
.search-box input:focus { background: var(--surface); }
.search-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search-actions { display: flex; justify-content: flex-end; gap: 8px; }
.results { display: grid; gap: 18px; }
.result-count { margin: 0 2px; color: var(--ink-3); font-size: 13px; }
.result-group .section-label { margin-bottom: 8px; }

/* ---------- 设置 ---------- */
.cat-list { list-style: none; display: grid; gap: 2px; margin: 0 0 12px; padding: 0; }
.cat-row-main { display: flex; align-items: center; gap: 6px; }
.cat-row-main input { min-height: 40px; border-color: transparent; background: transparent; font-weight: 600; }
.cat-row-main input:hover { border-color: var(--line); }
.cat-swatch-btn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.cat-swatch-btn:hover { background: var(--sunken); }
.cat-swatch-btn .cat-dot { width: 18px; height: 18px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line-2); }
.color-panel { padding: 6px 4px 12px; }
@media (min-width: 600px) { .color-panel { padding-left: 46px; } }
.cat-add { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.cat-add .cat-row-main input { border-color: var(--line); background: var(--surface); font-weight: 500; }
.cat-add .cat-new-preview { margin: 0 9px; }
.cat-add .color-panel { padding-bottom: 4px; }

/* ---------- 记录弹窗：手机底部抽屉 / 电脑居中 ---------- */
.sheet {
  width: 100%; max-width: 100%; max-height: calc(100dvh - 24px);
  margin: auto 0 0; padding: 0;
  border: 0; border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: auto; overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-up .26s cubic-bezier(.2, .8, .2, 1); }
.sheet::backdrop { background: rgb(15 15 14 / 42%); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet-form { display: grid; gap: 14px; padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px); }
.sheet-grip { display: block; width: 36px; height: 4px; margin: 2px auto 0; border-radius: 2px; background: var(--line-2); }
.sheet-title { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -.01em; }
.sheet-actions { display: flex; align-items: center; gap: 8px; padding-top: 2px; }
.sheet .cat-new { --ring-gap: var(--sunken); }
@media (min-width: 640px) {
  .sheet { width: min(540px, calc(100vw - 32px)); margin: auto; border-radius: 22px; }
  .sheet[open] { animation: pop .2s ease-out; }
  .sheet-grip { display: none; }
  .sheet-form { padding: 22px; }
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); z-index: 100;
  max-width: calc(100vw - 32px); padding: 10px 18px;
  border-radius: 999px; background: var(--ink); color: var(--surface);
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: toast-in .2s ease-out;
}
.toast[data-type="error"] { background: var(--danger); color: #fff; }
@media (min-width: 760px) { .toast { bottom: 28px; } }

/* ---------- 动画 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .5; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes breathe { 50% { opacity: .3; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 45%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- 小屏 ---------- */
@media (max-width: 380px) {
  .hero-title { font-size: 30px; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row .field:first-child { grid-column: 1 / -1; }
  .rating-btn { width: 36px; height: 36px; }
  .rating-energy .rating-btn { width: 26px; }
  .reflect-row { grid-template-columns: 32px auto 1fr; gap: 8px; }
}
