/* =========================================================
   life-workbench 样式 · 田园绿系（纯内联变量，零外链）
   ========================================================= */
[hidden] { display: none !important; }

:root {
  --sky-1: #bfe9ff;
  --sky-2: #eaf8ff;
  --grass-1: #7cc576;
  --grass-2: #57a85a;
  --leaf-deep: #2f7d43;
  --soil: #a9765a;
  --soil-dark: #7d523c;
  --sun: #ffd75e;
  --cloud: #ffffff;
  --parrot-body: #3ec46d;
  --parrot-belly: #ffd166;
  --parrot-cheek: #ff7a6b;
  --parrot-beak: #ff9b42;
  --parrot-eye: #2b2b2b;
  --bg: #f4faef;
  --card: #ffffff;
  --line: #dceccd;
  --text: #2f3a2c;
  --muted: #7d8b78;
  --ink: #22402a;
  --primary: #57a85a;
  --primary-2: #7cc576;
  --danger: #e0644f;
  --warn: #f0a93b;
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 8px 24px rgba(47, 125, 67, .10);
  --shadow-s: 0 2px 10px rgba(47, 125, 67, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- 登录遮罩 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(165deg, var(--sky-1) 0%, var(--grass-1) 100%);
  padding: 20px;
}
.login-card {
  width: 340px; max-width: 100%;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
  border-radius: 24px; padding: 32px 28px 24px;
  box-shadow: 0 20px 60px rgba(31, 80, 45, .25);
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 12px;
  border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 34px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.login-title { font-size: 22px; color: var(--ink); }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.login-field { display: block; text-align: left; margin-bottom: 14px; }
.login-field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.login-field input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: var(--radius-s); font-size: 15px; outline: none;
  transition: border-color .15s;
}
.login-field input:focus { border-color: var(--primary); }
.login-error {
  background: #fdecea; color: var(--danger);
  font-size: 13px; padding: 8px 12px; border-radius: var(--radius-s); margin-bottom: 12px;
}
.login-btn { width: 100%; padding: 13px; font-size: 16px; letter-spacing: 4px; margin-top: 4px; }
.login-tip { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---------- 按钮 ---------- */
.btn-primary {
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-s); padding: 10px 18px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-s); transition: transform .1s, background .15s;
}
.btn-primary:hover { background: var(--grass-2); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-primary.sm { padding: 7px 14px; font-size: 13px; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1.5px solid var(--line);
  border-radius: var(--radius-s); padding: 8px 14px; font-size: 13px; transition: all .15s;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost.sm { padding: 7px 12px; }
.inp {
  border: 1.5px solid var(--line); border-radius: var(--radius-s);
  padding: 9px 12px; font-size: 14px; outline: none; background: #fff; color: var(--text);
}
.inp:focus { border-color: var(--primary); }

/* ---------- 主布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px; flex-shrink: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f3faf0 100%);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 6px 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--primary);
  color: #fff; font-weight: 800; font-size: 19px; display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 700; color: var(--ink); font-size: 15px; }

.mascot { display: flex; justify-content: center; margin: 4px 0 10px; }
.mascot svg { width: 96px; height: 96px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; border-radius: var(--radius-s);
  padding: 11px 12px; font-size: 14.5px; color: var(--text); text-align: left;
  transition: background .15s, color .15s;
}
.nav-btn .nav-ico { font-size: 17px; }
.nav-btn:hover { background: #eef6e9; }
.nav-btn.is-active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: var(--shadow-s); }

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.acct { display: flex; align-items: center; justify-content: space-between; }
.acct-name { font-weight: 600; color: var(--ink); }
.acct-lv { font-size: 12px; color: var(--primary); background: #eaf5e4; padding: 2px 8px; border-radius: 20px; }
.coin-box { font-size: 14px; color: #b8860b; font-weight: 600; background: #fff7e0; padding: 6px 10px; border-radius: var(--radius-s); text-align: center; }
.logout-btn { width: 100%; }

/* ---------- 主内容 ---------- */
.main { flex: 1; padding: 22px 26px 40px; max-width: 1100px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.greeting { font-size: 22px; font-weight: 700; color: var(--ink); }
.today-date { color: var(--muted); font-size: 13px; margin-top: 2px; }
.top-tasks { display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-acct { display: none; align-items: center; gap: 8px; }
.top-task {
  font-size: 12px; padding: 5px 10px; border-radius: 20px; background: #fff;
  border: 1px solid var(--line); color: var(--text);
}
.top-task.over { background: #fdecea; color: var(--danger); border-color: #f5c6bd; }
.top-task.today { background: #fff3e0; color: var(--warn); border-color: #ffe0b2; }
.top-task.empty { background: transparent; border: none; color: var(--muted); }

.sec-title { font-size: 18px; color: var(--ink); margin-bottom: 14px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sec-head .sec-title { margin: 0; }

.tab { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 花园 ---------- */
.garden-wrap {
  background: linear-gradient(180deg, var(--sky-2), #eafaf0);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; box-shadow: var(--shadow); overflow: hidden;
}
.garden-svg svg { width: 100%; height: auto; display: block; }

.plot { cursor: default; }
.plot .plot-soil { fill: var(--soil); }
.plot .plot-soil-dark { fill: var(--soil-dark); }
.crop-stage-0 .seed { opacity: 1; }
.crop-stage-0 .stem, .crop-stage-0 .leaf, .crop-stage-0 .flower, .crop-stage-0 .fruit { opacity: 0; }
.crop-stage-1 .seed { opacity: 0; }
.crop-stage-1 .leaf, .crop-stage-1 .flower, .crop-stage-1 .fruit { opacity: 0; }
.crop-stage-2 .seed { opacity: 0; }
.crop-stage-2 .flower, .crop-stage-2 .fruit { opacity: 0; }
.crop-stage-3 .seed { opacity: 0; }
.crop-stage-3 .fruit { opacity: 0; }
.crop-stage-4 .seed { opacity: 0; }
.crop-stage-4 .flower { opacity: 0; }
.is-wilted { filter: saturate(.45) brightness(.95); }
.can-harvest .harvest-pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .25; } 50% { opacity: .9; } }
.stem { transform-origin: bottom center; }
.leaf { transform-box: fill-box; transform-origin: center; }
.crop-stage-2 .leaf, .crop-stage-3 .leaf, .crop-stage-4 .leaf { animation: sway 3s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.plot-label { font-size: 9px; fill: #4a5a44; }
.plot-streak { font-size: 8px; fill: var(--primary); }
.plot-progress-bg { fill: #e3e8df; }
.plot-progress-fg { fill: var(--primary); transition: width .5s ease; }

/* 地块操作 */
.plot-controls { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.plot-ctrl {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 11px 13px; box-shadow: var(--shadow-s); display: flex; flex-direction: column; gap: 7px;
}
.plot-ctrl.empty { opacity: .7; }
.plot-ctrl .pc-top { display: flex; align-items: center; gap: 7px; }
.plot-ctrl .pc-dot { width: 10px; height: 10px; border-radius: 50%; }
.plot-ctrl .pc-name { font-size: 13.5px; font-weight: 600; color: var(--ink); flex: 1; }
.plot-ctrl .pc-stage { font-size: 11px; color: var(--muted); }
.plot-ctrl .pc-bar { height: 6px; background: #eef3ea; border-radius: 4px; overflow: hidden; }
.plot-ctrl .pc-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width .5s; }
.plot-ctrl .pc-actions { display: flex; gap: 6px; margin-top: 2px; }
.plot-ctrl .pc-actions button { flex: 1; min-height: 38px; font-size: 13px; }
.btn-water { background: #e7f3ff; color: #2b7fd4; border: 1px solid #cfe6fb; border-radius: 8px; }
.btn-water:hover { background: #d6ebff; }
.btn-water:disabled { opacity: .5; cursor: default; }
.btn-harvest { background: #fff3d6; color: #b8860b; border: 1px solid #ffe6a8; border-radius: 8px; font-weight: 700; }
.btn-harvest:hover { background: #ffeec2; }

/* 商店 */
.shop { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.shop-item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-s);
}
.shop-item .si-name { font-weight: 600; color: var(--ink); }
.shop-item .si-price { font-size: 13px; color: #b8860b; font-weight: 600; }
.shop-item .si-btn { margin-top: auto; }

/* ---------- 首页仪表 ---------- */
.dash-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.dash-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-s); }
.dash-h { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.dash-badge { font-size: 12px; color: var(--primary); background: #eaf5e4; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.dash-habits { display: flex; flex-direction: column; gap: 8px; }
.dash-habit { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dash-habit .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dash-habit .nm { flex: 1; }
.dash-habit.on .nm { color: var(--primary); font-weight: 600; }
.dash-habit .st { color: var(--warn); font-size: 12px; }
.dash-tasks { display: flex; flex-direction: column; gap: 7px; }
.dash-task { font-size: 13px; padding: 6px 10px; background: #f7faf4; border-radius: 8px; }
.dash-task.over { background: #fdecea; color: var(--danger); }
.dash-week { display: flex; align-items: flex-end; gap: 6px; height: 64px; }
.wk-cell { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.wk-bar { width: 70%; background: var(--primary-2); border-radius: 4px 4px 0 0; min-height: 6px; transition: height .4s; }
.wk-d { font-size: 9px; color: var(--muted); }
.dash-streak { margin-top: 10px; font-size: 13px; color: var(--muted); }
.dash-streak b { color: var(--warn); }

/* ---------- 打卡 ---------- */
.checkin-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.checkin-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-s); position: relative; overflow: hidden;
}
.checkin-card .cc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.checkin-card .cc-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.checkin-card .cc-name { font-size: 17px; font-weight: 700; color: var(--ink); }
.checkin-card .cc-type { font-size: 12px; color: var(--muted); }
.checkin-card .cc-streak { margin-left: auto; font-size: 13px; color: var(--warn); font-weight: 600; }
.checkin-card .cc-amount { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkin-card .cc-amount input { width: 90px; }
.checkin-card .cc-actions { display: flex; gap: 8px; margin-top: 6px; }
.cc-done-badge {
  position: absolute; top: 12px; right: 12px; background: var(--primary); color: #fff;
  font-size: 11px; padding: 3px 9px; border-radius: 20px; opacity: 0; transform: scale(.6); transition: all .2s;
}
.checkin-card.done .cc-done-badge { opacity: 1; transform: scale(1); }
.checkin-card.done { border-color: var(--primary); }
.cc-supply { margin-top: 10px; font-size: 12px; }

/* ---------- 待办 ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.task-item {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 13px 15px; box-shadow: var(--shadow-s);
  transition: border-color .15s;
}
.task-item .t-check {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: transparent;
  transition: all .15s;
}
.task-item.done .t-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.task-item.done .t-title { text-decoration: line-through; color: var(--muted); }
.task-item .t-title { flex: 1; font-size: 14.5px; }
.task-item .t-due { font-size: 12px; color: var(--muted); }
.task-item.over { border-color: #f5c6bd; background: #fff6f4; }
.task-item.over .t-due { color: var(--danger); }
.task-item.soon { border-color: #ffe0b2; background: #fffaf0; }
.task-item.soon .t-due { color: var(--warn); }
.task-item .t-del { color: var(--muted); background: none; border: none; font-size: 16px; padding: 2px 6px; }
.task-item .t-del:hover { color: var(--danger); }
.task-form-box { display: flex; gap: 8px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; margin-top: 12px; }
.task-form-box .inp { flex: 1; min-width: 160px; }
.task-group-h { font-size: 13px; font-weight: 700; color: var(--muted); margin: 16px 0 6px; }
.task-empty { color: var(--muted); font-size: 13px; padding: 18px; text-align: center; }

/* ---------- 统计 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-s); }
.stat-card h3 { font-size: 14px; color: var(--ink); margin-bottom: 12px; }
.heatmap { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.heat-cell { aspect-ratio: 1; border-radius: 4px; background: #eef3ea; font-size: 9px; display: flex; align-items: center; justify-content: center; color: #fff; }
.stat-big { font-size: 32px; font-weight: 800; color: var(--primary); }
.stat-sub { color: var(--muted); font-size: 13px; }
.streak-list { display: flex; flex-direction: column; gap: 8px; }
.streak-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.streak-row .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- 设置 ---------- */
.settings-box { display: flex; flex-direction: column; gap: 18px; max-width: 560px; }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-s); }
.set-card h3 { font-size: 15px; color: var(--ink); margin-bottom: 12px; }
.set-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.set-row label { width: 90px; font-size: 13px; color: var(--muted); }
.set-row .inp { flex: 1; }
.set-habit { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.set-habit .dot { width: 10px; height: 10px; border-radius: 50%; }
.set-habit .nm { flex: 1; }
.set-habit .meta { color: var(--muted); font-size: 12px; }
.set-row .switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.set-row .switch input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- 鹦鹉动画 ---------- */
.mascot-bubble {
  position: absolute; left: 50%; top: -6px; transform: translate(-50%, -100%);
  background: #fff; color: var(--ink); font-size: 12.5px; padding: 8px 12px;
  border-radius: 14px; box-shadow: var(--shadow); white-space: nowrap; z-index: 5;
  animation: bubbleIn .25s ease;
}
.mascot-bubble::after {
  content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #fff; border-bottom: 0;
}
@keyframes bubbleIn { from { opacity: 0; transform: translate(-50%, -90%); } to { opacity: 1; transform: translate(-50%, -100%); } }
.mascot.no-motion *, .no-motion * { animation: none !important; }

.pr-body { transform-origin: 60px 70px; }
.is-idle #pr-body { animation: breathe 3.5s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.02); } }
.is-idle #pr-eye { animation: blink 4s infinite; transform-origin: center; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.is-wave #pr-wing { animation: wave 0.5s ease-in-out 2; transform-origin: 78px 52px; }
@keyframes wave { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-25deg); } }
.is-happy #pr-body { animation: hop 0.4s ease-in-out 3; }
@keyframes hop { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-8px); } }
.is-happy #pr-wing { animation: flap 0.3s ease-in-out 4; transform-origin: 78px 52px; }
@keyframes flap { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-30deg); } }
.is-cheer #pr-body { animation: hop 0.4s ease-in-out 4; }
.is-cheer .spark { animation: sparkle 1s ease-in-out infinite; transform-origin: center; }
@keyframes sparkle { 0%,100% { opacity: .2; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.1); } }
.is-sad #pr-head { animation: droop 0.6s ease forwards; transform-origin: 60px 40px; }
@keyframes droop { to { transform: rotate(8deg); } }
.is-sad #pr-eye { transform: scaleY(.5); }
.is-sad #pr-wing { transform: rotate(12deg); transform-origin: 78px 52px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 38px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 30px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 99; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ---------- 移动端 ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: fixed; bottom: 0; left: 0; right: 0;
    flex-direction: row; align-items: center; justify-content: center;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--line); z-index: 30;
    gap: 0;
  }
  .brand, .mascot, .side-foot { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; gap: 0; max-width: 480px; }
  .nav-btn { flex-direction: column; gap: 2px; padding: 6px 6px; font-size: 11px; text-align: center; min-width: 52px; }
  .nav-btn .nav-ico { font-size: 18px; }
  .mobile-acct { display: flex; }
  .mobile-acct .acct-name { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
  .mobile-acct .btn-ghost.sm { padding: 5px 10px; font-size: 12px; }
  .main { flex: 1; min-height: 100vh; padding: 14px 14px 100px; max-width: none; }
  .topbar { margin-bottom: 14px; gap: 10px; }
  .greeting { font-size: 18px; }
  .dash-grid { grid-template-columns: 1fr; }
  .checkin-list { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .top-tasks { display: none; }
  button, .nav-btn, .cc-actions button, .task-item .t-del { min-height: 44px; }
  .inp { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
