:root {
  --navy: #0A1628; --cyan: #06B6D4; --teal: #14B8A6;
  --slate: #1E293B; --gray: #64748B; --light: #E2E8F0; --bg: #F6F9FC;
  --shadow: 0 1px 2px rgba(10,22,40,.04), 0 8px 24px rgba(10,22,40,.06);
  --ease: cubic-bezier(.22,.9,.3,1);
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  font-family: Inter, -apple-system, sans-serif; background:
    radial-gradient(1200px 500px at 85% -10%, rgba(6,182,212,.07), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(20,184,166,.06), transparent 55%),
    var(--bg);
  color: var(--slate); height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
}
h1, h2, h3, .brand { font-family: "Space Grotesk", Inter, sans-serif; color: var(--navy); }

/* ---------- header ---------- */
header {
  background: rgba(255,255,255,.85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226,232,240,.8);
  padding: max(10px, env(safe-area-inset-top)) 18px 10px; display: flex; align-items: center; gap: 12px;
  z-index: 10;
}
header .avatar {
  width: 42px; height: 42px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--navy), #16304f);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: "Space Grotesk"; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 14px rgba(10,22,40,.25); position: relative;
}
header .avatar::after {
  content: ""; position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--teal); border: 2px solid #fff;
}
header .who { flex: 1; min-width: 0; }
.trust-pill {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  background: #ECFDF5; color: #047857; border: 1px solid rgba(20,184,166,.35);
  border-radius: 999px; padding: 6px 11px; font-size: 11.5px; font-weight: 600;
  transition: transform .15s var(--ease), background .2s;
}
.trust-pill:active { transform: scale(.95); }
.tp-short { display: none; }
@media (max-width: 480px) { .tp-long { display: none; } .tp-short { display: inline; } }
.trust-sheet {
  position: fixed; inset: 0; background: rgba(10,22,40,.55); backdrop-filter: blur(4px);
  z-index: 80; display: none; align-items: flex-end; justify-content: center;
}
.trust-sheet.show { display: flex; }
.trust-card {
  background: #fff; border-radius: 20px 20px 0 0; padding: 26px 24px calc(22px + env(safe-area-inset-bottom));
  max-width: 560px; width: 100%; max-height: 80dvh; overflow-y: auto;
  animation: sheetup .35s var(--ease);
}
@keyframes sheetup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.trust-card h3 { font-size: 19px; margin-bottom: 14px; }
.trust-card ul { list-style: none; padding: 0; margin: 0 0 18px; }
.trust-card li { font-size: 13.5px; color: var(--slate); line-height: 1.55; padding: 7px 0 7px 26px; position: relative; }
.trust-card li::before { content: "\2713"; position: absolute; left: 2px; color: var(--teal); font-weight: 700; }
.trust-card .send-btn { width: 100%; }
@media (min-width: 641px) { .trust-sheet { align-items: center; } .trust-card { border-radius: 20px; } }
header .who .name { font-family: "Space Grotesk"; font-weight: 600; color: var(--navy); font-size: 15.5px; }
header .who .sub { font-size: 12px; color: var(--gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- progress ---------- */
.progress-rail {
  background: rgba(255,255,255,.85); backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226,232,240,.8); padding: 10px 18px 12px; z-index: 9;
}
.segments { display: flex; gap: 4px; }
.seg {
  flex: 1; height: 6px; border-radius: 3px; background: var(--light);
  position: relative; overflow: hidden; transition: background .4s;
}
.seg .seg-fill {
  position: absolute; inset: 0; transform: scaleX(0); transform-origin: left;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
  transition: transform .8s var(--ease); border-radius: 3px;
}
.seg.partial .seg-fill { transform: scaleX(.5); }
.seg.covered .seg-fill { transform: scaleX(1); }
.seg.covered .seg-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.7) 50%, transparent 70%);
  animation: shimmer 2.6s 1 .3s;
}
@keyframes shimmer { from { transform: translateX(-110%); } to { transform: translateX(110%); } }
.progress-label { font-size: 12px; color: var(--gray); margin-top: 7px; display: flex; justify-content: space-between; align-items: center; }
.progress-label .insights {
  font-family: "Space Grotesk"; font-weight: 700; color: var(--navy); font-size: 13px;
  display: inline-flex; align-items: center; gap: 5px;
}
.progress-label .insights .gem { color: var(--cyan); font-size: 11px; }
.insights.tick { animation: tickup .5s var(--ease); }
@keyframes tickup { 30% { transform: translateY(-4px) scale(1.12); color: var(--cyan); } }
.milestone {
  position: fixed; top: 18%; left: 50%; transform: translate(-50%, 8px) scale(.96); opacity: 0;
  background: var(--navy); color: #fff; padding: 13px 22px; border-radius: 14px;
  font-family: "Space Grotesk"; font-size: 14.5px; z-index: 60; pointer-events: none;
  box-shadow: 0 16px 40px rgba(10,22,40,.35); text-align: center;
  transition: all .45s var(--ease);
}
.milestone .spark { color: var(--cyan); }
.milestone.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ---------- chat ---------- */
#chat { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 22px 14px 8px; }
.chat-inner { max-width: 720px; margin: 0 auto; }
.msg { margin-bottom: 14px; display: flex; animation: rise .45s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.msg .bubble {
  max-width: 84%; padding: 13px 17px; border-radius: 18px; line-height: 1.55; font-size: 15.5px;
  white-space: pre-wrap; word-break: break-word;
}
.msg.cos .bubble {
  background: #fff; border: 1px solid rgba(226,232,240,.9); border-bottom-left-radius: 6px;
  color: var(--slate); box-shadow: var(--shadow);
}
.msg.owner { justify-content: flex-end; }
.msg.owner .bubble {
  background: linear-gradient(135deg, var(--navy), #14304e);
  color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 6px 18px rgba(10,22,40,.22);
}
.msg .voice-tag { font-size: 11px; opacity: .6; display: block; margin-top: 5px; }

/* typing indicator */
.msg.typing-bubble .bubble { display: flex; gap: 5px; align-items: center; padding: 16px 18px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); animation: bounce 1.2s infinite; }
.dot:nth-child(2) { animation-delay: .15s; background: var(--teal); }
.dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }

.done-banner {
  background: linear-gradient(135deg, #ECFDF5, #F0FDFA); border: 1px solid var(--teal); color: #065F46;
  padding: 16px 20px; border-radius: 16px; margin: 8px auto; max-width: 720px; font-size: 14.5px;
  display: none; animation: rise .5s var(--ease);
}
.done-banner.show { display: block; }

/* ---------- composer ---------- */
footer {
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px);
  border-top: 1px solid rgba(226,232,240,.8);
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
}
.composer { max-width: 720px; margin: 0 auto; }
.confirm-strip {
  display: none; background: #ECFEFF; border: 1px solid rgba(6,182,212,.5); border-radius: 12px;
  padding: 10px 13px; font-size: 13px; margin-bottom: 9px; color: var(--slate); animation: rise .3s var(--ease);
}
.confirm-strip.show { display: block; }
.row { display: flex; gap: 8px; align-items: flex-end; }
textarea {
  flex: 1; resize: none; border: 1.5px solid var(--light); border-radius: 14px; padding: 13px 15px;
  font: 16px Inter, sans-serif; color: var(--slate); min-height: 50px; max-height: 150px;
  outline: none; background: #fff; transition: border-color .25s, box-shadow .25s;
}
textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(6,182,212,.12); }
button { cursor: pointer; border: none; font-family: Inter, sans-serif; }
.ghost-btn {
  width: 42px; height: 50px; border-radius: 12px; background: transparent; border: none;
  font-size: 24px; font-weight: 300; color: var(--gray); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s var(--ease), color .2s;
}
.ghost-btn:active { transform: scale(.88); }
.ghost-btn:hover { color: var(--cyan); }
.main-btn {
  width: 52px; height: 50px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  color: #fff; font-size: 20px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(6,182,212,.35);
  transition: transform .15s var(--ease), box-shadow .2s, opacity .2s, width .25s var(--ease);
}
.main-btn.send-mode { width: 84px; font-size: 15px; }
.main-btn:active { transform: scale(.93); }
.main-btn:disabled { opacity: .45; box-shadow: none; cursor: default; }
.main-btn.recording { background: #EF4444; box-shadow: 0 6px 16px rgba(239,68,68,.4); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(239,68,68,.14); } }
.hint {
  font-size: 11.5px; color: var(--gray); margin-top: 7px; text-align: center;
  transition: opacity .8s, max-height .8s; max-height: 30px; overflow: hidden;
}
.hint.gone { opacity: 0; max-height: 0; margin-top: 0; }
.send-btn {
  height: 50px; padding: 0 22px; border-radius: 14px;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  color: #fff; font-weight: 600; font-size: 15px; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(6,182,212,.35);
}
.send-btn:active { transform: scale(.95); }

/* recording state: waveform replaces the input row visuals */
.rec-bar {
  display: none; align-items: center; gap: 12px; background: var(--navy); border-radius: 14px;
  padding: 10px 14px; margin-bottom: 9px; animation: rise .3s var(--ease);
}
.rec-bar.show { display: flex; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #F87171; animation: blink 1s infinite; flex-shrink: 0; }
@keyframes blink { 50% { opacity: .3; } }
.rec-bar canvas { flex: 1; height: 34px; width: 100%; }
.rec-bar .rec-time { color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; }
.rec-stop {
  background: #fff; color: var(--navy); border-radius: 10px; padding: 7px 14px; font-weight: 600; font-size: 13px;
}
.icon-btn.recording { background: #FEF2F2; border-color: #EF4444; }

.drop-overlay {
  position: fixed; inset: 0; background: rgba(10,22,40,.88); color: #fff; z-index: 50;
  display: none; align-items: center; justify-content: center; font-family: "Space Grotesk"; font-size: 20px;
}
.drop-overlay.show { display: flex; }

/* ---------- landing + admin cards ---------- */
.page-scroll { overflow-y: auto; height: 100dvh; }
.card {
  max-width: 560px; margin: 8vh auto; background: #fff; border: 1px solid var(--light);
  border-radius: 20px; padding: 38px; box-shadow: var(--shadow); animation: rise .5s var(--ease);
}
.card h1 { font-size: 25px; margin-bottom: 10px; }
.card p { color: var(--gray); line-height: 1.6; }
.card input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--light); border-radius: 12px;
  font: 15px Inter; margin: 6px 0 12px; background: var(--bg);
}
.card .send-btn { width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--light); }
th { color: var(--gray); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--cyan); }

@media (max-width: 640px) {
  .msg .bubble { max-width: 90%; font-size: 15px; }
  header .who .name { font-size: 14.5px; }
  .send-btn { padding: 0 18px; }
  .card { margin: 4vh 14px; padding: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
