/* #region zone:health.dash.style — การ์ดภาพรวม กราฟ ท่าออกกำลัง หน้าต่างบันทึก และผลลัพธ์ */
:root {
  --chart-1: #1a56bd;
  --chart-2: #b45309;
  --chart-3: #6d4bd1;
  --band-low: #dce9f9;
  --band-normal: #dcf1e6;
  --band-risk: #fbecc8;
  --band-high: #f8d9d4;
}
:root[data-theme='dark'] {
  --chart-1: #6ea2f5;
  --chart-2: #cc7a30;
  --chart-3: #9078e0;
  --band-low: #1c3550;
  --band-normal: #17392e;
  --band-risk: #4a3a14;
  --band-high: #4d2420;
}
/* layout follows the width of the page column (container query), so the sidebar never breaks a grid */
.grid {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
}
.card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--sp-6);
  box-shadow: var(--card-shadow);
}
.card > h2 {
  font-size: 19px;
  font-weight: 700;
}
.card h2,
.card h3,
.card p {
  margin: 0;
}
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}
.card-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 0;
}
/* under a full-width clip tile the next step is full width too, so the two line up */
.clip-with-tv + .card-foot .btn-link {
  flex: 1 1 auto;
}
.stat {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-1) var(--sp-2);
}
.stat-num {
  font-size: 44px;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-unit {
  font-size: var(--u-text-lg);
  color: var(--muted);
}
.stat-note {
  flex-basis: 100%;
  font-size: 15px;
  color: var(--muted);
}
.sentence {
  padding: var(--sp-3) var(--sp-4);
  background: var(--health-sky);
  color: var(--health-sky-text);
  border-radius: var(--r-control);
  font-size: var(--u-body);
}
.sentence:empty {
  display: none;
}
.segmented {
  display: flex;
}
.segmented button {
  flex: 1 1 0;
  min-width: 0;
}

.empty {
  display: grid;
  justify-items: start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px dashed var(--line);
  border-radius: var(--r-inner);
  background: var(--panel2);
}
.loading {
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-2) 0;
}
.skeleton-card {
  padding: var(--sp-6);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}
.skeleton-lines {
  display: grid;
  gap: var(--sp-3);
}
.skeleton-line {
  display: block;
  height: 14px;
  border-radius: var(--r-pill);
  background: linear-gradient(100deg, var(--hover) 30%, var(--line) 50%, var(--hover) 70%) 0 0 / 200% 100%;
  animation: skeleton 1.4s linear infinite;
}
.skeleton-line:first-child {
  width: 40%;
  height: 18px;
}
.skeleton-line:nth-child(2) {
  width: 92%;
}
.skeleton-line:nth-child(3) {
  width: 70%;
}
.bar {
  height: 12px;
  border-radius: var(--r-pill);
  background: var(--panel2);
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  background: var(--accent-grad);
  border-radius: var(--r-pill);
}
.pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}
.pair strong {
  font-size: 22px;
}
.ring {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}
.ring-track {
  fill: none;
  stroke: var(--line);
  stroke-width: 9;
}
.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
}
.ring-text {
  fill: var(--text);
  font-size: 18px;
  font-weight: 700;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-5);
  margin: 0;
  padding: 0;
  list-style: none;
}
.swatch {
  font-size: 16px;
}
.swatch--0 {
  color: var(--chart-1);
}
.swatch--1 {
  color: var(--chart-2);
}
.swatch--2 {
  color: var(--chart-3);
}
/* charts */
.chart {
  position: relative;
  width: 100%;
  min-height: 220px;
}
.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-svg text {
  font-family: inherit;
  font-size: 16px;
}
.band--low {
  fill: var(--band-low);
}
.band--normal {
  fill: var(--band-normal);
}
.band--risk {
  fill: var(--band-risk);
}
.band--high {
  fill: var(--band-high);
}
.band-label,
.point-label {
  fill: var(--text);
  font-weight: 600;
}
.point-label {
  pointer-events: none;
}
.tick {
  fill: var(--muted);
}
.gridline {
  stroke: var(--line);
  stroke-width: 1;
}
.ref {
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}
.ref-label {
  fill: var(--muted);
}
.line {
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.line--0 {
  stroke: var(--chart-1);
}
.line--1 {
  stroke: var(--chart-2);
}
.line--2 {
  stroke: var(--chart-3);
}
.dot {
  stroke: var(--chart-surface, var(--panel));
  stroke-width: 2;
}
.dot--dense {
  stroke-width: 1;
}
.dot--0 {
  fill: var(--chart-1);
}
.dot--1 {
  fill: var(--chart-2);
}
.dot--2 {
  fill: var(--chart-3);
}
.dot-ring {
  fill: none;
  stroke: var(--text);
  stroke-width: 2;
  pointer-events: none;
}
.chart-svg.has-bands .line--0 {
  stroke: var(--accent-text);
}
.chart-svg.has-bands .dot--0 {
  fill: var(--accent-text);
}
.chart-svg.has-bands .dot--low {
  fill: var(--accent-text);
}
.chart-svg.has-bands .dot--normal {
  fill: var(--ok-text);
}
.chart-svg.has-bands .dot--risk {
  fill: var(--warn-text);
}
.chart-svg.has-bands .dot--high {
  fill: var(--danger-text);
}
.chart-start-note {
  color: var(--chart-note, var(--muted));
  font-size: 15px;
  padding: var(--sp-2);
}
.chart-tip {
  position: absolute;
  padding: var(--sp-1) var(--sp-3);
  background: var(--text);
  color: var(--panel);
  border-radius: var(--r-control);
  font-size: 15px;
  white-space: normal;
  overflow: hidden;
  pointer-events: none;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table caption {
  text-align: left;
  font-weight: 600;
  padding-bottom: var(--sp-2);
}
.data-table th,
.data-table td {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
}
/* clip pictures and the round play mark (tile layout lives in health-modes.css) */
.clip img,
.video-poster img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--hover);
}
.clip-play {
  position: absolute;
  top: calc(50% - 50px);
  left: 50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #1a56bd;
  box-shadow: 0 4px 14px rgba(19, 26, 36, 0.28);
  transition: transform var(--dur-base) var(--ease-out);
}
.clip:hover .clip-play,
.video-poster:hover .clip-play {
  transform: scale(1.06);
}
.clip-play .icon {
  fill: currentColor;
  margin-left: 2px;
}
/* exercise */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}
.section-head h2,
.section-tools {
  margin: 0;
}
.section-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.levels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.level {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0;
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  font-size: 22px;
  font-weight: 700;
  color: var(--muted);
}
.level small {
  font-size: 14px;
}
.level[aria-current='step'] {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: var(--accent-glow);
}
.note-card {
  background: var(--health-sky);
  color: var(--health-sky-text);
}
.safety {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin: 0;
  font-size: var(--u-text-lg);
}
.move-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}
.badge {
  flex-shrink: 0;
  padding: 2px var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--acc-soft);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.count {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-text);
}
.steps {
  margin: 0;
  padding-left: var(--sp-6);
}
.move-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: auto;
}
.move-actions button {
  flex: 1 1 140px;
}
/* record dialogs */
#modal {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
#modal.is-wide {
  width: min(820px, calc(100% - 32px));
}
#modal .dialog-heading {
  margin-bottom: var(--sp-4);
}
.rec-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-5);
}
.rec-form p {
  margin: 0;
}
.rec-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-2);
}
.big-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.big-input {
  flex: 1 1 0;
  min-width: 0;
  min-height: 64px;
  font-size: 32px;
  font-weight: 700;
}
.unit {
  color: var(--muted);
  white-space: nowrap;
}
.chips {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: var(--sp-2);
}
.chip {
  min-width: 0;
  min-height: var(--target);
  padding: 0;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.chip[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 0 0 3px var(--acc-soft);
}
.chip-read {
  font-size: 15px;
}
.wide {
  width: 100%;
}
.or {
  text-align: center;
}
.file-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--panel);
  font-weight: 600;
  cursor: pointer;
}
.file-button:hover {
  background: var(--hover);
}
.photo-pick:focus-within .file-button {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.scale-values {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--sp-2) var(--sp-5);
  margin: 0;
  padding: var(--sp-4);
  background: var(--panel2);
  border-radius: var(--r-inner);
}
.scale-values dt {
  color: var(--muted);
}
.scale-values dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}
.form-error {
  color: var(--danger-text);
  font-weight: 600;
}
.result {
  display: grid;
  gap: var(--sp-4);
  justify-items: center;
  text-align: center;
}
.result p {
  margin: 0;
}
.result-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: var(--on-accent);
  font-size: 32px;
}
.result-head {
  font-size: var(--u-text-2xl);
  font-weight: 700;
}
.result-alert {
  padding: var(--sp-4);
  border: 1px solid var(--danger-text);
  border-radius: var(--r-inner);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-weight: 600;
}
.result .primary {
  width: 100%;
}
.video-ratio {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--r-inner);
  overflow: hidden;
}
.video-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-wrap {
  display: grid;
  gap: var(--sp-4);
}
@container workspace (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 520px) {
  .card {
    padding: var(--sp-5);
  }
  .stat-num {
    font-size: 42px;
  }
  .chart {
    min-height: 200px;
  }
  .chips {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .ring {
    width: 80px;
    height: 80px;
  }
  .segmented button {
    padding-inline: var(--sp-2);
  }
  .section-tools {
    width: 100%;
    justify-content: space-between;
  }
}
/* polish batch: summary, wide glucose card, progress row, moves card, header, dialogs */
.line--avg {
  stroke: var(--text);
}
.line--dashed {
  stroke-dasharray: 7 5;
  stroke-width: 2;
}
.caption {
  font-size: 16px;
}
.trend {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-text);
}
/* A quiet tinted surface keeps the daily summary readable in either theme. */
.summary {
  position: relative;
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
  overflow: hidden;
  background: var(--health-sky);
  color: var(--health-sky-text);
  border-radius: var(--r-card);
  box-shadow: none;
}
.summary p {
  position: relative;
  margin: 0;
  font-size: var(--u-text-xl);
  font-weight: 650;
  line-height: 1.6;
}
.summary-label {
  justify-self: start;
  padding: 2px var(--sp-3);
  border-radius: var(--r-pill);
  background: transparent;
  font-size: 14px;
  font-weight: 650;
}
.progress {
  margin-bottom: var(--sp-6);
}
.progress > h2 {
  margin: var(--sp-2) 0 var(--sp-3);
}
.mini-row {
  display: grid;
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
}
.mini {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
  padding: var(--sp-6);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--card-shadow);
}
.mini h3,
.mini p {
  margin: 0;
}
.mini h3 {
  font-size: 18px;
  font-weight: 700;
}
.mini .stat-num {
  font-size: 36px;
}
.mini .more {
  align-self: flex-end;
  margin-top: 0;
}
.mini-list,
.mini-moves {
  display: grid;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.mini-moves li {
  display: grid;
}
.ring-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.ring-row .ring {
  width: 64px;
  height: 64px;
}
#modal .ring-row .ring {
  width: 96px;
  height: 96px;
}
.bmi {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  color: var(--muted);
}
.info-btn {
  width: var(--target);
  min-width: var(--target);
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
}
.info {
  flex-basis: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--health-sky);
  color: var(--health-sky-text);
  border-radius: var(--r-control);
  font-size: var(--u-text-lg);
}
.duo {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-control);
}
.duo-label {
  font-size: 16px;
  /* --muted on the duo tile's grey is 4.27:1; the body colour clears 4.5:1 in both themes */
  color: var(--text);
}
.duo strong {
  font-size: 22px;
  line-height: 1.3;
}
.duo--streak {
  background: var(--acc-soft);
}
.duo--week {
  background: var(--panel2);
}
/* a link that looks like the secondary button */
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--target);
  padding: 0 var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--panel);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
  transition:
    background var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}
.btn-link:hover {
  background: var(--acc-soft);
  border-color: var(--line-strong);
}
.segmented--scroll {
  min-width: max-content;
}
.segmented--scroll button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.clip img:not(.is-loaded),
.video-poster img:not(.is-loaded) {
  background: linear-gradient(100deg, var(--hover) 30%, var(--line) 50%, var(--hover) 70%) 0 0 / 200% 100%;
  animation: skeleton 1.4s linear infinite;
}
.clip img.is-broken,
.video-poster img.is-broken {
  animation: none;
}
@keyframes skeleton {
  to {
    background-position: -200% 0;
  }
}
.video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
}
.video-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-poster .clip-play {
  top: 50%;
}
.result-mark--warn {
  background: #a85f00;
  color: #fff;
}
:root[data-theme='dark'] .result-mark--warn {
  background: #f0b45e;
  color: #2a1600;
}
.result--warn .result-head {
  color: var(--danger-text);
}
.result-step {
  font-size: var(--u-text-xl);
  font-weight: 700;
  padding: var(--sp-4);
  background: var(--health-sky);
  color: var(--health-sky-text);
  border-radius: var(--r-inner);
}
.grid--pairs {
  grid-template-columns: minmax(0, 1fr);
}
@container workspace (min-width: 640px) {
  .grid--pairs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@container workspace (min-width: 900px) {
  .card--wide {
    grid-column: 1 / -1;
  }
  .mini-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@container workspace (min-width: 700px) {
  .mini-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* #endregion */

/* #region zone:health.edit.styles — รายละเอียดและประวัติใช้พื้นหลังตามทรงการ์ด */
.rec-edit-fields {
  display: grid;
  gap: var(--sp-4);
}
.rec-edit-fields input,
.rec-edit-fields textarea,
#rec-meal-text {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: var(--field);
  font: inherit;
}
.rec-actions {
  display: flex;
  gap: var(--sp-3);
}
.rec-actions > button {
  flex: 1;
  border-radius: 18px;
}
.rec-edit-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.rec-edit-list > li {
  border-radius: 20px;
  overflow: hidden;
}
.rec-edit-list .rec-entry {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  text-align: left;
  border: 0;
  border-radius: inherit;
  background: transparent;
}
.rec-entry:hover,
.rec-entry:focus-visible {
  background: var(--hover);
}
.rec-entry > span {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.rec-entry strong,
.rec-detail-value,
.rec-history {
  overflow-wrap: anywhere;
}
.rec-entry small,
.rec-edited {
  color: var(--muted);
}
.rec-edited {
  font-size: var(--u-text-xs);
  white-space: nowrap;
}
.rec-history {
  border-top: 1px solid var(--line);
  padding-top: var(--sp-4);
}
.rec-history summary {
  cursor: pointer;
  border-radius: 12px;
  padding: var(--sp-2);
}
.rec-history summary:hover {
  background: var(--hover);
}
.rec-history article {
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.rec-delete {
  text-align: center;
}
/* #endregion */
