/**
 * companion.css — Desktop-7 (Figma 703:5107)
 * 3-column workspace: patient 333 | center 501 | chat 486 · gap 16
 */

:root {
  --canvas: #fffbf4;
  --white: #ffffff;
  --yellow: #fed629;
  --yellow-soft: #fff2be;
  --yellow-chip: #fee783;
  --yellow-highlight: rgba(255, 242, 190, 0.28);
  --ink: #291f18;
  --muted: #6c6158;
  --body-text: #34302d;
  --gray-label: #7b7b7b;
  --cream-panel: #fdf6e9;
  --cream-header: #fdfaf4;
  --chat-bubble: #f8edd8;
  --chat-bubble-user: #fff4c3;
  --chat-bubble-text: #362c24;
  --accent-orange: #ea6500;
  --accent-orange-fill: #ef8225;
  --allergy-bg: #fde6e7;
  --allergy-border: #f7a1a5;
  --allergy-text: #e7000b;
  --done-gray: #e0e0e0;
  --done-pill-bg: #ddccbe;
  --done-pill-text: #7b7b7b;
  --dot-done-bg: #c5e6c1;
  --divider-muted: #c3c3c3;
  --rail-slot-bg: #ffffff;
  --rail-slot-active-bg: #fff2be;
  --shadow-card: 0 0 4px rgba(0, 0, 0, 0.25);
  --radius-frame: 36px;
  --radius-panel: 16px;
  --radius-card-32: 32px;
  --radius-chip: 48px;
  --font: "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --font-ui: Inter, "Noto Sans SC", system-ui, sans-serif;
  --rail-edge: 0px;
  --rail-w: 56px;
  --rail-total: calc(var(--rail-edge) + var(--rail-w));
  --topbar-h: 80px;
  --patient-pad-x: 20px;
  --patient-header-top: 26px;
  --d7-col-patient: 333px;
  --d7-col-center: 501px;
  --d7-gap: 16px;
  --d7-center-gap: 12px;
  --stage-h: 195px;
  --progress-h: 283px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #e8e4dc;
  font-family: var(--font);
  color: var(--ink);
}

/* —— Icons —— */
.figma-icon {
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.figma-icon--16 {
  width: 16px;
  height: 16px;
}

.figma-icon--20 {
  width: 20px;
  height: 20px;
}

.figma-icon--24 {
  width: 24px;
  height: 24px;
}

.figma-icon--30 {
  width: 30px;
  height: 30px;
}

.figma-icon--32 {
  width: 32px;
  height: 32px;
}

/* —— Shell —— */
.app-shell {
  margin-left: var(--rail-total);
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--canvas);
}

/* —— Topbar —— */
.topbar {
  min-width: 0;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--yellow);
  background: var(--white);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand__text {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__title {
  font-weight: 600;
  font-size: 28px;
  line-height: 28px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand__sub {
  font-size: 14px;
  line-height: 28px;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  margin-left: auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

/* —— Patient picker —— */
.comp-patient-picker {
  position: relative;
  flex-shrink: 0;
}

.comp-patient-picker__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 168px;
  margin: 0;
  padding: 8px 16px;
  border: 1px solid var(--yellow);
  border-radius: 38px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 20px;
  font-weight: 400;
  cursor: pointer;
}

.comp-patient-picker__trigger:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.comp-patient-picker__label {
  white-space: nowrap;
}

.comp-patient-picker__chevron {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  transition: transform 0.15s ease;
}

.comp-patient-picker--open .comp-patient-picker__chevron {
  transform: rotate(180deg);
}

.comp-patient-picker__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  min-width: 100%;
  margin: 0;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--yellow);
  background: var(--white);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comp-patient-picker__menu[hidden] {
  display: none;
}

.comp-patient-picker__option {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 25px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 18px;
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.comp-patient-picker__option:hover {
  background: var(--yellow-soft);
  border-color: rgba(234, 101, 0, 0.35);
}

.comp-patient-picker__option--active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: var(--ink);
  font-weight: 600;
}

.comp-patient-picker__option:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 1px;
}

/* —— Workspace grid (Desktop-7) —— */
.workspace--d7 {
  display: grid;
  grid-template-columns: var(--d7-col-patient) var(--d7-col-center) minmax(0, 1fr);
  gap: var(--d7-gap);
  align-items: stretch;
  padding: var(--d7-gap);
  min-width: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.card {
  background: var(--white);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-frame);
  box-shadow: var(--shadow-card);
}

.workspace--d7 > .card,
.workspace--d7 > .comp-center,
.workspace--d7 > .chat-panel {
  max-height: calc(100% - 6px);
}

.patient-card,
.chat-panel {
  height: calc(100% - 6px);
}

/* —— Patient card —— */
.patient-card {
  width: var(--d7-col-patient);
  min-width: var(--d7-col-patient);
  max-width: var(--d7-col-patient);
  height: calc(100% - 6px);
  max-height: calc(100% - 6px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.patient-card__header {
  flex-shrink: 0;
  width: 100%;
  padding: var(--patient-header-top) var(--patient-pad-x) 16px;
  border-bottom: 1px solid var(--yellow);
  border-radius: var(--radius-frame) var(--radius-frame) 0 0;
}

.patient-card__header-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  max-width: 100%;
}

.avatar-ring {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  padding: 2px;
  background: linear-gradient(135deg, rgba(228, 158, 34, 0.35), rgba(228, 158, 34, 0.15));
  flex-shrink: 0;
}

.avatar-ring__inner {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(228, 158, 34, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-ring__inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.patient-card__id {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 132px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.patient-card__name {
  margin: 0;
  font-weight: 600;
  font-size: 28px;
  line-height: 34px;
  color: var(--ink);
}

.patient-card__meta {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
  color: var(--muted);
  white-space: nowrap;
}

.patient-card__body {
  padding: 16px var(--patient-pad-x) 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.patient-card__body.patient-card__body--scrolled {
  padding-top: 0;
}

.section__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.section__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.panel {
  background: var(--cream-panel);
  border-radius: var(--radius-panel);
  padding: 10px 22px;
  font-size: 14px;
  line-height: 20px;
  color: var(--body-text);
}

.stack .panel + .panel {
  margin-top: 8px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: var(--radius-chip);
  background: var(--yellow-chip);
  font-size: 12px;
  color: var(--ink);
}

.chip--lg {
  font-size: 14px;
  padding: 2px 8px;
  color: var(--body-text);
}

.chip--allergy {
  background: var(--allergy-bg);
  border: 1px solid var(--allergy-border);
  color: var(--allergy-text);
  font-size: 12px;
}

.visits {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.visit-box {
  flex: 1 1 120px;
  background: var(--cream-panel);
  border-radius: var(--radius-panel);
  padding: 11px 12px;
  min-width: 0;
}

.visit-box__label {
  font-size: 12px;
  line-height: 20px;
  color: var(--muted);
}

.visit-box__date {
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  color: var(--ink);
}

.visit-box--next .visit-box__date {
  color: var(--accent-orange);
}

.note-block .panel {
  margin-top: 8px;
}

/* —— Center column —— */
.comp-center {
  display: flex;
  flex-direction: column;
  gap: var(--d7-center-gap);
  width: var(--d7-col-center);
  min-width: var(--d7-col-center);
  max-width: var(--d7-col-center);
  flex-shrink: 0;
  min-height: 0;
  height: calc(100% - 6px);
  max-height: calc(100% - 6px);
  padding-bottom: 6px;
  box-sizing: border-box;
  overflow: visible;
}

.comp-center > .card {
  flex-shrink: 0;
  min-height: 0;
}

.comp-center > .worklist-card {
  flex: 1 1 0;
}

/* —— Stage card (501×195) —— */
.stage-card {
  flex: 0 0 var(--stage-h);
  height: var(--stage-h);
  min-height: var(--stage-h);
  max-height: var(--stage-h);
  padding: 32px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  margin-bottom: 2px;
}

.stage-card__mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: block;
}

.stage-card__head {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.stage-card__text {
  min-width: 0;
}

.stage-card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--ink);
}

.stage-card__subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
}

.stage-stepbar {
  position: relative;
  margin-top: auto;
  padding-top: 16px;
}

.stage-stepbar__track {
  position: relative;
  height: 8px;
  border-radius: 24px;
  background: var(--yellow-soft);
  overflow: hidden;
}

.stage-stepbar__fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 19.52%;
  border-radius: 24px;
  background: linear-gradient(90deg, var(--yellow-soft) 0%, var(--accent-orange-fill) 100%);
}

.stage-stepbar__dots {
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 12px;
  pointer-events: none;
}

.stage-stepbar__dot-img {
  position: absolute;
  top: 0;
  width: 12px;
  height: 12px;
  display: block;
  transform: translateX(-50%);
}

.stage-stepbar__dot-img:nth-child(1) {
  left: 0%;
}

.stage-stepbar__dot-img:nth-child(2) {
  left: 19.52%;
}

.stage-stepbar__dot-img:nth-child(3) {
  left: 39.04%;
}

.stage-stepbar__dot-img:nth-child(4) {
  left: 58.57%;
}

.stage-stepbar__dot-img:nth-child(5) {
  left: 78.09%;
}

.stage-stepbar__dot-img:nth-child(6) {
  left: 97.61%;
}

.stage-stepbar__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  gap: 4px;
}

.stage-stepbar__label {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
}

.stage-stepbar__label:last-child {
  flex: 1.4;
}

/* —— Progress card (501×283) —— */
.progress-card {
  flex: 0 0 var(--progress-h);
  height: var(--progress-h);
  min-height: var(--progress-h);
  max-height: var(--progress-h);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 2px;
}

.progress-card__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 20px 28px;
}

.progress-card__fade {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(255, 255, 255, 0) 0%, var(--white) 62%);
  z-index: 1;
}

.progress-timeline {
  position: relative;
  padding-left: 0;
}

.progress-block {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  column-gap: 12px;
  align-items: stretch;
  margin-bottom: 0;
}

.progress-block + .progress-block {
  margin-top: 8px;
}

.progress-block__rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 14px;
  min-height: 100%;
}

.progress-block__dot {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}

.progress-block__connector {
  width: 10px;
  flex: 1 1 auto;
  min-height: 8px;
  margin-top: 0;
  border-radius: 24px;
  background: var(--yellow-soft);
}

.progress-block__connector--fill {
  background: linear-gradient(180deg, var(--yellow-soft) 0%, var(--accent-orange-fill) 100%);
}

.progress-block:last-child .progress-block__connector {
  display: none;
}

.progress-block__main {
  min-width: 0;
}

.progress-block__head {
  display: flex;
  align-items: center;
  margin: 0 0 8px;
}

.progress-block__label {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
  color: var(--ink);
}

.progress-detail {
  position: relative;
  margin: 0 0 8px;
  padding: 14px 16px;
  border: 1px solid var(--accent-orange-fill);
  border-radius: 20px;
  background: var(--white);
}

.progress-detail:last-child {
  margin-bottom: 0;
}

.progress-detail--blood {
  position: relative;
  overflow: hidden;
  background: var(--white);
}

.progress-detail--blood .progress-detail__overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(244, 244, 244, 0.6);
  pointer-events: none;
  z-index: 0;
}

.progress-detail--blood > *:not(.progress-detail__overlay) {
  position: relative;
  z-index: 1;
}

.progress-detail > * {
  position: relative;
  z-index: 1;
}

.progress-detail__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  color: var(--ink);
}

.progress-detail__title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-detail__title-row .progress-detail__title {
  flex: 1;
  min-width: 0;
}

.progress-detail__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.progress-detail__meta {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 20px;
  color: var(--muted);
}

.progress-detail__divider {
  height: 1px;
  margin: 12px 0;
  background: var(--divider-muted);
}

.progress-detail__rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.progress-detail__row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  line-height: 20px;
}

.progress-detail__row-label {
  flex: 0 0 56px;
  color: var(--muted);
}

.progress-detail__row-value {
  flex: 1;
  min-width: 0;
  color: var(--ink);
}

.progress-detail__hint {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--allergy-text);
}

/* —— Worklist card —— */
.worklist-card {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 20px 16px;
  margin-bottom: 2px;
}

.worklist-card__stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-top: 8px;
  padding-bottom: 12px;
}

/* —— Section mark —— */
.section-mark {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.section-mark__ring {
  width: 30px;
  height: 30px;
  display: block;
}

.section-mark__glyph {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 24px;
  height: 24px;
  display: block;
}

/* —— Worklist head —— */
.worklist-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.worklist-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--ink);
}

.worklist-head.worklist-head--toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  min-height: 40px;
}

.worklist-head__left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-shrink: 1;
}

.worklist-head__mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: block;
}

.worklist-head__stats {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.worklist-head__stats .home-progress__label {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: #000;
  white-space: nowrap;
}

.worklist-head__stats .home-progress__bar {
  width: 120px;
  height: 12px;
  margin: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent-orange) 20%, rgba(234, 101, 0, 0.15) 20%);
}

.home-progress__label {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: #000;
}

.home-progress__bar {
  width: 120px;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent-orange) 20%, rgba(234, 101, 0, 0.15) 20%);
}

/* —— Mini-task cards (461×88, radius 32) —— */
.mini-task {
  position: relative;
  width: 100%;
  max-width: 461px;
  height: 88px;
  border-radius: var(--radius-card-32);
  box-shadow: var(--shadow-card);
  border: none;
  display: block;
  overflow: hidden;
  flex-shrink: 0;
}

.mini-task--done {
  background: var(--done-gray);
}

.mini-task--todo {
  background: var(--white);
  border: 1px solid var(--yellow);
}

.mini-task--todo.mini-task--selected {
  background: var(--yellow-chip) !important;
  border: 1px solid var(--yellow);
  cursor: pointer;
}

.mini-task--todo[data-worklist-key] {
  cursor: pointer;
}

.mini-task__dot {
  position: absolute;
  left: 18px;
  top: 12px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--dot-done-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.mini-task--todo .mini-task__dot {
  background: var(--white);
  border: 2px solid var(--accent-orange);
}

.mini-task__dot-icon {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.mini-task--done .mini-task__dot-icon {
  filter: brightness(0) saturate(100%) invert(42%) sepia(95%) saturate(650%) hue-rotate(105deg) brightness(0.95) contrast(0.95);
}

.mini-task__status {
  position: absolute;
  right: 22px;
  top: 29px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  min-width: 73px;
  box-sizing: border-box;
  border-radius: 17px;
  font-size: 16px;
  font-weight: 400;
  line-height: 20px;
}

button.mini-task__status {
  appearance: none;
  border: none;
  margin: 0;
  font: inherit;
  font-family: inherit;
  cursor: pointer;
}

button.mini-task__status:disabled {
  cursor: default;
  opacity: 1;
}

.mini-task--done .mini-task__status {
  background: var(--done-pill-bg);
  color: var(--done-pill-text);
  border: none;
}

.mini-task--todo .mini-task__status {
  background: var(--white);
  border: 1px solid var(--accent-orange-fill);
  color: #000;
}

.mini-task__title {
  position: absolute;
  left: 100px;
  top: 14px;
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
  margin: 0;
  color: #000;
}

.mini-task--done .mini-task__title {
  text-decoration: line-through;
}

.mini-task__sub {
  position: absolute;
  left: 100px;
  top: 36px;
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  color: #000;
}

.mini-task__loc {
  position: absolute;
  left: 120px;
  top: 56px;
  margin: 0;
  padding: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  color: var(--muted);
}

.mini-task__loc .figma-icon {
  position: absolute;
  left: -20px;
  top: 2px;
}

.mini-task__time-pill {
  position: absolute;
  left: 170px;
  top: 14px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  min-height: 20px;
  border-radius: 17px;
  border: 1px solid var(--yellow);
  font-size: 12px;
  font-weight: 400;
  line-height: 20px;
  color: var(--gray-label);
  background: var(--white);
}

.mini-task--done .mini-task__time-pill {
  background: var(--done-pill-bg);
  color: var(--done-pill-text);
  border: none;
}

.mini-task--todo .mini-task__time-pill {
  border-color: var(--yellow);
  color: var(--accent-orange);
}

.mini-task--blood .mini-task__title-time {
  position: absolute;
  left: 100px;
  top: 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.mini-task--blood .mini-task__title-time .mini-task__title {
  position: static;
  margin: 0;
}

.mini-task--blood .mini-task__title-time .mini-task__time-pill {
  position: static;
}

.mini-task--done.mini-task--blood .mini-task__title-time {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0;
}

.mini-task--done.mini-task--blood .mini-task__title-time .mini-task__title {
  position: absolute;
  left: 100px;
  top: 14px;
  margin: 0;
}

.mini-task--done.mini-task--blood .mini-task__title-time .mini-task__time-pill {
  position: absolute;
  left: 170px;
  top: 14px;
}

.mini-task__icon-trail {
  position: absolute;
  left: 32px;
  top: 26px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  z-index: 3;
}

.mini-task__icon-trail .figma-icon {
  width: 36px;
  height: 36px;
}

.mini-task__icon-trail--sm {
  top: 28px;
}

.mini-task__icon-trail--sm .figma-icon {
  width: 32px;
  height: 32px;
}

/* —— Chat panel (flexible) —— */
.chat-panel {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: calc(100% - 6px);
  max-height: calc(100% - 6px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel__decor {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 66px));
  height: 291px;
  pointer-events: none;
  z-index: 0;
}

.chat-panel__decor img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

.chat-panel__hero {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  min-height: 82px;
  background: var(--cream-header);
  border-bottom: 1px solid var(--yellow);
  padding: 21px 24px 12px 69px;
}

.chat-panel__hero h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  color: var(--ink);
}

.chat-panel__hero p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 17px;
  color: var(--muted);
}

.chat-panel__hero-icon {
  position: absolute;
  left: 20px;
  top: 22px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--yellow);
  display: grid;
  place-items: center;
}

.chat-panel__body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

.chat-panel__messages {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 40px 18px 16px;
  background: transparent;
}

.chat-panel__messages .chat-messages {
  position: relative;
  z-index: 1;
}

.chat-panel__composer {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  padding: 16px 18px 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 28px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid rgba(254, 214, 41, 0.35);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg-row {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.msg-row--ai {
  justify-content: flex-start;
}

.msg-row--user {
  justify-content: flex-end;
  align-items: flex-start;
}

.msg-row__avatar-ai,
.msg-row__avatar-user {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--yellow);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.msg-row__avatar-ai-icon,
.msg-row__avatar-user-icon {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.msg-row__user-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: calc(100% - 45px);
  min-width: 0;
}

.user-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.user-thumbs img {
  height: 64px;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  border-radius: 16px;
  display: block;
}

.msg-bubble {
  max-width: 100%;
  background: var(--chat-bubble);
  border-radius: 24px;
  padding: 12px 18px;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg-bubble--user {
  background: var(--chat-bubble-user);
}

.msg-bubble .msg-text {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.62;
  color: var(--chat-bubble-text);
  white-space: pre-wrap;
}

.msg-bubble time {
  display: block;
  margin-top: 6px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.35;
  color: var(--muted);
}

.msg-comic-img {
  display: block;
  width: min(320px, 100%);
  max-width: 100%;
  height: auto;
  margin-top: 8px;
  border-radius: 16px;
  cursor: zoom-in;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.04);
}

body.comic-lightbox-open {
  overflow: hidden;
}

.comic-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.comic-lightbox.is-open {
  display: flex;
}

.comic-lightbox__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.72);
  cursor: zoom-out;
}

.comic-lightbox__panel {
  position: relative;
  z-index: 1;
  max-width: min(960px, 100%);
  max-height: calc(100dvh - 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.comic-lightbox__panel img {
  max-width: min(960px, 100%);
  max-height: calc(100dvh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  pointer-events: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.comic-lightbox__close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.ai-typing {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}

.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: aiDotPulse 1.1s infinite ease-in-out both;
}

.ai-typing span:nth-child(2) {
  animation-delay: 0.18s;
}

.ai-typing span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes aiDotPulse {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(1px) scale(0.9);
  }
  50% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.composer-preview {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
}

.composer-preview.is-visible {
  display: flex;
}

.composer-preview img {
  height: 64px;
  width: auto;
  max-width: 120px;
  object-fit: cover;
  border-radius: 16px;
}

.composer__row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.composer__attach {
  border: none;
  background: transparent;
  padding: 4px 2px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.08s ease;
}

.composer__sep {
  width: 1px;
  height: 32px;
  background: rgba(123, 123, 123, 0.25);
  flex-shrink: 0;
}

.composer__input-wrap {
  flex: 1 1 200px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--yellow);
  border-radius: 24px;
  padding: 12px 16px 13px;
  background: var(--white);
}

.composer__input-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: var(--font);
  color: var(--ink);
  background: transparent;
}

.composer__input-wrap input::placeholder {
  color: var(--gray-label);
}

.composer__send {
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  line-height: 0;
  transition: transform 0.08s ease;
}

.quick-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.qa-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--yellow);
  border-radius: 34px;
  background: var(--white);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.08s ease;
}

.qa-pill:hover {
  filter: brightness(0.98);
}

.qa-pill:active {
  transform: scale(0.98);
}

.qa-pill:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.qa-pill--active {
  background: var(--yellow);
}

.composer__attach:active,
.composer__send:active {
  transform: scale(0.96);
}

.composer__attach:focus-visible,
.composer__send:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Responsive: stack below 1200px —— */
@media (max-width: 1200px) {
  .workspace--d7 {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    overflow-y: auto;
    max-width: none;
    height: auto;
    max-height: none;
    padding: 16px;
  }

  .app-shell > .workspace--d7 {
    height: calc(100dvh - var(--topbar-h));
    max-height: calc(100dvh - var(--topbar-h));
  }

  .patient-card {
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: 42vh;
  }

  .comp-center {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .stage-card,
  .progress-card {
    flex: none;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .progress-card {
    min-height: 240px;
    max-height: 320px;
  }

  .worklist-card {
    flex: none;
    min-height: 280px;
    max-height: 50vh;
  }

  .chat-panel {
    min-height: 420px;
    max-height: 60vh;
  }

  .mini-task {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .brand__sub {
    display: none;
  }

  .stage-stepbar__label {
    font-size: 12px;
  }

  .chat-panel__hero {
    padding-left: 56px;
  }
}
