/* Reset, type, the app shell and the tab bar. Mobile first (390px). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}
body.sheet-open { overflow: hidden; }
h1, h2, h3, p, ul, blockquote { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.08rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1rem; line-height: 1.3; font-weight: 700; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; touch-action: manipulation; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
svg { display: block; flex-shrink: 0; }
ul.plain { list-style: none; padding: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }

.muted { color: var(--text-2); }
.small { font-size: 0.86rem; }
.center { text-align: center; justify-content: center; }
.block { display: block; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.with-icon { display: flex; align-items: center; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions > .btn { flex: 1 1 auto; }
.ember-text { color: var(--ember-strong); }
.danger-text { color: var(--danger); }

/* ---------- screens ---------- */
#boot, #auth, #onboarding { min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
#onboarding { align-items: flex-start; }
.boot-card { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; max-width: 320px; }
.brand-mark { width: 72px; height: 72px; border-radius: 22px; background: var(--accent-soft); display: grid; place-items: center; font-size: 36px; margin: 0 auto; }
.boot-pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); opacity: 0.85; } }

#shell { min-height: 100dvh; }
#main {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 14px;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 6px 2px 2px; }
.page-head p { margin-top: 2px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); font-weight: 650; color: var(--accent); margin-left: -4px; padding-right: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px 0; min-height: 36px; }
.sub-head { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); font-weight: 700; padding: 4px 2px 0; }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 50px; border-radius: 14px; color: var(--text-3); font-size: 0.72rem; font-weight: 650; }
.tab.on { color: var(--accent); }
.tab-icon { position: relative; display: grid; place-items: center; width: 52px; height: 28px; border-radius: 14px; transition: background 0.18s; }
.tab.on .tab-icon { background: var(--accent-soft); }
.tab .dot { position: absolute; top: 1px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--ember); border: 2px solid var(--paper); }

/* ---------- desktop: the tab bar becomes a side rail ---------- */
@media (min-width: 900px) {
  #tabbar { top: 0; right: auto; bottom: 0; width: 220px; grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; gap: 4px;
    padding: 28px 14px; border-top: 0; border-right: 1px solid var(--line); background: var(--paper); }
  #tabbar::before { content: "🌱  LifeIn"; font-weight: 800; font-size: 1.2rem; padding: 0 10px 18px; letter-spacing: -0.02em; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 0.98rem; padding: 0 10px; min-height: 48px; }
  .tab.on { background: var(--accent-soft); }
  .tab.on .tab-icon { background: none; }
  .tab-icon { width: 28px; }
  .tab .dot { right: -2px; }
  #main { max-width: 720px; padding-left: 244px; padding-right: 24px; padding-top: 32px; padding-bottom: 48px; box-sizing: content-box; }
  .sheet-backdrop { padding-left: 220px; }
}

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