:root {
  --bg: #f7f9fc;
  --card: rgba(255,255,255,.92);
  --text: #101828;
  --muted: #718096;
  --line: #e8edf4;
  --blue: #1677ff;
  --blue-soft: #eaf2ff;
  --green: #22c55e;
  --red: #ff4d4f;
  --red-soft: #fff0f0;
  --orange: #ff9f1a;
  --shadow: 0 10px 30px rgba(16,24,40,.06);
  --radius: 22px;
  --nav-h: calc(76px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, sans-serif; }
body { overflow-x: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100dvh; background: radial-gradient(circle at top right, rgba(22,119,255,.07), transparent 34%), var(--bg); }
.app-content { width: min(100%, 680px); min-height: 100dvh; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 18px calc(var(--nav-h) + 28px); }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 8px 2px 22px; }
.hello h1, .screen-title h1 { font-size: 31px; line-height: 1.05; margin: 0 0 7px; letter-spacing: -.8px; }
.hello p, .screen-title p { margin: 0; color: var(--muted); font-size: 16px; }
.sun { font-size: 30px; line-height: 1; padding-top: 4px; }

.progress-card { background: var(--card); border: 1px solid rgba(255,255,255,.9); box-shadow: var(--shadow); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.progress-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.progress-title { font-size: 18px; font-weight: 800; }
.progress-sub { color: var(--muted); margin-top: 5px; font-size: 14px; }
.progress-pct { color: #5e6b7d; font-weight: 700; }
.progress-track { height: 11px; background: #edf1f6; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #27c66f, #41d68a); border-radius: inherit; transition: width .25s ease; }

.task-list, .section-card, .month-card { display: grid; gap: 10px; }
.task-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; min-height: 58px; padding: 8px 12px; border-radius: 18px; background: rgba(255,255,255,.87); border: 1px solid rgba(231,236,244,.88); box-shadow: 0 4px 16px rgba(16,24,40,.035); }
.task-row:active { transform: scale(.995); }
.check-btn { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #a9b6c8; background: transparent; display: grid; place-items: center; color: white; padding: 0; }
.check-btn.checked { border-color: var(--blue); background: var(--blue); }
.check-btn.checked::after { content: "✓"; font-size: 15px; font-weight: 800; }
.task-main { min-width: 0; }
.task-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-row.done .task-title { text-decoration: line-through; color: #9aa4b2; }
.task-meta { margin-top: 4px; color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.task-time { color: #64748b; font-size: 14px; }
.priority-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 5px var(--red-soft); margin-right: 4px; }

.add-primary { width: 100%; border: 0; background: var(--blue); color: white; min-height: 56px; border-radius: 20px; margin-top: 14px; font-weight: 750; font-size: 16px; box-shadow: 0 12px 24px rgba(22,119,255,.24); }
.add-primary span { font-size: 24px; vertical-align: -2px; margin-right: 7px; font-weight: 300; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); background: rgba(255,255,255,.8); border-radius: var(--radius); border: 1px dashed #dce3ed; }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 680px); height: var(--nav-h); display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px 18px env(safe-area-inset-bottom); background: rgba(250,252,255,.92); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); border-top: 1px solid rgba(212,220,232,.85); }
.nav-btn { border: 0; background: transparent; color: #7b8799; display: grid; justify-items: center; align-content: center; gap: 4px; font-size: 12px; font-weight: 650; }
.nav-btn.active { color: var(--blue); }
.nav-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 19px; font-weight: 800; }
.nav-btn.active .nav-icon { background: var(--blue-soft); }

.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; }
.screen-title { text-align: center; flex: 1; }
.screen-title h1 { font-size: 21px; margin-bottom: 4px; }
.screen-title p { font-size: 14px; }
.arrow-btn, .icon-btn { border: 0; background: transparent; width: 42px; height: 42px; border-radius: 50%; font-size: 30px; color: #27364a; display: grid; place-items: center; }
.arrow-btn:active, .icon-btn:active { background: #eef2f7; }

.week-strip { display: grid; grid-template-columns: repeat(7, minmax(42px,1fr)); gap: 6px; margin-bottom: 16px; overflow: hidden; }
.day-pill { border: 0; background: rgba(255,255,255,.85); border-radius: 17px; min-height: 68px; padding: 8px 3px; color: #5d6b7e; box-shadow: 0 4px 14px rgba(16,24,40,.035); }
.day-pill span { display: block; font-size: 12px; margin-bottom: 6px; }
.day-pill strong { font-size: 17px; color: #263244; }
.day-pill.selected { background: var(--blue); color: white; box-shadow: 0 9px 22px rgba(22,119,255,.25); }
.day-pill.selected strong { color: white; }

.day-section { background: rgba(255,255,255,.82); border: 1px solid #edf0f5; border-radius: 20px; overflow: hidden; }
.day-section + .day-section { margin-top: 10px; }
.day-section-head { min-height: 54px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 760; }
.day-section-head small { color: #637086; font-size: 14px; }
.day-section .task-row { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; background: rgba(255,255,255,.66); }
.inline-add { width: 100%; border: 0; background: rgba(255,255,255,.7); color: var(--blue); text-align: left; padding: 14px 18px; font-weight: 700; }

.month-card { background: rgba(255,255,255,.86); border: 1px solid #edf1f6; border-radius: 22px; padding: 12px 10px 16px; box-shadow: var(--shadow); }
.month-weekdays, .month-grid { display: grid; grid-template-columns: repeat(7,1fr); }
.month-weekdays div { text-align: center; padding: 6px 0 10px; color: #7e8999; font-size: 12px; }
.calendar-day { position: relative; border: 0; background: transparent; min-height: 56px; border-radius: 16px; display: grid; place-items: center; align-content: center; gap: 5px; color: #1f2937; }
.calendar-day.outside { color: #b5beca; }
.calendar-day.selected { background: var(--blue); color: #fff; }
.calendar-day.today:not(.selected) { outline: 2px solid #d7e8ff; }
.dots { height: 5px; display: flex; gap: 3px; justify-content: center; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: #58a6ff; }
.dot.red { background: var(--red); }
.calendar-day.selected .dot { background: rgba(255,255,255,.8); }

.selected-day-card { margin-top: 16px; }
.selected-day-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin: 0 4px 10px; font-weight: 800; }
.selected-day-title span { color: #68758a; font-weight: 700; font-size: 14px; }

.sheet-backdrop { position: fixed; z-index: 70; inset: 0; background: rgba(15,23,42,.27); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.task-sheet { position: fixed; z-index: 80; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%,680px); max-height: 91dvh; overflow: auto; background: #f8fafc; border-radius: 28px 28px 0 0; padding: 8px 18px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -20px 60px rgba(15,23,42,.18); animation: sheetUp .22s ease-out; }
@keyframes sheetUp { from { transform: translate(-50%, 24px); opacity: .4; } to { transform: translate(-50%,0); opacity: 1; } }
.hidden { display: none !important; }
.sheet-grabber { width: 44px; height: 5px; border-radius: 999px; background: #cfd6df; margin: 2px auto 8px; }
.sheet-head { display: grid; grid-template-columns: 48px 1fr 70px; align-items: center; }
.sheet-head h2 { text-align: center; font-size: 18px; margin: 0; }
.text-btn { border: 0; background: transparent; color: var(--blue); height: 44px; }
.strong { font-weight: 800; }
.task-form { padding-top: 16px; }
.field-label { display: block; color: #5f6b7d; font-size: 13px; margin: 0 4px 8px; }
.title-input { width: 100%; border: 0; background: white; border-radius: 18px; min-height: 58px; padding: 0 16px; font-size: 18px; outline: none; box-shadow: 0 5px 18px rgba(16,24,40,.035); }
.title-input:focus { box-shadow: 0 0 0 3px rgba(22,119,255,.12); }
.form-card { margin-top: 16px; background: white; border-radius: 19px; overflow: hidden; box-shadow: 0 5px 18px rgba(16,24,40,.035); }
.form-row { min-height: 56px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid #eef2f6; }
.form-row:last-child { border-bottom: 0; }
.form-row > span { display: flex; align-items: center; gap: 9px; }
.form-row input, .form-row select { border: 0; background: transparent; color: #506079; text-align: right; outline: none; max-width: 52%; }
.row-icon { width: 27px; height: 27px; display: inline-grid; place-items: center; border-radius: 8px; font-weight: 800; }
.row-icon.blue { color: #267bff; background: #eaf2ff; }
.row-icon.orange { color: #e78200; background: #fff4e3; }
.row-icon.red { color: #f04444; background: #fff0f0; }
.delete-btn { width: 100%; border: 0; background: white; color: var(--red); border-radius: 18px; min-height: 54px; margin-top: 18px; font-weight: 760; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(var(--nav-h) + 14px); transform: translateX(-50%); background: rgba(17,24,39,.93); color: white; padding: 10px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 20px rgba(0,0,0,.18); animation: toastIn .18s ease; }
@keyframes toastIn { from { opacity:0; transform:translate(-50%,8px)} to {opacity:1;transform:translate(-50%,0)} }

@media (min-width: 700px) {
  body { background: #e8edf4; }
  .app-shell { width: 680px; margin: 20px auto; min-height: calc(100dvh - 40px); border-radius: 34px; overflow: hidden; box-shadow: 0 30px 80px rgba(15,23,42,.15); }
  .app-content { min-height: calc(100dvh - 40px); }
  .bottom-nav { bottom: 20px; border-radius: 0 0 34px 34px; }
  .task-sheet { bottom: 20px; border-radius: 28px; }
}
