/* NUT-205: ảnh bữa ăn. Bản mẫu cho apps/pwa/photos.css (nạp sau app.css). Chỉ token của tokens.css, không màu thô.
   Bo 10px như .btn/.input; khoảng cách 6/8/10/12 như phần còn lại của app. */

/* ---- Today: dải ảnh trong thẻ bữa (chỉ khi bữa có ảnh) ---- */
.mphotos {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mphoto {
  appearance: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--track);
  color: var(--text-dim);
  cursor: zoom-in;
}
.mphoto img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mphoto svg,
.ptile-img > svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mphoto.is-loading img {
  visibility: hidden;
}
.mphoto.is-failed {
  border-style: dashed;
  cursor: pointer;
}
.mphoto:hover {
  border-color: var(--text-dim);
}
.mphoto:focus-visible,
.ptile-add:focus-visible {
  outline: none;
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-text) 35%, transparent);
}
@media (min-width: 560px) {
  .mphoto {
    width: 72px;
    height: 72px;
  }
}

/* ---- Xem ảnh: <dialog> gốc, Esc đóng, focus quay về ô vừa bấm ---- */
.pview {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.pview::backdrop {
  background: color-mix(in srgb, var(--text) 55%, transparent);
}
.pview-head,
.pview-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.pview-head .stitle {
  margin: 0;
  font-size: 13px;
}
.pview-count {
  font-size: var(--fs-small);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.pview-head .btn {
  margin-left: auto;
}
.pview-frame {
  margin: 10px 0;
  border-radius: 10px;
  background: var(--track);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.pview-img {
  display: block;
  max-width: 100%;
  max-height: min(70vh, 640px);
  object-fit: contain;
}
.pview-nav {
  display: flex;
  gap: 6px;
}
.pview-foot > .btn {
  margin-left: auto;
}

/* ---- Màn sửa bữa: khối Photos ---- */
.pf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.pf-head .stitle {
  margin: 0;
}
/* Tiêu đề chỉ nhận focus bằng code (tabindex -1) sau mỗi thao tác để đọc màn hình đọc lại; không phải điểm dừng bàn phím nên không vẽ vòng focus. */
.pf-head .stitle:focus {
  outline: none;
}
.pf-count {
  font-size: var(--fs-small);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.pgrid {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 10px;
}
@media (min-width: 560px) {
  .pgrid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.ptile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.ptile-img {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--track);
  color: var(--text-dim);
}
.ptile-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ptile-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ptile-msg {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.4;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.ptile.busy .ptile-img img {
  opacity: 0.55;
}
.ptile.failed .ptile-img {
  border: 2px solid var(--over);
}
.pprog {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 6px;
  border-radius: 999px;
  background: var(--panel);
  overflow: hidden;
}
.pprog > span {
  display: block;
  height: 100%;
  background: var(--accent-text);
}
@media (prefers-reduced-motion: no-preference) {
  .pprog > span {
    transition: width 0.2s ease;
  }
}
.ptile-add {
  appearance: none;
  aspect-ratio: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  border: 1.5px dashed var(--text-dim);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ptile-add:hover {
  background: var(--track);
}
.ptile-add svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--accent-text);
  stroke-width: 2;
  stroke-linecap: round;
}
.ptile-add small {
  font-size: var(--fs-small);
  font-weight: 400;
  color: var(--text-dim);
}
.photos > .hint {
  margin-top: 8px;
}
.photos > .pf-consent {
  margin: 8px 0 0;
}

/* ---- Hỏi xoá ảnh: nằm đè lên ảnh nên chiều cao ô không đổi và các ô bên dưới không nhảy ---- */
.pconfirm {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  text-align: center;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  color: var(--text);
}
.pconfirm p {
  margin: 0;
  font-size: var(--fs-small);
  font-weight: 600;
}
