:root {
  --bg: #f7faf7;
  --surface: #ffffff;
  --surface-soft: #eef6f2;
  --mint: #dcefe7;
  --mint-strong: #a9d1c1;
  --blue-soft: #e7f1f5;
  --sage: #426d60;
  --sage-dark: #284a40;
  --ink: #25342f;
  --muted: #596a64;
  --line: #dfe8e3;
  --warm: #fff7ed;
  --danger: #a04f4f;
  --shadow: 0 14px 45px rgba(43, 77, 66, .08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --max: 980px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(66, 109, 96, .28); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; padding-bottom: 104px; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; height: 74px; padding: 0 max(22px, calc((100vw - var(--max)) / 2)); background: rgba(247, 250, 247, .9); border-bottom: 1px solid rgba(223, 232, 227, .75); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--sage-dark); font-family: ui-rounded, 'Avenir Next', Inter, ui-sans-serif, sans-serif; font-size: 18px; font-weight: 600; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50% 50% 48% 52%; background: var(--mint); font-family: Georgia, serif; font-size: 19px; font-style: italic; }
.privacy-button { display: flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 8px; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.privacy-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }

main { width: min(var(--max), calc(100% - 36px)); margin: 0 auto; }
.view { display: none; padding: 52px 0 26px; animation: fade-in .3s ease both; }
.view.active { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(5px); } }

.welcome-row { display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: center; margin: 10px 0 38px; }
.eyebrow, .step-label { margin: 0 0 9px; color: var(--sage); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; }
h1, h2 { font-family: ui-rounded, 'Avenir Next', Inter, ui-sans-serif, sans-serif; letter-spacing: -.035em; }
h1 { max-width: 720px; margin: 0; font-size: clamp(34px, 7vw, 58px); line-height: 1.04; font-weight: 500; text-wrap: balance; }
h2 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 500; }
.intro { max-width: 620px; margin: 15px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; text-wrap: pretty; }
.day-orb { display: grid; place-items: center; width: 120px; height: 120px; border-radius: 46% 54% 57% 43% / 47% 44% 56% 53%; background: var(--mint); transform: rotate(-7deg); }
.day-orb span { display: block; width: 52px; height: 26px; border: 3px solid var(--sage); border-top: 0; border-left-color: transparent; border-right-color: transparent; border-radius: 0 0 50% 50%; opacity: .75; transform: rotate(7deg); }

.panel { margin-bottom: 22px; padding: clamp(24px, 5vw, 40px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.selection-label { padding: 7px 11px; color: var(--muted); background: var(--surface-soft); border-radius: 99px; font-size: 12px; white-space: nowrap; }

.mood-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 28px 0 30px; }
.mood { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 112px; padding: 12px 5px; color: var(--muted); background: #fbfdfc; border: 1px solid var(--line); border-radius: var(--radius-md); cursor: pointer; transition: border-color .2s, background .2s, transform .2s, box-shadow .2s; }
.mood:hover { transform: translateY(-2px); border-color: var(--mint-strong); }
.mood[aria-checked="true"] { color: var(--sage-dark); background: var(--mint); border-color: var(--sage); box-shadow: 0 8px 20px rgba(66,109,96,.12); }
.mood-face { display: block; width: 54px; height: 54px; filter: saturate(.9) drop-shadow(0 3px 5px rgba(101,79,50,.12)); transform: scale(1); transition: transform .2s ease; }
.mood[aria-checked="true"] .mood-face { transform: scale(1.12); }
.mood > span:last-child { font-size: 12px; font-weight: 500; }
.feelings-field { padding: 24px 0 0; border-top: 1px solid var(--line); }
.feelings-field label { display: block; color: var(--ink); font-size: 14px; font-weight: 600; }
.feelings-field p { margin: 5px 0 12px; color: var(--muted); font-size: 13px; }
.feelings-field input { width: 100%; min-height: 48px; padding: 11px 15px; color: var(--ink); background: #fcfdfc; border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color .2s, box-shadow .2s; }
.feelings-field input:focus { border-color: var(--mint-strong); outline: 0; box-shadow: 0 0 0 4px rgba(169,209,193,.2); }
.feelings-field input::placeholder { color: #71817b; }

.prompt-box { position: relative; margin: 25px 0 16px; padding: 18px 22px 18px 52px; background: var(--warm); border-radius: var(--radius-md); }
.prompt-box p { margin: 0; color: #65584a; font-size: 15px; line-height: 1.55; }
.prompt-mark { position: absolute; top: 9px; left: 18px; color: #c39b6b; font-family: Georgia, serif; font-size: 42px; }
.quiet-link, .danger-link { min-height: 44px; padding: 4px 6px; color: var(--sage); background: transparent; border: 0; font-weight: 600; cursor: pointer; }
.danger-link { color: var(--danger); }
textarea { width: 100%; min-height: 230px; padding: 19px; resize: vertical; color: var(--ink); background: #fcfdfc; border: 1px solid var(--line); border-radius: var(--radius-md); line-height: 1.65; transition: border-color .2s, box-shadow .2s; }
textarea:focus { border-color: var(--mint-strong); outline: 0; box-shadow: 0 0 0 4px rgba(169,209,193,.2); }
textarea::placeholder { color: #71817b; }
.journal-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 15px; }
.autosave-note { color: var(--muted); font-size: 12px; }
.primary-button, .secondary-button { min-height: 46px; padding: 11px 20px; border-radius: 99px; font-weight: 600; cursor: pointer; transition: transform .2s, box-shadow .2s, background .2s; }
.primary-button { color: white; background: var(--sage); border: 1px solid var(--sage); box-shadow: 0 8px 18px rgba(66,109,96,.18); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.primary-button:hover { background: var(--sage-dark); box-shadow: 0 10px 22px rgba(66,109,96,.24); }
.secondary-button { color: var(--sage-dark); background: transparent; border: 1px solid var(--mint-strong); }
.gentle-note { display: flex; align-items: flex-start; gap: 13px; margin: 20px 6px; color: var(--muted); }
.gentle-note span { color: var(--sage); font-size: 18px; }
.gentle-note p { margin: 0; line-height: 1.55; }
.gentle-note strong { color: var(--ink); }

.page-heading { margin-bottom: 34px; }
.history-tools { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.search-field { flex: 1; }
.search-field input { width: 100%; height: 48px; padding: 0 17px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 99px; }
.entry-list { display: grid; gap: 13px; }
.entry-card { display: grid; grid-template-columns: 64px 1fr auto; gap: 18px; align-items: center; width: 100%; padding: 20px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); cursor: pointer; transition: .2s ease; }
.entry-card:hover { transform: translateY(-2px); border-color: var(--mint-strong); box-shadow: var(--shadow); }
.entry-mood { display: grid; place-items: center; width: 56px; height: 56px; color: var(--sage-dark); background: var(--mint); border-radius: 50%; font-family: Georgia, serif; font-size: 27px; }
.entry-card h2 { margin: 0 0 5px; font-size: 16px; }
.entry-card p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: 14px; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.entry-arrow { color: var(--sage); font-size: 20px; }
.empty-state { padding: 55px 24px; text-align: center; background: var(--surface); border: 1px dashed var(--mint-strong); border-radius: var(--radius-lg); }
.empty-state span { display: block; margin-bottom: 12px; color: var(--sage); font-family: Georgia, serif; font-size: 42px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { max-width: 420px; margin: 0 auto 18px; color: var(--muted); line-height: 1.6; }

.breathing-card { display: grid; grid-template-columns: 1fr 320px; gap: 44px; align-items: center; overflow: hidden; background: linear-gradient(120deg, white 0 56%, var(--surface-soft) 56%); }
.breathing-copy > p:not(.step-label) { max-width: 520px; color: var(--muted); line-height: 1.65; }
.breathing-controls, .prompt-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.breath-visual { display: grid; place-items: center; min-height: 300px; }
.breath-circle { display: grid; place-items: center; align-content: center; width: 220px; height: 220px; color: var(--sage-dark); background: rgba(169,209,193,.38); border: 1px solid rgba(66,109,96,.16); border-radius: 50%; box-shadow: 0 0 0 22px rgba(220,239,231,.58), 0 0 0 43px rgba(220,239,231,.22); transition: transform 4s ease-in-out, background 1s ease; }
.breath-circle.inhale { transform: scale(1.16); background: rgba(169,209,193,.65); }
.breath-circle.exhale { transform: scale(.9); transition-duration: 6s; }
.breath-circle span { font-family: ui-rounded, 'Avenir Next', Inter, ui-sans-serif, sans-serif; font-size: 22px; }
.breath-circle small { margin-top: 6px; color: var(--muted); font-size: 14px; }
.grounding-panel h2 { margin-bottom: 10px; }
.panel-intro { margin: 0 0 25px; color: var(--muted); line-height: 1.6; }
.grounding-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 12px; }
.grounding-list button { position: relative; min-height: 132px; padding: 14px; color: var(--muted); background: #fbfdfc; border: 1px solid var(--line); border-radius: var(--radius-md); cursor: pointer; }
.grounding-list button > span { display: block; margin-bottom: 8px; color: var(--sage); font-family: ui-rounded, 'Avenir Next', Inter, ui-sans-serif, sans-serif; font-size: 31px; }
.grounding-list button b { position: absolute; top: 9px; right: 10px; display: none; width: 22px; height: 22px; color: white; background: var(--sage); border-radius: 50%; font-size: 13px; line-height: 22px; }
.grounding-list button.done { color: var(--sage-dark); background: var(--mint); border-color: var(--mint-strong); }
.grounding-list button.done b { display: block; }

.prompt-feature { background: var(--blue-soft); border-color: #d7e5eb; box-shadow: none; }
.large-prompt { max-width: 770px; margin: 10px 0 0; font-family: ui-rounded, 'Avenir Next', Inter, ui-sans-serif, sans-serif; font-size: clamp(25px, 5vw, 40px); line-height: 1.25; letter-spacing: -.035em; }
.tip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.tip-card { min-height: 220px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.tip-card:nth-child(3n+2) { background: var(--surface-soft); }
.tip-card:nth-child(3n) { background: var(--warm); }
.tip-number { display: block; margin-bottom: 34px; color: var(--sage); font-size: 12px; font-weight: 600; letter-spacing: .1em; }
.tip-card h2 { margin-bottom: 10px; font-size: 21px; }
.tip-card p { margin: 0; color: var(--muted); line-height: 1.62; }
.support-note { margin-top: 24px; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.support-note h2 { margin-bottom: 8px; font-size: 18px; }
.support-note p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }

.bottom-nav { position: fixed; z-index: 30; bottom: 18px; left: 50%; display: flex; align-items: stretch; justify-content: space-around; width: min(520px, calc(100% - 28px)); padding: 8px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 14px 45px rgba(36,65,55,.16); backdrop-filter: blur(18px); transform: translateX(-50%); }
.bottom-nav a { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; color: var(--muted); border-radius: 15px; font-size: 11px; font-weight: 500; text-decoration: none; }
.bottom-nav a.active { color: var(--sage-dark); background: var(--mint); }
.nav-icon { height: 23px; font-size: 21px; line-height: 23px; }

dialog { width: min(520px, calc(100% - 32px)); padding: 34px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 25px 80px rgba(28,50,43,.25); }
dialog::backdrop { background: rgba(36,52,47,.38); backdrop-filter: blur(4px); }
dialog h2 { margin-bottom: 15px; font-size: 28px; }
dialog p { color: var(--muted); line-height: 1.65; }
.dialog-close { position: absolute; top: 14px; right: 16px; display: grid; place-items: center; width: 44px; height: 44px; color: var(--muted); background: transparent; border: 0; font-size: 28px; cursor: pointer; }
.dialog-feelings { display: flex; flex-wrap: wrap; gap: 7px; }
.dialog-feelings span { padding: 6px 10px; color: var(--sage-dark); background: var(--mint); border-radius: 99px; font-size: 12px; }
.entry-full-text { white-space: pre-wrap; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 100px; max-width: calc(100% - 32px); padding: 12px 18px; color: white; background: var(--sage-dark); border-radius: 99px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .app-shell { padding-bottom: 96px; }
  .topbar { height: 66px; padding-inline: 18px; }
  main { width: min(100% - 28px, var(--max)); }
  .view { padding-top: 35px; }
  .welcome-row { grid-template-columns: 1fr; margin-top: 0; }
  .day-orb { display: none; }
  .panel { padding: 24px 18px; border-radius: 23px; }
  .mood-picker { grid-template-columns: repeat(5, minmax(58px, 1fr)); gap: 6px; margin-inline: -4px; overflow-x: auto; }
  .mood { min-width: 60px; min-height: 99px; }
  .mood-face { width: 42px; height: 42px; font-size: 32px; }
  .mood > span:last-child { font-size: 10px; }
  .journal-footer { align-items: stretch; flex-direction: column; }
  .journal-footer .primary-button { width: 100%; }
  .breathing-card { grid-template-columns: 1fr; gap: 16px; background: white; }
  .breath-visual { min-height: 275px; background: var(--surface-soft); border-radius: 20px; }
  .grounding-list { grid-template-columns: 1fr; }
  .grounding-list button { display: flex; align-items: center; min-height: 68px; text-align: left; }
  .grounding-list button > span { width: 42px; margin: 0; }
  .tip-grid { grid-template-columns: 1fr; }
  .tip-card { min-height: 0; }
  .tip-number { margin-bottom: 22px; }
  .history-tools { align-items: stretch; flex-direction: column; }
  .entry-card { grid-template-columns: 54px 1fr auto; gap: 12px; padding: 15px; }
  .entry-mood { width: 50px; height: 50px; }
  .selection-label { display: none; }
  dialog { padding: 30px 23px; }
}

@media (max-width: 430px) {
  .brand { font-size: 17px; }
  .privacy-button { font-size: 12px; }
  h1 { font-size: 37px; }
  .intro { font-size: 15px; }
  .bottom-nav { bottom: max(10px, env(safe-area-inset-bottom)); }
  .bottom-nav a { font-size: 10px; }
}

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