/* ========================================================================
   MediScribe AI — Design system
   Tokens: emerald-600 primary, slate-900 ink, slate-50 canvas
   Typography: -apple-system stack, Inter on the web
   ======================================================================== */

:root {
  --brand:      #047857;
  --brand-2:    #10b981;
  --brand-soft: #ecfdf5;
  --ink:        #0f172a;
  --ink-2:      #334155;
  --muted:      #64748b;
  --line:       #e2e8f0;
  --canvas:     #f8fafc;
  --danger:     #b91c1c;
  --warn:       #b45309;
  --info:       #1d4ed8;
  --shadow-1:   0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.02);
  --shadow-2:   0 8px 24px -8px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.05);
  --shadow-pop: 0 12px 40px -12px rgba(4,120,87,.35);
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  20px;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter var', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: 'cv11','ss01','ss03';
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Brand mark */
.brand-mark {
  background: linear-gradient(135deg, #047857 0%, #10b981 100%);
  box-shadow: 0 4px 14px -4px rgba(4,120,87,.5);
}

/* Polished card surface used everywhere */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
}

/* Primary button */
.btn-primary {
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
  color: #fff;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 18px;
  transition: transform .12s, box-shadow .2s, opacity .2s;
  box-shadow: 0 6px 18px -6px rgba(4,120,87,.55), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -8px rgba(4,120,87,.6); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 500;
  color: var(--ink-2);
  transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: #f1f5f9; border-color: #cbd5e1; }

/* Inputs */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=file], select, textarea {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}

/* ============================================================
   App page — recording panel
   ============================================================ */

.recorder-shell {
  background: radial-gradient(circle at 50% 0%, #ecfdf5 0%, #f8fafc 60%);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

.mic-btn {
  width: 96px; height: 96px;
  border-radius: 999px;
  background: linear-gradient(180deg, #10b981, #047857);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-pop);
  transition: transform .12s ease, box-shadow .2s ease;
}
.mic-btn:hover { transform: scale(1.04); }
.mic-btn:active { transform: scale(.98); }

@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7), 0 8px 28px -6px rgba(220,38,38,.45); }
  50%      { box-shadow: 0 0 0 18px rgba(220, 38, 38, 0), 0 8px 28px -6px rgba(220,38,38,.45); }
}
.mic-btn.recording {
  background: linear-gradient(180deg, #ef4444, #b91c1c) !important;
  animation: pulse-rec 1.6s infinite;
}

/* VU meter */
.vu-meter { background: #e2e8f0; }
.vu-meter > div { background: linear-gradient(90deg, #10b981, #047857); transition: width .12s linear; }

/* ============================================================
   SOAP output
   ============================================================ */

#soap-output section {
  margin: 0 0 1rem 0;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--brand-2);
  background: linear-gradient(0deg, var(--canvas), #fff);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: var(--shadow-1);
}
#soap-output h3 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
  margin: 0 0 0.5rem 0;
}
#soap-output p {
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
  color: var(--ink);
}
#soap-output .cc {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  padding: 0.7rem 1rem;
  background: var(--brand-soft);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
}
#soap-output aside {
  margin-top: 1rem;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: var(--shadow-1);
}
#soap-output aside.red {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
#soap-output aside.dx { background: #eff6ff; border: 1px solid #bfdbfe; }
#soap-output aside.icd {
  background: #fefce8; border: 1px solid #fde68a;
}
#soap-output aside.icd table {
  width: 100%; margin-top: 0.5rem;
  border-collapse: collapse; font-size: 0.8rem;
}
#soap-output aside.icd td {
  padding: 0.3rem 0.5rem;
  border-top: 1px solid #fde68a;
}
#soap-output aside.icd code {
  font-weight: 600;
  background: #fff;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--ink);
}
#soap-output aside h4 {
  margin: 0 0 0.4rem 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}
#soap-output ul { margin: 0.25rem 0 0 1.25rem; padding: 0; }
#soap-output aside.followup {
  background: #f0fdf4; border: 1px solid #bbf7d0;
}

/* Prescriptions panel — emphasized like a real Rx pad */
#soap-output aside.rx {
  background: linear-gradient(180deg, #fff, #fafdf7);
  border: 1px solid #86efac;
  border-left: 4px solid #047857;
}
#soap-output aside.rx h4 {
  color: #047857;
  font-size: 0.8rem;
}
#soap-output .rx-row {
  background: #fff;
  border: 1px solid #d1fae5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}
#soap-output .rx-row b {
  color: #064e3b;
}
#soap-output .rx-line2 {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--ink-2);
  font-family: 'SF Mono', Menlo, monospace;
  letter-spacing: 0.01em;
}
#soap-output .rx-ind {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}
#soap-output .rx-cautions {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #d1fae5;
  font-size: 0.78rem;
  color: #92400e;
}
#soap-output .rx-cautions > div { margin: 2px 0; }
#soap-output .rx-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
#soap-output .rx-verified      { background: #d1fae5; color: #065f46; }
#soap-output .rx-needs-review  { background: #fef3c7; color: #92400e; }
#soap-output .rx-disclaimer {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: normal;
  text-transform: none;
}
#soap-output .rx-row-warn { border-color: #fcd34d; background: #fffbeb; }
#soap-output .rx-row-pending { border-left-width: 4px; border-left-color: #f59e0b; }
#soap-output .rx-quote {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #eff6ff;
  font-size: 0.78rem;
  color: #1e40af;
  font-style: italic;
}
#soap-output .rx-verify-notes {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #fde68a;
  font-size: 0.75rem;
  color: #78350f;
}
#soap-output .muted { color: var(--muted); font-weight: 400; }

/* Investigations panel */
#soap-output aside.inv {
  background: #f0f9ff; border: 1px solid #bae6fd;
}
#soap-output aside.inv h4 { color: #0369a1; }

/* Vitals captured */
#soap-output aside.vitals {
  background: #f0f9ff; border: 1px solid #bae6fd; border-left: 4px solid #0369a1;
}
#soap-output aside.vitals h4 { color: #075985; }
#soap-output .vitals-list {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.85rem;
  color: #0c4a6e;
  letter-spacing: 0.01em;
  margin-top: 4px;
}

/* Billing codes */
#soap-output aside.billing {
  background: #fefce8; border: 1px solid #fde68a; border-left: 4px solid #ca8a04;
}
#soap-output aside.billing h4 { color: #854d0e; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#soap-output aside.billing table { width: 100%; margin-top: 6px; font-size: 0.82rem; border-collapse: collapse; }
#soap-output aside.billing td { padding: 6px 8px; border-top: 1px solid #fde68a; vertical-align: top; }
#soap-output aside.billing code { background: #fff; padding: 2px 7px; border-radius: 6px; font-weight: 600; color: #854d0e; }

/* Follow-up radar (inline) */
#soap-output aside.followup-radar {
  background: linear-gradient(180deg, #ecfdf5, #fff);
  border: 1px solid #6ee7b7;
  border-left: 4px solid #047857;
  font-size: 0.9rem;
  color: #065f46;
}

/* Patient instructions */
#soap-output aside.inst {
  background: #faf5ff; border: 1px solid #e9d5ff;
}
#soap-output aside.inst h4 { color: #6b21a8; }
#soap-output aside.inst p {
  font-size: 0.9rem; line-height: 1.5; margin: 4px 0 0 0;
  white-space: pre-wrap;
}

/* ============================================================
   Loading & status
   ============================================================ */

.skeleton {
  background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Landing page polish
   ============================================================ */

.hero-bg {
  background:
    radial-gradient(1000px 500px at 50% -10%, #d1fae5 0%, transparent 60%),
    radial-gradient(800px 400px at 100% 0%, #dbeafe 0%, transparent 50%),
    #f8fafc;
}
.feature-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform .15s, box-shadow .25s, border-color .15s;
}
.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: #cbd5e1;
}
.price-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 2rem;
}
.price-card.featured {
  border: 2px solid var(--brand);
  box-shadow: 0 30px 60px -30px rgba(4,120,87,.45);
  position: relative;
}
.price-card.featured::after {
  content: 'Most popular';
  position: absolute;
  top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--brand);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 999px;
}

/* Subtle dividers */
.section-divider {
  border-top: 1px solid var(--line);
}

/* Header sticky polish */
.app-header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

/* Toast / alert */
.alert {
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.alert-info  { background: #eff6ff; border-color: #bfdbfe; color: var(--info); }
.alert-warn  { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.alert-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.alert-ok    { background: var(--brand-soft); border-color: #bbf7d0; color: var(--brand); }

/* Spinner */
.spinner {
  width: 44px; height: 44px;
  border: 4px solid #d1fae5;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.footer {
  background: linear-gradient(0deg, #f1f5f9, #fff);
  border-top: 1px solid var(--line);
}

/* ============================================================
   New components: chips, kbd, steps, waveform, responsive
   ============================================================ */

/* Pill-shaped template chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.chip:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.chip.chip-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

/* Keyboard key visual */
.kbd {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.2;
}

/* Loading-step list */
.step {
  transition: opacity .35s ease, color .35s ease;
}
.step.active {
  opacity: 1;
  color: var(--brand);
  font-weight: 600;
}
.step.done {
  opacity: 1;
  color: var(--ink-2);
}
.step.done::before {
  content: '✓ ';
  color: var(--brand);
  margin-right: 2px;
}

/* Live waveform */
#waveform {
  background: rgba(255,255,255,.6);
  border-radius: 6px;
}

/* SOAP output: smoother enter animation */
@keyframes soap-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#soap-output:not(.hidden) section,
#soap-output:not(.hidden) aside {
  animation: soap-in .32s ease both;
}
#soap-output:not(.hidden) section:nth-child(2) { animation-delay: .04s; }
#soap-output:not(.hidden) section:nth-child(3) { animation-delay: .08s; }
#soap-output:not(.hidden) section:nth-child(4) { animation-delay: .12s; }
#soap-output:not(.hidden) section:nth-child(5) { animation-delay: .16s; }
#soap-output:not(.hidden) aside { animation-delay: .2s; }

/* Mobile-only sticky generate bar */
@media (max-width: 1023px) {
  body.audio-ready #mobile-bar { display: block !important; }
  body.audio-ready { padding-bottom: 76px; }
}

/* Smaller cards on phone */
@media (max-width: 640px) {
  .card { border-radius: 14px; }
  .mic-btn { width: 86px; height: 86px; }
  .recorder-shell { border-radius: 12px; }
  #soap-output section { padding: 0.75rem 0.85rem; }
  #soap-output p { font-size: 0.9rem; }
  .price-card { padding: 1.5rem; }
}

/* Print styles — let doctors print/save SOAP as PDF */
@media print {
  header, footer, .card.p-5.sm\:p-7, .card.p-4.sm\:p-5,
  #welcome, #mobile-bar, #shortcuts-modal, #warnings, #meta,
  .alert { display: none !important; }
  body { background: #fff; padding: 0; }
  main { display: block !important; max-width: 100% !important; }
  .card { box-shadow: none !important; border: none !important; padding: 0 !important; }
  #soap-output section { box-shadow: none !important; border-left: 2px solid #047857 !important; }
}

/* User menu fade */
#user-menu, #shortcuts-modal {
  animation: menu-in .15s ease both;
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Clinical Decision Support cards (advisory side-cards)
   ============================================================ */
#soap-output aside.cds {
  background: linear-gradient(180deg, #fefce8, #fffefa);
  border: 1px solid #fde68a;
  border-left: 4px solid #ca8a04;
}
#soap-output aside.cds h4 {
  color: #854d0e;
  font-size: .8rem;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
#soap-output .cds-disclaimer {
  font-size: .7rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: normal;
  text-transform: none;
}
#soap-output .cds-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}
@media (min-width: 640px) {
  #soap-output .cds-grid { grid-template-columns: 1fr 1fr; }
}
#soap-output .cds-card {
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 12px 14px;
  transition: opacity .25s, transform .25s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 6px;
}
#soap-output .cds-card:hover { box-shadow: 0 6px 18px -8px rgba(202,138,4,.3); }
#soap-output .cds-head { font-size: .65rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #92400e; }
#soap-output .cds-cat { background: #fef3c7; padding: 2px 7px; border-radius: 999px; }
#soap-output .cds-title { font-size: .92rem; font-weight: 600; color: var(--ink); line-height: 1.4; }
#soap-output .cds-rationale { font-size: .8rem; color: var(--ink-2); line-height: 1.5; }
#soap-output .cds-evidence { font-size: .72rem; color: var(--muted); font-style: italic; }
#soap-output .cds-actions { display: flex; gap: 6px; margin-top: 4px; }
#soap-output .cds-actions button {
  flex: 1;
  font-size: .75rem; font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid;
  cursor: pointer;
  transition: background .12s;
}
#soap-output .cds-approve { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
#soap-output .cds-approve:hover { background: #a7f3d0; }
#soap-output .cds-discard { background: #fff; color: var(--muted); border-color: var(--line); }
#soap-output .cds-discard:hover { background: #f1f5f9; color: #b91c1c; border-color: #fca5a5; }
#soap-output .cds-discarded { opacity: 0; transform: translateY(-6px); }
#soap-output .cds-approved { background: #ecfdf5; border-color: #6ee7b7; }
#soap-output .cds-added {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 600; color: #047857;
  background: #d1fae5; padding: 6px 12px; border-radius: 8px;
}

/* ============================================================
   v6 Visual polish layer — calm, premium, medical
   ============================================================ */

/* Background canvas with subtle ambient gradient */
body {
  background:
    radial-gradient(80% 40% at 50% -10%, rgba(16,185,129,.08), transparent 70%),
    radial-gradient(50% 30% at 100% 100%, rgba(59,130,246,.05), transparent 70%),
    var(--canvas);
  min-height: 100vh;
}

/* Card refinement */
.card {
  border-color: rgba(15,23,42,.06);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.card:hover { box-shadow: 0 12px 32px -12px rgba(15,23,42,.12), 0 2px 8px rgba(15,23,42,.05); }

/* Header refinement */
.app-header {
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(15,23,42,.06);
}

/* Brand mark — softer halo */
.brand-mark { box-shadow: 0 6px 20px -6px rgba(4,120,87,.4), inset 0 1px 0 rgba(255,255,255,.2); }

/* Refined hero on landing — lift typography */
.hero-headline {
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 800;
}
.hero-sub {
  font-size: clamp(1rem, 2vw, 1.18rem);
  color: var(--muted);
  line-height: 1.55;
}

/* Buttons — subtle inner highlight */
.btn-primary {
  letter-spacing: -0.005em;
  background-image: linear-gradient(180deg, #10b981 0%, #047857 100%);
}
.btn-primary:focus-visible {
  outline: 3px solid rgba(16,185,129,.35); outline-offset: 2px;
}
.btn-ghost { color: var(--ink); }

/* Chip refinement */
.chip {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  border-color: rgba(15,23,42,.08);
}
.chip:hover { transform: translateY(-1px); box-shadow: 0 4px 12px -4px rgba(15,23,42,.1); }
.chip.chip-active {
  background: linear-gradient(180deg, #ecfdf5, #d1fae5);
  box-shadow: inset 0 0 0 1px var(--brand), 0 4px 12px -4px rgba(4,120,87,.25);
}

/* Mic button — premium glow */
.mic-btn {
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  box-shadow:
    0 12px 32px -8px rgba(4,120,87,.4),
    inset 0 1px 0 rgba(255,255,255,.2),
    inset 0 -2px 0 rgba(0,0,0,.05);
  transition: transform .15s, box-shadow .25s;
}
.mic-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 16px 40px -8px rgba(4,120,87,.5),
    inset 0 1px 0 rgba(255,255,255,.2);
}
.mic-btn:active { transform: translateY(0) scale(.98); }

/* Recorder shell — soft warm gradient + ring on activity */
.recorder-shell {
  background:
    radial-gradient(circle at 50% 30%, rgba(16,185,129,.08), transparent 60%),
    linear-gradient(180deg, #fff, #f8fafc);
  border: 1px solid rgba(15,23,42,.06);
  border-radius: 18px;
  position: relative;
  overflow: hidden;
}
body.audio-ready .recorder-shell::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 18px;
  box-shadow: inset 0 0 0 2px rgba(16,185,129,.4);
  animation: ready-pulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ready-pulse {
  0%,100% { opacity: .6; }
  50%     { opacity: 1; }
}

/* SOAP output — better surfaces */
#soap-output section {
  background: linear-gradient(180deg, #fff, #f8fafc);
  border-left: 3px solid var(--brand-2);
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
#soap-output section h3 {
  font-size: .68rem; letter-spacing: .12em;
}

/* Pricing cards on landing */
.price-card {
  border-radius: 20px;
  border: 1px solid rgba(15,23,42,.06);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(10px);
  transition: transform .2s, box-shadow .2s;
}
.price-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px -16px rgba(15,23,42,.14); }
.price-card.featured {
  border: 2px solid var(--brand-2);
  box-shadow: 0 16px 40px -12px rgba(4,120,87,.3);
}

/* Section dividers */
.section-divider { border-top: 1px solid rgba(15,23,42,.05); }

/* Better feature cards */
.feature-card {
  padding: 1.5rem;
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(15,23,42,.06);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}

/* Spinner — refined */
.spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(16,185,129,.18);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar (chrome/safari) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Selection */
::selection { background: rgba(16,185,129,.25); color: var(--ink); }

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

/* ============================================================
   v8 — animations + micro-interactions for premium feel
   ============================================================ */

/* Page-level entrance: cards stagger in */
@keyframes card-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
main > section, main > div, .card {
  animation: card-rise .35s cubic-bezier(.2,.8,.2,1) both;
}
main > section:nth-child(1), main > div:nth-child(1), .card:nth-child(1) { animation-delay: 0ms; }
main > section:nth-child(2), main > div:nth-child(2), .card:nth-child(2) { animation-delay: 50ms; }
main > section:nth-child(3), main > div:nth-child(3), .card:nth-child(3) { animation-delay: 100ms; }
main > section:nth-child(4), main > div:nth-child(4), .card:nth-child(4) { animation-delay: 150ms; }
main > section:nth-child(5), main > div:nth-child(5), .card:nth-child(5) { animation-delay: 200ms; }

/* Buttons: tactile press */
button, .btn-primary, .btn-ghost, .chip {
  transition: transform .12s cubic-bezier(.2,.8,.2,1), box-shadow .18s, background .15s, border-color .15s;
}
button:not(:disabled):active, .btn-primary:not(:disabled):active, .btn-ghost:active, .chip:active {
  transform: translateY(1px) scale(.98);
}

/* Table row hover with smooth bg shift */
tbody tr {
  transition: background-color .15s ease;
}
tbody tr:hover {
  background-color: #ecfdf5 !important;
}

/* Action icons in patient history — bigger hit area, smooth color */
.hist-act {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  margin: 0 1px;
  border-radius: 8px;
  transition: background-color .15s, transform .15s, color .15s;
  cursor: pointer;
}
.hist-act:hover { transform: scale(1.15); }
.hist-act:active { transform: scale(0.92); }

/* Skeleton shimmer for loading states */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
  display: inline-block;
}

/* Input focus glow — softer */
input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 4px rgba(16,185,129,.18);
}
.ring-2.ring-red-400 { animation: shake .35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* Mic button — breathing rest state to invite tap */
@keyframes mic-breath {
  0%, 100% { box-shadow: 0 12px 32px -8px rgba(4,120,87,.4), inset 0 1px 0 rgba(255,255,255,.2); }
  50%      { box-shadow: 0 18px 40px -8px rgba(4,120,87,.55), inset 0 1px 0 rgba(255,255,255,.2); }
}
#btn-record:not(.recording) { animation: mic-breath 3s ease-in-out infinite; }

/* SOAP sections in: stagger nicely */
#soap-output:not(.hidden) > * {
  animation: card-rise .4s cubic-bezier(.2,.8,.2,1) both;
}
#soap-output:not(.hidden) > *:nth-child(1) { animation-delay: 20ms; }
#soap-output:not(.hidden) > *:nth-child(2) { animation-delay: 60ms; }
#soap-output:not(.hidden) > *:nth-child(3) { animation-delay: 100ms; }
#soap-output:not(.hidden) > *:nth-child(4) { animation-delay: 140ms; }
#soap-output:not(.hidden) > *:nth-child(5) { animation-delay: 180ms; }
#soap-output:not(.hidden) > *:nth-child(6) { animation-delay: 220ms; }
#soap-output:not(.hidden) > *:nth-child(n+7) { animation-delay: 260ms; }

/* CDS card hover lift */
#soap-output .cds-card {
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s;
}
#soap-output .cds-card:hover { transform: translateY(-2px); }

/* Status pills update animation */
#serial-pill:not(.hidden), #usage-pill:not(:empty) {
  animation: pop-in .35s cubic-bezier(.2,1.5,.3,1) both;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(.7); }
  to   { opacity: 1; transform: scale(1); }
}

/* Table row entrance when re-rendered */
#hist-body tr {
  animation: card-rise .25s cubic-bezier(.2,.8,.2,1) both;
}

/* Quota bar fill animation */
#quota-bar { transition: width .8s cubic-bezier(.2,.8,.2,1); }

/* Smooth menu open/close (keep existing menu-in but extend) */
#user-menu, #shortcuts-modal {
  animation: menu-in .18s cubic-bezier(.2,.8,.2,1) both;
}

/* Header link hover underline grow */
.app-header nav a, .app-header div a {
  position: relative;
  padding-bottom: 2px;
}
.app-header nav a::after, .app-header > div a::after {
  content: "";
  position: absolute; left: 0; bottom: -2px;
  width: 0; height: 2px;
  background: var(--brand);
  transition: width .25s cubic-bezier(.2,.8,.2,1);
}
.app-header nav a:hover::after, .app-header > div a:hover::after { width: 100%; }

/* Patient timeline slide-over */
#timeline-panel:not(.hidden) {
  animation: slide-in-right .28s cubic-bezier(.2,.8,.2,1) both;
}
#timeline-overlay:not(.hidden) {
  animation: fade-in .25s ease both;
}
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Welcome banner subtle pulse on first load */
#welcome:not(.hidden) {
  animation: card-rise .5s cubic-bezier(.2,.8,.2,1) both, glow-soft 4s ease-in-out 1s;
}
@keyframes glow-soft {
  0%, 100% { box-shadow: 0 8px 24px -8px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.05); }
  50%      { box-shadow: 0 16px 32px -8px rgba(4,120,87,.18), 0 2px 6px rgba(15,23,42,.05); }
}
