/* Voice-first language welcome */
.language-picker {
  position: fixed; inset: 0; margin: 0; width: 100%; height: 100%;
  max-width: none; max-height: none; padding: clamp(16px, 5vw, 64px) 16px;
  border: none; border-radius: 0; color: var(--ink);
  background: var(--grad-canvas); overflow: auto;
}
.language-picker[open] { display: flex; }
.welcome-card {
  width: min(100%, 470px); margin: auto; padding: clamp(24px, 5vw, 44px);
  border: 1px solid white; border-radius: 32px; background: #fffdfefa;
  box-shadow: 0 32px 90px -44px #80345066; text-align: center;
}
.welcome-brand { display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 750; }
.welcome-brand span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--rose-100); color: var(--rose-700); }
.welcome-brand svg { width: 18px; height: 18px; }
.welcome-art { margin: 34px 0 24px; display: flex; align-items: center; justify-content: center; gap: 16px; }
.welcome-mic { flex: 0 0 72px; height: 72px; display: grid; place-items: center; border-radius: 24px; background: linear-gradient(145deg,#f8dce9,#fcf0ed); color: var(--rose-700); transform: rotate(-5deg); }
.welcome-mic svg { width: 34px; height: 34px; transform: rotate(5deg); }
.welcome-wave { display: flex; align-items: center; gap: 3px; color: var(--rose-300); }
.welcome-wave:last-child { transform: scaleX(-1); }
.welcome-wave i { width: 3px; border-radius: 4px; background: currentColor; }
[data-phase=listening] .welcome-wave { animation: welcome-pulse .8s ease-in-out infinite alternate; }
@keyframes welcome-pulse { to { opacity: .45; scale: 1 .55; } }
.welcome-card h1 { margin: 0; font-size: clamp(1.85rem, 4vw, 2.4rem); line-height: 1.25; }
.welcome-card h1:focus { outline: none; }
.welcome-instruction { color: var(--muted); margin: 12px auto 22px; max-width: 32ch; line-height: 1.5; }
.welcome-speak, .welcome-choices summary { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 52px; border-radius: 15px; padding: 10px 14px; cursor: pointer; }
.welcome-speak { background: var(--grad-primary); color: white; border: 0; font-weight: 700; box-shadow: var(--shadow-raised); }
.welcome-speak:disabled { cursor: progress; }
.welcome-speak svg, .welcome-choices summary svg { width: 20px; height: 20px; flex: none; }
.welcome-status { color: var(--muted); margin: 12px 0 0; font-size: .9rem; }
.welcome-status:empty { display: none; }
.welcome-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: .82rem; }
.welcome-divider::before, .welcome-divider::after { content: ''; background: var(--line); height: 1px; flex: 1; }
.welcome-choices { border: 1px solid var(--line-strong); border-radius: 15px; background: white; text-align: start; }
.welcome-choices summary { list-style: none; font-weight: 600; }
.welcome-choices summary::-webkit-details-marker { display: none; }
.welcome-choices summary svg:first-child { color: var(--rose-600); }
.welcome-choices summary svg:last-child { width: 15px; margin-inline-start: auto; transform: rotate(90deg); }
.welcome-choices[open] summary svg:last-child { transform: rotate(-90deg); }
.welcome-menu { padding: 0 10px 10px; }
.welcome-menu input { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; padding: 10px; background: var(--rose-50); }
.welcome-list { margin-top: 6px; max-height: min(26vh, 230px); overflow-y: auto; overscroll-behavior: contain; }
.welcome-list button { display: flex; gap: 8px; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; text-align: start; border: none; background: transparent; color: var(--ink); padding: 8px 12px; }
.welcome-list button:is(:hover,:focus-visible) { background: var(--rose-50); }
.welcome-list small { color: var(--muted); }

/* ---------- Voice readback ---------- */
.voice-readback {
  font-size: 1.25rem;
  padding: 1rem 1.2rem;
  background: var(--sky-100);
  color: #1f2f5c;
  border-radius: var(--r-md);
}
.read-label {
  background: transparent;
  color: var(--rose-600);
  border: 0;
  min-height: 48px;
  min-width: 48px;
  padding: 12px;
  vertical-align: middle;
  border-radius: 50%;
}
.read-label:hover {
  background: var(--rose-100);
}
.read-label svg {
  width: 18px;
  height: 18px;
}
.fieldgrid > .read-label,
.checks > .read-label {
  justify-self: start;
}
.reading-field {
  outline: 3px solid var(--sky-500);
  background: var(--sky-100);
}
@media (max-width: 660px) {
  /* The record button stays inside the hero card, full width, so it never
     covers the content below it. */
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions [data-act='record'] {
    width: 100%;
    min-height: 60px;
    font-size: 1.05rem;
    justify-content: center;
    box-shadow: var(--shadow-raised);
  }
  .workspace {
    padding-bottom: 155px;
  }
  .metrics {
    margin: 0 0 1rem;
  }
  .hero-actions .read-label {
    color: white;
  }
}
dialog.emergency {
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #7d1422;
  color: #fff;
}
dialog.emergency #sheetBody {
  max-width: 42rem;
  margin: auto;
  padding: clamp(1rem, 5vw, 4rem);
}
.emergency .emergency-call {
  background: white;
  color: #7d1422;
  font-weight: 700;
  display: block;
  padding: 1.5rem;
  text-align: center;
  font-size: 1.5rem;
  margin: 2rem 0;
}
.emergency input {
  color: #2b1820;
}
.emergency .read-label {
  color: inherit;
}
.referral-print pre {
  white-space: pre-wrap;
  font: inherit;
}
@media print {
  body:has(.referral-print) :is(.workspace, #sidebar, #toast),
  dialog:has(.referral-print) #sheetBody > :not(.referral-print) {
    display: none;
  }
  dialog:has(.referral-print) {
    position: static;
    max-height: none;
    width: 100%;
    max-width: none;
    overflow: visible;
    border: none;
  }
  .referral-print {
    color: #000;
    background: white;
  }
}

button,
a.primary,
select,
input:not([type='checkbox']),
textarea {
  min-height: 48px;
}
button,
.iconbtn,
.tool {
  min-width: 48px;
}
label:has(input[type='checkbox']) {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}
.fieldgrid,
.filters,
.metrics,
.columns,
.grow {
  min-width: 0;
}
.filters {
  flex-wrap: wrap;
}
.filters select,
.fieldgrid input,
.fieldgrid select {
  max-width: 100%;
  min-width: 0;
}
input,
select,
textarea {
  max-width: 100%;
}

.spoken-label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.25rem;
}
.spoken-label label {
  flex: 1;
  min-width: 0;
}
.hero .read-label {
  color: white;
}
button.primary,
button.secondary,
button.rowlink,
button.textbtn,
button.iconbtn {
  min-height: 48px;
  min-width: 48px;
}

.spoken-action {
  display: flex;
  align-items: center;
  min-width: 0;
}
.spoken-action > :first-child { flex: 1; min-width: 0; }
.spoken-action > .read-label { flex: 0 0 48px; padding: 10px; }
@media (max-width: 850px) {
  .nav .spoken-action { flex-direction: column; }
  .nav .spoken-action > .read-label { min-height: 48px; }
}
@media (max-width: 660px) {
  /* Only when spoken labels are on: the dock grows to fit them. */
  .labels-aloud .nav .spoken-action { flex: 1; }
  .labels-aloud #sidebar { height: 107px; }
  .labels-aloud .workspace { padding-bottom: 195px; }
  .labels-aloud #topbar { height: auto; flex-wrap: wrap; gap: 0; padding: 4px 10px; }
  .labels-aloud .topright { flex-wrap: wrap; gap: 2px; }
}
.nav .spoken-action > button[data-act] {
  width: 100%;
  min-width: 48px;
  min-height: 50px;
}

/* ---------- Screening & tasks ---------- */
.screening-card,
.task-form {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  border: 1px solid #c4e2d2;
  border-radius: var(--r-md);
  background: #f1faf5;
}
.screening-card.urgent {
  border-color: #f0b59d;
  background: var(--reviewbg);
  box-shadow: inset 4px 0 0 var(--review);
}
.screening-card h3,
.task-form h3 {
  margin: 0;
}
.screening-card h3 small {
  font-weight: 400;
}
.screening-card ul {
  margin: 0.5rem 0 0;
  padding-inline-start: 1.2rem;
}
.task-form {
  display: grid;
  gap: 0.75rem;
  background: var(--surface-solid);
  border-color: var(--line);
}
.task-form label {
  display: grid;
  gap: 0.3rem;
}
.task-form textarea {
  font: inherit;
  padding: 0.6rem;
}
.welcome-silence { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; color: var(--muted); font-size: .9rem; text-align: start; }
.welcome-silence input { width: 5.5rem; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 10px; }

/* Welcome: one shell for both the first-run front door and the language change */
.welcome-shell { margin: auto; width: min(100%, 470px); display: grid; gap: 28px; align-items: center; }
.language-picker.is-first .welcome-shell { width: min(100%, 1040px); }
@media (min-width: 900px) {
  .language-picker.is-first .welcome-shell { grid-template-columns: 1.1fr 1fr; gap: 56px; }
}
.welcome-shell .welcome-card { width: 100%; margin: 0; }
.is-first .welcome-card { text-align: start; padding: clamp(22px, 4vw, 34px); }

.welcome-intro { padding: 8px 4px; }
.welcome-intro .welcome-brand { justify-content: flex-start; font-size: 1.05rem; }
.welcome-eyebrow { display: inline-block; margin: 26px 0 14px; padding: 6px 12px; border-radius: 999px;
  background: var(--rose-100); color: var(--rose-700); font-size: .82rem; font-weight: 650; }
.welcome-intro h1 { margin: 0; font-size: clamp(2rem, 4.6vw, 3.25rem); line-height: 1.08; letter-spacing: -.03em; }
.welcome-intro h1:focus { outline: none; }
.welcome-hindi { margin: 14px 0 0; font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--rose-700); font-weight: 550; }
.welcome-steps { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 12px; }
.welcome-steps li { display: flex; gap: 12px; align-items: center; color: var(--ink); line-height: 1.4; }
.welcome-steps li > span { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px;
  background: white; color: var(--rose-600); box-shadow: var(--shadow-card); }
.welcome-steps svg { width: 20px; height: 20px; }
.welcome-note { margin: 24px 0 0; color: var(--muted); font-size: .88rem; }

.welcome-start { margin: 0 0 14px; font-size: 1.15rem; }
.welcome-open, .welcome-anm { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 12px 16px;
  border-radius: 18px; text-align: start; cursor: pointer; color: var(--ink); }
.welcome-open { border: 0; background: var(--grad-primary); color: white; box-shadow: var(--shadow-raised); }
.welcome-anm { margin-top: 10px; border: 1px solid var(--line-strong); background: white; }
.welcome-anm:is(:hover, :focus-visible) { background: var(--rose-50); }
.welcome-open:is(:hover, :focus-visible) { filter: brightness(1.05); }
.welcome-open-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: #ffffff2e; }
.welcome-anm .welcome-open-icon { background: var(--rose-100); color: var(--rose-700); }
.welcome-open-icon svg { width: 22px; height: 22px; }
.welcome-open-text { display: grid; gap: 2px; flex: 1; }
.welcome-open-text b { font-size: 1.05rem; }
.welcome-open-text small { font-size: .85rem; opacity: .85; }
.welcome-anm .welcome-open-text small { color: var(--muted); opacity: 1; }
.welcome-open > svg:last-child, .welcome-anm > svg:last-child { flex: none; width: 20px; height: 20px; }

.welcome-label { margin: 22px 0 10px; color: var(--muted); font-size: .9rem; font-weight: 600; }
.welcome-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.language-picker:not(.is-first) .welcome-quick { justify-content: center; margin-top: 22px; }
.welcome-quick button { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: white; color: var(--ink); font-weight: 600; cursor: pointer; }
.welcome-quick button:is(:hover, :focus-visible) { background: var(--rose-50); border-color: var(--rose-300); }
.welcome-quick button[aria-current] { background: var(--rose-100); border-color: var(--rose-400); color: var(--rose-700); }

/* First run: voice detection becomes a compact secondary row, not the hero */
.is-first .welcome-voice { margin-top: 18px; padding: 14px; border-radius: 16px; background: var(--rose-50); }
.is-first .welcome-art { display: none; }
.is-first .welcome-instruction { margin: 0 0 10px; max-width: none; font-size: .9rem; }
.is-first .welcome-speak { min-height: 46px; background: white; color: var(--rose-700); border: 1px solid var(--rose-300); box-shadow: none; }
.is-first .welcome-divider { margin: 14px 0; }
.language-picker:not(.is-first) .welcome-art { margin: 26px 0 18px; }

.welcome-settings { margin-top: 14px; color: var(--muted); font-size: .85rem; }
.welcome-settings summary { cursor: pointer; width: fit-content; }
.welcome-settings .welcome-silence { margin-top: 8px; }
.welcome-intro .welcome-brand { gap: 10px; }
.welcome-intro .welcome-brand span { width: 40px; height: 40px; border-radius: 13px; background: var(--grad-primary); color: white; box-shadow: var(--shadow-raised); }
.welcome-intro .welcome-brand svg { width: 22px; height: 22px; }
.welcome-eyebrow { background: white; border: 1px solid var(--rose-200); }
.is-first .welcome-divider { display: none; }
.is-first .welcome-choices { margin-top: 12px; }
.welcome-open, .welcome-anm { min-height: 64px; }
.language-picker:not(.is-first) #welcome-title { margin-top: 18px; }
@media (max-width: 899px) {
  .language-picker.is-first { padding-top: 20px; }
  .language-picker.is-first .welcome-shell { gap: 18px; }
  .welcome-intro { padding: 0 4px; }
  .welcome-eyebrow { margin: 16px 0 10px; }
  .welcome-intro h1 { font-size: clamp(1.7rem, 7vw, 2.2rem); }
  .welcome-hindi { margin-top: 8px; font-size: 1rem; }
  .welcome-steps, .welcome-note { display: none; }
}

/* Talk to Saathi · Live */
.live-btn { border: 1px solid var(--rose-300) !important; }
.live-log { max-height: min(46vh, 380px); overflow-y: auto; display: grid; gap: 8px; margin: 12px 0; padding: 12px; border-radius: 14px; background: var(--rose-50); }
.live-log:empty::before { content: '…'; color: var(--muted); }
.live-log p { margin: 0; padding: 8px 12px; border-radius: 12px; line-height: 1.45; max-width: 88%; }
.live-log p.me { justify-self: end; background: white; border: 1px solid var(--line); }
.live-log p.saathi { justify-self: start; background: var(--rose-100); }
#sheetBody .src { color: var(--muted); font-size: .8rem; margin-top: 10px; }
