:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --text: #172033;
  --muted: #6b7280;
  --border: #dce4ef;
  --success: #15803d;
  --danger: #dc6060;
  --active-outline: #e86666;
  --shadow: 0 14px 38px rgba(25, 44, 78, .08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body[data-theme="cream"] {
  --bg: #fff8ef; --card: #fffefb; --primary: #eaa386; --primary-dark: #b96f58;
  --primary-soft: #fbe2d6; --text: #51453e; --muted: #988a82; --border: #f0d5c8;
  --success: #72ad88; --danger: #de7772; --shadow: 0 12px 35px rgba(116, 77, 56, .08);
}

body[data-theme="mint"] {
  --bg: #f3faf5; --card: #fffefc; --primary: #8dbca3; --primary-dark: #5d8f74;
  --primary-soft: #e0f1e6; --text: #45534a; --muted: #89968e; --border: #d6e8db;
  --success: #70ad87; --danger: #df7e79; --shadow: 0 12px 35px rgba(62, 103, 79, .08);
}

body[data-theme="lavender"] {
  --bg: #f8f5fc; --card: #fffeff; --primary: #b7a1ce; --primary-dark: #846aa0;
  --primary-soft: #eee5f6; --text: #504859; --muted: #958b9d; --border: #e2d8ec;
  --success: #76aa8b; --danger: #df7e79; --shadow: 0 12px 35px rgba(91, 69, 109, .08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100%; margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none; transition: background .25s ease, color .25s ease;
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--primary); outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

.app-shell { width: min(100%, 720px); min-height: 100vh; min-height: 100dvh; margin: 0 auto; position: relative; background: var(--bg); }
.kumeng-appbar { position: sticky; top: 0; z-index: 45; min-height: calc(65px + var(--safe-top)); padding: calc(9px + var(--safe-top)) 18px 9px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); border-bottom: 1px solid color-mix(in srgb, var(--border) 82%, transparent); background: rgba(255, 255, 255, .96); background: color-mix(in srgb, var(--card) 92%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.kumeng-brand { min-width: 0; display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.kumeng-brand img { display: block; width: 124px; height: 42px; object-fit: contain; object-position: left center; }
.kumeng-brand span { padding-left: 10px; border-left: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.local-data-pill { padding: 7px 10px; border: 1px solid #cbdcf7; border-radius: 999px; color: var(--primary-dark); background: var(--primary-soft); font-size: 9px; font-weight: 800; white-space: nowrap; }
.page { min-height: calc(100vh - 65px); min-height: calc(100dvh - 65px); padding: 25px 20px calc(106px + var(--safe-bottom)); }
.page-inner { animation: page-in .22s ease-out; }
@keyframes page-in { from { opacity: .2; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.planner-boot { min-height: 55vh; display: grid; place-items: center; align-content: center; gap: 9px; color: var(--text); text-align: center; }
.planner-boot-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 20px; background: var(--primary-soft); color: var(--primary-dark); font-size: 27px; font-weight: 900; animation: boot-pulse 1.1s ease-in-out infinite alternate; }
.planner-boot h1 { font-size: 22px; }
.planner-boot p, .planner-script-warning { color: var(--muted); font-size: 12px; }
@keyframes boot-pulse { from { transform: scale(.96); opacity: .72; } to { transform: scale(1.03); opacity: 1; } }

.bottom-nav {
  position: fixed; z-index: 50; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 720px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
  padding: 9px 12px calc(9px + var(--safe-bottom)); background: rgba(255, 255, 255, .96); background: color-mix(in srgb, var(--card) 91%, transparent);
  border-top: 1px solid var(--border); border-top: 1px solid color-mix(in srgb, var(--border) 78%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
.nav-item { min-width: 0; height: 58px; padding: 4px 2px 3px; border: 0; border-radius: 18px; background: transparent; display: grid; place-items: center; gap: 0; cursor: pointer; color: var(--muted); transition: color .16s ease, transform .16s ease; }
.nav-item svg { width: 34px; height: 34px; padding: 6px; border-radius: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: background .16s ease, box-shadow .16s ease, transform .16s ease; }
.nav-item span { font-size: 10px; white-space: nowrap; }
.nav-item.is-active { color: var(--primary-dark); background: transparent; }
.nav-item.is-active svg { background: var(--primary-soft); box-shadow: 0 6px 15px rgba(37, 99, 235, .14); transform: translateY(-1px); }
.nav-item.is-active span { font-weight: 700; }

h1, h2, h3, p { margin: 0; }
.greeting, .page-title-row { display: flex; align-items: center; gap: 15px; justify-content: space-between; }
.greeting h1 { font-size: clamp(24px, 7vw, 31px); line-height: 1.22; letter-spacing: -.035em; }
.greeting p, .page-title p { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.sparkle { flex: 0 0 53px; height: 53px; border-radius: 20px; background: var(--primary-soft); border: 1px solid var(--border); color: var(--primary-dark); display: grid; place-items: center; font-size: 25px; box-shadow: var(--shadow); }
.page-title h1 { font-size: 28px; letter-spacing: -.04em; }
.eyebrow { display: block; color: var(--primary-dark); font-size: 9px; font-weight: 800; letter-spacing: .17em; margin-bottom: 5px; }

.date-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin-top: 20px; }
.date-cell { min-width: 0; height: 63px; padding: 7px 1px; border: 1px solid var(--border); border-radius: 17px; background: var(--card); color: var(--text); cursor: pointer; display: grid; place-items: center; align-content: center; gap: 3px; }
.date-cell small { color: var(--muted); font-size: 9px; }
.date-cell strong { font-size: 16px; }
.date-cell.is-selected { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); }
.date-cell.is-selected small { color: var(--primary-dark); }
.date-cell.is-today:not(.is-selected) strong { color: var(--primary-dark); }

.card { border: 1px solid var(--border); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.progress-card { margin-top: 15px; padding: 18px; }
.progress-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.progress-head strong:last-child { color: var(--primary-dark); font-size: 13px; }
.progress-track { height: 8px; margin-top: 14px; overflow: hidden; border-radius: 999px; background: var(--primary-soft); }
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); transition: width .35s ease; }
.progress-card p { margin-top: 10px; color: var(--muted); font-size: 11px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 23px 1px 10px; }
.section-head h2 { font-size: 15px; }
.add-button, .small-button { border: 1px solid var(--border); border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); padding: 8px 13px; font-size: 11px; font-weight: 700; cursor: pointer; }

.swipe-shell { position: relative; overflow: hidden; margin-bottom: 10px; border-radius: 21px; background: var(--danger); }
.swipe-delete-bg { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 22px; color: white; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.swipe-card { position: relative; z-index: 1; min-height: 72px; display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 20px; background: var(--card); touch-action: pan-y; user-select: none; transition: transform .2s ease; }
.swipe-card.is-swiping { transition: none; }
.task-time { flex: 0 0 58px; height: 36px; display: grid; place-items: center; border-radius: 13px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; font-weight: 700; }
.habit-symbol { flex: 0 0 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-size: 19px; }
.item-copy { min-width: 0; flex: 1; }
.item-copy h3 { overflow-wrap: anywhere; font-size: 14px; line-height: 1.4; }
.item-copy h3.is-done { color: var(--muted); opacity: .75; text-decoration: line-through; }
.item-copy p { margin-top: 4px; color: var(--muted); font-size: 10px; }
.status-button { flex: 0 0 42px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--danger); color: white; font-size: 20px; font-weight: 800; cursor: pointer; }
.status-button.is-done { background: var(--success); }
.empty-card { padding: 27px 18px; text-align: center; }
.empty-card .empty-icon { color: var(--primary); font-size: 25px; }
.empty-card h3 { margin-top: 8px; font-size: 14px; }
.empty-card p { margin-top: 5px; color: var(--muted); font-size: 11px; }

.calendar-card { margin-top: 17px; padding: 14px; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.calendar-toolbar h2 { font-size: 17px; }
.calendar-move { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 13px; background: var(--primary-soft); color: var(--primary-dark); font-size: 21px; cursor: pointer; }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-week span { padding: 5px 0 8px; color: var(--muted); text-align: center; font-size: 9px; }
.calendar-day { position: relative; aspect-ratio: 1; min-height: 39px; border: 1px solid transparent; border-radius: 13px; background: transparent; color: var(--text); font-size: 12px; cursor: pointer; }
.calendar-day.is-outside { color: var(--muted); opacity: .45; color: color-mix(in srgb, var(--muted) 45%, transparent); }
.calendar-day.has-plan::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); transform: translateX(-50%); }
.calendar-day.is-selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: 800; }
.calendar-day.is-today:not(.is-selected) { color: var(--primary-dark); font-weight: 800; }

.streak-card { margin-top: 15px; display: flex; align-items: center; gap: 12px; padding: 17px; background: linear-gradient(135deg, var(--primary-soft), var(--card)); }
.streak-symbol { width: 48px; height: 48px; display: grid; place-items: center; color: var(--primary-dark); font-size: 27px; }
.streak-card h2 { font-size: 18px; }
.streak-card p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.recent-card { margin-top: 13px; padding: 16px; }
.recent-card h2 { font-size: 13px; }
.recent-days { display: grid; grid-template-columns: repeat(7, 1fr); margin-top: 12px; }
.recent-day { display: grid; place-items: center; gap: 5px; color: var(--muted); font-size: 9px; }
.recent-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); font-size: 14px; font-weight: 800; }
.recent-day.is-checked .recent-mark { background: var(--success); color: white; }

.profile-card { margin-top: 17px; padding: 18px; display: flex; align-items: center; gap: 13px; background: linear-gradient(135deg, var(--primary-soft), var(--card)); }
.avatar { flex: 0 0 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: white; font-size: 23px; font-weight: 800; }
.profile-copy { min-width: 0; flex: 1; }
.profile-copy h2 { font-size: 20px; overflow-wrap: anywhere; }
.profile-copy p { margin-top: 5px; color: var(--muted); font-size: 11px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 13px; }
.stat-card { min-width: 0; height: 88px; display: grid; place-items: center; align-content: center; border: 1px solid var(--border); border-radius: 19px; background: var(--card); }
.stat-card strong { color: var(--primary-dark); font-size: 22px; }
.stat-card span { margin-top: 5px; color: var(--muted); text-align: center; font-size: 10px; }
.block-title { margin: 21px 1px 9px; font-size: 15px; }
.list-card { padding: 6px 16px; }
.row { min-height: 66px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row-icon { flex: 0 0 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-size: 18px; font-weight: 800; }
.row-icon.unlocked { background: var(--primary); color: white; }
.row-copy { min-width: 0; flex: 1; }
.row-copy strong { display: block; font-size: 13px; }
.row-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.row-state { color: var(--muted); font-size: 10px; font-weight: 700; }
.row-state.unlocked { color: var(--success); }
.settings-row { width: 100%; padding: 0; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; }
.settings-row:last-child { border-bottom: 0; }
.settings-row .row { border: 0; }
.chevron { color: var(--muted); font-size: 22px; }
.version-note { margin: 18px 0 2px; color: var(--muted); text-align: center; font-size: 10px; }

.app-dialog { width: min(calc(100% - 28px), 440px); max-height: calc(100vh - 30px); max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 30px); padding: 0; border: 1px solid var(--border); border-radius: 27px; background: var(--card); color: var(--text); box-shadow: 0 22px 70px rgba(65, 43, 33, .22); }
.app-dialog:not([open]) { display: none; }
.app-dialog[open] { display: block; }
.app-dialog.is-open { position: fixed; z-index: 90; top: 50%; left: 50%; display: block; margin: 0; transform: translate(-50%, -50%); overflow: auto; }
.app-dialog::backdrop { background: rgba(54, 42, 35, .34); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.app-dialog form, .install-panel { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.dialog-heading h2 { font-size: 21px; }
.icon-button { flex: 0 0 36px; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-size: 22px; cursor: pointer; }
.app-dialog label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.app-dialog input, .app-dialog select { width: 100%; height: 48px; padding: 0 13px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); color: var(--text); font-size: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 13px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
.button { min-height: 46px; border: 1px solid transparent; border-radius: 15px; font-size: 13px; font-weight: 800; cursor: pointer; }
.button.primary { background: var(--primary); color: white; }
.button.secondary { border-color: var(--border); background: var(--primary-soft); color: var(--primary-dark); }
.button.danger { background: var(--danger); color: white; }
.button.full { width: 100%; margin-top: 17px; }
.theme-options { display: grid; gap: 9px; }
.theme-choice { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 17px; background: var(--bg); text-align: left; cursor: pointer; }
.theme-choice.is-current { border-color: var(--primary); background: var(--primary-soft); }
.theme-dot { flex: 0 0 36px; height: 36px; border-radius: 50%; box-shadow: inset 0 0 0 7px rgba(255,255,255,.55); }
.theme-dot.kumeng { background: #2563eb; }.theme-dot.cream { background: #eaa386; }.theme-dot.mint { background: #8dbca3; }.theme-dot.lavender { background: #b7a1ce; }
.theme-choice span:nth-child(2) { flex: 1; }
.theme-choice strong, .theme-choice small { display: block; }
.theme-choice strong { font-size: 13px; }.theme-choice small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.theme-choice b { visibility: hidden; color: var(--primary-dark); }.theme-choice.is-current b { visibility: visible; }
.install-steps { margin: 0; padding-left: 23px; color: var(--text); font-size: 13px; line-height: 1.8; }
.install-note { margin-top: 13px; padding: 12px; border-radius: 14px; background: var(--primary-soft); color: var(--muted); font-size: 11px; line-height: 1.6; }
.confirm-dialog form { text-align: center; }
.confirm-mark { width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; background: #fde8e8; background: color-mix(in srgb, var(--danger) 18%, var(--card)); color: var(--danger); font-size: 25px; font-weight: 900; }
.confirm-dialog p { margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(86px + var(--safe-bottom)); max-width: calc(100% - 38px); padding: 10px 16px; border-radius: 999px; background: var(--text); color: var(--card); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .22s ease; }
.toast.is-visible { opacity: .95; transform: translate(-50%, 0); }

@media (min-width: 721px) {
  body { background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, white); }
  .app-shell { border-inline: 1px solid var(--border); box-shadow: 0 0 60px rgba(80, 58, 45, .08); }
  .page { padding-inline: 32px; }
}
@media (max-width: 370px) {
  .page { padding-inline: 14px; }
  .kumeng-appbar { padding-inline: 12px; }
  .kumeng-brand img { width: 104px; }
  .kumeng-brand span { display: none; }
  .local-data-pill { padding-inline: 8px; font-size: 8px; }
  .nav-item span { font-size: 9px; }
  .greeting h1 { font-size: 23px; }
  .date-strip { gap: 3px; }
  .date-cell { border-radius: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
