/* ============================================================
   Nest — app styles
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--sage-strong); text-decoration: none; }

/* ---------- desktop: iPhone frame ---------- */
#frame { height: 100%; }

@media (min-width: 760px) {
  body { display: flex; align-items: center; justify-content: center; padding: 28px 0; min-height: 100vh; background:
    radial-gradient(1200px 600px at 20% -10%, var(--surface-2), transparent 60%), var(--bg); }
  #frame {
    width: 390px; height: 844px; max-height: calc(100vh - 56px);
    border-radius: 54px; border: 11px solid #33312e;
    box-shadow: 0 24px 80px rgba(40, 30, 15, 0.35);
    overflow: hidden; position: relative; background: var(--bg);
  }
  #frame::after { /* notch */
    content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 120px; height: 24px; border-radius: 999px; background: #33312e; z-index: 60; pointer-events: none;
  }
  #frame .app { padding-top: 34px; }
}

/* ---------- app shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; overflow: hidden; }

.screen {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px 18px calc(96px + env(safe-area-inset-bottom, 0px));
}
.screen.no-tabs { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
}
#frame { position: relative; }
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-3); font-size: 10.5px; font-weight: 500; padding: 4px 0; border-radius: var(--radius-sm);
}
.tabbar button svg { width: 23px; height: 23px; }
.tabbar button.active { color: var(--sage-strong); }

/* ---------- typography ---------- */
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--text-2); }
.small { font-size: 13.5px; }
.tiny { font-size: 12px; }
.screen-title { margin: 6px 2px 14px; }
.screen-title .sub { color: var(--text-2); font-size: 14.5px; margin-top: 3px; }
.section-label {
  font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); margin: 22px 4px 9px;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.card.flat { box-shadow: none; }
.card .card-title { display: flex; align-items: center; gap: 8px; font-weight: 650; margin-bottom: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px; border-radius: var(--radius-pill);
  font-weight: 600; font-size: 16px; transition: transform 0.06s ease, opacity 0.15s;
  border: 1px solid transparent; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--sage); color: var(--text-on-accent); }
.btn-primary:disabled { opacity: 0.45; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--sage-strong); border-color: var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 9px 15px; font-size: 14px; }
.btn-applepay { background: #000; color: #fff; font-size: 17px; font-weight: 500; letter-spacing: 0.01em; }
html[data-theme="dark"] .btn-applepay { background: #f5f2ec; color: #111; }

.link-btn { color: var(--sage-strong); font-weight: 600; font-size: 14.5px; padding: 10px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2); border: 1px solid transparent;
  transition: all 0.12s ease;
}
.chip.on { background: var(--sage-soft); color: var(--sage-strong); border-color: var(--sage); font-weight: 600; }

/* ---------- segmented ---------- */
.segmented {
  display: flex; background: var(--surface-2); border-radius: var(--radius-pill); padding: 3px; gap: 2px;
}
.segmented button {
  flex: 1; padding: 8px 10px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 550; color: var(--text-2); white-space: nowrap;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 650; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  outline: none; appearance: none; -webkit-appearance: none;
}
.input:focus { border-color: var(--sage); }
textarea.input { resize: none; min-height: 84px; }

/* ---------- home ---------- */
.home-hero { margin: 4px 2px 16px; }
.home-hero .hello { color: var(--text-2); font-size: 15px; }
.home-hero h1 { margin-top: 2px; }

.child-switch { display: flex; gap: 8px; overflow-x: auto; padding: 2px; margin-bottom: 16px; scrollbar-width: none; }
.child-switch::-webkit-scrollbar { display: none; }
.child-pill {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 8px 14px 8px 9px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text-2); font-weight: 550; font-size: 14.5px;
}
.child-pill .avatar { width: 26px; height: 26px; font-size: 13px; }
.child-pill.on { border-color: var(--sage); background: var(--sage-soft); color: var(--sage-strong); font-weight: 650; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--terracotta-soft); color: var(--terracotta);
  font-weight: 700; font-size: 15px; flex: none;
}

.sit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.sit-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left;
  padding: 15px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: transform 0.08s ease;
}
.sit-tile:active { transform: scale(0.965); }
.sit-tile .emoji {
  width: 42px; height: 42px; border-radius: 13px; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
.sit-tile .t { font-weight: 650; font-size: 15px; line-height: 1.25; }
.sit-tile .s { font-size: 12px; color: var(--text-3); line-height: 1.35; }
.tint-sage { background: var(--sage-soft); }
.tint-rose { background: var(--rose-soft); }
.tint-terracotta { background: var(--terracotta-soft); }
.tint-lavender { background: var(--lavender-soft); }
.tint-sand { background: var(--sand-soft); }

/* ---------- situation screen ---------- */
.sit-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sit-header .emoji { width: 52px; height: 52px; border-radius: 16px; font-size: 27px; display: flex; align-items: center; justify-content: center; flex: none; }
.sit-header h1 { font-size: 21px; }
.sit-header .for-child { color: var(--text-2); font-size: 13.5px; }

.timerbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; }
.timerbar .elapsed { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.timerbar .est { text-align: right; font-size: 12.5px; color: var(--text-2); line-height: 1.4; }
.timerbar .est b { color: var(--text); }
.est-track { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 0 16px 12px; }
.est-fill { height: 100%; border-radius: 999px; background: var(--sage); transition: width 1s linear; }

.pilltabs { display: flex; gap: 7px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; position: sticky; top: -18px; background: var(--bg); z-index: 5; }
.pilltabs::-webkit-scrollbar { display: none; }
.pilltabs button {
  white-space: nowrap; padding: 8px 14px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-2); font-size: 13.5px; font-weight: 600;
}
.pilltabs button.on { background: var(--text); color: var(--bg); }

.guide-item { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.guide-item:last-child { border-bottom: none; }
.guide-item .mark { flex: none; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; margin-top: 1px; }
.guide-item .mark.do { background: var(--sage-soft); color: var(--sage-strong); }
.guide-item .mark.dont { background: var(--danger-soft); color: var(--danger); }
.guide-item .mark.info { background: var(--lavender-soft); color: var(--lavender); }
.guide-item .body { flex: 1; font-size: 15px; }
.guide-item .say {
  margin-top: 6px; padding: 9px 12px; border-radius: 12px; border-left: 3px solid var(--sage);
  background: var(--sage-soft); font-style: italic; font-size: 14.5px; color: var(--text);
}
.guide-item .why { margin-top: 4px; font-size: 13.5px; color: var(--text-2); }

.feelings-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.feeling-tag { padding: 6px 12px; border-radius: 999px; background: var(--lavender-soft); color: var(--lavender); font-size: 13px; font-weight: 600; }

.breath { display: flex; flex-direction: column; align-items: center; padding: 18px 0 10px; }
.breath .circle {
  width: 92px; height: 92px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--sage-soft), var(--sage));
  animation: breathe 10s ease-in-out infinite; opacity: 0.9;
}
.breath .cap { margin-top: 12px; font-size: 13.5px; color: var(--text-2); }
@keyframes breathe {
  0% { transform: scale(0.72); } 40% { transform: scale(1); }
  50% { transform: scale(1); } 100% { transform: scale(0.72); }
}

.settle-dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, var(--bg) 34%);
  display: flex; gap: 10px;
}

/* ---------- feedback ---------- */
.rate-row { display: flex; justify-content: space-between; gap: 8px; margin: 10px 0 4px; }
.rate {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 12px 4px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1.5px solid transparent; font-size: 24px;
}
.rate small { font-size: 10.5px; color: var(--text-3); font-weight: 600; }
.rate.on { border-color: var(--sage); background: var(--sage-soft); }
.rate.on small { color: var(--sage-strong); }

/* ---------- journal ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h2 { font-size: 17px; }
.cal-head button { padding: 8px 12px; color: var(--text-2); font-size: 18px; border-radius: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-grid .dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-3); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 11px; font-size: 13.5px; color: var(--text-2); position: relative; gap: 2px;
}
.cal-day.out { opacity: 0.28; }
.cal-day.today { background: var(--surface-2); font-weight: 700; color: var(--text); }
.cal-day.sel { background: var(--sage); color: var(--text-on-accent); font-weight: 700; }
.cal-day .dots { display: flex; gap: 2.5px; height: 5px; }
.cal-day .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--terracotta); }
.cal-day.sel .dots i { background: var(--text-on-accent); }

.event-row { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--border); width: 100%; text-align: left; }
.event-row:last-child { border-bottom: none; }
.event-row .emoji { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; display: flex; align-items: center; justify-content: center; flex: none; }
.event-row .mid { flex: 1; min-width: 0; }
.event-row .t { font-weight: 600; font-size: 15px; }
.event-row .s { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-row .right { text-align: right; font-size: 12px; color: var(--text-3); flex: none; }

/* ---------- trends ---------- */
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 12px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat-tile .v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat-tile .l { font-size: 12.5px; color: var(--text-2); margin-top: 1px; line-height: 1.3; }
.stat-tile .d { font-size: 11.5px; margin-top: 5px; font-weight: 600; }
.stat-tile .d.up { color: var(--danger); }
.stat-tile .d.down { color: var(--sage-strong); }
.stat-tile .d.flat { color: var(--text-3); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.legend i { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- learn ---------- */
.article-card { display: flex; gap: 13px; align-items: flex-start; width: 100%; text-align: left; }
.article-card .emoji { width: 46px; height: 46px; border-radius: 14px; font-size: 23px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--surface-2); }
.article-card .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); margin-top: 5px; }
.article-card .tag { padding: 2.5px 9px; border-radius: 999px; background: var(--lavender-soft); color: var(--lavender); font-weight: 600; }
.article-card .read-dot { color: var(--sage-strong); font-weight: 600; }

.reader h1 { font-size: 23px; margin: 10px 0 6px; line-height: 1.25; }
.reader .lede { color: var(--text-2); font-size: 15.5px; font-style: italic; margin-bottom: 16px; }
.reader .prose h2 { font-size: 17.5px; margin: 22px 0 8px; }
.reader .prose p { margin: 0 0 12px; font-size: 15.5px; line-height: 1.65; }
.reader .prose li { margin: 0 0 8px 20px; font-size: 15.5px; line-height: 1.6; }
.reader .prose ul, .reader .prose ol { margin-bottom: 12px; }

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 2px; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-row .mid { flex: 1; }
.set-row .t { display: block; font-weight: 550; font-size: 15.5px; }
.set-row .s { display: block; font-size: 12.5px; color: var(--text-2); }
.set-row .chev { color: var(--text-3); font-size: 17px; }

/* ---------- paywall ---------- */
.plan {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 15px 16px; border-radius: var(--radius); margin-bottom: 10px;
  background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow);
}
.plan.on { border-color: var(--sage); background: var(--sage-soft); }
.plan .radio { width: 21px; height: 21px; border-radius: 50%; border: 2px solid var(--text-3); flex: none; }
.plan.on .radio { border-color: var(--sage-strong); background: radial-gradient(circle, var(--sage-strong) 45%, transparent 50%); }
.plan .mid { flex: 1; }
.plan .t { font-weight: 700; font-size: 15.5px; }
.plan .s { font-size: 12.5px; color: var(--text-2); }
.plan .price { text-align: right; }
.plan .price b { font-size: 16px; }
.plan .price span { display: block; font-size: 11.5px; color: var(--text-2); }
.plan .badge-pop {
  position: absolute; top: -9px; right: 14px; padding: 3px 11px; border-radius: 999px;
  background: var(--gold); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
}
html[data-theme="dark"] .plan .badge-pop { color: #211d17; }

/* ---------- onboarding ---------- */
.ob-dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0 4px; }
.ob-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); }
.ob-dots i.on { background: var(--sage); width: 20px; border-radius: 999px; }
.ob-hero { text-align: center; padding: 34px 10px 20px; }
.ob-hero .logo { font-size: 56px; }
.ob-hero h1 { margin-top: 14px; }
.ob-hero p { color: var(--text-2); margin-top: 8px; font-size: 15.5px; }

/* ---------- badges, misc ---------- */
.draft-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  background: var(--sand-soft); color: var(--sand); border: 1px dashed var(--sand);
}
.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 13px; line-height: 1.5; }

.empty { text-align: center; padding: 38px 20px; color: var(--text-3); }
.empty .e { font-size: 38px; margin-bottom: 10px; }
.empty p { font-size: 14.5px; }

.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 36px; }
.topbar .back { display: inline-flex; align-items: center; gap: 3px; color: var(--sage-strong); font-weight: 600; font-size: 15.5px; padding: 6px 8px 6px 0; }
.topbar .title { flex: 1; text-align: center; font-weight: 650; font-size: 16px; }
.topbar .spacer { width: 64px; }

/* bottom sheet modal */
.sheet-wrap { position: absolute; inset: 0; z-index: 100; display: flex; align-items: flex-end; background: var(--overlay); animation: fadein 0.18s ease; }
.sheet {
  width: 100%; max-height: 86%; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lg); animation: sheetup 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet .grab { width: 40px; height: 4.5px; border-radius: 999px; background: var(--surface-3); margin: 4px auto 14px; }
@keyframes sheetup { from { transform: translateY(60px); opacity: 0.5; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 200; box-shadow: var(--shadow-lg);
  animation: fadein 0.2s ease; white-space: nowrap; max-width: 88%; overflow: hidden; text-overflow: ellipsis;
}

.divider { height: 1px; background: var(--border); margin: 14px 0; }

.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.center { text-align: center; }

/* chart svg */
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg text { font-family: var(--font); }
