:root {
  color-scheme: light;
  --ink: #28243d;
  --muted: #77728b;
  --paper: #fffdf8;
  --violet: #6c5ce7;
  --violet-dark: #5545d6;
  --lavender: #eeeaff;
  --mint: #dff7ec;
  --coral: #ffded5;
  --yellow: #fff0bd;
  --blue: #dff2ff;
  --line: #ebe8f1;
  --danger: #d84e66;
  --shadow: 0 14px 36px rgba(54, 42, 101, .10);
  font-family: "Trebuchet MS", "Avenir Next", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 4%, #fff2c9 0 9rem, transparent 9.1rem),
    radial-gradient(circle at 94% 14%, #e7e1ff 0 11rem, transparent 11.1rem),
    #f8f6ff;
  color: var(--ink);
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.05; }
h2 { margin-bottom: 0; font-size: 1.42rem; }
h3 { margin-bottom: 5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.center-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  align-content: center;
  padding: 24px;
  text-align: center;
}

.center-screen > p { color: var(--muted); }
.brand-mark { display: grid; width: 78px; height: 78px; margin: 0 auto 18px; place-items: center; border-radius: 27px; background: linear-gradient(135deg, #ffe38b, #ffb95c); box-shadow: 0 16px 36px rgba(226, 148, 55, .25); font-size: 2.3rem; }
.auth-card { width: min(100%, 390px); padding: 32px 24px; border: 1px solid rgba(255,255,255,.8); border-radius: 32px; background: rgba(255,255,255,.90); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.auth-card.wide-card { width: min(100%, 540px); }
.auth-intro { margin: 12px auto 24px; color: var(--muted); line-height: 1.5; }
.family-avatars { display: flex; justify-content: center; margin-bottom: 18px; }
.family-avatars .avatar + .avatar { margin-left: -8px; outline: 4px solid white; }

.eyebrow, .section-kicker {
  margin: 0 0 4px;
  color: #de7c38;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.section-kicker { color: #ef9c34; font-size: .68rem; }
.section-kicker.purple { color: #8b6ce6; }

.pin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; text-align: left; }
.pin-form .primary-button, .pin-form .form-error { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: #514c63; font-size: .84rem; font-weight: 900; }
input, select { width: 100%; border: 2px solid var(--line); border-radius: 14px; background: white; color: var(--ink); outline: none; }
input { min-height: 48px; padding: 10px 13px; }
select { min-height: 48px; padding: 10px; }
input:focus, select:focus { border-color: #9387ed; box-shadow: 0 0 0 4px rgba(108,92,231,.10); }
.pin-form input { text-align: center; font-size: 1.3rem; letter-spacing: .4em; }
.form-error { min-height: 1.1em; margin: 0; color: var(--danger); font-size: .82rem; font-weight: 800; text-align: center; }

.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 22px 0; }
.pin-dots span { width: 17px; height: 17px; border: 2px solid #cfc9e3; border-radius: 50%; background: white; transition: background .15s ease, transform .15s ease; }
.pin-dots span.filled { border-color: var(--violet); background: var(--violet); transform: scale(1.08); }
.keypad { display: grid; grid-template-columns: repeat(3, 64px); justify-content: center; gap: 11px; }
.keypad button { width: 64px; height: 58px; border: 0; border-radius: 20px; background: #f4f1ff; color: var(--ink); font-size: 1.22rem; font-weight: 900; cursor: pointer; }
.keypad button:active { background: var(--lavender); transform: scale(.96); }

.primary-button, .secondary-button { min-height: 46px; padding: 11px 17px; border: 0; border-radius: 15px; font-weight: 900; cursor: pointer; }
.primary-button { background: linear-gradient(135deg, var(--violet), #8b7af0); color: white; box-shadow: 0 8px 20px rgba(91,73,207,.22); }
.secondary-button { background: var(--lavender); color: var(--violet-dark); }
.primary-button:disabled { cursor: wait; opacity: .6; }
.small-button { min-height: 42px; font-size: .86rem; }
.text-button { padding: 12px; border: 0; background: none; font-weight: 900; cursor: pointer; }
.danger-text { display: block; margin: 20px auto 0; color: var(--danger); }

.app-shell { width: min(100%, 720px); min-height: 100vh; margin: 0 auto; padding: 28px 20px 112px; }
.preview-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -10px 0 18px; padding: 9px 12px; border-radius: 12px; background: #fff7d9; color: #7a6220; font-size: .76rem; font-weight: 800; text-align: left; }
.preview-note button { flex: 0 0 auto; padding: 7px 10px; border: 0; border-radius: 10px; background: #7a6220; color: white; font-size: .72rem; font-weight: 900; cursor: pointer; }
.topbar, .profile-switcher, .section-heading, .routine-item, .bottom-nav, .parent-actions, .manager-item, .dialog-heading, .dialog-actions { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: 16px; }
.round-button { width: 48px; height: 48px; border: 0; border-radius: 17px; background: rgba(255,255,255,.86); box-shadow: var(--shadow); cursor: pointer; }

.profile-switcher { gap: 10px; margin: 28px 0 18px; padding: 5px; border-radius: 22px; background: rgba(255,255,255,.72); }
.profile { display: flex; flex: 1; align-items: center; justify-content: center; gap: 9px; padding: 8px 14px; border: 0; border-radius: 17px; background: transparent; color: var(--muted); font-weight: 900; cursor: pointer; }
.profile.active { background: white; color: var(--ink); box-shadow: 0 6px 18px rgba(67,54,112,.10); }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 13px; color: white; font-weight: 900; }
.avatar-lucas { background: linear-gradient(135deg, #59b9ef, #4b7de8); }
.avatar-natalia { background: linear-gradient(135deg, #ff8eb6, #ef66a6); }

.progress-card { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 14px 20px; overflow: hidden; padding: 24px; border-radius: 28px; background: linear-gradient(135deg, var(--violet), #8c7ff1); color: white; box-shadow: 0 18px 42px rgba(90,70,200,.25); }
.progress-card::after { content: ""; position: absolute; right: -28px; bottom: -45px; width: 150px; height: 150px; border: 24px solid rgba(255,255,255,.08); border-radius: 50%; }
.progress-copy p { margin-bottom: 4px; opacity: .82; font-weight: 700; }
.progress-copy strong { font-size: 1.42rem; }
.progress-ring { display: grid; width: 66px; height: 66px; place-items: center; border: 7px solid rgba(255,255,255,.24); border-radius: 50%; font-size: 1.3rem; transform: rotate(18deg); }
.progress-ring span { transform: rotate(-18deg); }
.progress-track { grid-column: 1 / -1; height: 9px; overflow: hidden; border-radius: 10px; background: rgba(255,255,255,.2); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #ffdc73; transition: width .25s ease; }
.encouragement { grid-column: 1 / -1; margin: -4px 0 0; font-size: .9rem; opacity: .9; }

.routine-section { margin-top: 30px; }
.section-heading { justify-content: space-between; margin: 0 3px 12px; }
.section-score { padding: 6px 10px; border-radius: 12px; background: white; color: var(--muted); font-size: .82rem; font-weight: 900; }
.routine-list { display: grid; gap: 10px; }
.routine-item { width: 100%; gap: 14px; padding: 13px; border: 2px solid transparent; border-radius: 21px; background: rgba(255,255,255,.92); color: var(--ink); text-align: left; box-shadow: 0 8px 24px rgba(54,42,101,.06); cursor: pointer; transition: transform .16s ease, border-color .16s ease; }
.routine-item:active { transform: scale(.98); }
.routine-item.completed { border-color: #9edfc1; background: #f8fffb; }
.routine-item.completed .task-copy strong { color: #77728b; text-decoration: line-through; }
.task-icon { display: grid; flex: 0 0 50px; height: 50px; place-items: center; border-radius: 17px; background: var(--blue); font-size: 1.55rem; }
.routine-item:nth-child(5n+2) .task-icon { background: var(--yellow); }
.routine-item:nth-child(5n+3) .task-icon { background: var(--mint); }
.routine-item:nth-child(5n+4) .task-icon { background: var(--lavender); }
.routine-item:nth-child(5n+5) .task-icon { background: var(--coral); }
.task-copy { display: grid; flex: 1; gap: 3px; }
.task-copy strong { font-size: 1rem; }
.task-copy small { color: var(--muted); font-size: .8rem; }
.checkmark { display: grid; flex: 0 0 31px; height: 31px; place-items: center; border: 2px solid #dcd8e6; border-radius: 50%; color: transparent; font-weight: 900; }
.completed .checkmark { border-color: #43bf82; background: #43bf82; color: white; }

.view { animation: appear .22s ease both; }
.page-heading { margin: 28px 2px 20px; }
.page-heading .muted { margin: 8px 0 0; font-size: .88rem; }
.week-children { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.week-child-card { padding: 19px; border-radius: 23px; background: white; box-shadow: 0 9px 26px rgba(54,42,101,.07); }
.week-child-card .avatar { margin-bottom: 12px; }
.week-child-card strong { display: block; font-size: 1.75rem; }
.week-child-card small { color: var(--muted); }
.mini-track { height: 8px; margin-top: 12px; overflow: hidden; border-radius: 8px; background: #efedf4; }
.mini-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #63c99a, #48b97f); }
.sunday-card { margin-bottom: 14px; padding: 20px; border-radius: 24px; background: linear-gradient(135deg, #fff0b7, #ffe0ec); box-shadow: 0 10px 28px rgba(213,148,74,.14); }
.sunday-card strong { display: block; margin-bottom: 5px; font-size: 1.1rem; }
.sunday-card p { margin: 0; color: #6c5970; }
.week-calendar { margin-top: 14px; padding: 20px; border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: 0 9px 26px rgba(54,42,101,.07); }
.week-calendar h3 { margin-bottom: 14px; }
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.day-cell { display: grid; justify-items: center; gap: 7px; padding: 9px 2px; border-radius: 15px; color: var(--muted); font-size: .72rem; font-weight: 900; }
.day-cell.today { background: var(--lavender); color: var(--violet-dark); }
.day-score { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #f0eef4; color: var(--muted); font-size: .68rem; }
.day-score.good { background: var(--mint); color: #247754; }
.day-score.great { background: #ffe8a2; color: #876212; }
.day-score.future { background: transparent; border: 2px dashed #e6e1ee; color: #bbb5c7; }

.panel { padding: 20px; border-radius: 24px; background: rgba(255,255,255,.92); box-shadow: 0 9px 26px rgba(54,42,101,.07); }
.parent-lock { max-width: 420px; margin: 28px auto; text-align: center; }
.large-emoji { display: block; margin-bottom: 10px; font-size: 2rem; }
.compact-pin-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 18px; }
.compact-pin-form input { text-align: center; letter-spacing: .35em; }
.compact-pin-form .form-error { grid-column: 1 / -1; }
.parent-actions { justify-content: space-between; gap: 16px; }
.parent-actions p { margin-bottom: 0; font-size: .82rem; }
.manager-list { display: grid; gap: 9px; margin-top: 14px; }
.manager-item { gap: 12px; padding: 12px; border-radius: 18px; background: rgba(255,255,255,.9); box-shadow: 0 6px 18px rgba(54,42,101,.05); }
.manager-item .task-icon { flex-basis: 43px; height: 43px; border-radius: 14px; font-size: 1.3rem; }
.manager-copy { flex: 1; min-width: 0; }
.manager-copy strong, .manager-copy small { display: block; }
.manager-copy small { overflow: hidden; margin-top: 3px; color: var(--muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.manager-actions { display: flex; gap: 5px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 13px; background: var(--lavender); cursor: pointer; }
.icon-button.delete { background: #fff0f2; }

.bottom-nav { position: fixed; z-index: 10; right: 50%; bottom: 14px; justify-content: space-around; width: min(calc(100% - 28px), 690px); padding: 9px; border: 1px solid rgba(235,232,241,.8); border-radius: 24px; background: rgba(255,255,255,.92); box-shadow: 0 16px 40px rgba(47,38,87,.16); backdrop-filter: blur(18px); transform: translateX(50%); }
.nav-item { display: grid; min-width: 76px; padding: 7px 10px; justify-items: center; gap: 2px; border: 0; border-radius: 15px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 900; cursor: pointer; }
.nav-item span { font-size: 1.2rem; }
.nav-item.active { background: var(--lavender); color: var(--violet-dark); }

.routine-dialog { width: min(calc(100% - 30px), 560px); padding: 0; border: 0; border-radius: 28px; color: var(--ink); box-shadow: 0 28px 80px rgba(35,25,75,.28); }
.routine-dialog::backdrop { background: rgba(35,28,61,.48); backdrop-filter: blur(5px); }
.routine-dialog form { padding: 24px; }
.dialog-heading { justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.close-button { width: 40px; height: 40px; border: 0; border-radius: 14px; background: #f2eff8; color: #716b80; font-size: 1.5rem; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 110px 1fr; gap: 14px; }
.form-grid .full-width { grid-column: 1 / -1; }
.emoji-field input { text-align: center; font-size: 1.45rem; }
fieldset { display: flex; align-items: center; gap: 15px; margin: 0; padding: 8px 12px; border: 2px solid var(--line); border-radius: 14px; }
.weekday-fieldset { flex-wrap: wrap; justify-content: space-between; }
legend { padding: 0 4px; color: #514c63; font-size: .76rem; font-weight: 900; }
.check-label { display: flex; align-items: center; gap: 5px; font-size: .82rem; }
.check-label input { width: 18px; min-height: 18px; accent-color: var(--violet); }
.dialog-actions { justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 100px; max-width: calc(100% - 30px); padding: 11px 17px; border-radius: 15px; background: #2e2942; color: white; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 700px) {
  .app-shell { padding-inline: 32px; }
  .routine-list { grid-template-columns: 1fr 1fr; }
  .routine-item:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .preview-note { align-items: stretch; flex-direction: column; text-align: center; }
  .pin-form { grid-template-columns: 1fr; }
  .pin-form .primary-button, .pin-form .form-error { grid-column: auto; }
  .auth-card { padding: 27px 20px; }
  .week-child-card { padding: 15px; }
  .week-child-card strong { font-size: 1.45rem; }
  .week-calendar { padding: 16px 10px; }
  .week-days { gap: 3px; }
  .parent-actions { align-items: stretch; flex-direction: column; }
  .form-grid { grid-template-columns: 90px 1fr; }
  .form-grid fieldset { grid-column: 1 / -1; }
}

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