:root {
  --paper: #f7f4ee;
  --surface: #fffdf9;
  --ink: #242623;
  --muted: #77786f;
  --line: #deddd5;
  --green: #28785d;
  --green-dark: #185744;
  --mint: #dceee3;
  --coral: #eb715d;
  --yellow: #f1bd4b;
  --blue: #4e83a9;
  --shadow: 0 18px 50px rgba(55, 54, 44, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; letter-spacing: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 32px 22px; background: #213d35; color: white; display: flex; flex-direction: column; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: var(--yellow); color: #233a33; font-size: 23px; font-weight: 900; transform: rotate(-3deg); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 19px; }
.brand small { margin-top: 2px; color: #b8cec4; font-size: 11px; }
.nav { margin-top: 54px; display: grid; gap: 8px; }
.nav-item { width: 100%; border: 0; border-radius: 6px; padding: 12px 14px; background: transparent; color: #c9d9d2; text-align: left; display: flex; gap: 12px; align-items: center; }
.nav-item span { width: 20px; font-size: 20px; line-height: 1; }
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.11); color: #fff; }
.family-panel { margin-top: auto; border-top: 1px solid rgba(255,255,255,.14); padding-top: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.sidebar .eyebrow { color: #9ebbb0; }
.member-list { display: grid; gap: 7px; }
.member-button { border: 0; border-radius: 6px; padding: 7px 8px; background: transparent; color: #dbe6e1; display: flex; align-items: center; gap: 9px; text-align: left; }
.member-button.active { background: rgba(255,255,255,.12); color: white; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #f6e0a9; font-size: 16px; }
.member-button small { margin-left: auto; color: #aac0b7; }
.text-button { border: 0; background: transparent; color: #c4d7cf; padding: 11px 7px 0; font-size: 13px; }

.main { min-width: 0; padding: 38px clamp(24px, 4vw, 64px) 60px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; max-width: 1180px; margin: 0 auto 34px; }
.date-label { margin: 0 0 5px; color: var(--muted); font-size: 13px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(25px, 3vw, 38px); line-height: 1.2; font-weight: 850; }
h2 { margin: 0; font-size: 22px; }
.points-pill { min-width: 170px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 9px 13px; box-shadow: 0 4px 15px rgba(55,54,44,.04); }
.coin { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); color: #5a4615; font-weight: 900; border: 2px solid #d9a638; }
.points-pill small, .points-pill strong { display: block; }
.points-pill small { max-width: 76px; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.points-pill strong { font-size: 20px; line-height: 1.1; }
.points-unit { margin-left: auto; color: var(--muted); font-size: 12px; }
.page { display: none; max-width: 1180px; margin: auto; }
.page.active { display: block; animation: page-in .3s ease; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .75fr); gap: 28px; align-items: stretch; }
.draw-panel, .summary-block, .wheel-section, .shop-section, .records-layout > section { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.draw-panel { padding: 28px; min-height: 570px; }
.checkin-picker { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: -6px -6px 24px; padding: 15px 17px; border: 1px solid #cddfd6; border-radius: 7px; background: #f0f7f3; }
.checkin-picker strong { font-size: 15px; }
.checkin-members { display: flex; gap: 7px; }
.checkin-member { min-width: 90px; height: 42px; padding: 5px 10px; border: 1px solid #cbd7d1; border-radius: 6px; background: white; color: var(--ink); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; font-weight: 800; }
.checkin-member.active { border-color: var(--green); background: var(--green); color: white; box-shadow: 0 4px 12px rgba(40,120,93,.18); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.section-heading.compact h2 { font-size: 18px; }
.status-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; background: var(--mint); color: var(--green-dark); font-size: 11px; font-weight: 800; white-space: nowrap; }
.draw-stage { min-height: 470px; display: grid; place-content: center; justify-items: center; text-align: center; }
.draw-stage p { margin: 25px 0 20px; color: var(--muted); font-size: 14px; }
.chore-orbit { position: relative; width: 270px; height: 220px; }
.chore-orbit > span { position: absolute; width: 48px; height: 48px; display: grid; place-items: center; background: white; border: 1px solid var(--line); border-radius: 50%; font-size: 23px; box-shadow: 0 7px 20px rgba(55,54,44,.09); }
.chore-orbit > span:nth-child(1) { left: 7px; top: 35px; transform: rotate(-10deg); }
.chore-orbit > span:nth-child(2) { right: 2px; top: 28px; transform: rotate(8deg); }
.chore-orbit > span:nth-child(3) { left: 20px; bottom: 2px; transform: rotate(7deg); }
.chore-orbit > span:nth-child(4) { right: 20px; bottom: 0; transform: rotate(-7deg); }
.draw-box { position: absolute; inset: 30px 66px 10px; display: grid; place-items: center; background: var(--coral); border-radius: 8px; box-shadow: inset 0 -12px rgba(130,42,31,.12), 0 14px 30px rgba(171,73,57,.22); transform: rotate(1deg); }
.draw-box::before { content: ""; position: absolute; top: -14px; width: 116%; height: 26px; background: #f08975; border-radius: 5px; }
.draw-box span { width: 70px; height: 92px; display: grid; place-items: center; background: #fff8e7; color: #30352f; font-size: 36px; font-weight: 900; box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: rotate(-3deg); }
.draw-actions, .assignment-actions, .modal-actions { display: flex; align-items: center; gap: 10px; }
.primary-button, .secondary-button, .danger-button { border-radius: 6px; padding: 11px 18px; font-weight: 750; border: 1px solid transparent; }
.primary-button { background: var(--green); color: white; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled, .secondary-button:disabled, .spin-button:disabled, .chore-option:disabled { opacity: .45; cursor: not-allowed; }
.secondary-button { background: transparent; color: var(--ink); border-color: var(--line); }
.secondary-button:hover { background: #f3f1eb; }
.danger-button { width: 100%; margin-top: 25px; background: transparent; color: #a74c41; border-color: #e8c9c4; }
.icon-button, .close-button { display: grid; place-items: center; border: 1px solid var(--line); background: white; color: var(--ink); }
.icon-button { width: 43px; height: 43px; border-radius: 6px; font-size: 20px; }
.assignment-card { min-height: 470px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; animation: reveal .45s cubic-bezier(.2,.8,.2,1); }
@keyframes reveal { from { opacity: 0; transform: scale(.92) rotate(-1deg); } }
.assignment-icon { width: 122px; height: 122px; display: grid; place-items: center; border-radius: 50%; background: #e9eee5; font-size: 61px; margin-bottom: 22px; }
.difficulty-row { display: flex; gap: 10px; align-items: center; color: var(--green); font-size: 12px; font-weight: 800; }
.difficulty { padding: 4px 8px; border-radius: 4px; background: var(--mint); }
.assignment-card h3 { margin: 10px 0 6px; font-size: 32px; }
.assignment-card > p { max-width: 420px; margin: 0 0 25px; color: var(--muted); }
.completed-stamp { padding: 11px 18px; border: 1px solid #a7cbb9; border-radius: 6px; color: var(--green); background: #f0f8f3; font-weight: 800; }
.completed-stamp span { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 5px; border-radius: 50%; background: var(--green); color: white; }
.summary-column { display: grid; gap: 20px; grid-template-rows: 1fr auto auto; }
.summary-block { padding: 22px; }
.progress-track { height: 7px; margin: 19px 0 20px; border-radius: 8px; background: #e9e8e2; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width .4s ease; }
.family-progress { display: grid; gap: 12px; }
.progress-person { display: grid; grid-template-columns: 35px 1fr auto; align-items: center; gap: 9px; }
.progress-person strong { font-size: 13px; }
.progress-person small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.progress-state { color: var(--muted); font-size: 11px; }
.progress-state.done { color: var(--green); font-weight: 800; }
.warm-block { position: relative; min-height: 160px; overflow: hidden; background: #f8dfaa; border-color: #e8c982; }
.warm-block .eyebrow { color: #7c5d19; }
.warm-block strong { font-size: 35px; }
.warm-block > p:last-child { width: 64%; margin: 10px 0 0; color: #725f34; font-size: 12px; }
.mini-illustration { position: absolute; right: 19px; bottom: 20px; font-size: 63px; transform: rotate(3deg); }
.rules-block { padding-top: 18px; padding-bottom: 18px; }
.rules-block ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.8; }

.rewards-layout { display: grid; grid-template-columns: minmax(390px, .95fr) minmax(0, 1.05fr); gap: 28px; }
.wheel-section, .shop-section { padding: 27px; }
.wheel-wrap { position: relative; width: min(100%, 440px); aspect-ratio: 1; margin: 28px auto 15px; }
#wheel { width: 100%; height: 100%; filter: drop-shadow(0 15px 19px rgba(60,55,40,.17)); transition: transform 5.2s cubic-bezier(.12,.72,.12,1); }
.wheel-pointer { position: absolute; z-index: 3; left: 50%; top: -9px; transform: translateX(-50%); width: 0; height: 0; border-left: 15px solid transparent; border-right: 15px solid transparent; border-top: 34px solid #233c34; filter: drop-shadow(0 2px 2px rgba(0,0,0,.15)); }
.spin-button { position: absolute; z-index: 2; inset: 50% auto auto 50%; transform: translate(-50%,-50%); width: 86px; height: 86px; border-radius: 50%; border: 7px solid white; background: #223d35; color: white; box-shadow: 0 3px 14px rgba(0,0,0,.2); }
.spin-button strong, .spin-button small { display: block; }
.spin-button strong { font-size: 17px; }
.spin-button small { margin-top: 2px; font-size: 9px; color: #d5e4dd; }
.odds-note { margin: 0; text-align: center; color: var(--muted); font-size: 11px; }
.reward-shop { margin-top: 22px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.reward-card { min-height: 168px; padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: #fff; display: flex; flex-direction: column; }
.reward-card .reward-icon { font-size: 32px; }
.reward-card h3 { margin: 10px 0 4px; font-size: 16px; }
.reward-card p { margin: 0; color: var(--muted); font-size: 11px; }
.reward-card button { margin-top: auto; width: 100%; padding: 8px; border: 0; border-radius: 5px; background: #edf4ef; color: var(--green-dark); font-size: 12px; font-weight: 800; }

.records-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(270px,.55fr); gap: 28px; align-items: start; }
.records-layout > section { padding: 27px; }
.activity-list { margin-top: 20px; }
.activity-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid #eceae4; }
.activity-item:first-child { border-top: 0; }
.activity-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #edf2eb; }
.activity-item strong { display: block; font-size: 13px; }
.activity-item p, .activity-item time { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.activity-delta { font-weight: 900; color: var(--green); }
.activity-delta.negative { color: var(--coral); }
.empty-state { padding: 55px 15px; text-align: center; color: var(--muted); }
.ranking-list { margin-top: 16px; display: grid; gap: 9px; }
.rank-item { display: grid; grid-template-columns: 24px 35px 1fr auto; align-items: center; gap: 7px; padding: 9px 0; border-bottom: 1px solid #eceae4; }
.rank-item > span:first-child { color: var(--muted); font-size: 12px; font-weight: 800; }
.rank-item strong { font-size: 13px; }
.rank-item b { color: var(--green); font-size: 13px; }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(23,32,29,.55); backdrop-filter: blur(3px); }
.modal { width: min(650px,100%); max-height: min(760px,90vh); overflow: auto; padding: 28px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.small-modal { width: min(430px,100%); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.close-button { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; }
.chore-options { margin-top: 21px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.chore-option { border: 1px solid var(--line); border-radius: 7px; background: white; padding: 14px; display: grid; grid-template-columns: 45px 1fr auto; gap: 10px; align-items: center; text-align: left; }
.chore-option:hover { border-color: var(--green); background: #f5faf7; }
.chore-option:disabled:hover { border-color: var(--line); background: white; }
.chore-option > span:first-child { font-size: 29px; }
.chore-option strong, .chore-option small { display: block; }
.chore-option small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.chore-option b { color: var(--green); font-size: 12px; }
.result-modal { position: relative; width: min(420px,100%); text-align: center; padding: 40px 30px 31px; }
.close-button.floating { position: absolute; right: 18px; top: 18px; }
.result-burst { width: 104px; height: 104px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; background: #f7e0a8; font-size: 54px; }
.result-modal p:not(.eyebrow) { margin: 10px 0 24px; color: var(--muted); }
form label { display: block; margin: 20px 0 7px; font-size: 12px; font-weight: 800; }
input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 11px; background: white; outline: none; }
input:focus { border-color: var(--green); }
.avatar-options { display: flex; gap: 7px; margin-bottom: 22px; }
.avatar-choice { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: white; font-size: 21px; }
.avatar-choice.active { border: 2px solid var(--green); background: var(--mint); }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 25px; transform: translate(-50%,20px); border-radius: 6px; padding: 11px 17px; background: #213d35; color: white; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s ease; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%,0); opacity: 1; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 10; inset: auto 0 0; height: 66px; padding: 7px 15px max(7px, env(safe-area-inset-bottom)); flex-direction: row; align-items: center; }
  .brand, .family-panel { display: none; }
  .nav { width: 100%; margin: 0; grid-template-columns: repeat(3,1fr); gap: 4px; }
  .nav-item { justify-content: center; flex-direction: column; gap: 3px; padding: 5px; font-size: 10px; text-align: center; }
  .nav-item span { width: auto; font-size: 18px; }
  .main { padding: 25px 18px 94px; }
  .home-grid, .rewards-layout, .records-layout { grid-template-columns: 1fr; }
  .summary-column { grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; margin-bottom: 23px; }
  h1 { font-size: 24px; }
  .points-pill { min-width: 110px; padding: 7px 9px; }
  .points-unit, .points-pill small { display: none; }
  .coin { width: 29px; height: 29px; }
  .draw-panel, .wheel-section, .shop-section, .records-layout > section, .summary-block { padding: 19px; }
  .draw-panel { min-height: 510px; }
  .checkin-picker { align-items: flex-start; flex-direction: column; }
  .checkin-members { width: 100%; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
  .checkin-member { min-width: 0; padding: 5px; }
  .draw-stage, .assignment-card { min-height: 410px; }
  .chore-orbit { transform: scale(.87); }
  .summary-column { grid-template-columns: 1fr; }
  .rewards-layout { gap: 18px; }
  .wheel-wrap { width: min(100%, 360px); }
  .reward-shop { grid-template-columns: 1fr 1fr; }
  .reward-card { min-height: 156px; padding: 13px; }
  .chore-options { grid-template-columns: 1fr; }
  .modal { padding: 21px; }
  .draw-actions { flex-direction: column; width: 100%; max-width: 230px; }
  .draw-actions button { width: 100%; }
}

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