:root {
  --bg: #f2f4f8;
  --bg-soft: #e9edf3;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --line: #e5e9f0;
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --primary-soft: #eff6ff;
  --accent: #14b8a6;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --warn: #f59e0b;
  --ok: #22c55e;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -14px rgba(15, 23, 42, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 62px;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --bg-soft: #0f172a;
  --card: #151f33;
  --text: #e8edf5;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --line: #23304c;
  --primary: #5b9cfa;
  --primary-2: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --danger-soft: rgba(239, 68, 68, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -16px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  color: inherit;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(var(--bg) 78%, rgba(0, 0, 0, 0));
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.5px;
}

#page-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 4px;
}

.icon-btn {
  appearance: none;
  border: none;
  background: var(--card);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.94);
}

.sync-indicator {
  appearance: none;
  border: none;
  background: var(--card);
  border-radius: 20px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.sync-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}

.sync-indicator.ok .dot {
  background: var(--ok);
}

.sync-indicator.syncing .dot {
  background: var(--primary);
  animation: pulse 1s infinite;
}

.sync-indicator.error .dot {
  background: var(--danger);
}

.sync-indicator.warn .dot {
  background: var(--warn);
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* ---------- 主区域 ---------- */
#main {
  padding: 4px 16px calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom));
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade-up 0.22s ease;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- 今日头部卡片 ---------- */
.hero {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius);
  padding: 16px;
  color: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.hero-date {
  font-size: 17px;
  font-weight: 600;
}

.hero-pct {
  font-size: 22px;
  font-weight: 700;
}

.hero-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0 8px;
}

.hero-bar i {
  display: block;
  height: 100%;
  background: #fff;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.hero-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  opacity: 0.95;
}

/* ---------- 区块 ---------- */
.section {
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  min-height: 26px;
}

.section-head h2 {
  font-size: 15px;
  margin: 0;
  color: var(--text);
  font-weight: 600;
}

.text-btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.text-btn:active {
  background: var(--primary-soft);
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  font-size: 11px;
  border-radius: 9px;
  text-align: center;
  vertical-align: 1px;
}

.badge-red {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- 列表行 ---------- */
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}

.row.prio-1::before {
  background: var(--warn);
}

.row.prio-2::before {
  background: var(--danger);
}

.row:active {
  transform: scale(0.995);
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row.done .row-title {
  text-decoration: line-through;
  color: var(--text-3);
}

.row-icon {
  font-size: 16px;
}

.prio-tag {
  font-size: 10px;
  color: var(--danger);
  border: 1px solid currentColor;
  border-radius: 5px;
  padding: 0 4px;
  vertical-align: 1px;
}

.repeat-tag {
  color: var(--text-3);
  font-size: 15px;
}

.time-badge {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--primary-2);
  background: var(--primary-soft);
  border-radius: 8px;
  padding: 3px 7px;
  min-width: 52px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .time-badge {
  color: var(--primary);
}

.more-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  padding: 4px;
}

/* 自定义复选框 */
.check {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.check input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.check i {
  position: absolute;
  inset: 0;
  border: 2px solid var(--text-3);
  border-radius: 7px;
  pointer-events: none;
  transition: all 0.15s ease;
}

.check input:checked + i {
  background: var(--primary);
  border-color: var(--primary);
}

.check input:checked + i::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.event-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  flex-shrink: 0;
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 22px 12px;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.empty-emoji {
  font-size: 26px;
}

.empty-title {
  font-size: 14px;
  margin-top: 6px;
}

.empty-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ---------- 今日打卡 ---------- */
.habit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.habit-chip {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.habit-chip::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--hc, var(--primary));
}

.habit-chip-main {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 8px;
  appearance: none;
  border: none;
  background: none;
  text-align: left;
  padding: 10px 4px 12px 14px;
  cursor: pointer;
}

.habit-emoji {
  grid-row: 1;
  font-size: 18px;
}

.habit-name {
  grid-row: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-count {
  grid-row: 1;
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.streak {
  font-style: normal;
  color: var(--warn);
  font-size: 11px;
}

.habit-progress {
  grid-column: 1 / -1;
  grid-row: 2;
  height: 4px;
  border-radius: 3px;
  background: var(--bg-soft);
  overflow: hidden;
}

.habit-progress i {
  display: block;
  height: 100%;
  background: var(--hc, var(--primary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.habit-bump,
.habit-decr {
  appearance: none;
  border: none;
  background: none;
  width: 46px;
  align-self: stretch;
  font-size: 18px;
  color: var(--text-3);
  cursor: pointer;
}

.habit-bump {
  color: var(--hc, var(--primary));
  font-weight: 600;
}

.habit-bump:active,
.habit-decr:active {
  background: var(--bg-soft);
}

.habit-chip.done .habit-chip-main {
  opacity: 0.72;
}

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 500;
}

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

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger-ghost {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-block {
  flex: 1;
}

.mini-btn {
  appearance: none;
  border: none;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 12px;
  border-radius: 9px;
  padding: 5px 10px;
  cursor: pointer;
}

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

.mini-btn.round {
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 16px;
  padding: 0;
}

.mini-btn:active {
  transform: scale(0.93);
}

/* ---------- 浮动按钮 ---------- */
.fab {
  position: fixed;
  right: max(16px, calc(50vw - 320px + 16px));
  bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 26px;
  box-shadow: 0 8px 20px -6px rgba(59, 130, 246, 0.55);
  cursor: pointer;
  z-index: 25;
}

.fab:active {
  transform: scale(0.92);
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 640px;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 30;
}

.tab {
  flex: 1;
  appearance: none;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-3);
  cursor: pointer;
}

.tab svg {
  width: 23px;
  height: 23px;
}

.tab.active {
  color: var(--primary);
}

/* ---------- 月历 ---------- */
.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.cal-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.cal-today {
  margin-left: -4px;
}

.cal-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 8px;
  box-shadow: var(--shadow);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  padding-bottom: 6px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-cell {
  appearance: none;
  border: none;
  background: none;
  border-radius: 10px;
  aspect-ratio: 1 / 1.05;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text);
}

.cal-cell.outside {
  color: var(--text-3);
  opacity: 0.55;
}

.cal-cell.weekend .cal-num {
  color: var(--text-2);
}

.cal-cell.today .cal-num {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.cal-cell.selected {
  background: var(--primary-soft);
}

.cal-num {
  font-size: 14px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.cal-dots {
  display: flex;
  gap: 3px;
  height: 6px;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}

.dot-task {
  background: var(--primary);
}

.dot-event {
  background: var(--accent);
}

.dot-habit {
  background: var(--warn);
}

.cal-legend {
  display: flex;
  gap: 14px;
  justify-content: center;
  font-size: 11px;
  color: var(--text-3);
  padding: 10px 0 14px;
}

.cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.day-panel {
  margin-top: 4px;
}

.day-habits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.day-habit {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}

.day-habit.done {
  background: var(--hc);
  border-color: var(--hc);
  color: #fff;
}

/* ---------- 打卡视图 ---------- */
.habits-hero {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 14px;
}

.habits-hero-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.habits-hero-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}

.habits-hero .hero-bar {
  background: var(--bg-soft);
  margin: 0;
}

.habits-hero .hero-bar i {
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.habit-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.habit-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-left: 4px solid var(--hc);
}

.habit-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 8px;
  cursor: pointer;
}

.habit-card-emoji {
  font-size: 24px;
}

.habit-card-title {
  flex: 1;
  min-width: 0;
}

.habit-card-name {
  font-size: 15px;
  font-weight: 600;
}

.habit-card-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remind-tag {
  font-size: 10px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 1px 5px;
  vertical-align: 1px;
}

.expand-arrow {
  color: var(--text-3);
  font-size: 12px;
}

.habit-card-body {
  padding: 0 14px 12px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}

.week-cell {
  appearance: none;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
  cursor: pointer;
}

.week-day-label {
  font-size: 10px;
  color: var(--text-3);
}

.week-dot {
  width: 100%;
  max-width: 26px;
  height: 10px;
  border-radius: 5px;
  background: var(--bg-soft);
}

.week-cell.off {
  opacity: 0.35;
}

.week-cell.miss .week-dot {
  background: var(--danger-soft);
  box-shadow: inset 0 0 0 1px var(--danger);
}

.week-cell.full .week-dot {
  background: var(--hc);
}

.week-cell.today .week-day-label {
  color: var(--primary);
  font-weight: 700;
}

.habit-today {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 6px 0 10px;
}

.habit-today-count {
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  min-width: 64px;
}

.habit-today-count b {
  font-size: 22px;
  color: var(--text);
  margin-right: 1px;
}

.habit-today-label {
  display: block;
  font-size: 10px;
  color: var(--text-3);
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 6px 0 2px;
  border-top: 1px dashed var(--line);
}

.heat-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--bg-soft);
}

.heat-cell.future {
  opacity: 0.4;
}

.heat-cell.off {
  opacity: 0.3;
}

.habit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 6px;
}

/* ---------- 设置 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-head h2 {
  font-size: 15px;
  margin: 0;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-2);
  margin: 6px 0 12px;
  line-height: 1.6;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions .btn {
  flex: 1;
  min-width: 96px;
  text-align: center;
}

.status-pill {
  font-size: 11px;
  border-radius: 20px;
  padding: 3px 10px;
  background: var(--bg-soft);
  color: var(--text-2);
  max-width: 62%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.ok {
  background: rgba(34, 197, 94, 0.14);
  color: var(--ok);
}

.status-pill.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.warn {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warn);
}

.status-pill.syncing {
  background: var(--primary-soft);
  color: var(--primary);
}

.sync-join {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.sync-join .input {
  flex: 1;
  text-transform: uppercase;
}

.sync-code-box {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.sync-code-label {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.sync-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sync-code {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--primary);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- 表单 ---------- */
.input {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
}

.input-lg {
  font-size: 16px;
  padding: 12px;
}

.form-row {
  margin-bottom: 12px;
}

.form-row.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row.two > div {
  min-width: 0;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
}

textarea.input {
  resize: vertical;
  min-height: 44px;
}

.seg {
  display: flex;
  background: var(--bg-soft);
  border-radius: 11px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  flex: 1;
  appearance: none;
  border: none;
  background: none;
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.seg.small .seg-btn {
  padding: 6px;
  font-size: 12px;
}

.seg-btn.active {
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

/* ---------- 弹层 ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.sheet.open {
  display: block;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.sheet-panel {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: env(safe-area-inset-bottom);
}

@keyframes slide-up {
  from {
    transform: translate(-50%, 40px);
    opacity: 0.5;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.sheet-head h3 {
  margin: 0;
  font-size: 17px;
}

.sheet-head .icon-btn {
  box-shadow: none;
  background: var(--bg-soft);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
}

.sheet-body {
  padding: 4px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-foot {
  display: flex;
  gap: 10px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
}

/* 习惯编辑器 */
.emoji-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.emoji-input {
  width: 74px;
  text-align: center;
  font-size: 20px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.emoji-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  font-size: 17px;
  padding: 7px 0;
  cursor: pointer;
}

.emoji-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.color-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.color-btn.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--card) inset;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 16px;
}

.stepper span {
  font-size: 18px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.day-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ---------- 确认框 ---------- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confirm-overlay.open {
  display: flex;
  animation: fade-in 0.16s ease;
}

.confirm-box {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 320px;
  padding: 20px;
  animation: pop 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pop {
  from {
    transform: scale(0.94);
    opacity: 0.6;
  }
}

.confirm-box h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.confirm-box p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions .btn {
  flex: 1;
}

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 34px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: rgba(31, 41, 55, 0.94);
  color: #fff;
  font-size: 13px;
  border-radius: 12px;
  padding: 10px 16px;
  max-width: 82vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  z-index: 90;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: rgba(220, 38, 38, 0.95);
}

.footer-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  padding: 8px 16px 0;
}

body.sheet-open {
  overflow: hidden;
}

/* ---------- 每日心得 ---------- */
.journal-card {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  border: none;
  font-family: inherit;
  color: inherit;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  cursor: pointer;
}

.journal-card:active {
  transform: scale(0.995);
}

.journal-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  border: 1px dashed var(--line);
  box-shadow: none;
  background: transparent;
}

.journal-empty-icon {
  font-size: 20px;
}

.journal-empty-text {
  font-size: 13px;
}

.journal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.journal-mood {
  font-size: 20px;
  line-height: 1;
}

.journal-date {
  flex: 1;
  font-size: 12px;
  color: var(--text-3);
}

.journal-edit {
  font-size: 12px;
  color: var(--primary);
}

.journal-text {
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.journal-card-compact {
  margin-bottom: 8px;
}

.journal-hint {
  font-size: 11px;
  color: var(--text-3);
  padding: 2px 0 6px;
}

.journal-textarea {
  min-height: 150px;
  line-height: 1.6;
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.mood-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 8px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.mood-btn .mood-emoji {
  font-size: 20px;
  line-height: 1.2;
}

.mood-btn .mood-label {
  font-size: 10px;
  color: var(--text-3);
}

.mood-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.mood-btn.active .mood-label {
  color: var(--primary);
}

.badge-note {
  background: rgba(139, 92, 246, 0.14);
  color: #8b5cf6;
}

.dot-note {
  background: #8b5cf6;
}

/* ---------- 桌面适配 ---------- */
@media (min-width: 700px) {
  body {
    background:
      radial-gradient(1200px 500px at 50% -100px, var(--primary-soft), transparent),
      var(--bg);
  }

  .topbar {
    padding-top: 22px;
  }

  .fab {
    right: calc(50vw - 320px + 16px);
  }

  .sheet-panel {
    bottom: 24px;
    border-radius: 20px;
    max-height: 86vh;
  }

  .sheet-backdrop {
    background: rgba(15, 23, 42, 0.35);
  }
}
