/* ============================================================
   打卡 PWA · “小鹿娘”软萌风格 · 绿色调（参考图片 008bc085）
   绿意奶白底 + 薄荷绿主色 + 嫩黄绿 + 鹿角棕点缀 + 小粉蓝点染
   ============================================================ */
:root {
  /* 背景 */
  --bg: #f3f8ee;
  --surface: #fdfff8;
  --panel: #eef5e4;
  --panel-2: #e4eecf;

  /* 文字 */
  --ink: #3b4a3d;
  --muted: #8b9b84;

  /* 线条 */
  --line: #e1ecd8;

  /* 主题色（绿色系） */
  --green: #7fc99b;         /* 主绿：连衣裙的嫩绿 */
  --green-dark: #56a97c;
  --green-deep: #3d8a63;
  --green-soft: #e2f4e6;
  --mint: #7fc99b;          /* 别名：主绿 */
  --mint-dark: #56a97c;
  --mint-soft: #e2f4e6;
  --leaf: #bee087;          /* 图片色卡里的黄绿/草绿 */
  --leaf-soft: #eef6d8;

  /* 点缀色（保留，面积小） */
  --pink: #f6a9c5;          /* 腮红/暖粉 */
  --pink-soft: #fdeef3;
  --periwinkle: #a3c2ea;    /* 蝴蝶结蓝 */
  --periwinkle-dark: #7ea3d6;
  --periwinkle-soft: #eef3fb;
  --yellow: #e6c85c;        /* avoid 暖黄（鹿角附近的暖色） */
  --yellow-soft: #f8f0cf;

  /* 危险/破功 */
  --red: #ef8296;
  --red-dark: #dd5f76;
  --red-soft: #fdecef;

  /* 鹿角棕 */
  --brown: #b98d5f;
  --brown-dark: #9d7a4f;
  --brown-soft: #f4ecdc;

  --radius: 16px;
  --shadow: 0 3px 14px rgba(110, 150, 118, .12);
  --shadow-sm: 0 1px 6px rgba(110, 150, 118, .10);
  --danger: #dd5f76;
}

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

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

body {
  min-height: 100vh;
  background-color: var(--bg);
  /* 绿意柔光斑 */
  background-image:
    radial-gradient(circle at 8% 12%, rgba(127, 201, 155, .22) 0, transparent 34%),
    radial-gradient(circle at 92% 20%, rgba(190, 224, 135, .18) 0, transparent 30%),
    radial-gradient(circle at 14% 86%, rgba(150, 200, 170, .18) 0, transparent 32%),
    radial-gradient(circle at 88% 78%, rgba(230, 200, 92, .14) 0, transparent 28%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Nunito", "Quicksand", -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 12px;
  background: linear-gradient(180deg, #fdfff8 0%, #f2f8e8 100%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--green-soft), var(--leaf-soft) 55%, var(--periwinkle-soft));
  box-shadow: inset 0 0 0 1px #fff, 0 2px 8px rgba(110, 150, 118, .18);
  overflow: hidden;
}

.brand-mark .deer-mark {
  width: 44px;
  height: 44px;
  display: block;
  object-fit: cover;
  animation: deer-bob 4.2s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes deer-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(-2deg); }
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: .02em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--green-soft);
  background: linear-gradient(145deg, #fdfff8, var(--green-soft));
  color: var(--green-dark);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  transition: .18s;
}

.icon-btn:hover {
  transform: translateY(-1px) scale(1.04);
  border-color: var(--green);
}

/* ---------- 视图与底部导航 ---------- */
.view {
  display: none;
  padding: 8px 16px 20px;
  max-width: 560px;
  margin: 0 auto;
}

.view.active {
  display: block;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(253, 255, 248, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 4px 14px;
  border-radius: 14px;
  transition: .15s;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 28px;
  border-radius: 12px;
  background: transparent;
  font-size: 15px;
  transition: .18s;
}

.nav-item.active {
  color: var(--green-dark);
}

.nav-item.active span {
  background: linear-gradient(145deg, var(--green-soft), var(--leaf-soft));
  box-shadow: inset 0 0 0 1px #fff;
}

.nav-item b {
  font-size: 11px;
  font-weight: 800;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 10px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}

.page-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 600;
  max-width: 100%;
  box-shadow: var(--shadow-sm);
}

/* ---------- 习惯列表 ---------- */
.habit-list {
  display: grid;
  gap: 12px;
}

.habit-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 16px 18px;
  overflow: hidden;
  transition: .18s;
}

.habit-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--green), var(--green-dark));
  border-radius: 0 4px 4px 0;
}

.habit-card.type-boolean::before { background: linear-gradient(180deg, var(--green), var(--leaf)); }
.habit-card.type-amount::before { background: linear-gradient(180deg, var(--green-deep), var(--green)); }
.habit-card.type-avoid::before { background: linear-gradient(180deg, var(--yellow), var(--brown)); }

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

.habit-name {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
}

.habit-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 12px;
  transition: .15s;
}

.mini-btn:hover {
  background: var(--panel);
  color: var(--ink);
}

.habit-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.habit-status {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.habit-status b {
  color: var(--ink);
  font-size: 20px;
  margin-right: 2px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
  transition: .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.btn-primary {
  background: linear-gradient(145deg, var(--green), var(--green-dark));
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(86, 169, 124, .4);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red-dark);
  border-color: #f4cdd6;
}

.btn-ok {
  background: var(--green-soft);
  color: var(--green-dark);
  border-color: #c6e6d1;
}

.btn-warn {
  background: var(--yellow-soft);
  color: #a8842e;
  border-color: #ecdcae;
}

.btn:disabled {
  opacity: .55;
  cursor: default;
  transform: none;
}

/* ---------- 空状态 ---------- */
.empty-tips {
  text-align: center;
  color: var(--muted);
  padding: 44px 20px;
  background: var(--surface);
  border: 1px dashed #d8e6c8;
  border-radius: var(--radius);
}

/* ---------- 日历 ---------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.calendar-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11px;
  color: var(--muted);
  padding: 2px;
  transition: .12s;
}

.calendar-cell .d {
  font-weight: 700;
  color: var(--ink);
}

.calendar-cell .v {
  font-size: 10px;
  line-height: 1.1;
  word-break: break-all;
}

.calendar-cell.today {
  box-shadow: 0 0 0 2px var(--green);
}

.calendar-cell.break {
  background: var(--red-soft);
  border-color: #f2c2cc;
}

.calendar-cell.kept {
  background: var(--green-soft);
  border-color: #c6e6d1;
}

.calendar-cell.done {
  background: var(--green-soft);
  border-color: #c6e6d1;
}

.calendar-cell.amount {
  background: var(--leaf-soft);
  border-color: #dceaab;
}

.calendar-cell.empty {
  background: var(--panel);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot-avoid { background: var(--red); }
.dot-ok { background: var(--green); }
.dot-none { background: var(--line); }

.record-list {
  display: grid;
  gap: 7px;
}

.record-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.record-item .date {
  color: var(--muted);
  font-size: 12px;
  min-width: 72px;
}

.record-item .val {
  font-weight: 800;
}

.record-actions {
  display: flex;
  gap: 5px;
}

.record-actions .mini-btn {
  padding: 5px 9px;
  font-size: 12px;
}

/* ---------- 统计 ---------- */
.stats-list {
  display: grid;
  gap: 12px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #e6efda;
}

.stat-line:last-child {
  border-bottom: 0;
}

.stat-line b {
  font-size: 16px;
}

/* ---------- 设置 ---------- */
.settings-card {
  padding: 16px;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0;
}

#dataInfo {
  margin-top: 10px;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(59, 74, 61, .30);
  backdrop-filter: blur(2px);
}

.modal {
  width: 100%;
  max-width: 380px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 14px 40px rgba(59, 74, 61, .20);
  padding: 20px;
}

.modal-sm {
  max-width: 300px;
}

.modal h3 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 800;
}

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

.field span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 600;
}

.field input:focus,
.field select:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(127, 201, 155, .22);
}

#typeHint {
  margin: 2px 0 10px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.day-status {
  text-align: center;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 800;
  border-radius: 12px;
  margin-bottom: 10px;
}

.day-status.ok {
  background: var(--green-soft);
  color: var(--green-dark);
}

.day-status.bad {
  background: var(--red-soft);
  color: var(--red-dark);
}

.day-status.neutral {
  background: var(--panel);
  color: var(--muted);
}

.day-amount-list {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(59, 74, 61, .94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
  animation: toast-in .18s ease-out;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: #cfe0c2;
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 380px) {
  .view { padding-left: 10px; padding-right: 10px; }
  .habit-main { flex-direction: column; align-items: flex-start; }
}
