/* ============================================================
   Nuron — design system (LIGHT)
   Calm, premium health intelligence. Warm paper-white surfaces,
   soft aura pastels, deep-ink text, editorial serif/sans pairing.
   Bright, fresh, wellness-forward.
   ============================================================ */

:root {
  /* Warm light surfaces */
  --paper: #fbf8f3;         /* page background (warm paper) */
  --paper-2: #f4efe7;       /* soft secondary background */
  --surface: #ffffff;       /* cards */
  --surface-2: #f6f1ea;     /* insets, chip tracks */
  --hair: #e7dfd3;          /* hairlines / borders */
  --hair-soft: #efe8dd;

  /* Ink text ramp (deep warm plum-charcoal) */
  --ink: #2a2431;           /* primary text */
  --muted: #6c6473;         /* secondary text */
  --faint: #9b93a2;         /* tertiary text */
  --cream: #fcfaf6;         /* text on dark fills (e.g. primary button) */
  --ink-strong: #272131;    /* dark primary button */

  /* Aura — the signature brand gradient + decorative stops */
  --aura: linear-gradient(135deg, #f4b58e 0%, #e98aa6 48%, #b58ce0 100%);
  --aura-peach: #f4b58e;
  --aura-rose: #e98aa6;
  --aura-violet: #b58ce0;
  --gold: #f0c987;          /* light fill */

  /* Deep, legible-on-light accent text */
  --peach-deep: #c8633b;
  --violet-deep: #7c50b8;
  --gold-deep: #a9772b;
  --sage: #bfe6cd;          /* light fill */
  --sage-deep: #2e8b5c;     /* text */
  --rose: #f6d4d0;          /* light fill */
  --rose-deep: #c24e48;     /* text */

  --radius: 18px;
  --radius-sm: 12px;
  /* Layered shadow: soft, cool — reads as gentle depth on a light page. */
  --shadow: 0 1px 2px rgba(40, 28, 55, 0.05), 0 12px 30px rgba(70, 50, 95, 0.08);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 88% -10%, rgba(233, 138, 166, 0.12), transparent 60%),
    radial-gradient(820px 620px at -8% 8%, rgba(181, 140, 224, 0.10), transparent 55%),
    var(--paper);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Display serif for headings; balanced wrapping; pretty body. */
h1, h2, .digest-headline, .empty h2, .drawer-head h2 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 500;
  letter-spacing: -0.01em;
}
h1, h2, .digest-headline, .card-title, .action-item a { text-wrap: balance; }
p, .ins-text, .action-why, .field-hint, .hint { text-wrap: pretty; }
/* Dynamic numbers shouldn't cause layout shift. */
.score-num, .tab-count, .meta, .area-chip { font-variant-numeric: tabular-nums; }

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

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 28px;
  border-bottom: 1px solid var(--hair-soft);
  position: sticky; top: 0; z-index: 5;
  background: rgba(251, 248, 243, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo { width: 36px; height: 36px; display: block; filter: drop-shadow(0 2px 8px rgba(233, 138, 166, 0.35)); }
.topbar h1 { margin: 0; font-size: 25px; line-height: 1; letter-spacing: 0; color: var(--ink); }
.tag { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; letter-spacing: 0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta { color: var(--faint); font-size: 12px; text-align: right; line-height: 1.4; }

.btn {
  border: 1px solid var(--hair); background: var(--surface); color: var(--ink);
  padding: 10px 17px; border-radius: 11px; cursor: pointer; font-size: 14px; font-weight: 600;
  font-family: inherit;
  transition: transform 0.06s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.btn:hover { border-color: var(--aura-rose); }
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: var(--ink-strong); color: var(--cream); border: none; font-weight: 600;
  box-shadow: 0 2px 10px rgba(40, 28, 55, 0.16);
}
.btn.primary:hover { box-shadow: 0 5px 18px rgba(124, 80, 184, 0.28); }
.btn.primary:disabled { opacity: 0.5; cursor: progress; box-shadow: none; }
.btn.ghost { background: transparent; border-color: var(--hair); color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }

/* ---------- Runner ---------- */
.runner { max-width: 1080px; margin: 18px auto 0; padding: 18px 22px; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow); }
.runner-head { display: flex; align-items: center; gap: 11px; margin-bottom: 13px; font-size: 15px; font-weight: 500; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 4%; border-radius: 999px; background: var(--aura); transition: width 0.5s ease; }
.runner-details { margin-top: 12px; }
.runner-details summary { cursor: pointer; color: var(--faint); font-size: 12px; user-select: none; }
.runner-log { margin: 8px 0 0; max-height: 160px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.spinner { width: 15px; height: 15px; border: 2px solid var(--hair); border-top-color: var(--aura-rose); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Enter animations — split per item, staggered (delay set inline by index). */
@keyframes riseIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view { animation: viewIn 0.28s cubic-bezier(0.2, 0, 0, 1) both; }
.card, .action-item { animation: riseIn 0.34s cubic-bezier(0.2, 0, 0, 1) both; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; max-width: 1080px; margin: 0 auto; padding: 10px 28px 0; border-bottom: 1px solid var(--hair-soft); }
.tab { background: transparent; border: none; color: var(--muted); font-size: 15px; font-weight: 600; min-height: 46px; padding: 12px 14px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; position: relative; transition: color 0.14s ease, transform 0.06s ease; }
.tab::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--aura); opacity: 0; transition: opacity 0.18s ease; }
.tab:hover { color: var(--ink); }
.tab:active { transform: scale(0.97); }
.tab.active { color: var(--ink); }
.tab.active::after { opacity: 1; }
.tab-sub { font-size: 11px; font-weight: 500; color: var(--faint); }
.tab-count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--hair); border-radius: 999px; padding: 1px 9px; }
.tab.active .tab-count { color: var(--ink); background: var(--gold); border-color: transparent; }

.view-all-cta { display: inline-flex; align-items: center; gap: 7px; min-height: 42px; margin-top: 20px; background: var(--surface); border: 1px solid var(--hair); color: var(--ink); border-radius: 12px; padding: 11px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: border-color 0.18s ease, color 0.18s ease, transform 0.06s ease, box-shadow 0.18s ease; }
.view-all-cta:hover { border-color: var(--aura-rose); box-shadow: var(--shadow); }
.view-all-cta:active { transform: scale(0.96); }

main { max-width: 1080px; margin: 0 auto; padding: 28px; }

/* ---------- Daily brief (digest) ---------- */
.digest { margin-bottom: 8px; }
.digest-card {
  position: relative; overflow: hidden;
  background:
    radial-gradient(620px 220px at 100% 0%, rgba(233, 138, 166, 0.12), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, var(--paper-2) 100%);
  border: 1px solid var(--hair); border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow);
}
.digest-eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-deep); margin: 0 0 10px; }
.digest-headline { font-size: 26px; line-height: 1.2; margin: 0 0 8px; color: var(--ink); }
.digest-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.action-list { display: grid; gap: 11px; }
.action-item { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; padding: 15px 17px; background: var(--surface); border: 1px solid var(--hair-soft); border-radius: var(--radius-sm); transition: border-color 0.18s ease, box-shadow 0.18s ease; }
.action-item:hover { border-color: var(--hair); box-shadow: var(--shadow); }
.action-badges { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.action-item a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; }
.action-item a:hover { color: var(--peach-deep); }
.action-why { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.action-text { color: var(--peach-deep); font-size: 13.5px; font-weight: 600; margin-top: 7px; }
.area-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--hair-soft); }
.area-chip { font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--hair-soft); border-radius: 999px; padding: 5px 12px; }
.area-chip b { color: var(--ink); font-weight: 600; }

/* ---------- Controls ---------- */
.controls { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle { display: inline-flex; align-items: center; min-height: 40px; font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--hair); border-radius: 999px; padding: 6px 15px; cursor: pointer; user-select: none; transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.06s ease; }
.chip-toggle:hover { color: var(--ink); border-color: var(--aura-rose); }
.chip-toggle.on { color: var(--ink); background: var(--gold); border-color: transparent; font-weight: 600; }
.chip-toggle:active { transform: scale(0.96); }
.control-right { display: flex; gap: 16px; }
.control-right label { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; display: flex; flex-direction: column; gap: 5px; }
select { background: var(--surface); color: var(--ink); border: 1px solid var(--hair); border-radius: 9px; padding: 8px 11px; font-size: 13px; font-family: inherit; cursor: pointer; }
select:focus { outline: none; border-color: var(--aura-rose); }

/* ---------- Feed ---------- */
.feed { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); transition: border-color 0.18s ease; }
.card:hover { border-color: #d9cebf; }
.card-top { display: flex; gap: 16px; align-items: flex-start; }
.score { flex: none; width: 54px; height: 54px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--hair); cursor: help; }
.score-num { font-weight: 700; font-size: 19px; line-height: 1.05; font-family: var(--font-display); }
.score-cap { font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.7; }
.score.s-hi { color: #43273a; background: var(--aura); border-color: transparent; }
.score.s-mid { color: #4a3410; background: var(--gold); border-color: transparent; }
.score.s-lo { color: var(--muted); }
.card-title { font-size: 16.5px; font-weight: 600; color: var(--ink); text-decoration: none; line-height: 1.35; }
.card-title:hover { color: var(--peach-deep); }
.card-sub { color: var(--faint); font-size: 12px; margin-top: 4px; }
.badges { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 9px; }
.pill { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--hair); color: var(--muted); background: var(--surface); }
.pill.src { color: var(--violet-deep); border-color: #e3d6f5; background: #f4eefc; }
.pill.evi { color: var(--ink); cursor: help; }
.pill.evi, .pill[class*="conf-"], .pill[class*="im-"] { cursor: help; }
/* Evidence-strength tones */
.pill.ev-strong { color: var(--sage-deep); border-color: #cdeed9; background: #e9f7ee; }
.pill.ev-mod { color: var(--gold-deep); border-color: #f2e2c2; background: #fbf2df; }
.pill.ev-early { color: var(--muted); border-color: var(--hair); }
.pill.ev-vearly { color: var(--faint); border-color: var(--hair); }
/* Expected-impact tones */
.pill.im-high { color: #43273a; background: var(--aura); border: none; }
.pill.im-med { color: #4a3410; background: var(--gold); border: none; }
.pill.im-low { color: var(--muted); border-color: var(--hair); }
.pill.im-none { color: var(--faint); border-color: var(--hair); }
/* Confidence tones */
.pill.conf-high { color: #16472f; background: var(--sage); border: none; }
.pill.conf-moderate { color: #4a3410; background: var(--gold); border: none; }
.pill.conf-low { color: var(--muted); border-color: var(--faint); }
.pill.conf-speculative { color: var(--rose-deep); border-color: #f1c9c6; background: #fdf0ef; }

.why { color: var(--faint); font-size: 12.5px; margin: 0 0 15px; font-style: italic; }
.insight { display: grid; gap: 11px; background: var(--paper-2); border: 1px solid var(--hair-soft); border-radius: var(--radius-sm); padding: 16px 18px; }
.ins-row { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: start; }
.ins-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); padding-top: 3px; }
.ins-action .ins-label { color: var(--peach-deep); }
.ins-impact .ins-label { color: var(--gold-deep); }
.ins-text { font-size: 14px; color: var(--ink); line-height: 1.6; }
.ins-action .ins-text { font-weight: 500; }

/* ---------- Empty / welcome ---------- */
.empty { text-align: center; color: var(--muted); padding: 72px 20px; }
.empty-orb { width: 84px; height: 84px; margin: 0 auto 26px; border-radius: 50%; background: var(--aura); filter: blur(1px); box-shadow: 0 8px 50px rgba(233, 138, 166, 0.5); animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.92; } 50% { transform: scale(1.06); opacity: 1; } }
.empty h2 { color: var(--ink); font-size: 30px; margin: 0 0 14px; }
.empty p { font-size: 15.5px; line-height: 1.75; margin: 0 0 14px; }
.empty .empty-cta { color: var(--faint); font-size: 14px; }

/* ---------- Drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(42, 30, 55, 0.32); backdrop-filter: blur(2px); }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(620px, 94vw); background: var(--surface); border-left: 1px solid var(--hair); padding: 26px; display: flex; flex-direction: column; gap: 14px; z-index: 1; box-shadow: -20px 0 60px rgba(70, 50, 95, 0.18); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; font-size: 22px; color: var(--ink); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- Profile form ---------- */
.form { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; padding: 4px 4px 8px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field > label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.field-hint { margin: -3px 0 2px; font-size: 12px; color: var(--muted); }
.opt { font-weight: 400; color: var(--faint); font-size: 12px; }
.form input[type="text"], .form input[type="number"], .form select {
  background: var(--paper); color: var(--ink); border: 1px solid var(--hair);
  border-radius: 10px; padding: 11px 13px; font-size: 14px; width: 100%; font-family: inherit;
}
.form input:focus, .form select:focus { outline: none; border-color: var(--aura-rose); }
.field input + input { margin-top: 8px; }

.toggle-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.pick {
  display: inline-flex; align-items: center; min-height: 40px;
  font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--hair);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; user-select: none;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.06s ease;
}
.pick:hover { border-color: var(--aura-rose); color: var(--ink); }
.pick.on { color: var(--ink); background: var(--gold); border-color: transparent; font-weight: 600; }
.pick:active { transform: scale(0.96); }

.supp-list { display: flex; flex-direction: column; gap: 8px; }
.supp-row { display: grid; grid-template-columns: 1fr 130px auto; gap: 8px; align-items: center; }
.supp-rm { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--hair); color: var(--muted); border-radius: 10px; cursor: pointer; font-size: 14px; transition: border-color 0.15s ease, color 0.15s ease, transform 0.06s ease; }
.supp-rm:active { transform: scale(0.96); }
.supp-rm:hover { border-color: var(--rose-deep); color: var(--rose-deep); }
.btn.small { padding: 9px 14px; font-size: 13px; align-self: flex-start; }

.drawer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 8px; border-top: 1px solid var(--hair-soft); }
.msg { font-size: 13px; color: var(--muted); margin-right: auto; }
.msg.ok { color: var(--sage-deep); }
.msg.err { color: var(--rose-deep); }

.hidden { display: none !important; }

/* ---------- Auth gating ---------- */
/* Before the auth check resolves, hide both app and sign-in to avoid a flash. */
.auth-loading .topbar, .auth-loading .tabs, .auth-loading #main, .auth-loading #drawer, .auth-loading #authScreen { display: none !important; }
body.signed-out .topbar, body.signed-out .tabs, body.signed-out #main, body.signed-out #drawer, body.signed-out #runner { display: none !important; }
body:not(.signed-out):not(.auth-loading) #authScreen { display: none !important; }
/* User chip only shows once signed in. */
body.signed-out .user-chip { display: none !important; }

/* ---------- Sign-in screen ---------- */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(700px 460px at 78% -8%, rgba(233, 138, 166, 0.16), transparent 60%),
    radial-gradient(700px 520px at -6% 10%, rgba(181, 140, 224, 0.14), transparent 55%),
    var(--paper);
}
.auth-card {
  width: 100%; max-width: 400px; text-align: center;
  background: var(--surface); border: 1px solid var(--hair); border-radius: 22px;
  padding: 40px 34px; box-shadow: var(--shadow);
}
.auth-logo { width: 56px; height: 56px; display: block; margin: 0 auto 18px; filter: drop-shadow(0 4px 16px rgba(233, 138, 166, 0.4)); }
.auth-title { font-family: var(--font-display); font-weight: 500; font-size: 30px; margin: 0; color: var(--ink); }
.auth-tagline { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.auth-sub { margin: 18px 0 24px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.auth-google {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 12px 18px; font-size: 14.5px; font-weight: 600; font-family: inherit;
  background: var(--surface); color: var(--ink); border: 1px solid var(--hair); border-radius: 12px; cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.06s ease;
}
.auth-google:hover { border-color: #c9bfae; box-shadow: var(--shadow); }
.auth-google:active { transform: scale(0.98); }
.auth-google[disabled] { opacity: 0.5; cursor: not-allowed; }
.auth-note { margin: 10px 0 0; font-size: 12.5px; color: var(--faint); }

.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--faint); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--hair); }

.auth-magic { display: flex; flex-direction: column; gap: 10px; }
.auth-magic input { width: 100%; background: var(--paper); color: var(--ink); border: 1px solid var(--hair); border-radius: 12px; padding: 13px 14px; font-size: 14.5px; font-family: inherit; text-align: center; }
.auth-magic input:focus { outline: none; border-color: var(--aura-rose); }
.auth-magic .btn.primary { min-height: 46px; }
.auth-result { margin-top: 16px; font-size: 13.5px; line-height: 1.6; color: var(--ink); background: var(--paper-2); border: 1px solid var(--hair-soft); border-radius: 12px; padding: 14px 16px; }
.auth-result a { color: var(--peach-deep); font-weight: 600; word-break: break-all; }
.auth-result .ok { color: var(--sage-deep); font-weight: 600; }
.auth-legal { margin: 22px 0 0; font-size: 11.5px; color: var(--faint); }

/* ---------- User chip (topbar) ---------- */
.user-chip { display: inline-flex; align-items: center; gap: 9px; padding-left: 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; background: var(--aura); background-size: cover; background-position: center; }
.user-name { font-size: 13px; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .user-name { display: none; } }

@media (max-width: 640px) {
  .ins-row { grid-template-columns: 1fr; gap: 3px; }
  .topbar { padding: 14px 18px; }
  .tabs { padding: 10px 18px 0; }
  main { padding: 18px; }
  .digest-headline { font-size: 22px; }
  .digest-card { padding: 22px 20px; }
}
