:root {
  --bg: #f4efe6;
  --panel: rgba(255, 252, 247, 0.94);
  --panel-strong: #fffdf9;
  --line: #d8cfc2;
  --text: #2f241d;
  --muted: #6f6257;
  --accent: #c55c35;
  --accent-strong: #a24826;
  --accent-soft: rgba(197, 92, 53, 0.12);
  --success: #2f8f58;
  --warning: #d58a1a;
  --info: #3d73c9;
  --danger: #bc3d30;
  --shadow: 0 20px 40px rgba(53, 36, 20, 0.1);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-display: "Trebuchet MS", "Aptos", sans-serif;
  --font-body: "Segoe UI", "Aptos", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(197, 92, 53, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(74, 143, 170, 0.18), transparent 26%),
    linear-gradient(160deg, #f8f2ea 0%, #f1e7d6 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover:not(:disabled),
.upload-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-button {
  background: white;
  color: var(--danger);
  border: 1px solid rgba(188, 61, 48, 0.28);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
}

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 1.25rem;
  min-height: 100vh;
  padding: 1.25rem;
}

.sidebar,
.main-panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
}

.sidebar {
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.main-panel {
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand h1,
.topbar h2,
.section-heading h2,
.page-header h3,
.modal-card h3 {
  margin: 0;
  font-family: var(--font-display);
}

.eyebrow {
  margin: 0 0 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.sidebar-actions,
.topbar-actions,
.action-row,
.card-actions,
.note-actions,
.modal-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.upload-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  cursor: pointer;
}

.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.section-heading,
.topbar,
.page-header,
.subsection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.topbar {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(111, 98, 87, 0.18);
}

.people-list,
.main-content,
.goal-grid,
.task-list,
.profile-sections {
  display: grid;
  gap: 0.9rem;
}

.people-list {
  overflow: auto;
  padding-right: 0.25rem;
}

.person-card,
.goal-card,
.task-card,
.surface-card,
.step-row,
.profile-history-row,
.note-history-row {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(111, 98, 87, 0.14);
  background: var(--panel-strong);
}

.person-card {
  padding: 0.95rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
}

.person-card.is-active {
  background: linear-gradient(135deg, rgba(197, 92, 53, 0.2), rgba(255, 244, 236, 0.96));
  border-color: rgba(197, 92, 53, 0.42);
  box-shadow: inset 0 0 0 1px rgba(197, 92, 53, 0.24);
}

.person-card.is-active h3,
.person-card.is-active .muted {
  font-weight: 700;
  color: var(--text);
}

.goal-card.is-active,
.task-card.is-active {
  background: linear-gradient(135deg, rgba(197, 92, 53, 0.2), rgba(255, 244, 236, 0.96));
  border-color: rgba(197, 92, 53, 0.42);
  box-shadow: inset 0 0 0 1px rgba(197, 92, 53, 0.24);
}

.goal-card.is-active h3,
.task-card.is-active h3,
.goal-card.is-active .muted,
.task-card.is-active .muted,
.goal-card.is-active .tiny-chip {
  font-weight: 700;
  color: var(--text);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: white;
}

.avatar.girl {
  background: linear-gradient(135deg, #d66a8b, #f4a6b3);
}

.avatar.boy {
  background: linear-gradient(135deg, #5b8bd9, #83b6ff);
}

.person-card h3,
.goal-card h3,
.task-card h3,
.surface-card h3 {
  margin: 0;
  font-size: 1rem;
}

.count-chip,
.status-chip,
.tiny-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
}

.count-chip,
.tiny-chip {
  background: rgba(47, 36, 29, 0.08);
}

.status-chip.done {
  background: rgba(47, 143, 88, 0.14);
  color: var(--success);
}

.status-chip.current {
  background: rgba(213, 138, 26, 0.16);
  color: var(--warning);
}

.status-chip.inactive {
  background: rgba(61, 115, 201, 0.14);
  color: var(--info);
}

.goal-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.goal-card,
.task-card,
.surface-card {
  padding: 1rem;
}

.goal-card {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.goal-card .delete-corner,
.task-card .delete-corner {
  align-self: flex-end;
}

.task-card {
  display: grid;
  gap: 1rem;
}

.progress-track {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  margin-top: 1rem;
  padding-top: 1.8rem;
}

.progress-track::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 10px;
  height: 4px;
  border-radius: 999px;
  background: rgba(111, 98, 87, 0.16);
}

.step-pill {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.step-dot {
  width: 20px;
  height: 20px;
  margin: 0 auto 0.55rem;
  border-radius: 999px;
  border: 3px solid white;
  box-shadow: 0 0 0 1px rgba(111, 98, 87, 0.18);
}

.step-pill.done .step-dot {
  background: var(--success);
}

.step-pill.current .step-dot {
  background: var(--warning);
}

.step-pill.inactive .step-dot {
  background: var(--info);
}

.step-pill span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.surface-card textarea,
.modal-card textarea,
.modal-card input,
.modal-card select,
.surface-card input,
.surface-card select {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  padding: 0.85rem 0.95rem;
  background: white;
}

.surface-card textarea,
.modal-card textarea {
  min-height: 140px;
  resize: vertical;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
  gap: 1rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.step-row,
.profile-history-row,
.note-history-row {
  padding: 0.85rem 0.95rem;
  display: grid;
  gap: 0.7rem;
}

.step-row header,
.profile-history-row header,
.note-history-row header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.8rem;
}

.step-meta,
.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.history-list {
  display: grid;
  gap: 0.75rem;
}

.empty-state {
  padding: 2rem;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(111, 98, 87, 0.25);
  background: rgba(255, 255, 255, 0.4);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35, 24, 17, 0.54);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 20;
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border-radius: 28px;
  background: #fffaf3;
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 26px 50px rgba(19, 12, 8, 0.24);
  padding: 1.25rem;
}

.modal-card.wide {
  width: min(980px, 100%);
}

.form-grid {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  font-size: 0.9rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--text);
  color: white;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 30;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0.75rem;
  }

  .sidebar,
  .main-panel {
    border-radius: 22px;
    padding: 1rem;
  }

  .topbar,
  .section-heading,
  .page-header,
  .subsection-header,
  .step-row header,
  .profile-history-row header,
  .note-history-row header {
    align-items: stretch;
    flex-direction: column;
  }

  .person-card {
    grid-template-columns: auto 1fr;
  }

  .person-card > .card-actions {
    grid-column: 1 / -1;
  }
}
