:root {
  --bg: #f7f4ec;
  --surface: #fffdf8;
  --surface-2: #f1eee5;
  --text: #24332c;
  --muted: #78827b;
  --green: #668c72;
  --green-dark: #456951;
  --green-light: #dfeadd;
  --yellow: #e9c96b;
  --border: #e2ded3;
  --danger: #b85c5c;
  --shadow: 0 12px 35px rgba(50,60,50,.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  transition: background .3s, color .3s;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  margin: auto;
  min-height: 100vh;
  padding-bottom: 90px;
}

.topbar {
  height: 70px;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(15px);
}

.brand {
  border: 0;
  background: transparent;
  font-size: 25px;
  font-weight: 700;
  color: var(--text);
}

.brand-mark {
  color: var(--green);
}

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

.icon-button {
  border: 0;
  background: var(--surface);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.screen {
  display: none;
  padding: 30px 20px;
  animation: fade .25s ease;
}

.screen.active {
  display: block;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-family: Fraunces, serif;
  font-size: clamp(38px, 8vw, 58px);
  line-height: 1.03;
  margin-bottom: 18px;
  letter-spacing: -1px;
}

h2 {
  font-size: 23px;
}

h3 {
  margin-bottom: 5px;
}

.intro {
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

.label {
  font-weight: 700;
}

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

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 14px;
  padding: 14px 19px;
  font-weight: 700;
  transition: transform .15s, opacity .15s;
}

.primary-button {
  color: white;
  background: var(--green-dark);
}

.secondary-button {
  color: var(--text);
  background: var(--surface-2);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.full-button {
  width: 100%;
  margin-top: 15px;
}

.text-link,
.small-link,
.danger-link,
.quiet-button {
  border: 0;
  background: transparent;
  color: var(--green-dark);
  font-weight: 700;
}

.text-link {
  display: block;
  margin: 28px auto;
}

.back-button {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  margin-bottom: 35px;
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 28px;
}

.mood-card {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 25px 10px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  box-shadow: var(--shadow);
  transition: .2s;
}

.mood-card:hover {
  transform: translateY(-3px);
  border-color: var(--green);
}

.mood-face {
  font-size: 28px;
  color: var(--green);
}

.tag-section {
  margin-top: 30px;
}

.tag-grid,
.goal-tools,
.theme-grid,
.exercise-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.exercise,
.theme-choice {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 13px;
  border-radius: 99px;
}

.tag.active,
.exercise.active,
.theme-choice.active {
  background: var(--green-dark);
  color: white;
  border-color: var(--green-dark);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  padding: 15px;
  outline: none;
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
}

.reflection-footer,
.journal-actions,
.focus-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.home-greeting {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.streak-pill {
  background: var(--surface);
  border-radius: 99px;
  padding: 10px 15px;
  box-shadow: var(--shadow);
}

.today-card,
.wellbeing-card,
.nudge-card,
.timeline-preview,
.insight-card,
.settings-card,
.privacy-card,
.sleep-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}

.today-card {
  position: relative;
  overflow: hidden;
  min-height: 170px;
}

.card-orb {
  position: absolute;
  width: 150px;
  height: 150px;
  right: -40px;
  top: -45px;
  border-radius: 50%;
  background: var(--green-light);
}

.today-card > * {
  position: relative;
}

.today-card h2 {
  margin-bottom: 7px;
}

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

.home-section-title {
  margin-top: 32px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
}

.quick-card,
.game-card {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 18px;
  padding: 18px;
  text-align: left;
  box-shadow: var(--shadow);
}

.quick-card span,
.game-card {
  font-size: 25px;
}

.quick-card strong,
.quick-card small,
.game-card strong,
.game-card small {
  display: block;
}

.quick-card strong,
.game-card strong {
  font-size: 16px;
  margin-top: 8px;
}

.quick-card small,
.game-card small {
  margin-top: 3px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.section-heading h2 {
  margin: 0;
}

.progress-row {
  display: grid;
  grid-template-columns: 80px 1fr 45px;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.progress {
  height: 9px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: inherit;
  transition: width .4s;
}

.nudge-card {
  display: flex;
  gap: 15px;
}

.nudge-icon {
  font-size: 28px;
  color: var(--green);
}

.support-button {
  width: 100%;
  border: 1px solid #e0b7b7;
  background: #fff4f2;
  color: #8e4949;
  padding: 16px;
  border-radius: 15px;
  font-weight: 700;
  margin-top: 15px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

.chat-header h1 {
  font-size: 37px;
}

.private-badge {
  background: var(--green-light);
  color: var(--green-dark);
  padding: 8px 11px;
  height: fit-content;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.chat-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin: 15px 0;
}

.buddy-selector {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.personality {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 99px;
  padding: 9px 13px;
}

.personality.active {
  background: var(--green-dark);
  color: white;
}

.chat-messages {
  min-height: 360px;
  max-height: 520px;
  overflow-y: auto;
  padding: 15px 3px;
}

.message {
  width: fit-content;
  max-width: 85%;
  padding: 12px 15px;
  border-radius: 18px;
  margin: 8px 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.bot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.message.user {
  margin-left: auto;
  background: var(--green-dark);
  color: white;
  border-bottom-right-radius: 5px;
}

.chat-suggestions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.chat-suggestions button {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 99px;
  padding: 8px 11px;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 7px;
  margin-top: 8px;
}

.chat-compose button {
  border: 0;
  background: var(--green-dark);
  color: white;
  width: 48px;
  border-radius: 14px;
}

.chat-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 12px;
}

.chat-actions button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.chat-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.search-input {
  margin-bottom: 12px;
}

.journal-entry,
.history-item,
.memory-item,
.timeline-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  margin: 10px 0;
}

.entry-actions,
.memory-actions {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}

.entry-actions button,
.memory-actions button {
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 10px;
}

.breathing-circle,
.focus-circle {
  width: 240px;
  height: 240px;
  margin: 35px auto 15px;
  border-radius: 50%;
  background: var(--green-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--green-dark);
  transition: transform 1s ease, background .5s;
}

.breathing-circle.breathe-in {
  transform: scale(1.18);
}

.breathing-circle.breathe-out {
  transform: scale(.9);
}

.timer-text {
  text-align: center;
  color: var(--muted);
}

.calm-tips {
  display: grid;
  gap: 8px;
  margin-top: 25px;
}

.calm-tips div {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 13px;
  border-radius: 13px;
}

.grounding-step {
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 45px 20px;
  box-shadow: var(--shadow);
  margin: 30px 0;
}

.grounding-step span {
  display: block;
  font-size: 70px;
  font-family: Fraunces, serif;
  color: var(--green);
}

.goal-input {
  display: grid;
  grid-template-columns: 1fr 50px;
  gap: 8px;
  margin-bottom: 15px;
}

.goal-input button {
  border: 0;
  border-radius: 15px;
  background: var(--green-dark);
  color: white;
  font-size: 25px;
}

.goal-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  margin: 9px 0;
}

.goal-main {
  display: flex;
  gap: 12px;
  align-items: center;
}

.goal-main input {
  width: auto;
}

.goal-item.completed strong {
  text-decoration: line-through;
  color: var(--muted);
}

.goal-progress {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  margin-top: 12px;
}

.goal-progress span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.sleep-form {
  display: grid;
  gap: 12px;
}

.sleep-form label,
.settings-card label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  margin: 10px 0;
}

.focus-circle {
  width: 250px;
  height: 250px;
  background: var(--green-light);
}

.focus-circle strong {
  font-size: 45px;
  font-family: Fraunces, serif;
}

.focus-circle span {
  color: var(--muted);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.game-result {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: 18px;
  margin-top: 15px;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
}

.stat-card strong {
  display: block;
  font-size: 30px;
  color: var(--green-dark);
}

.stat-card span {
  color: var(--muted);
}

.mood-calendar {
  display: grid;
  grid-template-columns: repeat(7,1fr);
  gap: 6px;
  margin: 15px 0 30px;
}

.calendar-day {
  aspect-ratio: 1;
  border-radius: 9px;
  background: var(--surface-2);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
}

.calendar-day.great { background: #a7d9ad; }
.calendar-day.good { background: #c8e2a2; }
.calendar-day.okay { background: #e8df9e; }
.calendar-day.low { background: #c7d5df; }
.calendar-day.anxious { background: #d6c7e5; }
.calendar-day.rough { background: #e5b7b7; }

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.history-icon {
  font-size: 25px;
  color: var(--green);
}

.history-item small {
  display: block;
  margin-top: 4px;
}

.timeline-item {
  position: relative;
}

.timeline-date {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.timeline-icon {
  font-size: 25px;
  margin-right: 5px;
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 10px;
}

.achievement {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  padding: 18px;
  opacity: .45;
}

.achievement.unlocked {
  opacity: 1;
  border-color: var(--green);
}

.achievement-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.achievement strong,
.achievement small {
  display: block;
}

.switch {
  display: flex !important;
  position: relative;
  width: 48px;
  height: 28px;
  margin: 0 !important;
}

.switch input {
  display: none;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #ccc;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.privacy-card {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: auto 1fr !important;
  flex-direction: row;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.import-button {
  display: block;
  text-align: center;
  cursor: pointer;
}

.import-button input {
  display: none;
}

.danger-link {
  color: var(--danger);
  display: block;
  margin: 25px auto;
}

.emergency-screen {
  background: #342b2b;
  color: #fff;
  min-height: calc(100vh - 70px);
}

.emergency-screen .eyebrow {
  color: #e9b4a9;
}

.emergency-screen .back-button {
  color: white;
}

.emergency-icon {
  font-size: 50px;
  color: #efb7ad;
}

.support-copy,
.support-footnote {
  color: #d9caca;
  line-height: 1.7;
}

.support-action {
  display: flex;
  justify-content: space-between;
  padding: 17px;
  background: #f1d5d0;
  color: #392b2b;
  text-decoration: none;
  border-radius: 15px;
  margin: 10px 0;
  font-weight: 700;
}

.support-action.secondary {
  background: #4a3e3e;
  color: white;
}

.bottom-nav {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 600px);
  display: grid;
  grid-template-columns: repeat(4,1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 7px;
  box-shadow: 0 15px 45px rgba(0,0,0,.12);
  z-index: 50;
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  font-size: 11px;
}

.nav-item span {
  font-size: 19px;
}

.nav-item.active {
  background: var(--green-light);
  color: var(--green-dark);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%,20px);
  opacity: 0;
  background: #26342c;
  color: white;
  padding: 12px 18px;
  border-radius: 99px;
  z-index: 100;
  pointer-events: none;
  transition: .25s;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%,0);
}

body.dark {
  --bg: #18211d;
  --surface: #202b25;
  --surface-2: #29352e;
  --text: #edf4ee;
  --muted: #a9b5ad;
  --green: #91bb9b;
  --green-dark: #6f9f7b;
  --green-light: #304638;
  --border: #35443b;
}

body.sage {
  --bg: #edf3ec;
  --surface: #fbfdf9;
  --surface-2: #dfe9df;
  --green: #668c72;
  --green-dark: #456951;
}

body.large {
  font-size: 18px;
}

body.xl {
  font-size: 20px;
}

@media (max-width: 480px) {

  .mood-grid {
    grid-template-columns: repeat(2,1fr);
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .chat-header {
    display: block;
  }

  .private-badge {
    display: inline-block;
    margin-top: 5px;
  }

  .reflection-footer,
  .journal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .reflection-footer .primary-button {
    width: 100%;
  }

  h1 {
    font-size: 42px;
  }
}