/* LifeOS — warm dark design system (matches the canvas mockups) */
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url('/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url('/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url('/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url('/fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-weight: 600; font-display: swap; src: url('/fonts/sora-600.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-weight: 700; font-display: swap; src: url('/fonts/sora-700.woff2') format('woff2'); }

:root {
  --bg: #16100C; --s1: #211913; --s2: #2B2119; --tab: #1C150F;
  --line: #3A2E25; --border: #2E241C; --edge: #4A3A2D;
  --t1: #F7F0E6; --t2: #CDBBA5; --t3: #A8957F;
  --green: #5BC89A; --blue: #6FA8F5; --orange: #EE9A62; --purple: #A98BF5; --amber: #F2B85B; --red: #F07B6B;
  --ink: #1B120C;
  --display: 'Sora', 'Inter', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--t1); font-family: var(--body); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--orange); text-decoration: none; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 8px; }
input::placeholder, textarea::placeholder { color: var(--t3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; position: relative; }
.screen { padding: 0 20px calc(120px + var(--safe-b)); }
.screen.sub { padding-bottom: calc(120px + var(--safe-b)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--t3); }
.soft { color: var(--t2); }
.small { font-size: 12px; }
.num { font-family: var(--display); font-weight: 700; letter-spacing: -0.3px; }
.tabular { font-variant-numeric: tabular-nums; }

/* header */
.hdr { padding: calc(env(safe-area-inset-top, 0px) + 28px) 0 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--t3); text-transform: uppercase; letter-spacing: 0.8px; }
.h1 { margin: 4px 0 0; font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.15; }
.subhdr { padding: calc(env(safe-area-inset-top, 0px) + 28px) 0 12px; display: flex; align-items: center; gap: 12px; }
.subhdr .h1 { font-size: 24px; margin: 0; }

/* cards */
.card { background: var(--s1); border: 1px solid var(--border); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.card.raised { background: var(--s2); border-color: var(--edge); }
.inner { background: var(--s2); border-radius: 16px; padding: 14px; }
.sec { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sec h2 { margin: 0; font-size: 16px; font-weight: 600; }
.link-btn { min-height: 44px; margin: -12px -8px; padding: 0 8px; background: none; border: none; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--accent, var(--orange)); }
.divider { height: 1px; background: var(--border); }

/* buttons */
.btn { min-height: 48px; padding: 0 18px; border-radius: 14px; border: none; cursor: pointer; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent, var(--orange)); color: var(--ink); }
.btn.ghost { background: transparent; border: 1px solid var(--edge); color: var(--t2); }
.btn.soft { background: var(--s2); color: var(--t1); border: 1px solid var(--border); }
.btn.danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--s2); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; padding: 0; color: var(--t1); }
.icon-btn.filled { background: var(--accent, var(--orange)); border: none; color: var(--ink); }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; background: transparent; border: 1px solid var(--edge); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--t2); }
.chip[aria-pressed="true"] { background: var(--accent, var(--orange)); border-color: transparent; color: var(--ink); font-weight: 600; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--s1); border: 1px solid var(--border); border-radius: 16px; }
.seg button { flex: 1; min-height: 40px; border-radius: 12px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; background: transparent; color: var(--t2); }
.seg button[aria-pressed="true"] { background: var(--t1); color: var(--ink); }

/* pills, tiles, bars */
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.tile { width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 6px; }
.bars { display: flex; align-items: flex-end; gap: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.bars .b { width: 100%; max-width: 28px; border-radius: 6px; min-height: 4px; }
.bars .lab { font-size: 11px; color: var(--t3); font-weight: 500; }
.bars .lab.on { color: var(--t1); font-weight: 600; }
.ring-wrap { position: relative; flex-shrink: 0; }
.ring-wrap .mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--s2); border-radius: 14px; }
.item .title { font-size: 14px; font-weight: 600; }
.item .sub { font-size: 12px; color: var(--t3); margin-top: 2px; }
.dashed { border: 1.5px dashed var(--edge); background: transparent; }
.empty { padding: 18px; border: 1.5px dashed var(--edge); border-radius: 16px; text-align: center; color: var(--t3); font-size: 14px; line-height: 1.5; }

/* tab bar + fab */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--tab); border-top: 1px solid var(--border); padding: 8px 8px calc(10px + var(--safe-b)); }
.tabbar nav { max-width: 480px; margin: 0 auto; display: flex; justify-content: space-around; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 60px; min-height: 48px; color: var(--t3); font-size: 11px; font-weight: 500; }
.tab .pillbg { display: flex; align-items: center; justify-content: center; width: 52px; height: 30px; border-radius: 15px; }
.tab[aria-current="page"] { font-weight: 600; }
.fab { position: fixed; z-index: 21; bottom: calc(84px + var(--safe-b)); right: max(20px, calc(50vw - 220px)); width: 64px; height: 64px; border-radius: 32px; background: var(--s2); border: 1px solid var(--edge); box-shadow: 0 10px 28px rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; }

/* kora */
.nudge { background: var(--s2); border: 1px solid var(--edge); border-radius: 20px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.nudge .who { font-size: 12px; font-weight: 700; color: var(--orange); letter-spacing: 0.6px; text-transform: uppercase; }
.nudge p { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.bubble { padding: 12px 14px; border-radius: 18px 18px 18px 6px; background: var(--s2); max-width: 80%; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.me { border-radius: 18px 18px 6px 18px; background: var(--orange); color: var(--ink); font-weight: 500; margin-left: auto; }

/* forms + sheets */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .lbl { font-size: 13px; font-weight: 600; color: var(--t2); }
.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 0 14px; background: var(--s2); border: 1px solid var(--edge); border-radius: 14px; color: var(--t1); font-size: 16px; outline: none; }
textarea.input { padding: 12px 14px; min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--orange); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; max-height: 92dvh; overflow: auto; background: var(--s1); border-radius: 24px 24px 0 0; border: 1px solid var(--edge); border-bottom: none; padding: 20px 20px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--edge); margin: -8px auto 0; }
.err { color: var(--red); font-size: 13px; }
.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(100px + var(--safe-b)); background: var(--t1); color: var(--ink); padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,0.5); max-width: calc(100vw - 40px); }
.toast.error { background: var(--red); }
.loading { padding: 80px 0; display: flex; justify-content: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--orange); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* habit grid */
.hgrid { display: flex; gap: 3px; }
.hgrid button { flex: 1; aspect-ratio: 1; max-width: 16px; border-radius: 4px; border: none; padding: 0; cursor: pointer; }

/* login */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 24px; padding: 32px 24px; max-width: 420px; margin: 0 auto; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
