/* PCTU – Tư vấn gói khám lâm sàng (consultation page)
 * Concept: a consultant's case record. Quiet conversation, one memorable element: the decision sheet
 * (criteria → finding → verdict, then the orders and what was ruled out).
 * Palette: sage paper, pine ink of the hospital record, clinical red only for warning signs.
 * Type: Be Vietnam Pro (designed for Vietnamese diacritics).
 */
:root {
  --paper: #edf1ef;
  --sheet: #ffffff;
  --ink: #14211d;
  --ink-2: #4c5b56;
  --ink-3: #66746f;
  --rule: #d4ddd9;
  --rule-strong: #b9c7c1;
  --pine: #0b5a4c;
  --pine-ink: #ffffff;
  --pine-wash: #e2eeea;
  --alert: #a3261f;
  --alert-wash: #f8e8e6;
  --focus: #1f7a68;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --tap: 2.5rem;
  --frame-shadow: 0 1px 2px rgba(20, 33, 29, 0.05), 0 8px 28px rgba(20, 33, 29, 0.07);
  --col: 46rem;
  font-size: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1714;
    --sheet: #16211d;
    --ink: #e3ebe7;
    --ink-2: #a9b8b2;
    --ink-3: #7f8f89;
    --rule: #2a3934;
    --rule-strong: #3a4c45;
    --pine: #5cc2ab;
    --pine-ink: #0c1a16;
    --pine-wash: #183630;
    --alert: #f08f86;
    --alert-wash: #3a1d1b;
    --focus: #7fd8c4;
    --frame-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1714;
  --sheet: #16211d;
  --ink: #e3ebe7;
  --ink-2: #a9b8b2;
  --ink-3: #7f8f89;
  --rule: #2a3934;
  --rule-strong: #3a4c45;
  --pine: #5cc2ab;
  --pine-ink: #0c1a16;
  --pine-wash: #183630;
  --alert: #f08f86;
  --alert-wash: #3a1d1b;
  --focus: #7fd8c4;
  --frame-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, textarea, input { font: inherit; color: inherit; }
a { color: var(--pine); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { margin: 0; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: calc(var(--col) + 8rem);
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark { flex: none; display: block; width: 2.5rem; height: 2.5rem; object-fit: contain; }   /* the hospital's cross logo */
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 600; font-size: 1.02rem; line-height: 1.25; }
.brand-title, .brand-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-title-short { display: none; }
.brand-sub { font-size: 0.8rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; flex: none; }

/* VI / EN, left of the account button: as tall as it, pill-shaped like it */
.lang-switch {
  flex: none; display: inline-flex; height: var(--tap); padding: 0.2rem; gap: 0.15rem;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-pill);
}
.lang-btn {
  min-width: 2.3rem; padding: 0 0.55rem; border: 0; border-radius: var(--radius-pill); background: transparent;
  color: var(--ink-2); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em; cursor: pointer;
}
.lang-btn:hover:not([aria-pressed="true"]) { background: var(--pine-wash); color: var(--ink); }
.lang-btn[aria-pressed="true"] { background: var(--pine); color: var(--pine-ink); }

/* account & options popover (login, history, new session, theme) */
.menu-wrap { position: relative; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: var(--tap); max-width: 11rem; padding: 0 0.7rem;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-pill); background: transparent; color: var(--ink);
  font-size: 0.86rem; font-weight: 600; cursor: pointer;
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--pine-wash); }
.menu-btn.is-in { border-color: var(--pine); color: var(--pine); }
.menu-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-icon, .menu-caret { flex: none; }
.menu-btn[aria-expanded="true"] .menu-caret { transform: rotate(180deg); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 30; width: 20rem; max-height: calc(100dvh - 5rem); overflow: auto;
  background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  box-shadow: var(--frame-shadow);
}
.pop-sec { padding: 0.95rem 1rem; }
.pop-sec + .pop-sec { border-top: 1px solid var(--rule); }
.pop-heading { font-size: 1rem; font-weight: 700; line-height: 1.3; }
.pop-title { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 0.4rem; }
.pop-hint { margin: 0.15rem 0 0; font-size: 0.82rem; line-height: 1.45; color: var(--ink-2); }
.pop-heading + .pop-hint { margin-bottom: 0.8rem; }
.pop-icon { flex: none; }
.pop-error { display: flex; align-items: flex-start; gap: 0.4rem; margin: 0; font-size: 0.84rem; line-height: 1.4; color: var(--alert); }
.pop-error .pop-icon { width: 16px; height: 16px; margin-top: 0.1rem; }
.pop-form { display: flex; flex-direction: column; gap: 0.7rem; }
.pop-field { display: flex; flex-direction: column; gap: 0.25rem; }
.pop-field label { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
.pop-field input {
  width: 100%; min-height: var(--tap); padding: 0 0.75rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm);
  background: var(--sheet); color: var(--ink); font-weight: 400; font-size: 0.95rem;
}
.pop-field input:focus-visible { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px var(--pine-wash); }
.pop-note { font-size: 0.76rem; color: var(--ink-3); }
.pop-pw { position: relative; }
.pop-pw input { padding-right: 2.9rem; }
.pop-eye {
  position: absolute; top: 0; right: 0; width: 2.75rem; height: 100%; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.pop-eye:hover, .pop-eye[aria-pressed="true"] { color: var(--pine); }
.pop-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 1rem;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: transparent; color: var(--ink);
  font-weight: 600; font-size: 0.92rem; text-decoration: none; cursor: pointer;
}
.pop-btn.is-primary { background: var(--pine); border-color: var(--pine); color: var(--pine-ink); }
.pop-btn.is-primary:hover { filter: brightness(1.06); }
.pop-btn:disabled { opacity: 0.6; cursor: default; }
.pop-wide { display: flex; width: 100%; margin-top: 0.85rem; }
.pop-link { border: 0; background: transparent; padding: 0.2rem 0; color: var(--pine); font: inherit; font-weight: 600; cursor: pointer; }
.pop-link:hover { text-decoration: underline; }
.pop-switch { margin: 0.75rem 0 0; text-align: center; font-size: 0.85rem; color: var(--ink-2); }
.pop-back {
  display: inline-flex; align-items: center; gap: 0.2rem; margin: -0.3rem 0 0.5rem -0.35rem; padding: 0.25rem 0.4rem 0.25rem 0.15rem;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.pop-back:hover { background: var(--pine-wash); color: var(--ink); }
.pop-back .pop-icon { width: 16px; height: 16px; }
.pop-account { display: flex; align-items: center; gap: 0.75rem; }
.pop-account > div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pop-account strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-sub { font-size: 0.82rem; color: var(--ink-2); }
.pop-avatar {
  flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%;
  background: var(--pine-wash); color: var(--pine); font-weight: 700;
}
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: transparent; min-height: 2.15rem; padding: 0 0.6rem; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--pine); color: var(--pine-ink); }
.seg button:hover:not([aria-pressed="true"]) { background: var(--pine-wash); }
/* option rows: icon, label, control; the hover background reaches past the text so the icons line up with the section */
.pop-opts { display: flex; flex-direction: column; gap: 0.15rem; padding-top: 0.55rem; padding-bottom: 0.55rem; }
.pop-row {
  display: flex; align-items: center; gap: 0.7rem; width: calc(100% + 1rem); min-height: var(--tap); margin: 0 -0.5rem; padding: 0 0.5rem;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font-size: 0.92rem; text-align: left;
}
.pop-row > span { flex: 1; }
.pop-row .pop-icon { color: var(--ink-2); }
.pop-row .seg { flex: none; width: 7.6rem; }
button.pop-row { cursor: pointer; font-weight: 500; }
button.pop-row:hover { background: var(--pine-wash); }
.pop-row.is-armed { color: var(--alert); font-weight: 600; }
.pop-row.is-armed .pop-icon { color: var(--alert); }
.pop-history { list-style: none; margin: 0 -0.5rem; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; max-height: 15rem; overflow: auto; }
.pop-history button {
  display: flex; flex-direction: column; gap: 0.1rem; width: 100%; text-align: left; padding: 0.45rem 0.5rem; border: 0;
  border-radius: var(--radius-sm); background: transparent; color: var(--ink); cursor: pointer;
}
.pop-history button:hover, .pop-history button[aria-current="true"] { background: var(--pine-wash); }
.h-when { font-size: 0.76rem; color: var(--ink-2); }
.h-when em { font-style: normal; color: var(--pine); font-weight: 600; }
.h-what { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


/* ------------------------------------------------------------------- thread */
.consult { flex: 1; width: 100%; padding: 1.25rem 1rem 0.5rem; }
/* the conversation sits in its own frame, separated from the page background; it grows with the conversation */
.thread {
  max-width: var(--col);
  margin: 0 auto;
  padding: 1.5rem 1.4rem 1.4rem;
  display: flex; flex-direction: column; gap: 1.15rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--frame-shadow);
}
.msg { max-width: 100%; scroll-margin-top: 7.5rem; }
.msg-text { overflow-wrap: anywhere; }
.msg-text p { margin: 0 0 0.6rem; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-text ul { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }
.msg-text a { font-weight: 600; }

/* the consultant: avatar on the left (only on the first of consecutive messages), text in a soft bubble;
   the profile and the decision sheet take the whole width of the column */
.msg-expert { align-self: flex-start; width: 100%; display: grid; grid-template-columns: 2.1rem minmax(0, 1fr); column-gap: 0.65rem; }
.msg-avatar {
  width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--sheet); border: 1px solid var(--rule);
}
.msg-avatar img { width: 72%; height: 72%; object-fit: contain; }
.msg-expert + .msg-expert .msg-avatar { visibility: hidden; }
.msg-body { min-width: 0; }
.msg-expert .msg-text {
  font-size: 1rem; width: fit-content; max-width: 40rem;
  background: var(--paper); padding: 0.6rem 0.95rem; border-radius: 4px 14px 14px 14px;
}
.msg-user { align-self: flex-end; max-width: min(34rem, 85%); }
.msg-user .msg-text {
  background: var(--pine); color: var(--pine-ink);
  padding: 0.55rem 0.85rem;
  border-radius: 14px 14px 4px 14px;
}
.msg-time { font-size: 0.72rem; color: var(--ink-3); margin-top: 0.25rem; }
.msg-user .msg-time { text-align: right; }
.msg-error .msg-text { color: var(--alert); background: var(--alert-wash); }
.msg-success .msg-text { border-left: 3px solid var(--pine); }

.thinking { padding-top: 0.45rem; color: var(--ink-3); font-size: 0.92rem; display: inline-flex; gap: 0.5rem; align-items: center; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); display: inline-block; animation: pulse 1.2s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: 0.2s; }
.thinking i:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ------------------------------------------------------------ welcome screen */
.welcome { display: flex; flex-direction: column; align-items: flex-start; padding: 0.6rem 0.4rem 0.3rem; }
.w-mark {
  display: grid; place-items: center; width: 3.4rem; height: 3.4rem; border-radius: 16px;
  background: var(--pine-wash); color: var(--pine); margin-bottom: 1rem;
}
.w-title { font-size: 1.55rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; max-width: 38rem; }
.w-lead { margin: 0.6rem 0 1.3rem; color: var(--ink-2); max-width: 36rem; }
.w-steps { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; width: 100%; }
.w-steps li {
  display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.85rem 0.9rem;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
}
.w-steps strong { display: block; font-size: 0.93rem; line-height: 1.35; }
.w-steps small { display: block; margin-top: 0.2rem; font-size: 0.8rem; line-height: 1.4; color: var(--ink-2); }
.w-num {
  flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--pine); color: var(--pine-ink); font-size: 0.8rem; font-weight: 700;
}
.w-start { gap: 0.5rem; }
.w-note { display: flex; align-items: flex-start; gap: 0.45rem; margin: 1.1rem 0 0; font-size: 0.82rem; color: var(--ink-3); max-width: 36rem; }
.w-note svg { flex: none; margin-top: 0.15rem; color: var(--pine); }

/* ------------------------------------------------------------- summary card */
.sheet {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-top: 0.75rem;
  overflow-wrap: anywhere;
}
.summary { padding: 1rem 1.1rem 1.05rem; max-width: 40rem; }
.summary h2 { margin: 0 0 0.6rem; font-size: 1rem; font-weight: 600; }
.summary dl { margin: 0; display: grid; grid-template-columns: minmax(8rem, 34%) 1fr; }
.summary dt, .summary dd { margin: 0; padding: 0.45rem 0; border-top: 1px solid var(--rule); font-size: 0.92rem; }
.summary dt { color: var(--ink-2); padding-right: 0.8rem; }
.summary-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.5rem; padding: 0.45rem 1rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 0.92rem; text-decoration: none; cursor: pointer;
}
.btn-primary:hover:not([disabled]) { filter: brightness(1.08); }
.btn-ghost:hover:not([disabled]) { background: var(--pine-wash); }
.btn-primary { background: var(--pine); color: var(--pine-ink); }
.btn-ghost { background: transparent; border-color: var(--rule-strong); color: var(--ink); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-lg { min-height: 3rem; padding: 0.6rem 1.4rem; font-size: 1rem; border-radius: var(--radius); }
.summary.is-answered .summary-actions { display: none; }

/* ------------------------------------------------------- the decision sheet */
.decision { overflow: hidden; scroll-margin-top: 5rem; }   /* shown from its top, under the sticky top bar */
.decision-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.3rem 1rem;
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 2px solid var(--pine);
}
.decision-head h2 { margin: 0; font-size: 1.18rem; font-weight: 700; letter-spacing: -0.005em; }
.decision-patient { font-size: 0.88rem; color: var(--ink-2); }
.decision-version { font-size: 0.78rem; color: var(--pine); font-weight: 600; }

.decision-hero {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.9rem 1.2rem;
  margin: 0.9rem 1.15rem 0.3rem; padding: 1rem 1.1rem;
  background: var(--pine-wash); border: 1px solid var(--pine); border-radius: var(--radius);
}
.decision-hero.is-urgent { background: var(--alert-wash); border-color: var(--alert); }
.hero-text { min-width: 0; flex: 1 1 18rem; }
.hero-kicker { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--pine); }
.decision-hero.is-urgent .hero-kicker { color: var(--alert); }
.hero-name { margin-top: 0.15rem; font-size: 1.18rem; font-weight: 700; line-height: 1.3; }
.hero-dept { margin-top: 0.2rem; font-size: 0.86rem; color: var(--ink-2); }
.hero-price { margin-top: 0.35rem; font-size: 0.92rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hero-price strong { color: var(--ink); font-size: 1.02rem; }
.hero-cta { flex: none; }

.criteria { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.criteria th, .criteria td { text-align: left; vertical-align: top; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--rule); }
.criteria th { width: 24%; font-weight: 600; padding-left: 1.15rem; }
.criteria td.finding { width: 30%; color: var(--ink-2); }
.criteria td.verdict { padding-right: 1.15rem; position: relative; padding-left: 1.6rem; }
.criteria td.verdict::before {
  content: ""; position: absolute; left: 0.75rem; top: 0.95rem;
  width: 0.45rem; height: 0.45rem; border-radius: 50%;
  background: var(--rule-strong);
}
.criteria tr.tone-key td.verdict { font-weight: 600; }
.criteria tr.tone-key td.verdict::before { background: var(--pine); }
.criteria tr.tone-ok td.verdict::before { background: transparent; border: 1.5px solid var(--pine); }
.criteria tr.tone-na td { color: var(--ink-3); }

.decision-section { padding: 0.95rem 1.15rem 0.2rem; }
.decision-section h3 { margin: 0 0 0.55rem; font-size: 0.95rem; font-weight: 700; }
.order { padding: 0.75rem 0 0.95rem; border-top: 1px solid var(--rule); }
.order:first-of-type { border-top: 0; padding-top: 0.2rem; }
.order-name { font-weight: 600; font-size: 1.02rem; line-height: 1.35; }
.order-group {
  display: inline-block; margin-left: 0.35rem; padding: 0.05rem 0.5rem; border-radius: var(--radius-pill);
  background: var(--pine-wash); color: var(--pine); font-size: 0.72rem; font-weight: 600; vertical-align: 0.12em; white-space: nowrap;
}
.order-dept { font-size: 0.85rem; color: var(--ink-2); margin-top: 0.1rem; }
.order-why { margin: 0.4rem 0 0.55rem; font-size: 0.92rem; }
.order-reasons { margin: 0.45rem 0 0.4rem; font-size: 0.92rem; }
.order-label { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); text-transform: none; margin-bottom: 0.2rem; }
.order-reasons ul { margin: 0; padding-left: 1.15rem; }
.order-reasons li { margin-bottom: 0.25rem; line-height: 1.45; }
.order-reasons li::marker { color: var(--pine); }
.order-purpose { margin: 0.35rem 0 0.55rem; font-size: 0.9rem; color: var(--ink-2); }
.order-purpose strong { color: var(--ink); font-weight: 600; }
.order details { font-size: 0.88rem; color: var(--ink-2); margin-bottom: 0.65rem; }
.order summary { cursor: pointer; color: var(--pine); font-weight: 600; }
.order details ul { margin: 0.45rem 0 0.4rem; padding-left: 1.1rem; }
.order details li { margin-bottom: 0.2rem; }
.order details li strong { color: var(--ink); font-weight: 600; }
.order-prep { margin: 0.3rem 0 0; }
.order-price { margin: 0 0 0.55rem; font-size: 0.92rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.order-price strong { color: var(--ink); font-weight: 600; }
.order details ul.order-items { list-style: none; padding-left: 0; margin: 0.2rem 0 0.5rem; }
.order details .item-group ul.order-items { padding-left: 1rem; }   /* the tests indented under their section */
/* the tests under section titles, as in the admin console */
.item-group-title {
  margin-top: 0.7rem; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2);
}
.order-items li { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem;
  padding: 0.3rem 0; border-top: 1px solid var(--rule); margin: 0; }
.order-items li:first-child { border-top: 0; }
.item-name { min-width: 0; }
.item-why { display: block; font-size: 0.8rem; color: var(--ink-3); }
.item-price { flex: none; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.order-removed summary { cursor: pointer; }

.excluded { list-style: none; margin: 0; padding: 0 0 0.6rem; }
.excluded li { display: grid; grid-template-columns: minmax(9rem, 36%) 1fr; gap: 0.8rem; padding: 0.42rem 0; border-top: 1px solid var(--rule); font-size: 0.88rem; }
.excluded li:first-child { border-top: 0; }
.excluded .ex-name { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.excluded .ex-why { color: var(--ink-2); }

.advice { margin: 0 0 0.6rem; padding-left: 1.1rem; font-size: 0.9rem; }
.advice li { margin-bottom: 0.25rem; }

.decision-empty { margin: 0 0 0.75rem; padding: 0.6rem 0.8rem; background: var(--pine-wash); border-radius: 8px; font-size: 0.9rem; }
.decision-note { margin: 0 1.15rem; padding: 0.6rem 0.8rem; background: var(--pine-wash); border-radius: 8px; font-size: 0.86rem; }
.decision-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.6rem 1rem;
  padding: 0.85rem 1.15rem 1rem; margin-top: 0.6rem;
  border-top: 1px solid var(--rule);
  font-size: 0.84rem; color: var(--ink-2);
}


/* ----------------------------------------------------------------- composer */
.composer-wrap {
  position: sticky; bottom: 0;
  background: linear-gradient(to bottom, transparent, var(--paper) 22%);
  padding: 0.9rem 1rem max(0.7rem, env(safe-area-inset-bottom));
}
/* steps answered with buttons: no text box, so no empty band over the end of the conversation */
.composer-wrap.is-empty { padding: 0 0 env(safe-area-inset-bottom); background: none; }
.composer {
  max-width: var(--col); margin: 0 auto;
  display: flex; align-items: flex-end; gap: 0.5rem;
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  padding: 0.4rem 0.4rem 0.4rem 0.85rem;
}
.composer:focus-within { border-color: var(--pine); box-shadow: 0 0 0 3px var(--pine-wash); }
.composer[hidden] { display: none; }

/* answer panel: buttons of the current question, inside the conversation under the question */
.answer-panel { align-self: stretch; margin-top: -0.35rem; margin-left: 2.75rem; }
.answer-panel[hidden] { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  border: 1.5px solid var(--pine); color: var(--pine); background: var(--sheet);
  padding: 0.4rem 0.9rem; min-height: var(--tap); border-radius: var(--radius-pill);
  font-size: 0.94rem; font-weight: 500; text-align: left; cursor: pointer;
  min-height: 2.75rem; transition: background-color 0.15s ease, transform 0.1s ease;
}
.chip:hover { background: var(--pine-wash); }
.chip:active { transform: scale(0.98); }
.chip[aria-pressed="true"] { background: var(--pine); color: var(--pine-ink); }
.panel-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem; }
.panel-options { flex: 1; min-width: 0; }
.panel-go { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; }
.fields { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; color: var(--ink-2); }
.field-box {
  display: flex; align-items: center; gap: 0.4rem;
  border: 1.5px solid var(--rule-strong); border-radius: 10px; background: var(--sheet); padding: 0 0.75rem;
}
.field-box:focus-within { border-color: var(--pine); box-shadow: 0 0 0 3px var(--pine-wash); }
.field-box:has(input[aria-invalid="true"]) { border-color: var(--alert); }
.field-box input { width: 6em; border: 0; outline: none; background: transparent; padding: 0.5rem 0; font-size: 1rem; color: var(--ink); }
.field-box small { color: var(--ink-3); font-size: 0.86rem; }
.field-err { color: var(--alert); font-size: 0.86rem; margin-top: 0.4rem; min-height: 0; }
.field-err:empty { display: none; }
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; background: transparent;
  padding: 0.45rem 0; max-height: 9rem; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--ink-3); }
.send-btn {
  flex: none; border: 0; border-radius: var(--radius-sm); background: var(--pine); color: var(--pine-ink);
  font-weight: 600; min-height: var(--tap); padding: 0 1.05rem; cursor: pointer;
}
.send-btn:disabled { opacity: 0.5; cursor: default; }

/* ------------------------------------------------------- computer: split screen */
/* phones and tablets: the wrappers add no box, the page stays exactly as before and the photos are not loaded */
.split, .chat-col { display: contents; }
.showcase, .chat-head { display: none; }
@media (min-width: 1100px) {
  :root { --split-max: 100rem; }
  /* two panels exactly as tall as the screen under the top bar: only the conversation scrolls */
  body { height: 100vh; height: 100dvh; }
  .topbar-inner { max-width: var(--split-max); padding-left: 1.5rem; padding-right: 1.5rem; }
  .split {
    display: grid; flex: 1; min-height: 0; width: 100%; max-width: var(--split-max); margin: 0 auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 1.5rem;
    padding: 1.25rem 1.5rem 1.5rem;
  }

  /* left: the hospital's photos, a fixed title on top, two feature cards at the bottom */
  .showcase {
    display: block; position: relative; height: 100%; min-height: 0;
    border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--frame-shadow); background: #0d1a16;
  }
  .slides, .slide { position: absolute; inset: 0; margin: 0; }
  .slide { opacity: 0; transition: opacity 0.6s ease; }
  .slide.is-active { opacity: 1; }
  .slide img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
  /* the darkness of the overlay set in the admin console ("Độ mờ", 0-80 %) */
  .slides::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, var(--slide-dim, 0)); pointer-events: none; }
  /* one photo: nothing to switch; none: the panel keeps the title and the cards on the hospital green */
  .showcase[data-count="0"] .slider-side, .showcase[data-count="0"] .slider-bar, .showcase[data-count="0"] .slider-credit,
  .showcase[data-count="1"] .slider-side, .showcase[data-count="1"] .slider-bar { display: none; }
  .showcase[data-count="0"] { background: linear-gradient(160deg, #0b5a4c, #06231d); }
  .slide img[src$="/hospital-3.jpg"] { object-position: 30% center; }   /* the nurse on the left stays in the frame */
  /* shades over the photos (z-index: above the slides, under the title / cards / controls that come later) */
  .showcase::before, .showcase::after { content: ""; position: absolute; z-index: 1; left: 0; right: 0; pointer-events: none; }
  .showcase::before { top: 0; height: 58%; background: linear-gradient(to bottom, rgba(6, 18, 15, 0.86), rgba(6, 18, 15, 0.62) 45%, transparent); }
  .showcase::after { bottom: 0; height: 40%; background: linear-gradient(to top, rgba(6, 18, 15, 0.72), transparent); }
  .showcase-head { position: absolute; z-index: 2; top: 0; left: 0; right: 0; padding: 2.2rem 2.4rem 0; color: #fff; }
  .showcase-head h2 {
    font-size: clamp(1.9rem, 2.9vw, 2.9rem); font-weight: 800; line-height: 1.1; letter-spacing: 0.01em; text-transform: uppercase;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }
  .showcase-head h2::after { content: ""; display: block; width: 4.5rem; height: 4px; margin-top: 1rem; border-radius: 2px; background: #5cc2ab; }
  .showcase-head p { margin: 0.9rem 0 0; max-width: 30rem; font-size: 1rem; line-height: 1.5; color: rgba(255, 255, 255, 0.92); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
  .showcase-features {
    position: absolute; z-index: 2; left: 2.4rem; bottom: 4rem; margin: 0; padding: 0; list-style: none;
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.7rem; max-width: calc(100% - 4.8rem);
  }
  .showcase-features li {
    display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 1rem 0.7rem 0.75rem;
    border-radius: var(--radius); border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(10, 24, 20, 0.55); backdrop-filter: blur(8px); color: #fff;
  }
  .feat-icon {
    flex: none; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 10px;
    background: rgba(92, 194, 171, 0.18); color: #7fd8c4;
  }
  .showcase-features strong { display: block; font-size: 0.98rem; line-height: 1.3; }
  .showcase-features small { display: block; font-size: 0.82rem; line-height: 1.35; color: rgba(255, 255, 255, 0.78); }
  .slider-btn {
    display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(6, 18, 15, 0.35); backdrop-filter: blur(4px);
  }
  .slider-btn:hover { background: rgba(255, 255, 255, 0.22); }
  .slider-side { position: absolute; z-index: 3; top: 50%; width: 2.5rem; height: 2.5rem; transform: translateY(-50%); opacity: 0.75; }
  .slider-side.is-prev { left: 0.9rem; }
  .slider-side.is-next { right: 0.9rem; }
  .showcase:hover .slider-side, .slider-side:focus-visible { opacity: 1; }
  .slider-bar {
    position: absolute; z-index: 3; left: 50%; bottom: 1.3rem; transform: translateX(-50%);
    display: flex; align-items: center; padding: 0.55rem 0.75rem;
    border-radius: var(--radius-pill); background: rgba(6, 18, 15, 0.45); backdrop-filter: blur(4px);
  }
  .slider-dots { display: flex; gap: 0.35rem; }
  .slider-dot {
    position: relative; width: 0.55rem; height: 0.55rem; padding: 0; border-radius: var(--radius-pill); cursor: pointer;
    border: 0; background: rgba(255, 255, 255, 0.5); transition: width 0.3s ease, background-color 0.3s ease;
  }
  .slider-dot[aria-current="true"] { width: 1.5rem; background: #fff; }
  .slider-dot::after { content: ""; position: absolute; inset: -0.6rem -0.2rem; }   /* a bigger target than the dot */
  .showcase :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
  .slider-credit {
    position: absolute; z-index: 2; right: 1.4rem; bottom: 1.45rem; margin: 0;
    font-size: 0.72rem; color: rgba(255, 255, 255, 0.72); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  }

  /* right: the chat in its own panel (header, conversation scrolling inside, text box at the bottom) */
  .chat-col {
    display: flex; flex-direction: column; min-width: 0; height: 100%; min-height: 0; overflow: hidden;
    background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--frame-shadow);
  }
  .chat-head {
    flex: none; display: flex; align-items: center; gap: 0.8rem; padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--rule);
  }
  .chat-head-logo { flex: none; width: 2.5rem; height: 2.5rem; padding: 0.3rem; border-radius: 50%; border: 1px solid var(--rule); background: var(--sheet); object-fit: contain; }
  .chat-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .chat-head-text strong { font-size: 1.05rem; line-height: 1.3; }
  .chat-head-text span { font-size: 0.82rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* position: relative keeps the screen-reader-only announcer inside the panel (it would lengthen the page) */
  .chat-col .consult { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0; }
  .chat-col .thread { border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: 1.25rem 1.4rem 1.2rem; }
  .chat-col .msg, .chat-col .decision { scroll-margin-top: 1rem; }
  .chat-col .composer-wrap { position: static; flex: none; background: var(--sheet); border-top: 1px solid var(--rule); padding: 0.8rem 1.1rem 0.9rem; }
  .chat-col .composer-wrap.is-empty { padding: 0; border-top: 0; }
  /* the narrower chat panel: the welcome steps one under the other */
  .thread { container-type: inline-size; }
}
/* a low window: the page scrolls rather than squeezing the two panels */
@media (min-width: 1100px) and (max-height: 640px) {
  body { height: auto; }
  .split { height: 40rem; flex: none; }
}
@container (max-width: 40rem) {
  .w-steps { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------- mobile */
@media (max-width: 640px) {
  .consult { padding: 0.75rem 0.5rem 0.4rem; }
  .thread { padding: 1.1rem 0.9rem 1rem; border-radius: 12px; }
  .brand-title-long { display: none; }
  /* "Smart Medical Oncology" on two lines rather than cut */
  .brand-title { white-space: normal; }
  .brand-title-short {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
    font-size: 0.84rem; line-height: 1.2;
  }
  .msg-expert { grid-template-columns: 1.75rem minmax(0, 1fr); column-gap: 0.5rem; }
  .msg-avatar { width: 1.75rem; height: 1.75rem; }
  .answer-panel { margin-left: 2.25rem; }
  .welcome { padding: 0.2rem 0 0; }
  .w-title { font-size: 1.3rem; }
  .w-steps { grid-template-columns: 1fr; gap: 0.5rem; }
  .w-start { align-self: stretch; }
  .decision-hero { margin: 0.75rem 0.75rem 0.2rem; padding: 0.85rem 0.9rem; }
  .hero-cta { flex: 1 1 100%; }
  .topbar-inner { padding: 0.55rem 1rem; gap: 0.6rem; }
  .brand { gap: 0.55rem; }
  .brand-mark { width: 2.1rem; height: 2.1rem; }
  .brand-title { font-size: 0.92rem; }
  .brand-sub { display: none; }
  .topbar-actions { gap: 0.35rem; }
  .menu-btn { max-width: 9.5rem; padding: 0 0.6rem; }
  .menu-caret { display: none; }
  .menu-pop { position: fixed; left: 0.75rem; right: 0.75rem; top: 3.6rem; width: auto; max-height: calc(100dvh - 4.4rem); }
  .chips { gap: 0.45rem; }
  .chip { font-size: 0.92rem; padding: 0.35rem 0.85rem; }
  /* narrow screens: options take the full width, "Tiếp tục" stays bottom-right on the line below */
  .panel-main { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .panel-go { align-self: flex-end; }
  .criteria, .criteria tbody, .criteria tr, .criteria th, .criteria td,
  .criteria td.finding, .criteria td.verdict { display: block; width: 100%; }
  .criteria tr { padding: 0.55rem 1rem 0.6rem; border-bottom: 1px solid var(--rule); }
  .criteria th, .criteria td { border: 0; padding: 0.08rem 0; }
  .criteria th { padding-left: 0; }
  .criteria td.verdict { padding-left: 1rem; }
  .criteria td.verdict::before { left: 0; top: 0.5rem; }
  .excluded li { grid-template-columns: 1fr; gap: 0.1rem; }
  .summary dl { grid-template-columns: 1fr; }
  .summary dt { border-top: 1px solid var(--rule); padding-bottom: 0; }
  .summary dd { border-top: 0; padding-top: 0.1rem; }
}
/* narrow phones: tighter controls, so "Smart Medical Oncology" keeps its two lines */
@media (max-width: 420px) {
  .topbar-inner { padding-left: 0.8rem; padding-right: 0.8rem; }
  .lang-btn { min-width: 1.9rem; padding: 0 0.35rem; }
  .menu-btn { gap: 0.3rem; padding: 0 0.55rem; }
}
/* very narrow phones: the title gives way to the controls */
@media (max-width: 380px) {
  .brand-text { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .thinking i { animation: none; opacity: 0.6; }
  .chip, .slide, .slider-dot { transition: none; }
  .chip:active { transform: none; }
}

/* ------------------------------------------------------------------- print: the decision sheet on paper */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; display: block; }
  .topbar, .composer-wrap, .answer-panel, .msg-user, .msg-time, .thinking, .decision-foot, .hero-cta, .msg-avatar { display: none !important; }
  .msg-expert { display: block; }
  .consult { padding: 0; }
  .showcase, .chat-head { display: none !important; }
  body { height: auto; }
  .split, .chat-col { display: block; padding: 0; height: auto; border: 0; box-shadow: none; overflow: visible; }
  .chat-col .consult { overflow: visible; }
  .thread { border: 0; box-shadow: none; padding: 0; min-height: 0; max-width: none; gap: 0.6rem; }
  /* only the latest decision sheet (and the message that carries it) */
  .msg-expert:not(:has(.decision)) { display: none; }
  .msg-expert:has(.decision):has(~ .msg-expert .decision) { display: none; }   /* an older sheet replaced by an update */
  .msg-expert:has(.decision) .msg-body > .msg-text { display: none; }                       /* the chat line above the sheet */
  .sheet { background: #fff; border-color: #999; }
  .order, .criteria tr, .excluded li { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}
