:root {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f5f2eb);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #171717);
  --muted: var(--tg-theme-hint-color, #77746d);
  --line: rgba(23, 23, 23, 0.1);
  --yellow: #ffd84d;
  --yellow-deep: #efbf18;
  --dark: #171717;
  --green: #237a54;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 14px 40px rgba(31, 27, 18, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  color: inherit;
  font: inherit;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(104px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar h1,
.section-heading h2,
.family-hero h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

.topbar h1 {
  font-size: clamp(26px, 7vw, 38px);
  line-height: 1.05;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 7px 20px rgba(31, 27, 18, 0.06);
  cursor: pointer;
}

.icon-button span {
  display: block;
  font-size: 23px;
  line-height: 1;
  transition: transform 260ms ease;
}

.icon-button.loading span {
  transform: rotate(180deg);
}

.family-hero {
  display: flex;
  min-height: 142px;
  align-items: flex-end;
  justify-content: space-between;
  overflow: hidden;
  padding: 24px;
  border: 1px solid rgba(23, 23, 23, 0.08);
  border-radius: var(--radius-xl);
  background: var(--yellow);
  box-shadow: var(--shadow);
}

.family-copy {
  position: relative;
  z-index: 1;
}

.family-label {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.family-hero h2 {
  max-width: 260px;
  font-size: 30px;
  line-height: 1;
}

.family-hero p {
  margin: 8px 0 0;
  color: rgba(23, 23, 23, 0.68);
  font-size: 14px;
  font-weight: 650;
}

.family-monogram {
  display: grid;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  place-items: center;
  transform: rotate(7deg) translate(7px, 8px);
  border: 2px solid rgba(23, 23, 23, 0.14);
  border-radius: 24px;
  background: var(--dark);
  color: #fff;
  font-size: 34px;
  font-weight: 900;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 12px 0 30px;
}

.stat-card {
  display: flex;
  min-height: 92px;
  flex-direction: column;
  justify-content: space-between;
  padding: 15px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.stat-dark {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}

.stat-yellow {
  background: #fff8d6;
}

.stat-light {
  background: var(--surface);
}

.stat-value {
  font-size: 27px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.stat-label {
  color: currentColor;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  opacity: 0.7;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 28px;
}

.counter {
  min-width: 34px;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--dark);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.card-list,
.member-list {
  display: grid;
  gap: 10px;
}

.task-card {
  position: relative;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 8px 25px rgba(31, 27, 18, 0.045);
}

.task-topline,
.task-meta,
.member-card {
  display: flex;
  align-items: center;
}

.task-topline {
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eaf7f0;
  color: var(--green);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-pill.draft {
  background: #f0eee8;
  color: #6a675f;
}

.task-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.task-card h3 {
  margin: 17px 0 8px;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.task-outcome {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.task-meta {
  justify-content: space-between;
  gap: 12px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 13px;
}

.task-action {
  min-height: 38px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f5f0;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.task-action.delete {
  flex: 0 0 42px;
  color: #a53333;
}

.person {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.avatar {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  place-items: center;
  border-radius: 9px;
  background: var(--yellow);
  color: var(--dark);
  font-size: 11px;
  font-weight: 900;
}

.reminder-badge {
  white-space: nowrap;
}

.timeline {
  position: relative;
  display: grid;
  gap: 0;
}

.timeline::before {
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 15px;
  width: 1px;
  background: var(--line);
  content: "";
}

.reminder-item {
  position: relative;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0 16px;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  width: 13px;
  height: 13px;
  margin: 7px 0 0 9px;
  border: 3px solid var(--bg);
  border-radius: 50%;
  background: var(--yellow-deep);
  box-shadow: 0 0 0 1px var(--yellow-deep);
}

.reminder-item.sent .timeline-dot {
  background: #aaa69d;
  box-shadow: 0 0 0 1px #aaa69d;
}

.reminder-content {
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.reminder-time {
  margin: 0 0 7px;
  color: var(--yellow-deep);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.reminder-item.sent .reminder-time {
  color: var(--muted);
}

.reminder-content h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.reminder-content p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.member-card {
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.member-avatar {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--dark);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
}

.member-info {
  min-width: 0;
  flex: 1;
}

.member-info h3 {
  overflow: hidden;
  margin: 0 0 4px;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-info p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.role-pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: #f0eee8;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.family-tip {
  display: flex;
  gap: 11px;
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: #fff8d6;
  color: #665619;
  font-size: 13px;
  line-height: 1.4;
}

.family-tip span {
  font-size: 20px;
  font-weight: 900;
}

.family-tip p {
  margin: 0;
}

.empty-state {
  padding: 30px 20px;
  border: 1px dashed rgba(23, 23, 23, 0.18);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 16px;
}

.bottom-nav {
  position: fixed;
  z-index: 10;
  right: max(14px, calc((100vw - 720px) / 2 + 14px));
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: max(14px, calc((100vw - 720px) / 2 + 14px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(23, 23, 23, 0.12);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 38px rgba(23, 23, 23, 0.16);
  backdrop-filter: blur(16px);
}

.nav-item {
  display: flex;
  min-width: 0;
  height: 54px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #79766e;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.nav-item.active {
  background: var(--dark);
  color: #fff;
}

.nav-icon {
  font-size: 15px;
  font-weight: 900;
}

.loading-state {
  display: grid;
  gap: 12px;
}

.skeleton {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #e8e5de;
  animation: pulse 1.4s ease-in-out infinite alternate;
}

.skeleton-title {
  width: 70%;
  height: 140px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.skeleton-stat {
  height: 90px;
}

.skeleton-card {
  height: 145px;
}

.error-state {
  padding: 70px 20px;
  text-align: center;
}

.error-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 18px;
  background: var(--yellow);
  font-size: 30px;
  font-weight: 900;
}

.error-state h2 {
  margin: 0 0 10px;
}

.error-state p {
  max-width: 360px;
  margin: 0 auto 22px;
  color: var(--muted);
  line-height: 1.5;
}

.primary-button {
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: var(--dark);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.edit-dialog {
  width: min(100%, 720px);
  max-width: none;
  max-height: min(92vh, 850px);
  margin: auto auto 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.22);
}

.edit-dialog::backdrop {
  background: rgba(15, 15, 15, 0.48);
  backdrop-filter: blur(3px);
}

.edit-form {
  max-height: min(92vh, 850px);
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.dialog-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 18px;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.2);
}

.dialog-heading,
.dialog-actions,
.reminder-editor-heading,
.reminder-field {
  display: flex;
  align-items: center;
}

.dialog-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.035em;
}

.dialog-close {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 0;
  border-radius: 50%;
  background: #e9e6df;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.form-field {
  display: grid;
  min-width: 0;
  gap: 7px;
  margin-bottom: 14px;
}

.form-field > span,
.reminder-editor-heading > div > span {
  font-size: 12px;
  font-weight: 800;
}

.form-field input,
.form-field textarea,
.form-field select,
.reminder-field input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid rgba(23, 23, 23, 0.14);
  border-radius: 13px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.form-field textarea {
  min-height: 72px;
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus,
.reminder-field input:focus {
  border-color: var(--yellow-deep);
  box-shadow: 0 0 0 3px rgba(239, 191, 24, 0.16);
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 10px;
}

.reminder-editor {
  margin: 2px 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.48);
}

.reminder-editor-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.reminder-editor-heading small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.text-button {
  padding: 7px 9px;
  border: 0;
  border-radius: 10px;
  background: #fff2b6;
  color: #6d5710;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.reminder-fields {
  display: grid;
  gap: 8px;
}

.reminder-field {
  gap: 8px;
}

.reminder-field input {
  min-width: 0;
  min-height: 44px;
  font-size: 13px;
}

.remove-reminder {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 0;
  border-radius: 12px;
  background: #f6e6e3;
  color: #a53333;
  font-size: 20px;
  cursor: pointer;
}

.no-reminders {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.form-hint {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.dialog-actions {
  gap: 9px;
}

.dialog-actions button {
  flex: 1;
}

.dialog-actions button:disabled,
.task-action:disabled {
  cursor: wait;
  opacity: 0.55;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 20px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 20px;
  width: fit-content;
  max-width: min(460px, calc(100% - 40px));
  margin: auto;
  padding: 13px 16px;
  border-radius: 14px;
  background: var(--dark);
  color: #fff;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.toast.error {
  background: #9d3434;
}

.hidden {
  display: none !important;
}

@keyframes pulse {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

@media (min-width: 640px) {
  .app-shell {
    padding-right: 28px;
    padding-left: 28px;
  }

  .card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
