/* MedDex — a patient's case in Chat: the section labels on a presented case,
   its export bar, and the edit-before-export sheet. Tokens come from the
   shell (light and dark), with literal fallbacks for /spatial. Mobile first:
   the sheet rises from the bottom on a phone and centres on a wide screen. */
.mdx-case {
  --k-ink: var(--mdx-ink, #0e1726); --k-ink-2: var(--mdx-ink-2, #33415a); --k-muted: var(--mdx-muted, #5f6c80);
  --k-hair: var(--mdx-hair, rgba(14, 23, 38, 0.08)); --k-hair-strong: var(--mdx-hair-strong, rgba(14, 23, 38, 0.16));
  --k-surface: var(--mdx-surface, #ffffff); --k-sunken: var(--mdx-surface-2, #f7f9fc); --k-accent: var(--mdx-blue, #1769ff);
  --k-documented: #0f766e; --k-interpretation: #6d5ce7; --k-missing: #b45309;
}
.mdx-case-bar {
  display: grid; grid-template-columns: 1fr; gap: 8px; margin: 16px 0 0; padding: 11px 12px;
  border: 1px solid var(--k-hair); border-radius: 16px; background: var(--k-surface);
  box-shadow: 0 6px 18px -14px rgba(14, 23, 38, 0.35);
}
.mdx-case-label { display: grid; gap: 1px; min-width: 0; }
.mdx-case-eyebrow { color: var(--k-accent); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.mdx-case-name { color: var(--k-ink); font-size: 0.92rem; line-height: 1.3; overflow-wrap: anywhere; }
.mdx-case-legend { display: flex; flex-wrap: wrap; gap: 5px; }
.mdx-case-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.mdx-case-acts .mdx-btn {
  min-height: 44px; padding: 6px 14px; border: 1px solid var(--k-hair-strong); border-radius: 999px;
  background: var(--k-surface); color: var(--k-ink); font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.mdx-case-acts .mdx-btn:hover { border-color: var(--k-accent); color: var(--k-accent); }
.mdx-case-acts .mdx-btn.is-primary { border-color: transparent; background: var(--k-accent); color: #fff; }
.mdx-case-acts .mdx-btn.is-primary:hover { background: var(--mdx-blue-ink, #0b46b5); color: #fff; }
.mdx-case-badge {
  --tone: var(--k-interpretation, #6d5ce7);
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; vertical-align: middle;
  background: color-mix(in srgb, var(--tone) 12%, transparent); color: var(--tone);
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em; line-height: 1.5; text-transform: uppercase; white-space: nowrap;
}
.mdx-case-badge.is-documented { --tone: var(--k-documented, #0f766e); }
.mdx-case-badge.is-missing { --tone: var(--k-missing, #b45309); }
.mdx-case-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.mdx-case-heading > .mdx-case-badge { margin-left: auto; }
.mdx-case-heading.is-missing { color: var(--k-missing, #b45309); }
@media (min-width: 560px) {
  .mdx-case-bar { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .mdx-case-legend { grid-column: 1; }
  .mdx-case-acts { grid-column: 2; grid-row: 1 / span 2; justify-content: flex-end; }
}

/* ---- the export sheet ---- */
.mdx-case-sheet {
  --k-ink: var(--mdx-ink, #0e1726); --k-muted: var(--mdx-muted, #5f6c80); --k-hair: var(--mdx-hair, rgba(14, 23, 38, 0.08));
  --k-hair-strong: var(--mdx-hair-strong, rgba(14, 23, 38, 0.16)); --k-surface: var(--mdx-surface, #ffffff); --k-sunken: var(--mdx-surface-2, #f7f9fc);
  --k-accent: var(--mdx-blue, #1769ff); --k-accent-ink: var(--mdx-blue-ink, #0b46b5);
  --k-documented: #0f766e; --k-interpretation: #6d5ce7; --k-missing: #b45309;
  position: fixed; inset: 0; z-index: 2147483000; display: flex; align-items: flex-end; justify-content: center;
  font: inherit; color: var(--k-ink);
}
.mdx-case-scrim { position: absolute; inset: 0; background: rgba(8, 12, 20, 0.42); opacity: 0; transition: opacity 180ms ease; }
.mdx-case-panel {
  position: relative; box-sizing: border-box; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; gap: 10px;
  width: 100%; max-width: 760px; max-height: min(92vh, 92dvh); padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0; background: var(--k-surface); box-shadow: 0 -18px 50px -20px rgba(8, 12, 20, 0.5);
  transform: translateY(24px); opacity: 0; transition: transform 220ms cubic-bezier(0.22, 0.9, 0.24, 1), opacity 180ms ease;
}
.mdx-case-sheet.is-open .mdx-case-scrim { opacity: 1; }
.mdx-case-sheet.is-open .mdx-case-panel { transform: none; opacity: 1; }
.mdx-case-sheet.is-leaving .mdx-case-scrim, .mdx-case-sheet.is-leaving .mdx-case-panel { opacity: 0; }
.mdx-case-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mdx-case-head h2 { margin: 0; font-size: 1.08rem; font-weight: 750; letter-spacing: -0.01em; }
.mdx-case-close { width: 40px; height: 40px; border: 1px solid var(--k-hair); border-radius: 999px; background: var(--k-sunken); color: var(--k-ink); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.mdx-case-privacy { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; padding: 8px 10px; border-radius: 12px; background: var(--k-sunken); font-size: 0.78rem; color: var(--k-muted); }
.mdx-case-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--k-ink); font-weight: 700; cursor: pointer; }
.mdx-case-toggle input { width: 18px; height: 18px; accent-color: var(--k-accent); }
.mdx-case-field { display: grid; gap: 4px; font-size: 0.74rem; font-weight: 700; color: var(--k-muted); }
.mdx-case-field input, .mdx-case-section-name, .mdx-case-section-text {
  width: 100%; box-sizing: border-box; border: 1px solid var(--k-hair-strong); border-radius: 10px; background: var(--k-surface); color: var(--k-ink);
  font: inherit; font-size: 16px; /* 16 px: iOS does not zoom the page on focus */
}
.mdx-case-field input { min-height: 42px; padding: 8px 10px; font-weight: 600; }
.mdx-case-sections { display: grid; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px 4px; -webkit-overflow-scrolling: touch; }
.mdx-case-section { --tone: var(--k-interpretation); display: grid; gap: 6px; padding: 9px 10px; border: 1px solid var(--k-hair); border-left: 3px solid var(--tone); border-radius: 6px 12px 12px 6px; background: var(--k-surface); }
.mdx-case-section.is-documented { --tone: var(--k-documented); }
.mdx-case-section.is-missing { --tone: var(--k-missing); }
.mdx-case-section.is-excluded { opacity: 0.5; }
.mdx-case-section.is-excluded .mdx-case-section-text { display: none; }
.mdx-case-section-top { display: flex; align-items: center; gap: 8px; }
.mdx-case-section-top input[type="checkbox"] { flex: none; width: 20px; height: 20px; accent-color: var(--tone); }
.mdx-case-section-name { flex: 1 1 auto; min-width: 0; min-height: 36px; padding: 5px 8px; border-color: transparent; background: transparent; font-weight: 700; font-size: 15px; }
.mdx-case-section-name:focus { border-color: var(--k-hair-strong); }
.mdx-case-kind { flex: none; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--tone) 12%, transparent); color: var(--tone); font-size: 0.6rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.mdx-case-section-text { min-height: 64px; padding: 8px 10px; resize: vertical; line-height: 1.45; font-size: 15px; }
.mdx-case-status { min-height: 1.2em; margin: 0; color: var(--k-muted); font-size: 0.8rem; }
.mdx-case-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.mdx-case-btn { min-height: 46px; padding: 8px 10px; border: 1px solid var(--k-hair-strong); border-radius: 14px; background: var(--k-surface); color: var(--k-ink); font: inherit; font-size: 0.86rem; font-weight: 750; cursor: pointer; }
.mdx-case-btn.is-primary { border-color: transparent; background: var(--k-accent); color: #fff; }
.mdx-case-btn:disabled { opacity: 0.5; cursor: progress; }
.mdx-case-panel.is-busy .mdx-case-status::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 7px; border: 2px solid var(--k-accent); border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: mdxCaseSpin 800ms linear infinite; }
@keyframes mdxCaseSpin { to { transform: rotate(360deg); } }
@media (min-width: 720px) {
  .mdx-case-sheet { align-items: center; }
  .mdx-case-panel { border-radius: 22px; max-height: min(86vh, 86dvh); box-shadow: 0 30px 80px -30px rgba(8, 12, 20, 0.55); }
}
@media (prefers-reduced-motion: reduce) {
  .mdx-case-scrim, .mdx-case-panel { transition: none; }
  .mdx-case-panel.is-busy .mdx-case-status::before { animation: none; }
}

.mdx-case-followups { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.mdx-case-followups .mdx-btn { min-height: 44px; max-width: 100%; padding: 8px 12px; border: 1px solid var(--k-hair-strong); border-radius: 12px; background: var(--k-sunken); color: var(--k-ink); font: inherit; font-size: 0.8rem; cursor: pointer; text-align: left; }

.mdx-case-preview { margin: 12px 0; padding: 18px; border: 1px solid rgba(23,105,255,.2); border-radius: 12px; background: #f5f8ff; color: #0e1726; }
.mdx-case-preview h3 { margin: 0 0 12px; font-size: 1.1rem; line-height: 1.35; }
.mdx-case-preview ul { min-height: 100px; margin: 0; padding-left: 20px; font-size: .85rem; line-height: 1.5; overflow-wrap: anywhere; }
.mdx-case-preview-controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; margin-top: 14px; font-size: .75rem; }
.mdx-case-preview-controls button { min-height: 44px; }
