/* ============================================================
   Patient Inside — Design System v2 "Fable"
   Warm clinical calm · glassmorphism · tactile motion
   ============================================================ */

:root {
  --brand: #0d9488;
  --brand-deep: #0f766e;
  --brand-ink: #134e4a;
  --paper: #faf8f4;
  --line: rgba(120, 100, 70, .14);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}

* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  background: var(--paper);
  font-feature-settings: 'ss05';
  letter-spacing: -0.011em;
}

/* ---------- ambient aurora background ---------- */
#bg-aurora {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42rem 30rem at 85% -8%, rgba(20, 184, 166, .10), transparent 60%),
    radial-gradient(36rem 26rem at -10% 30%, rgba(217, 203, 176, .35), transparent 60%),
    radial-gradient(30rem 24rem at 60% 110%, rgba(13, 148, 136, .07), transparent 55%),
    var(--paper);
}

/* subtle paper grain */
#bg-aurora::after {
  content: ''; position: absolute; inset: 0; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.40 0 0 0 0 0.33 0 0 0 0.03 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- glass card ---------- */
.card {
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .85);
  outline: 1px solid var(--line);
  outline-offset: -1px;
  border-radius: 1.25rem;
  box-shadow: 0 1px 2px rgba(28,25,23,.04), 0 6px 20px rgba(28,25,23,.05);
  transition: box-shadow .3s var(--ease-out), transform .3s var(--ease-out);
}
a.card:hover, a.card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(28,25,23,.05), 0 14px 34px rgba(28,25,23,.11);
}
a.card:active { transform: translateY(0) scale(.99); }

/* hero variant — brand-tinted panel */
.card-hero {
  background: linear-gradient(140deg, #0d9488 0%, #0f766e 55%, #134e4a 100%);
  border: none; outline: none; color: #fff;
  border-radius: 1.5rem;
  box-shadow: 0 4px 12px rgba(13,148,136,.25), 0 16px 40px rgba(13,148,136,.22);
  position: relative; overflow: hidden;
}
.card-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(20rem 12rem at 110% -20%, rgba(255,255,255,.18), transparent 60%),
    radial-gradient(14rem 10rem at -10% 120%, rgba(255,255,255,.08), transparent 55%);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border-radius: .9rem; font-weight: 700; cursor: pointer;
  transition: transform .18s var(--ease-spring), box-shadow .25s var(--ease-out),
              background-color .18s, border-color .18s, color .18s;
  will-change: transform;
}
.btn:active { transform: scale(.965); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%);
  color: #fff; padding: .8rem 1.3rem;
  box-shadow: 0 1px 2px rgba(13,148,136,.35), 0 6px 16px rgba(13,148,136,.28),
              inset 0 1px 0 rgba(255,255,255,.22);
  text-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.btn-primary:hover { box-shadow: 0 2px 4px rgba(13,148,136,.4), 0 10px 26px rgba(13,148,136,.36), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  background: rgba(255,255,255,.7); color: #57534e;
  padding: .65rem 1.05rem; border: 1px solid rgba(120,100,70,.18);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: #fff; border-color: rgba(120,100,70,.3); color: #292524; }

.btn-danger {
  background: linear-gradient(180deg, #ef4444, #dc2626); color: #fff;
  padding: .8rem 1.3rem;
  box-shadow: 0 1px 2px rgba(220,38,38,.35), 0 6px 16px rgba(220,38,38,.25), inset 0 1px 0 rgba(255,255,255,.2);
}

/* ---------- inputs ---------- */
.input {
  width: 100%; border: 1.5px solid rgba(120,100,70,.18); border-radius: .9rem;
  padding: .75rem 1rem; background: rgba(255,255,255,.85); outline: none;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.input:hover { border-color: rgba(120,100,70,.32); }
.input:focus {
  border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 4px rgba(13,148,136,.13);
}
.input::placeholder { color: #b3ab9f; }

/* ---------- badges & category chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 700; border-radius: 9999px; padding: .2rem .65rem;
  letter-spacing: -.01em;
}
.cat-pain      { background: linear-gradient(180deg,#fef2f2,#fee2e2); color:#b91c1c; box-shadow: inset 0 0 0 1px rgba(185,28,28,.14); }
.cat-joy       { background: linear-gradient(180deg,#fefce8,#fef9c3); color:#a16207; box-shadow: inset 0 0 0 1px rgba(161,98,7,.14); }
.cat-want      { background: linear-gradient(180deg,#eff6ff,#dbeafe); color:#1d4ed8; box-shadow: inset 0 0 0 1px rgba(29,78,216,.14); }
.cat-can_do    { background: linear-gradient(180deg,#f0fdf4,#dcfce7); color:#15803d; box-shadow: inset 0 0 0 1px rgba(21,128,61,.14); }
.cat-cannot_do { background: linear-gradient(180deg,#faf5ff,#f3e8ff); color:#7e22ce; box-shadow: inset 0 0 0 1px rgba(126,34,206,.14); }

/* category accent bars on insight cards */
.ins-card { position: relative; overflow: hidden; }
.ins-card::before { content:''; position:absolute; left:0; top:0; bottom:0; width:4px; border-radius: 4px 0 0 4px; }
.ins-pain::before      { background: linear-gradient(180deg,#f87171,#dc2626); }
.ins-joy::before       { background: linear-gradient(180deg,#facc15,#ca8a04); }
.ins-want::before      { background: linear-gradient(180deg,#60a5fa,#2563eb); }
.ins-can_do::before    { background: linear-gradient(180deg,#4ade80,#16a34a); }
.ins-cannot_do::before { background: linear-gradient(180deg,#c084fc,#9333ea); }

/* ---------- filter pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600; border-radius: 9999px; padding: .42rem .95rem;
  white-space: nowrap; cursor: pointer;
  background: rgba(255,255,255,.75); color: #57534e;
  border: 1px solid rgba(120,100,70,.16);
  transition: all .2s var(--ease-out);
}
.pill:hover { border-color: rgba(13,148,136,.4); color: var(--brand-deep); }
.pill.active {
  background: linear-gradient(180deg,#14b8a6,#0d9488); color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px rgba(13,148,136,.35);
}

/* ---------- bottom nav ---------- */
.nav-shell {
  background: rgba(255,255,255,.82);
  -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
  border-top: 1px solid rgba(120,100,70,.12);
  box-shadow: 0 -6px 24px rgba(28,25,23,.06);
}
.nav-item { position: relative; color: #a8a29e; transition: color .2s, transform .2s var(--ease-spring); }
.nav-item:active { transform: scale(.92); }
.nav-item.active { color: var(--brand-deep); }
.nav-item.active::after {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 1.4rem; height: 3px; border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg,#14b8a6,#0d9488);
}

/* center mic button */
.nav-mic {
  width: 3.4rem; height: 3.4rem; margin-top: -1.4rem;
  border-radius: 9999px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg,#14b8a6,#0d9488 60%,#0f766e);
  color: #fff; font-size: 1.15rem;
  box-shadow: 0 3px 8px rgba(13,148,136,.4), 0 10px 24px rgba(13,148,136,.35),
              inset 0 1.5px 0 rgba(255,255,255,.3);
  transition: transform .2s var(--ease-spring), box-shadow .25s;
}
.nav-mic:hover { transform: translateY(-2px) scale(1.04); }
.nav-mic:active { transform: scale(.94); }

/* ---------- header ---------- */
.app-header {
  background: rgba(250,248,244,.75);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid rgba(120,100,70,.1);
}

/* ---------- motion ---------- */
.fade-in { animation: fadein .4s var(--ease-out) both; }
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.stagger > * { animation: fadein .45s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(7) { animation-delay: .26s; }
.stagger > *:nth-child(8) { animation-delay: .30s; }

.rec-pulse { animation: recpulse 1.6s ease-in-out infinite; }
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* recording ring ripple */
.rec-ring { position: relative; }
.rec-ring::before, .rec-ring::after {
  content: ''; position: absolute; inset: 0; border-radius: 9999px;
  border: 2px solid rgba(239,68,68,.5); animation: ripple 2s var(--ease-out) infinite;
}
.rec-ring::after { animation-delay: 1s; }
@keyframes ripple { from { transform: scale(1); opacity: .8; } to { transform: scale(1.55); opacity: 0; } }

/* processing shimmer bar */
.shimmer {
  position: relative; overflow: hidden; background: #e9e2d4; border-radius: 9999px; height: 6px;
}
.shimmer::after {
  content: ''; position: absolute; inset: 0; width: 45%;
  background: linear-gradient(90deg, transparent, #14b8a6, transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { transform: translateX(-110%); } to { transform: translateX(320%); } }

/* skeleton loading */
.skeleton {
  border-radius: 1.25rem; background: linear-gradient(100deg, #efe9dd 40%, #f7f2e9 50%, #efe9dd 60%);
  background-size: 200% 100%; animation: skel 1.3s ease-in-out infinite;
}
@keyframes skel { from { background-position: 120% 0; } to { background-position: -80% 0; } }

/* stat ring (conic gauge) */
.ring { position: relative; border-radius: 9999px; display: grid; place-items: center; }
.ring::before {
  content: ''; position: absolute; inset: 5px; border-radius: 9999px; background: #fff;
}
.ring > * { position: relative; }

/* toast */
.toast {
  position: fixed; bottom: 6.5rem; left: 50%; transform: translateX(-50%);
  z-index: 60; padding: .7rem 1.15rem; border-radius: 1rem;
  font-size: .84rem; font-weight: 600; color: #fff;
  background: rgba(28,25,23,.92);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(28,25,23,.3);
  animation: toastin .35s var(--ease-spring) both;
}
.toast.bad { background: rgba(185,28,28,.94); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px) scale(.94); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* empty state */
.empty {
  text-align: center; padding: 2.2rem 1.2rem; color: #a8a29e;
  border: 1.5px dashed rgba(120,100,70,.22); border-radius: 1.25rem;
  background: rgba(255,255,255,.4);
}
.empty i { font-size: 1.6rem; display: block; margin-bottom: .55rem; opacity: .55; }

/* divider label */
.section-label {
  display: flex; align-items: center; gap: .6rem;
  font-size: .78rem; font-weight: 800; color: #78716c;
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: .65rem;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(120,100,70,.18), transparent); }

/* scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(120,100,70,.2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,100,70,.35); }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* print */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; inset: 0; padding: 2rem; }
  #bg-aurora { display: none; }
}
