/* #region zone:health.modes.style — ปุ่มบันทึกด่วน รายการล่าสุด คลิป AI ผู้ช่วย เอกสาร และยา */
.page {
  display: block;
}
/* ---------- quick record + recent entries ---------- */
.quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
@container workspace (min-width: 760px) {
  .quick {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.quick-btn {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    'mark title'
    'mark hint';
  align-items: center;
  column-gap: var(--sp-3);
  row-gap: 0;
  min-height: 84px;
  padding: var(--sp-4);
  border-radius: var(--r-card);
  background: var(--panel);
  box-shadow: var(--card-shadow);
  text-align: left;
}
.quick-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--panel);
  box-shadow: var(--lift-shadow);
  transform: translateY(-2px);
}
.quick-mark {
  grid-area: mark;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-inner);
  background: var(--acc-soft);
  color: var(--accent-text);
  transition:
    background var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
}
.quick-btn:hover .quick-mark {
  background: var(--accent-grad);
  color: var(--on-accent);
}
.quick-btn strong {
  grid-area: title;
  align-self: end;
  font-size: var(--u-text-lg);
  line-height: 1.4;
}
.quick-btn small {
  grid-area: hint;
  align-self: start;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--muted);
}
/* narrow two-column tiles: the icon sits above the words so a Thai title never breaks mid-word */
@container workspace (max-width: 520px) {
  .quick-btn {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'mark'
      'title'
      'hint';
    align-content: start;
    row-gap: var(--sp-1);
  }
  .quick-mark {
    margin-bottom: var(--sp-2);
  }
}
.entries {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}
.entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line);
}
.entry:first-child {
  border-top: 0;
}
.entry-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel2);
  color: var(--muted);
}
.entry--warn .entry-mark {
  background: var(--warn-soft);
  color: var(--warn-text);
}
.entry-text {
  display: grid;
  line-height: 1.4;
}
.entry-text small {
  font-size: 14px;
}
.entry-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* ---------- clips ---------- */
.ask {
  display: grid;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  padding: var(--sp-5);
  border-radius: var(--r-card);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
}
.ask-label {
  font-weight: 650;
}
.ask-row {
  display: flex;
  gap: var(--sp-3);
}
.ask-input {
  flex: 1 1 auto;
  min-width: 0;
}
.ask .hint {
  margin: 0;
  font-size: 14px;
}
/* Search box suggestions: touch-sized rows via --target, one column, never wider than the box. */
.suggest-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.suggest-wrap .ask-input {
  width: 100%;
}
.suggest {
  position: absolute;
  top: calc(100% + var(--sp-2));
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  gap: var(--sp-1);
  max-height: min(60vh, 440px);
  margin: 0;
  padding: var(--sp-2);
  overflow-y: auto;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-inner);
  box-shadow: var(--lift-shadow);
}
.suggest-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--target);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-control);
  font-size: 16px;
  cursor: pointer;
}
.suggest-row:hover,
.suggest-row[aria-selected='true'] {
  background: var(--acc-soft);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.suggest-row:hover:not([aria-selected='true']) {
  outline-color: transparent;
}
.suggest-kind {
  flex: none;
  min-width: 4.5em;
  font-size: var(--u-text-sm);
  font-weight: 650;
  color: var(--accent-text);
}
.suggest-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.suggest-hint {
  flex: none;
  color: var(--muted);
  font-size: var(--u-text-sm);
}
/* Filters: categories always visible, the rest behind one "ตัวเลือก" button. */
.filter-toggle {
  min-height: var(--target);
  margin-bottom: var(--sp-4);
}
.filter-toggle svg {
  transition: transform 0.2s ease;
}
.filter-toggle[aria-expanded='true'] svg {
  transform: rotate(180deg);
}
.filter-extras {
  display: grid;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  padding: var(--sp-4);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
}
.filter-label {
  margin: 0 0 var(--sp-2);
  font-weight: 650;
  font-size: 15px;
}
.filter-group .chip-row {
  margin-bottom: 0;
}
.chip-row--center {
  justify-content: center;
  margin-top: var(--sp-4);
}
.result-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.result-bar p {
  margin: 0;
}
.clear-filters {
  min-height: var(--target);
}
.clip-group {
  margin: var(--sp-6) 0 var(--sp-3);
  font-size: 18px;
}
.clip-group:first-child {
  margin-top: 0;
}
#clip-more {
  display: flex;
  justify-content: center;
  width: min(100%, 320px);
  min-height: var(--target);
  margin: var(--sp-6) auto var(--sp-4);
}
.clip-kind {
  color: var(--muted);
}
.understood {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-4);
  font-size: var(--u-body);
  color: var(--muted);
}
.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: var(--sp-5);
}
/* A clip tile is one card: the picture + title button on top, the "open on the TV" action as its footer.
   Both are full width, so the action always lines up with the tile above it. */
.clip-with-tv {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  box-shadow: var(--card-shadow);
  transition:
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}
.clip-with-tv:hover {
  box-shadow: var(--lift-shadow);
  transform: translateY(-2px);
}
.clip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  align-content: start;
  width: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.clip:hover {
  background: transparent;
}
.clip:focus-visible {
  outline-offset: -3px;
}
.clip > img,
.clip > .clip-play {
  grid-area: 1 / 1;
}
.clip > .clip-play {
  position: static;
  align-self: center;
  justify-self: center;
  margin: 0;
}
.clip-text {
  grid-area: 2 / 1;
  display: grid;
  align-content: start;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
}
.clip-text strong {
  font-size: var(--u-text-lg);
  line-height: 1.45;
}
.clip-text small {
  color: var(--muted);
  font-size: 15px;
  font-weight: 400;
}
.clip-text .badge {
  justify-self: start;
}
.video-tv {
  display: grid;
}
.tv-btn {
  width: 100%;
}
.clip-with-tv .video-tv {
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
}
.clip-with-tv .tv-btn {
  border-color: var(--line);
  background: var(--panel2);
  color: var(--accent-text);
}
.clip-with-tv .tv-btn:hover {
  background: var(--acc-soft);
  border-color: var(--line-strong);
}
.badge-row {
  margin-top: var(--sp-1);
}
.video-wrap p {
  margin: 0;
}
/* Clip details under the player: short label/value rows, then one safety line. */
.clip-details {
  display: grid;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}
.clip-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
}
.clip-facts dt {
  color: var(--muted);
}
.clip-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.video-wrap .clip-safety {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-inner);
  background: var(--acc-soft);
}
.clip-safety svg {
  flex: none;
  margin-top: 2px;
}
/* ---------- AI assist ---------- */
.chat {
  gap: var(--sp-4);
  max-width: 820px;
}
.chat-log {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 120px;
  max-height: 46dvh;
  margin: 0;
  padding: var(--sp-4);
  overflow-y: auto;
  scrollbar-gutter: stable;
  list-style: none;
}
.chat-log:empty {
  display: none;
}
.bubble {
  box-sizing: border-box;
  min-width: 0;
  flex-shrink: 0;
  max-width: 80%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-inner);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.bubble--me {
  align-self: flex-end;
  background: var(--accent);
  color: var(--on-accent);
  border-bottom-right-radius: 4px;
}
.bubble--bot {
  align-self: flex-start;
  white-space: pre-line;
  background: var(--panel2);
  border-bottom-left-radius: 4px;
}
.bubble--error {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.assist-sources {
  margin-top: var(--sp-3);
  font-size: var(--text-sm);
}
.assist-citations {
  margin: var(--sp-1) 0 0;
  padding-left: var(--sp-4);
}
.assist-citations a {
  color: inherit;
}
.prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.prompt {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-size: 14px;
  flex: 0 1 auto;
}
.prompt:disabled {
  opacity: 0.6;
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-3);
}
.chat-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: calc(3em + 28px);
  max-height: 160px;
  resize: vertical;
  line-height: 1.5;
}
.chat-input:disabled {
  background: var(--panel2);
  cursor: not-allowed;
}
.soon-card {
  display: grid;
  justify-items: start;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border-radius: var(--r-inner);
  background: var(--acc-soft);
  color: var(--text);
}
.soon-card p {
  margin: 0;
}
.soon-card .muted {
  color: var(--text);
  opacity: 0.8;
}
.chat > .callout {
  margin: 0;
}
/* ---------- documents ---------- */
.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}
@container workspace (min-width: 900px) {
  .docs-layout {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
}
.doc-list {
  display: grid;
  gap: var(--sp-2);
}
.doc-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3);
  text-align: left;
}
.doc-mark,
.med-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--acc-soft);
  color: var(--accent-text);
}
.doc-text,
.med-text {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}
.doc-preview {
  min-height: 200px;
}
.doc-preview h2 {
  font-size: 18px;
}
/* ---------- medicine ---------- */
.meds {
  gap: 0;
  margin: 0;
  list-style: none;
}
.med {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line);
}
.med:first-child {
  border-top: 0;
}
.stock {
  font-size: 14px;
  font-weight: 650;
}
.stock--low {
  color: var(--warn-text);
}
.stock--out {
  color: var(--danger-text);
}
.stock--ok,
.stock--none {
  color: var(--muted);
}
.time-checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.check-chip {
  position: relative;
  flex-direction: row;
  font-weight: 500;
}
.check-chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  opacity: 0;
  cursor: pointer;
}
.check-chip span {
  display: flex;
  align-items: center;
  min-height: var(--target);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel);
}
.check-chip input:checked + span {
  background: var(--acc-soft);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
}
.check-chip input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
/* ---------- phone ---------- */
@media (max-width: 599px) {
  .prompt-row .prompt {
    flex-basis: calc(50% - var(--sp-2) / 2);
  }
  .ask-row {
    flex-direction: column;
  }
  .ask-row .primary {
    width: 100%;
  }
  .med {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .med .stock {
    grid-column: 2;
    grid-row: 2;
  }
  .composer {
    flex-direction: column;
    align-items: stretch;
  }
}
/* #endregion */

/* #region zone:health.assist.case — สรุปเคสแบบอ่านอย่างเดียว */
.assist-case {
  max-width: 820px;
  margin-bottom: var(--sp-4);
}
.assist-case h2 {
  margin: 0;
  font-size: 1.05rem;
}
.assist-case p {
  margin: 0;
}
.case-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.case-tile {
  display: grid;
  align-content: start;
  gap: var(--sp-1);
  min-width: 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--panel2);
  border-radius: var(--r-inner);
}
.case-tile__label {
  font-size: var(--text-sm);
  color: var(--muted);
}
.case-tile__value {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.case-tile__value small {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
}
.case-tile--empty .case-tile__value {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}
.case-tile__wait {
  width: 70%;
  height: 22px;
}
.assist-wait .skeleton-line:first-child {
  width: 55%;
}
.bubble--typing {
  padding-block: var(--sp-4);
}
.typing {
  display: inline-flex;
  gap: 6px;
}
.typing i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.typing i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}
/* #endregion */
