/* AI Lab (development-only prompt preview harness) */
.ai-lab-body {
  background: #f4f6f2;
  color: #1c2721;
}

.ai-lab {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem;
}

.ai-lab__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #cfd7d1;
}

.ai-lab__header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.ai-lab__sub {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: #637067;
}

.ai-lab__sub code {
  font-size: 0.72rem;
}

.ai-lab__model {
  font-size: 0.74rem;
  color: #637067;
  text-align: right;
  line-height: 1.7;
}

.ai-lab__panel {
  margin-top: 1.5rem;
}

.ai-lab__panel h2 {
  margin: 0 0 0.625rem;
  font-size: 1rem;
  font-weight: 800;
}

.ai-lab textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.7rem 0.85rem;
  border: 1px solid #cfd7d1;
  border-radius: 10px;
  background: #ffffff;
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.ai-lab__examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.ai-lab__examples button {
  padding: 0.3rem 0.7rem;
  border: 1px solid #cfd7d1;
  border-radius: 999px;
  background: #ffffff;
  color: #4a5850;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.ai-lab__examples button:hover {
  border-color: #3f6b52;
  color: #1c2721;
}

.ai-lab__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.ai-lab__controls label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #4a5850;
}

.ai-lab__controls select {
  padding: 0.35rem 0.5rem;
  border: 1px solid #cfd7d1;
  border-radius: 8px;
  font: inherit;
  font-size: 0.78rem;
  background: #ffffff;
}

.ai-lab__variants {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  font-size: 0.74rem;
  color: #4a5850;
}

.ai-lab__variant {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.ai-lab__note {
  color: #93a099;
}

.ai-lab__run {
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: #1c2721;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.ai-lab__run:hover {
  background: #3f6b52;
}

.ai-lab__status {
  font-size: 0.78rem;
  color: #637067;
}

.ai-lab__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(430px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

.ai-lab__card {
  border: 1px solid #cfd7d1;
  border-radius: 12px;
  background: #ffffff;
  padding: 0.875rem 1rem 1rem;
}

.ai-lab__card.is-preferred {
  border-color: #3f6b52;
  box-shadow: 0 0 0 2px color-mix(in srgb, #3f6b52 35%, transparent);
}

.ai-lab__card--error {
  border-color: #c0392b;
}

.ai-lab__error {
  color: #c0392b;
  font-size: 0.8rem;
}

.ai-lab__card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.ai-lab__card-head h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ai-lab__latency {
  font-size: 0.7rem;
  color: #93a099;
  font-weight: 700;
}

.ai-lab__desc {
  width: 100%;
  margin: 0;
  font-size: 0.72rem;
  color: #637067;
}

.ai-lab__card .ai-answer {
  padding: 0.5rem 0 0;
}

.ai-lab__raw {
  margin-top: 0.6rem;
  font-size: 0.72rem;
}

.ai-lab__raw summary {
  cursor: pointer;
  color: #93a099;
  font-weight: 600;
}

.ai-lab__raw pre {
  max-height: 18rem;
  overflow: auto;
  padding: 0.6rem;
  border: 1px solid #e3e8e4;
  border-radius: 8px;
  background: #f8faf8;
  font-size: 0.66rem;
}

.ai-lab__rate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed #e3e8e4;
}

.ai-lab__rate-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #637067;
}

.ai-lab__rate [data-star] {
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid #cfd7d1;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  color: #637067;
  cursor: pointer;
}

.ai-lab__rate [data-star].is-on {
  background: #3f6b52;
  border-color: #3f6b52;
  color: #ffffff;
}

.ai-lab__rate [data-comment] {
  flex: 1 1 10rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #cfd7d1;
  border-radius: 8px;
  font: inherit;
  font-size: 0.74rem;
}

.ai-lab__rate [data-save],
.ai-lab__rate [data-prefer] {
  padding: 0.35rem 0.7rem;
  border: 1px solid #cfd7d1;
  border-radius: 999px;
  background: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.ai-lab__rate [data-prefer]:hover,
.ai-lab__rate [data-save]:hover {
  border-color: #3f6b52;
}

.ai-lab__quiz {
  width: 100%;
  margin-top: 0.75rem;
  border-collapse: collapse;
  font-size: 0.76rem;
  background: #ffffff;
}

.ai-lab__quiz th,
.ai-lab__quiz td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #e3e8e4;
  text-align: left;
  vertical-align: top;
}

.ai-lab__quiz th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #637067;
}

.ai-lab__quiz-q {
  max-width: 26rem;
  font-size: 0.72rem;
}

.ai-lab__quiz tr.is-correct {
  background: color-mix(in srgb, #3f6b52 8%, #ffffff);
}

.ai-lab__quiz tr.is-wrong {
  background: color-mix(in srgb, #c0392b 8%, #ffffff);
}

.ai-lab__quiz [data-ok],
.ai-lab__quiz [data-bad] {
  border: 1px solid #cfd7d1;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  font-size: 0.72rem;
}

.ai-lab__chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #eef1ee;
  font-size: 0.66rem;
  font-weight: 700;
}

.ai-lab__chip--ok {
  background: color-mix(in srgb, #3f6b52 15%, #ffffff);
  color: #2d5a42;
}

.ai-lab__chip--bad {
  background: color-mix(in srgb, #c0392b 15%, #ffffff);
  color: #a93226;
}

/* Patient information sheet — friendlier than doctor-facing cards, print-ready */
.ai-sheet {
  background: #ffffff;
  border: 1px solid #dbe5df;
  border-radius: 12px;
  padding: 1.25rem 1.4rem 1.1rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #1c2721;
}

.ai-sheet__kicker {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0f766e;
}

.ai-sheet__title {
  margin: 0.3rem 0 0.4rem;
  font-size: 1.45rem;
  font-weight: 800;
  color: #0b4f4a;
}

.ai-sheet__summary {
  margin: 0 0 0.75rem;
  color: #37473f;
}

.ai-sheet__section {
  margin-top: 1rem;
}

.ai-sheet__heading {
  margin: 0 0 0.4rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid color-mix(in srgb, #0f766e 25%, #ffffff);
  color: #0b4f4a;
  font-size: 0.98rem;
  font-weight: 750;
}

.ai-sheet__list {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ai-sheet__list li::marker {
  color: #0f766e;
}

.ai-sheet__section--alert {
  padding: 0.7rem 0.9rem;
  border: 1px solid color-mix(in srgb, #b3261e 35%, #ffffff);
  border-left: 4px solid #b3261e;
  border-radius: 8px;
  background: color-mix(in srgb, #b3261e 4%, #ffffff);
}

.ai-sheet__section--alert .ai-sheet__heading {
  border-bottom-color: color-mix(in srgb, #b3261e 25%, #ffffff);
  color: #b3261e;
}

.ai-sheet__section--alert .ai-sheet__list li::marker {
  color: #b3261e;
}

.ai-sheet__list--checklist {
  padding-left: 0;
  list-style: none;
}

.ai-sheet__list--checklist li::before {
  content: "☐";
  margin-right: 0.5rem;
  color: #0f766e;
}

.ai-sheet__footer {
  margin-top: 1.25rem;
  padding-top: 0.7rem;
  border-top: 1px dashed #dbe5df;
}

.ai-sheet__note {
  margin: 0 0 0.35rem;
  font-size: 0.74rem;
  color: #637067;
}

.ai-sheet__sources {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  color: #637067;
}

.ai-sheet__sources a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-sheet__sources a:hover {
  opacity: 0.75;
}

.ai-sheet__meta {
  margin: 0;
  font-size: 0.7rem;
  color: #93a099;
}

.ai-lab__card-actions {
  margin-top: 0.6rem;
}

.ai-lab__print {
  padding: 0.35rem 0.8rem;
  border: 1px solid #0f766e;
  border-radius: 999px;
  background: #ffffff;
  color: #0f766e;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.ai-lab__print:hover {
  background: #0f766e;
  color: #ffffff;
}

/* Print: dedicated print root isolates the chosen patient sheet */
#print-root {
  display: none;
}

@media print {
  .ai-lab__rate,
  .ai-lab__raw,
  .ai-lab__card-actions,
  .ai-lab__header,
  .ai-lab__examples,
  .ai-lab__controls {
    display: none !important;
  }

  .ai-lab__grid {
    display: block;
  }

  .ai-lab__card {
    border: none;
    padding: 0;
    margin-bottom: 1rem;
    break-inside: avoid;
  }

  .ai-sheet {
    border: none;
    padding: 0;
  }

  body.ai-lab-printing .ai-lab {
    display: none !important;
  }

  body.ai-lab-printing #print-root {
    display: block;
  }
}
