/* ============================================================
   墨与朱 — design tokens
   ============================================================ */
:root {
  --paper: #FAF7F1;      /* 底色 暖纸白 */
  --ink: #1C1C24;        /* 文字 墨蓝黑 */
  --mist: #8B8B94;       /* 次级 */
  --line: #ECE8E0;       /* 边框 */
  --cinnabar: #E4562E;   /* 强调 朱砂橙（行动色） */
  --jade: #2F7D5A;       /* 完成/正常 松绿 */
  --sticky: #FBF4E3;     /* 便签 淡黄 */
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --paper: #141419;
  --ink: #ECECF1;
  --mist: #8B8B94;
  --line: #2A2A32;
  --sticky: #232327;
  color-scheme: dark;
}

/* ============================================================
   基础 reset
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: pan-x pan-y;
  transition: background-color 0.2s ease, color 0.2s ease;
}

:focus-visible {
  outline: 2px solid var(--cinnabar);
  outline-offset: 2px;
}

/* ============================================================
   页面容器（section）
   ============================================================ */
.section {
  display: none;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
}

.section.active {
  display: block;
}

/* ============================================================
   底部页签栏 tabbar
   ============================================================ */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tabbar-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 0 8px;
  background: none;
  border: none;
  color: var(--mist);
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.22s var(--ease);
}

.tabbar-item .ph {
  font-size: 22px;
  line-height: 1;
}

.tabbar-item.active,
.tabbar-item[aria-current="page"] {
  color: var(--cinnabar);
}

/* ============================================================
   通用：卡片 / 按钮
   ============================================================ */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(28, 28, 36, 0.03), 0 6px 16px rgba(28, 28, 36, 0.06);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.22s var(--ease), background-color 0.22s var(--ease), color 0.22s var(--ease), transform 0.12s var(--ease);
}

.btn:hover {
  border-color: var(--mist);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fff;
}

.btn-primary:hover {
  background: #cf4a24;
}

/* 数字（时间/金额/token/计时）统一等宽 */
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   占位页（calendar / usage / focus）
   ============================================================ */
.page-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 55vh;
  color: var(--mist);
  font-size: 14px;
  text-align: center;
}

/* ============================================================
   对话页骨架占位（懒加载期间避免纯白屏）
   ============================================================ */
.chat-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 2px;
}

.chat-skeleton-line {
  height: 14px;
  border-radius: 8px;
  background: var(--line);
  animation: chat-skeleton-pulse 1.4s ease-in-out infinite;
}

.chat-skeleton-line.short {
  width: 62%;
}

@keyframes chat-skeleton-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.95; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
