/* ===========================================================
   FERN APP — UI KIT styles
   Built on the foundations in colors_and_type.css
   =========================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #F2F6EE 0%, rgba(242,246,238,0) 60%),
    var(--bg);
  font-family: var(--font-sans);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }

/* ---------- App frame: centered phone-ish column ---------- */
.stage { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 28px 16px; }
.app {
  width: 100%; max-width: 600px; height: min(880px, calc(100vh - 56px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* top chrome */
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.topbar .mark { display: flex; align-items: center; gap: 6px; }
.topbar .mark img { width: 18px; }
.topbar .mark span { font-family: var(--font-serif); font-weight: 500; font-size: 20px; color: var(--forest-800); letter-spacing: -0.01em; }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; display: grid; place-items: center; color: var(--ink-500); cursor: pointer; transition: background var(--dur) var(--ease-out); }
.iconbtn:hover { background: var(--bg-tint); }
.iconbtn svg { width: 20px; height: 20px; }
.topbar .spacer { flex: 1; }
.topbar .step { font-size: 12px; color: var(--ink-400); font-weight: 600; }

/* scroll body */
.screen { flex: 1; overflow-y: auto; padding: 26px 28px 8px; display: flex; flex-direction: column; }
.screen::-webkit-scrollbar { width: 8px; }
.screen::-webkit-scrollbar-thumb { background: var(--sage-200); border-radius: 8px; }
.center { align-items: center; text-align: center; justify-content: flex-start; }
.fade-in { animation: fade var(--dur-slow) var(--ease-out) both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce){ .fade-in{ animation: none; } }

/* ---------- Voice bar ---------- */
.voicebar-wrap { flex: none; padding: 14px 18px 18px; }
.voicebar { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 9px 10px 9px 14px; box-shadow: var(--shadow-sm); }
.voicebar .vplus { width: 30px; height: 30px; border-radius: 50%; border: none; background: transparent; display: grid; place-items: center; color: var(--ink-500); cursor: pointer; }
.voicebar .vplus svg { width: 20px; height: 20px; }
.voicebar input { flex: 1; border: none; outline: none; background: transparent; font-size: 15px; color: var(--ink-900); font-family: var(--font-sans); }
.voicebar input::placeholder { color: var(--ink-400); }
.voicebar .vmic { width: 32px; height: 32px; border-radius: 50%; border: none; background: transparent; display: grid; place-items: center; color: var(--ink-700); cursor: pointer; }
.voicebar .vmic svg { width: 19px; height: 19px; }
.voicebar .vsend { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--sage-100); color: var(--forest-600); display: grid; place-items: center; cursor: pointer; transition: all var(--dur) var(--ease-out); flex: none; }
.voicebar .vsend.armed { background: var(--forest-800); color: var(--on-forest); }
.voicebar .vsend svg { width: 18px; height: 18px; }
.voicebar .vsend:active { transform: scale(0.94); }

/* suggestion chips above the bar */
.suggests { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 12px; }
.chip-sg { border: 1px solid var(--sage-300); background: var(--surface); color: var(--forest-700); font-weight: 600; font-size: 13px; border-radius: var(--r-pill); padding: 8px 14px; cursor: pointer; transition: all var(--dur) var(--ease-out); }
.chip-sg:hover { background: var(--sage-100); }
.chip-sg:active { transform: scale(0.97); }

/* ---------- Voice orb ---------- */
.orb-shell { position: relative; width: 168px; height: 168px; display: grid; place-items: center; margin: 8px 0; }
.orb-ring { position: absolute; border-radius: 50%; border: 1.5px solid var(--sage-200); }
.orb-ring.r1 { inset: 0; opacity: .9; }
.orb-ring.r2 { inset: 20px; opacity: .6; }
.orb-core {
  width: 96px; height: 96px; border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, var(--forest-500) 0%, var(--forest-600) 48%, var(--forest-700) 100%);
  box-shadow: var(--shadow-orb);
}
.orb-core.listening { animation: breathe 3.2s var(--ease-in-out) infinite; }
.orb-core.idle { opacity: .92; }
@keyframes breathe { 0%,100% { transform: scale(1); box-shadow: 0 0 36px rgba(78,154,99,.32);} 50% { transform: scale(1.07); box-shadow: 0 0 60px rgba(78,154,99,.5);} }
.orb-glow { position: absolute; inset: -24px; border-radius: 50%; background: radial-gradient(circle, rgba(124,180,137,.28) 0%, rgba(124,180,137,0) 65%); }
@media (prefers-reduced-motion: reduce){ .orb-core.listening{ animation: none; } }

/* waveform (animated bars) */
.wf { display: inline-flex; align-items: center; gap: 3px; height: 28px; }
.wf i { width: 3px; border-radius: 2px; background: var(--forest-600); animation: wfb 1s var(--ease-in-out) infinite; }
.wf.sm i { width: 2.5px; }
@keyframes wfb { 0%,100% { height: 6px; } 50% { height: 24px; } }
.wf.paused i { animation-play-state: paused; height: 10px; }
@media (prefers-reduced-motion: reduce){ .wf i{ animation: none; height: 14px; } }

/* listening caption */
.listening-cap { font-size: 17px; font-weight: 600; color: var(--ink-900); margin-top: 6px; }
.listening-sub { font-size: 13px; color: var(--ink-400); margin-top: 2px; }

/* ---------- Landing ---------- */
.landing-lock { display: flex; flex-direction: column; align-items: center; }
.landing-lock img { width: 46px; margin-bottom: -4px; }
.landing-lock .wm { font-family: var(--font-serif); font-weight: 500; font-size: 60px; line-height: 1; color: var(--forest-800); letter-spacing: -0.01em; }
.landing-tag { font-size: 16px; color: var(--ink-500); margin-top: 10px; }

/* generic voice quote */
.vq { font-family: var(--font-serif); font-style: italic; font-size: 19px; line-height: 1.5; color: var(--ink-500); max-width: 400px; }
.vq b { font-style: normal; font-weight: 600; color: var(--forest-700); }

/* small wordmark for inner screens */
.wm-sm { font-family: var(--font-serif); font-weight: 500; font-size: 40px; color: var(--forest-800); display: inline-flex; align-items: flex-start; gap: 4px; letter-spacing: -0.01em; }
.wm-sm img { width: 20px; margin-top: 3px; }

/* ---------- Onboarding learned card ---------- */
.learned { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md); padding: 18px 20px; text-align: left; margin-top: 4px; }
.learned h4 { margin: 0 0 12px; font-size: 15px; font-weight: 700; color: var(--ink-900); }
.learned ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.learned li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-700); }
.learned li .tick { width: 20px; height: 20px; border-radius: 50%; background: var(--success-bg); color: var(--success); display: grid; place-items: center; flex: none; margin-top: 1px; }
.learned li .tick svg { width: 13px; height: 13px; }
.learned li b { color: var(--ink-900); font-weight: 600; }
.learned li.pending .tick { background: var(--bg-tint); color: var(--ink-300); }

/* ---------- Arc hub ---------- */
.arc { position: relative; width: 100%; max-width: 460px; height: 340px; margin: 6px auto 0; }
.arc svg.arc-line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.arc-node { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 7px; cursor: pointer; }
.arc-node .bubble { width: 60px; height: 60px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); display: grid; place-items: center; color: var(--forest-600); transition: all var(--dur) var(--ease-out); }
.arc-node .bubble svg { width: 24px; height: 24px; }
.arc-node.primary .bubble { background: var(--forest-800); color: var(--on-forest); border-color: var(--forest-800); width: 64px; height: 64px; }
.arc-node:hover .bubble { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.arc-node .lbl { font-size: 13px; font-weight: 600; color: var(--ink-700); white-space: nowrap; }
.arc-node.primary .lbl { color: var(--ink-900); }

/* ---------- List rows ---------- */
.list-head { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 14px; }
.list-head .ph-ic { width: 40px; height: 40px; color: var(--forest-700); display: grid; place-items: center; }
.list-head .ph-ic svg { width: 30px; height: 30px; }
.list-head h3 { margin: 0; font-size: 19px; font-weight: 700; color: var(--ink-900); }
.rows { width: 100%; max-width: 440px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.row { width: 100%; box-sizing: border-box; appearance: none; -webkit-appearance: none; font-family: inherit; color: inherit; display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border: none; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--dur) var(--ease-out); text-align: left; }
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-tint); }
.row.active { background: var(--sage-100); }
.row .av { width: 36px; height: 36px; border-radius: 50%; background: var(--sage-200); color: var(--forest-700); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; overflow: hidden; }
.row .av img { width: 100%; height: 100%; object-fit: cover; }
.row.active .av { background: var(--forest-600); color: #fff; }
.row .nm { font-size: 15px; font-weight: 600; color: var(--ink-900); }
.row .sub { font-size: 12px; color: var(--ink-500); margin-top: 1px; }
.row .grow { flex: 1; min-width: 0; }
.row .chev { color: var(--ink-300); display: grid; }
.row .chev svg { width: 18px; height: 18px; }

/* ---------- Donor profile ---------- */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.profile-head .photo { width: 76px; height: 76px; border-radius: 50%; overflow: hidden; background: var(--sage-200); display: grid; place-items: center; font-size: 22px; font-weight: 700; color: var(--forest-700); box-shadow: var(--shadow-sm); }
.profile-head .photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-head .pn { font-family: var(--font-serif); font-weight: 500; font-size: 30px; color: var(--ink-900); }
.profile-head .pmeta { font-size: 14px; color: var(--ink-500); }
.facts { width: 100%; max-width: 440px; margin: 18px auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.fact { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.fact:last-child { border-bottom: none; }
.fact .fic { width: 30px; color: var(--forest-600); display: grid; place-items: center; }
.fact .fic svg { width: 18px; height: 18px; }
.fact .fk { font-size: 14px; color: var(--ink-500); }
.fact .fv { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--ink-900); text-align: right; }

/* action quick buttons (under profile) */
.act-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; max-width: 440px; margin: 16px auto 0; }
.act-btn { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; border-radius: var(--r-md); padding: 10px 16px; cursor: pointer; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-900); box-shadow: var(--shadow-xs); transition: all var(--dur) var(--ease-out); }
.act-btn:hover { background: var(--bg-tint); }
.act-btn:active { transform: scale(0.98); }
.act-btn svg { width: 16px; height: 16px; color: var(--forest-600); }

/* ---------- Email composer ---------- */
.compose { width: 100%; max-width: 460px; margin: 14px auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md); overflow: hidden; text-align: left; }
.compose .line { display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.compose .line .k { color: var(--ink-400); width: 64px; flex: none; }
.compose .line .v { color: var(--ink-900); }
.compose .body { padding: 16px; font-size: 14px; line-height: 1.6; color: var(--ink-700); white-space: pre-line; min-height: 150px; }
.compose .foot { display: flex; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-tint); }
.compose .ai { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--forest-600); cursor: pointer; }
.compose .ai svg { width: 15px; height: 15px; }
.btn-primary { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; background: var(--forest-800); color: var(--on-forest); font-weight: 600; font-size: 14px; border: none; border-radius: var(--r-md); padding: 10px 18px; cursor: pointer; transition: background var(--dur) var(--ease-out); }
.btn-primary:hover { background: var(--forest-900); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary svg { width: 16px; height: 16px; }

/* sent confirmation */
.sent { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 30px; }
.sent .big-tick { width: 64px; height: 64px; border-radius: 50%; background: var(--success-bg); color: var(--success); display: grid; place-items: center; }
.sent .big-tick svg { width: 32px; height: 32px; }

/* section heading on inner screens */
.scr-title { font-size: 19px; font-weight: 700; color: var(--ink-900); }
.scr-sub { font-size: 14px; color: var(--ink-500); margin-top: 4px; }
.mt-auto { margin-top: auto; }
.pt-tight { padding-top: 6px; }
.research { width: 100%; max-width: 440px; margin: 14px auto 0; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.research .ri { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px 15px; box-shadow: var(--shadow-xs); font-size: 14px; color: var(--ink-700); line-height: 1.45; }
.research .ri .tick { width: 20px; height: 20px; border-radius: 50%; background: var(--success-bg); color: var(--success); display: grid; place-items: center; flex: none; margin-top: 1px; }
.research .ri .tick svg { width: 12px; height: 12px; }

/* ===========================================================
   FULL CRM (on-demand desktop view) — overlay
   =========================================================== */
.crm-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20,30,18,.32); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade var(--dur) var(--ease-out) both; }
.crm { width: 100%; max-width: 1040px; height: min(700px, calc(100vh - 48px)); background: var(--bg); border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; overflow: hidden; border: 1px solid var(--border); }
.crm-side { width: 188px; flex: none; background: var(--forest-700); color: var(--on-forest); display: flex; flex-direction: column; padding: 16px 12px; }
.crm-side .brand { display: flex; align-items: center; gap: 7px; padding: 6px 8px 18px; }
.crm-side .brand span { font-family: var(--font-serif); font-size: 22px; font-weight: 500; color: #fff; }
.crm-side .brand img { width: 18px; filter: brightness(1.6); }
.crm-side nav { display: flex; flex-direction: column; gap: 2px; }
.crm-side a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm); color: rgba(244,248,241,.75); font-size: 14px; font-weight: 500; cursor: pointer; transition: background var(--dur) var(--ease-out); }
.crm-side a svg { width: 17px; height: 17px; }
.crm-side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.crm-side a.active { background: rgba(255,255,255,.13); color: #fff; }
.crm-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.crm-top { display: flex; align-items: center; gap: 14px; padding: 18px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.crm-top .av { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--sage-200); flex: none; }
.crm-top .av img { width: 100%; height: 100%; object-fit: cover; }
.crm-top .pn { font-size: 19px; font-weight: 700; color: var(--ink-900); }
.crm-top .pm { font-size: 13px; color: var(--ink-500); }
.crm-top .actions { margin-left: auto; display: flex; gap: 10px; }
.crm-top .gbtn { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-900); border-radius: var(--r-md); padding: 8px 13px; cursor: pointer; }
.crm-top .gbtn svg { width: 15px; height: 15px; color: var(--forest-600); }
.crm-top .close { width: 34px; height: 34px; }
.crm-tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.crm-tabs button { border: none; background: transparent; padding: 12px 12px; font-size: 14px; font-weight: 600; color: var(--ink-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.crm-tabs button.active { color: var(--forest-800); border-bottom-color: var(--forest-800); }
.crm-body { flex: 1; overflow-y: auto; padding: 22px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-content: start; }
.crm-body::-webkit-scrollbar { width: 8px; }
.crm-body::-webkit-scrollbar-thumb { background: var(--sage-200); border-radius: 8px; }
.crm-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); padding: 16px 18px; }
.crm-card.full { grid-column: 1 / -1; }
.crm-card h5 { margin: 0 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-400); }
.kv { display: flex; flex-direction: column; gap: 11px; }
.kv .k { font-size: 12px; color: var(--ink-400); }
.kv .v { font-size: 15px; font-weight: 600; color: var(--ink-900); }
.kv .row2 { display: flex; justify-content: space-between; align-items: baseline; }
.giving-total { font-size: 26px; font-weight: 700; color: var(--ink-900); letter-spacing: -0.01em; }
.bars { display: flex; align-items: flex-end; gap: 18px; height: 120px; margin-top: 16px; padding-bottom: 22px; border-bottom: 1px solid var(--border); position: relative; }
.bars .bar { flex: 1; background: var(--forest-600); border-radius: 5px 5px 0 0; position: relative; transition: height var(--dur-slow) var(--ease-out); }
.bars .bar::after { content: attr(data-yr); position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--ink-400); font-weight: 600; }
.bars .bar::before { content: attr(data-val); position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--ink-500); font-weight: 600; }
.timeline { display: flex; flex-direction: column; }
.timeline .ti { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.timeline .ti:last-child { border-bottom: none; }
.timeline .ti .date { width: 84px; flex: none; color: var(--ink-400); font-size: 13px; }
.timeline .ti .what { color: var(--ink-900); flex: 1; }
.timeline .ti .badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: var(--r-pill); background: var(--success-bg); color: var(--success); }

/* tiny helper */
.muted { color: var(--ink-500); }
.tap-hint { font-size: 12px; color: var(--ink-400); margin-top: 10px; }

/* ===========================================================
   DARK THEME — hand-tuned forest-night palette.
   Overrides the foundation tokens under [data-theme="dark"].
   =========================================================== */
:root[data-theme="dark"] {
  --bg:        #10150E;   /* deep warm forest-black canvas */
  --bg-tint:   #191F16;
  --surface:   #1A2218;   /* cards / bars / panels */
  --border:    #2A3327;
  --border-strong: #3A4536;

  --ink-900:   #EEF3EA;   /* primary text — cream */
  --ink-700:   #C6D0C1;
  --ink-500:   #97A291;
  --ink-400:   #717C6B;
  --ink-300:   #545E4F;

  /* greens lift to read as accents on dark */
  --forest-800: #2F9150;  /* primary action */
  --forest-900: #36A65C;  /* primary hover (brighter on dark) */
  --forest-700: #5AA56E;  /* accent text/icons (NOT a surface here) */
  --forest-600: #5CB074;  /* icons, orb, bars */
  --forest-500: #62BC7C;

  --sage-100:  #20301D;   /* active row / soft fills */
  --sage-200:  #2A3A26;
  --sage-300:  #3A4B35;

  --success:    #74BF85;
  --success-bg: #1E2E1E;
  --on-forest:  #0E1410;  /* dark text on the bright green button */

  /* warmer, deeper elevation so cards lift off the near-black bg */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.40);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.32);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.40);
}

/* canvas glow flips to a soft green halo on dark */
:root[data-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #1A2616 0%, rgba(26,38,22,0) 60%),
    var(--bg);
}

/* CRM left nav keeps a distinct deep-forest surface (forest-700 is an accent in dark) */
:root[data-theme="dark"] .crm-side { background: #18221580; background: #182215; }
:root[data-theme="dark"] .crm-side .brand img { filter: brightness(1.8); }

/* wordmark reads as bright fern-green on dark */
:root[data-theme="dark"] .landing-lock .wm,
:root[data-theme="dark"] .wm-sm,
:root[data-theme="dark"] .topbar .mark span { color: var(--forest-700); }
