/* 每日打卡 · 样式（移动优先，深色模式，无外部依赖） */

:root {
  color-scheme: light dark;

  --bg: #f4f4fa;
  --card: #ffffff;
  --card-2: #f6f6fc;
  --text: #1b1d29;
  --text-2: #6c7181;
  --line: rgba(24, 26, 44, 0.08);
  --line-strong: rgba(24, 26, 44, 0.16);
  --ring-track: rgba(24, 26, 44, 0.08);
  --primary: #5b5bf5;
  --primary-soft: rgba(91, 91, 245, 0.12);
  --danger: #e5484d;
  --tab-bg: rgba(255, 255, 255, 0.84);
  --sheet-bg: #ffffff;
  --input-bg: #f7f7fc;

  --shadow-sm: 0 2px 10px rgba(28, 30, 60, 0.05);
  --shadow: 0 10px 30px rgba(28, 30, 60, 0.07);
  --shadow-lg: 0 18px 44px rgba(28, 30, 60, 0.12);

  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d14;
    --card: #151824;
    --card-2: #1c2030;
    --text: #eef0f7;
    --text-2: #9aa1b5;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.18);
    --ring-track: rgba(255, 255, 255, 0.09);
    --primary: #7c7cf8;
    --primary-soft: rgba(124, 124, 248, 0.16);
    --danger: #ff6369;
    --tab-bg: rgba(21, 24, 36, 0.82);
    --sheet-bg: #141722;
    --input-bg: #1c2030;

    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.42);
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  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.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(58% 42% at 12% -4%, rgba(99, 102, 241, 0.16), transparent 70%),
    radial-gradient(48% 36% at 102% 8%, rgba(249, 115, 22, 0.12), transparent 70%),
    radial-gradient(55% 40% at 50% 104%, rgba(14, 165, 233, 0.09), transparent 70%);
}

@media (prefers-color-scheme: dark) {
  body::before {
    background:
      radial-gradient(58% 42% at 12% -4%, rgba(124, 124, 248, 0.18), transparent 70%),
      radial-gradient(48% 36% at 102% 8%, rgba(249, 115, 22, 0.1), transparent 70%),
      radial-gradient(55% 40% at 50% 104%, rgba(14, 165, 233, 0.08), transparent 70%);
  }
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

::selection {
  background: var(--primary-soft);
}

.app {
  position: relative;
  max-width: 620px;
  margin: 0 auto;
}

.view {
  padding: 0 18px calc(112px + var(--safe-bottom));
}

.view-inner {
  padding-top: calc(var(--safe-top) + 18px);
  animation: screen-in 0.32s cubic-bezier(0.22, 0.9, 0.35, 1) both;
}

/* ---------- 顶部 ---------- */

.hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.hero-title {
  margin: 0;
  font-size: clamp(21px, 5.8vw, 27px);
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.round-btn {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.2s ease;
}

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

.round-btn.small {
  width: 38px;
  height: 38px;
}

.round-btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-2);
}

/* ---------- 卡片 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ---------- 今日进度 ---------- */

.progress-card {
  position: relative;
  margin-top: 18px;
  padding: 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px 16px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.progress-card::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -52px;
  top: -66px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary-soft), transparent 68%);
  pointer-events: none;
}

.ring {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--pct, 0) * 1%), var(--ring-track) 0);
  display: grid;
  place-items: center;
}

.ring::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--card);
}

.ring-inner {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 1px;
}

.ring-inner b {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.ring-inner span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.progress-text {
  min-width: 0;
}

.progress-text h2 {
  margin: 0 0 3px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.progress-text p {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--text-2);
}

.bar {
  height: 6px;
  border-radius: 99px;
  background: var(--ring-track);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b8bfa, var(--primary));
  transition: width 0.45s cubic-bezier(0.22, 0.9, 0.35, 1);
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.16s ease, background 0.2s ease, filter 0.2s ease;
}

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

.btn svg {
  flex: none;
}

.btn-primary {
  background: linear-gradient(180deg, #6d6df8, #5b5bf5);
  color: #fff;
  box-shadow: 0 8px 20px rgba(91, 91, 245, 0.28);
}

.btn-primary:hover {
  filter: brightness(1.04);
}

.btn-ghost {
  background: var(--card-2);
  color: var(--text);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--line-strong);
}

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

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.26);
}

.btn-danger-ghost:hover {
  background: rgba(229, 72, 77, 0.07);
}

.btn[disabled] {
  opacity: 0.6;
  pointer-events: none;
}

.btn-block {
  width: 100%;
}

.progress-card .btn-block {
  grid-column: 1 / -1;
}

/* ---------- 最近 7 天 ---------- */

.week-card {
  margin-top: 16px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.week-card .section-head {
  margin: 0 2px 12px;
}

.week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 0 4px;
  border-radius: 12px;
}

.week-day.is-today {
  background: var(--primary-soft);
}

.wd-label {
  font-size: 11px;
  color: var(--text-2);
}

.wd-ring {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--pct, 0) * 1%), var(--ring-track) 0);
  display: grid;
  place-items: center;
}

.wd-ring i {
  display: block;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--card);
}

.wd-ring i.is-full {
  background: var(--primary);
}

.wd-date {
  font-size: 10px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- 区块标题 ---------- */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 4px 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 700;
  vertical-align: 1px;
}

.link {
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 0;
}

/* ---------- 打卡卡片 ---------- */

.habit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.habit-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.habit-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--c);
  opacity: 0.8;
}

.habit-card.is-done {
  background: linear-gradient(180deg, var(--card), var(--c-soft));
}

.habit-emoji {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--c-soft);
  font-size: 23px;
  line-height: 1;
}

.habit-emoji.small {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 18px;
}

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

.habit-name {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.habit-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-2);
}

.streak {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--c-soft);
  color: var(--c);
  font-size: 11px;
  font-weight: 700;
}

.streak.is-idle {
  background: var(--card-2);
  color: var(--text-2);
  font-weight: 600;
}

.meta-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.check-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 88px;
  height: 44px;
  padding: 0 13px;
  border: 1.5px solid var(--c);
  border-radius: 14px;
  background: transparent;
  color: var(--c);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.16s ease, background 0.2s ease, color 0.2s ease;
}

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

.check-btn.is-on {
  background: var(--c);
  color: #fff;
}

.check-btn.just-checked {
  animation: pop 0.5s cubic-bezier(0.2, 0.7, 0.3, 1.25);
}

.check-btn.compact {
  min-width: 76px;
  height: 38px;
  border-radius: 11px;
  font-size: 12.5px;
}

/* ---------- 空状态 ---------- */

.empty {
  margin-top: 18px;
  padding: 26px 20px 20px;
  text-align: center;
}

.empty-emoji {
  margin-bottom: 6px;
  font-size: 44px;
  line-height: 1.1;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.empty p {
  max-width: 300px;
  margin: 0 auto 18px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2);
}

.suggest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.suggest-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.suggest-chip span {
  font-size: 17px;
  line-height: 1;
}

.suggest-chip:active {
  background: var(--c-soft);
  border-color: var(--c);
}

.empty .btn + .btn {
  margin-top: 8px;
}

/* ---------- 页面标题 ---------- */

.page-head {
  padding: 4px 4px 18px;
}

.page-head h1 {
  margin: 0 0 8px;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-head .sub {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
}

/* ---------- 日历 ---------- */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 12px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.month-nav h2 {
  min-width: 118px;
  margin: 0;
  font-size: 16.5px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.nav-btn {
  width: 34px;
  height: 34px;
  padding: 0 0 3px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--text-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease;
}

.nav-btn:active {
  transform: scale(0.92);
}

.today-pill {
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--card);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filters::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--card);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.chip.is-active {
  background: var(--c);
  border-color: var(--c);
  color: #fff;
}

.calendar {
  padding: 12px 8px 10px;
}

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

.cal-week span {
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}

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

.day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 50px;
  padding: 4px 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease;
}

.day.is-out {
  opacity: 0.3;
}

.day.is-future {
  opacity: 0.42;
}

.day .dnum {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s ease, color 0.15s ease;
}

.day.is-marked {
  background: var(--c-soft);
}

.day.is-marked .dnum {
  background: var(--c);
  color: #fff;
}

.day.is-today .dnum {
  background: var(--primary);
  color: #fff;
}

.day .dots {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 6px;
}

.dot {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c);
}

.dot-more {
  font-size: 8px;
  font-style: normal;
  line-height: 1;
  color: var(--text-2);
}

.cal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.stat-tile {
  padding: 14px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-value i {
  margin-left: 2px;
  font-size: 11.5px;
  font-style: normal;
  font-weight: 600;
  color: var(--text-2);
}

.stat-label {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-2);
}

.cal-note {
  margin: 12px 6px 0;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-2);
}

/* ---------- 类型管理 ---------- */

.habit-list-page {
  margin-top: 14px;
}

.habit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

.habit-row + .habit-row {
  margin-top: 10px;
}

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

.habit-info h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.habit-info p {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-2);
}

.data-card {
  margin-top: 26px;
  padding: 18px;
}

.data-card h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.data-card > p {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-2);
}

.data-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.data-card .btn {
  width: 100%;
  min-height: 44px;
  font-size: 13px;
  padding: 0 10px;
}

.data-foot {
  margin: 12px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-2);
}

.page-foot {
  margin: 24px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.muted-note {
  padding: 20px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}

/* ---------- 底部导航 ---------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 30;
  width: min(520px, calc(100% - 28px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px;
  background: var(--tab-bg);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 0 5px;
  border-radius: 16px;
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.18s ease, background 0.18s ease;
}

.tab svg {
  display: block;
}

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

/* ---------- 弹层 ---------- */

body.sheet-open {
  overflow: hidden;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 12, 22, 0.42);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fade-in 0.2s ease both;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 41;
  width: min(560px, 100%);
  max-height: 88vh;
  max-height: 88dvh;
  padding: 6px 20px calc(18px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(-50%);
  background: var(--sheet-bg);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -22px 60px rgba(18, 20, 40, 0.22);
  animation: slide-up 0.3s cubic-bezier(0.22, 0.9, 0.35, 1) both;
}

.sheet-grip {
  width: 38px;
  height: 4px;
  margin: 4px auto 10px;
  border-radius: 99px;
  background: var(--line-strong);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 14px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.sheet-sub {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--text-2);
}

.sheet-body {
  padding-bottom: 4px;
}

.preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 16px;
  background: var(--c-soft);
}

.preview strong {
  display: block;
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.preview span {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-2);
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  margin: 0 2px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
}

input[name="name"] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[name="name"]::placeholder {
  color: var(--text-2);
  opacity: 0.75;
}

input[name="name"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  max-height: 170px;
  padding: 2px;
  overflow-y: auto;
}

.emoji-btn {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--card-2);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 380px) {
  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.emoji-btn.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

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

.color-btn {
  width: 32px;
  height: 32px;
  padding: 3px;
  display: grid;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
}

.color-btn span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.color-btn.is-active {
  border-color: var(--text);
}

.color-btn.is-active span::after {
  content: "✓";
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

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

.day-list {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}

.day-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}

.day-row:last-child {
  border-bottom: 0;
}

.day-row-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-row .check-btn {
  flex: none;
}

.hint {
  margin: 4px 2px 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-2);
}

.confirm-text {
  margin: 0 2px 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 60;
  max-width: calc(100% - 48px);
  padding: 10px 16px;
  border-radius: 99px;
  background: rgba(24, 26, 38, 0.93);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

@media (prefers-color-scheme: dark) {
  .toast {
    background: rgba(238, 240, 247, 0.95);
    color: #16181f;
  }
}

/* ---------- 桌面端微调 ---------- */

@media (min-width: 720px) {
  .view {
    padding-left: 26px;
    padding-right: 26px;
  }

  .day {
    min-height: 56px;
  }

  .day .dnum {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .habit-card {
    padding: 16px;
  }
}

/* ---------- 动效 ---------- */

@keyframes pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.09); }
  62% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

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

@keyframes slide-up {
  from { transform: translate(-50%, 24px); opacity: 0.4; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (hover: hover) {
  .day:hover {
    background: var(--card-2);
  }

  .check-btn:hover {
    background: var(--c-soft);
  }

  .check-btn.is-on:hover {
    filter: brightness(1.06);
  }

  .chip:hover,
  .today-pill:hover,
  .nav-btn:hover {
    border-color: var(--line-strong);
  }

  .suggest-chip:hover {
    border-color: var(--c);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
