/* ════════════════════════════════════════════════════════════════
   Life Operator — "Quiet" Design System
   Calm & editorial · warm · mobile-first · terracotta accent
   Two themes (dark default / light paper) via [data-theme]
   Ported from the design handoff prototype; adapted to a full-bleed,
   responsive production app (no device frame).
   ════════════════════════════════════════════════════════════════ */

/* ── Fonts ─────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300..600;1,6..72,300..500&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Base / root ───────────────────────────────────────────────── */
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg, #0f1318);
  overscroll-behavior: none;
}

.lo {
  --font-serif: "Newsreader", Georgia, serif;
  --font-ui: "Hanken Grotesk", -apple-system, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 30px;
  --r-pill: 999px;

  --pad: 22px;            /* screen gutter */
  --maxw: 640px;          /* center column on wide screens */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* cool data palette (desaturated, shared chroma, blue family) */
  --d-terra: #5b9cf6;   /* primary blue */
  --d-sage:  #57a89f;   /* teal */
  --d-clay:  #9a8fd6;   /* indigo / lavender */
  --d-sand:  #9fb2c8;   /* steel blue */
  --d-stone: #828d9d;   /* slate gray */
  --d-slate: #6f90c4;   /* muted blue */
}

/* ── Dark (default) — cool charcoal-navy ──────────────────────── */
.lo[data-theme="dark"] {
  --bg:        #0f1318;
  --bg-2:      #151b23;
  --surface:   #1b212c;
  --surface-2: #232b38;
  --surface-3: #2e3744;
  --hairline:  rgba(226, 234, 247, 0.09);
  --hairline-2:rgba(226, 234, 247, 0.15);
  --text:      #eef2f8;
  --text-2:    #aab5c4;
  --text-3:    #76818f;
  --text-4:    #515b68;
  --accent:    #5b9cf6;   /* premium blue — THE accent */
  --accent-2:  #84b6ff;
  --accent-soft: rgba(91, 156, 246, 0.15);
  --accent-line: rgba(91, 156, 246, 0.35);
  --good:      #82b39c;   /* cool sage */
  --warn:      #d6a45c;   /* warm amber — complement */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.45);
  --shadow:    0 8px 30px rgba(0,0,0,0.5);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.6);
  --scrim:     rgba(6, 9, 14, 0.72);
  color-scheme: dark;
}

/* ── Light — cool paper ────────────────────────────────────────── */
.lo[data-theme="light"] {
  --bg:        #eef1f7;
  --bg-2:      #e6eaf2;
  --surface:   #fbfcff;
  --surface-2: #eceff5;
  --surface-3: #dfe4ee;
  --hairline:  rgba(22, 32, 50, 0.10);
  --hairline-2:rgba(22, 32, 50, 0.16);
  --text:      #15202f;
  --text-2:    #515c6c;
  --text-3:    #828d9d;
  --text-4:    #a9b2c0;
  --accent:    #2f6ccf;   /* deeper premium blue for paper contrast */
  --accent-2:  #245ab0;
  --accent-soft: rgba(47, 108, 207, 0.12);
  --accent-line: rgba(47, 108, 207, 0.30);
  --good:      #4e7d68;
  --warn:      #b07a2a;
  --shadow-sm: 0 1px 2px rgba(30,45,75,0.06);
  --shadow:    0 10px 30px rgba(30,50,90,0.12);
  --shadow-lg: 0 24px 50px rgba(30,50,90,0.18);
  --scrim:     rgba(15, 25, 45, 0.38);
  color-scheme: light;
}

/* ── Reset within app ──────────────────────────────────────────── */
.lo, .lo *, .lo *::before, .lo *::after { box-sizing: border-box; margin: 0; padding: 0; }
.lo {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}
/* :where() keeps the reset at low specificity so component classes (.btn-primary, .nav-center, …) win. */
.lo :where(button) { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.lo :where(input, textarea) { font-family: inherit; color: inherit; }
.lo ::selection { background: var(--accent-soft); }
.lo a { color: var(--accent); text-decoration: none; }
.lo :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── Scroll body ───────────────────────────────────────────────── */
.lo-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  scroll-behavior: smooth;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
}
.lo-body::-webkit-scrollbar { width: 0; }
.lo-body.has-nav { padding-bottom: 116px; }            /* clears bottom nav */
.lo-body.has-nav.has-composer { padding-bottom: 168px; } /* clears nav + docked composer above it */
.lo-body.has-composer { padding-bottom: 96px; }

/* ── Type utilities ────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}
.serif { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.01em; }
.display {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--text);
  text-wrap: balance;
}
.title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.h-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}
.body { font-size: 15.5px; line-height: 1.55; color: var(--text); }
.body-2 { font-size: 14px; line-height: 1.5; color: var(--text-2); }
.caption { font-size: 12.5px; line-height: 1.45; color: var(--text-3); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.accent-text { color: var(--accent); }

/* ── Screen header (custom, calm) ──────────────────────────────── */
.lo-head {
  padding: 6px var(--pad) 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.lo-head .display { font-size: 27px; }

/* ── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-tight { padding: 16px; }
.card-flat { background: var(--bg-2); }
[data-theme="light"] .card { box-shadow: var(--shadow-sm); }

/* ── Section ───────────────────────────────────────────────────── */
.section { padding: 8px var(--pad) 0; }
.section + .section { margin-top: 22px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.link {
  font-size: 13px; color: var(--accent); font-weight: 600;
  display: inline-flex; align-items: center; gap: 3px;
}

/* ── Pills / chips ─────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--hairline);
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  white-space: nowrap; transition: all 0.2s var(--ease);
}
.pill:active { transform: scale(0.96); }
.pill.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px; border-radius: var(--r-pill);
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  transition: all 0.2s var(--ease); border: 1px solid transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
[data-theme="light"] .btn-primary { color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--hairline); }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ── Score ring ───────────────────────────────────────────────── */
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}

/* ── Now card (hero) ───────────────────────────────────────────── */
.now-card {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-xl);
  padding: 22px;
}
.now-card::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.now-card > * { position: relative; }

/* ── List rows (domains) ──────────────────────────────────────── */
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 0;
  border-bottom: 1px solid var(--hairline);
}
.row:last-child { border-bottom: none; }
.row-icon {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
  font-weight: 600;
}
.row-grow { flex: 1; min-width: 0; }
.row-title { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; display: block; }
.row-sub { font-size: 13px; color: var(--text-3); margin-top: 1px; display: block; }
.chev { color: var(--text-4); flex-shrink: 0; }

/* ── Progress / bars ──────────────────────────────────────────── */
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent);
  transition: width 0.7s var(--ease); }

/* ── Habit ring dots ──────────────────────────────────────────── */
.habit-dot {
  width: 54px; flex-shrink: 0; display: flex; flex-direction: column;
  align-items: center; gap: 7px; cursor: pointer;
}
.habit-dot .ring-wrap { transition: transform 0.25s var(--ease-spring); }
.habit-dot:active .ring-wrap { transform: scale(0.9); }
.habit-name { font-size: 11px; color: var(--text-3); text-align: center; line-height: 1.2;
  max-width: 56px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-dot.done .habit-name { color: var(--text-2); }

/* ── Bottom nav ───────────────────────────────────────────────── */
.lo-nav {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 40;
  width: 100%; max-width: var(--maxw);
  padding: 10px 18px calc(env(safe-area-inset-bottom, 0px) + 22px);
  display: flex; align-items: center; justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border-top: 1px solid var(--hairline);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-4); font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
  transition: color 0.2s var(--ease); padding: 4px 6px; flex: 1;
  min-height: 44px; justify-content: center;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 23px; height: 23px; }
.nav-center {
  width: 52px; height: 52px; border-radius: 50%; margin-top: -22px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 24px var(--accent-soft), 0 4px 12px rgba(0,0,0,0.25);
  transition: transform 0.25s var(--ease-spring);
}
.nav-center:active { transform: scale(0.9); }

/* ── Composer ─────────────────────────────────────────────────── */
.composer {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom,0px) + 22px);
  width: calc(100% - 28px); max-width: calc(var(--maxw) - 28px);
  z-index: 45;
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-pill);
  padding: 7px 7px 7px 18px;
  box-shadow: var(--shadow);
}
/* When the bottom nav is also present (Home), float the composer above it. */
.composer.above-nav { bottom: calc(env(safe-area-inset-bottom,0px) + 92px); }
.composer input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text); min-width: 0;
}
.composer input::placeholder { color: var(--text-3); }
.composer-send {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  transition: transform 0.2s var(--ease-spring);
}
.composer-send:active { transform: scale(0.88); }
.composer-mic {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: var(--text-3);
}
.composer-mic.recording { color: var(--accent); animation: pulse 1.2s infinite; }

/* ── Chat bubbles ─────────────────────────────────────────────── */
.bubble { max-width: 84%; padding: 13px 16px; border-radius: 20px; font-size: 15px;
  line-height: 1.5; animation: rise 0.4s var(--ease) both; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff;
  border-bottom-right-radius: 7px; }
.bubble.op { align-self: flex-start; background: var(--surface); border: 1px solid var(--hairline);
  border-bottom-left-radius: 7px; }
.op-tag { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.op-glyph { width: 22px; height: 22px; border-radius: 7px; background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.via { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-4); }
.tool-line { font-size: 13px; color: var(--text-3); font-style: italic; margin-top: 6px; }

/* ── Sheet / modal ────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 90; background: var(--scrim);
  backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.25s var(--ease) both;
}
.scrim.center { align-items: center; justify-content: center; }
.sheet {
  width: 100%; max-width: var(--maxw); background: var(--bg-2); border-top-left-radius: var(--r-xl);
  border-top-right-radius: var(--r-xl); padding: 10px var(--pad) calc(env(safe-area-inset-bottom,0px) + 28px);
  border-top: 1px solid var(--hairline-2); box-shadow: var(--shadow-lg);
  animation: sheetUp 0.35s var(--ease) both;
}
.sheet-grab { width: 38px; height: 4px; border-radius: 999px; background: var(--text-4);
  margin: 4px auto 16px; opacity: 0.5; }
.dialog {
  width: calc(100% - 48px); max-width: 380px; background: var(--bg-2);
  border-radius: var(--r-xl); border: 1px solid var(--hairline-2);
  padding: 24px; box-shadow: var(--shadow-lg); animation: pop 0.3s var(--ease-spring) both;
}

/* ── Focus overlay ────────────────────────────────────────────── */
.focus-overlay {
  position: absolute; inset: 0; z-index: 80;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; animation: fade 0.4s var(--ease) both; padding: var(--pad);
}

/* ── Inputs ───────────────────────────────────────────────────── */
.field {
  width: 100%; padding: 13px 15px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--hairline-2);
  font-size: 15px; outline: none; transition: border-color 0.2s var(--ease);
}
.field:focus { border-color: var(--accent-line); }
textarea.field { resize: none; line-height: 1.5; }

/* ── Toggle ───────────────────────────────────────────────────── */
.toggle { width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3);
  position: relative; transition: background 0.25s var(--ease); flex-shrink: 0; cursor: pointer; }
.toggle.on { background: var(--accent); }
.toggle > i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: transform 0.25s var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.toggle.on > i { transform: translateX(18px); }

/* ── Segmented (theme switch) ─────────────────────────────────── */
.segmented { display: inline-flex; gap: 6px; background: var(--surface-2);
  border-radius: 999px; padding: 4px; }
.segmented button { width: 40px; height: 32px; border-radius: 999px; display: grid;
  place-items: center; color: var(--text-3); transition: all 0.2s var(--ease); }
.segmented button.on { background: var(--accent); color: #fff; }

/* ── Skeletons ────────────────────────────────────────────────── */
.skel { border-radius: 8px; background: linear-gradient(90deg,
  var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skel-line { height: 13px; margin: 8px 0; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast-wrap { position: absolute; left: 0; right: 0; bottom: 110px; z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--hairline-2);
  color: var(--text); padding: 11px 18px; border-radius: var(--r-pill);
  font-size: 14px; box-shadow: var(--shadow); animation: rise 0.3s var(--ease) both;
  max-width: calc(100% - 40px); }

/* ── Empty state ──────────────────────────────────────────────── */
.empty { text-align: center; padding: 30px 12px; }
.empty .body-2 { margin-bottom: 16px; }

/* ── Login backdrop ───────────────────────────────────────────── */
.login-backdrop {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 120% at 50% 0%,
    color-mix(in srgb, var(--accent) 8%, var(--bg)) 0%, var(--bg) 55%, var(--bg-2) 100%);
}
.lo-mark {
  width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 18px;
  display: grid; place-items: center; position: relative;
  background: var(--surface); border: 1px solid var(--hairline-2);
}
.lo-mark .ring-mark { position: absolute; inset: 8px; border-radius: 50%;
  border: 2.5px solid var(--accent); border-right-color: transparent; transform: rotate(-45deg); }
.lo-mark span { font-family: var(--font-serif); font-size: 26px; color: var(--text);
  letter-spacing: -0.02em; }

/* ── Misc ─────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--hairline); margin: 0 var(--pad); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.stack { display: flex; flex-direction: column; }
.rowflex { display: flex; align-items: center; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; } .gap18 { gap: 18px; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.scroll-x { display: flex; gap: 10px; overflow-x: auto; padding: 2px var(--pad) 4px;
  scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.center-col { width: 100%; max-width: var(--maxw); margin: 0 auto; }
[hidden] { display: none !important; }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.stagger > * { animation: rise 0.5s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.07s; }
.stagger > *:nth-child(3) { animation-delay: 0.12s; }
.stagger > *:nth-child(4) { animation-delay: 0.17s; }
.stagger > *:nth-child(5) { animation-delay: 0.22s; }
.stagger > *:nth-child(6) { animation-delay: 0.27s; }
.stagger > *:nth-child(7) { animation-delay: 0.32s; }
.stagger > *:nth-child(8) { animation-delay: 0.37s; }

@media (prefers-reduced-motion: reduce) {
  .lo *, .lo *::before, .lo *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .lo-nav { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .composer { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ── Responsive: tablet / desktop (calm widen, never re-densify) ─ */
@media (min-width: 1024px) {
  .lo { --pad: 34px; }
  .lo-body { max-width: 760px; padding-top: 28px; }
  .lo-head .display { font-size: 34px; }
  .lo-nav { max-width: 760px; }
  .composer { max-width: 720px; }
}
