/* css/screens-attview.css · ไฟล์แนบแบบตารางภาพย่อ + ตัวดูภาพ (M17 lane V · components/attview.html · attview.js)
   สีจาก themes.css เท่านั้น (TestAppCSSUsesTokensOnly) · ไม่มี JS = ลิงก์ดาวน์โหลด (ตารางยังแสดงครบ)
   การตัดสินใจด้านภาพ (README ข้อ 942–951):
   - ตาราง: การ์ดภาพย่อ 4:3 กว้างอย่างน้อย 136 px (1366 = 5–6 คอลัมน์ในการ์ดกว้าง · 375 = 2 คอลัมน์) · ชื่อไฟล์บรรทัดเดียว + ขนาด · ผู้แนบ · เวลา
     ไฟล์ที่ไม่มีภาพย่อ = ไอคอนชนิดไฟล์บนพื้น surf2 + ป้ายนามสกุล (ชนิดจากเนื้อไฟล์) · ป้ายผู้เห็นมีไอคอน + ข้อความเสมอ (ไม่ใช้สีอย่างเดียว)
   - ตัวดู: เต็มจอ พื้นมืดทั้งสองโหมด (โหมดสว่าง = --ink · โหมดมืด = --bg) ให้ภาพเด่น · ตัวอักษรบนพื้นมืด = --bg / --ink (≥ 12:1)
     ปุ่ม 44 × 44 · ปุ่มก่อนหน้า/ถัดไป 52 px ลอยข้างภาพ · วงโฟกัสสีตัวอักษรของตัวดู (≥ 12:1 บนพื้นมืด · --ring มืดเกินบนพื้นนี้)
     แถบภาพย่อด้านล่าง · ภาพปัจจุบันมีกรอบ 2 px · จอ ≤ 640 px เครื่องมือย้ายลงแถบล่าง ปัดซ้าย/ขวาเลื่อนไฟล์ จีบนิ้วซูม
   - การเคลื่อนไหว ≤ 180 ms (จาง/เลื่อนเล็กน้อย) · prefers-reduced-motion = ไม่มี */

/* ── ตารางไฟล์แนบ ── */
.att { margin: 4px 0 8px; }
.att-n { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: var(--r-pill);
  background: var(--surf2); color: var(--ink2); font: 600 12px/1 var(--font-sans); vertical-align: 2px; }
.att-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 14px 12px; }
.att-compact .att-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 136px)); gap: 10px; }
.att-compact .att-by, .att-compact .att-tags { display: none; }
.att-it { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.att-tile { display: flex; flex-direction: column; gap: 6px; color: var(--ink); text-decoration: none; border-radius: var(--r-lg); min-width: 0; }
.att-thumb { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; overflow: hidden;
  background: var(--surf2); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--muted); box-shadow: var(--shadow-1);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-thumb .ico.s24 { width: 32px; height: 32px; stroke-width: 1.5; }
.att-ext { position: absolute; left: 8px; bottom: 8px; padding: 1px 7px; border-radius: var(--r-pill); background: var(--surf); color: var(--ink2);
  border: 1px solid var(--line); font: 600 12px/1.5 var(--font-mono); letter-spacing: .02em; }
a.att-tile:hover .att-thumb { border-color: var(--brand); box-shadow: var(--shadow-2); transform: translateY(-1px); }
a.att-tile:focus-visible { outline: none; }
a.att-tile:focus-visible .att-thumb { outline: 2px solid var(--ring); outline-offset: 2px; }
a.att-tile:hover .att-name { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
.att-name { display: block; font: 500 13px/1.45 var(--font-sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.att-nolink { cursor: default; }
.att-meta { display: block; padding: 0 2px; font-size: 12px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.att-by { margin-top: -4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-tags { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 2px; }
.att-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--soft); color: var(--fg);
  font: 600 12px/1.6 var(--font-sans); }
.att-tag .ico { width: 12px; height: 12px; }
.att-vis-internal { background: var(--p4-bg); color: var(--p4-fg); }
.att-vis-requester { background: var(--p3-bg); color: var(--p3-fg); }
.att-vis-vendor { background: var(--vendor-bg); color: var(--vendor-fg); }
.att-sha { display: block; padding: 0 2px; font: 12px/1.4 var(--font-mono); color: var(--muted); }
.att-empty { margin: 4px 0; }

/* ── ตัวดูภาพ (<dialog id="att-viewer">) ── */
.atv {
  --atv-bg: var(--ink); --atv-fg: var(--bg); --atv-fg2: var(--line);
  --atv-soft: color-mix(in srgb, var(--atv-fg) 12%, transparent);
  --atv-glass: color-mix(in srgb, var(--atv-bg) 72%, transparent);
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--atv-bg); color: var(--atv-fg); overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-columns: minmax(0, 1fr);
}
.atv:not([open]) { display: none; }
.atv [hidden] { display: none !important; }
.atv::backdrop { background: var(--scrim); }
[data-mode="dark"] .atv { --atv-bg: var(--bg); --atv-fg: var(--ink); --atv-fg2: var(--ink2); }
@media (prefers-color-scheme: dark) {
  [data-mode="system"] .atv { --atv-bg: var(--bg); --atv-fg: var(--ink); --atv-fg2: var(--ink2); }
}
.atv :focus-visible { outline: 2px solid var(--atv-fg); outline-offset: 2px; }

.atv-top { display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 10px 16px 10px 20px; border-bottom: 1px solid var(--atv-soft); }
.atv-count { margin: 0; flex: none; min-width: 56px; font: 600 14px/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--atv-fg2); }
.atv-cap { flex: 1; min-width: 0; }
.atv-name { margin: 0; font: 600 15px/1.45 var(--font-sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--atv-fg); }
.atv-meta { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--atv-fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atv-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.atv-zoom { display: inline-flex; align-items: center; gap: 2px; padding-right: 6px; margin-right: 4px; border-right: 1px solid var(--atv-soft); }
.atv-zl { min-width: 48px; text-align: center; font: 500 12.5px/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--atv-fg2); }
.atv-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--atv-fg); cursor: pointer; text-decoration: none; }
.atv-btn:hover { background: var(--atv-soft); }
.atv-btn:disabled, .atv-btn[aria-disabled="true"] { opacity: .38; cursor: default; background: transparent; }
.atv-btn .ico { width: 20px; height: 20px; }
.atv-close { margin-left: 4px; }

.atv-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; touch-action: none; user-select: none; }
.atv-view { position: absolute; inset: 16px 84px; display: flex; align-items: center; justify-content: center; }
.atv-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: var(--r-sm); box-shadow: var(--shadow-3);
  transform-origin: 50% 50%; will-change: transform; cursor: zoom-in; opacity: 1; transition: opacity .18s ease; -webkit-user-drag: none; }
.atv-img.is-loading { opacity: 0; }
.atv-img.is-zoomed { cursor: grab; }
.atv-img.is-panning { cursor: grabbing; }
.atv-img.is-page { background: var(--surf); border: 1px solid var(--atv-soft); }
.atv-nav { position: absolute; top: 50%; z-index: 2; display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin-top: -26px;
  border: 1px solid var(--atv-soft); border-radius: var(--r-pill); background: var(--atv-glass); color: var(--atv-fg); cursor: pointer; transition: background .15s ease; }
.atv-nav:hover { background: var(--atv-soft); }
.atv-nav:disabled { opacity: 0; pointer-events: none; }
.atv-prev { left: 16px; }
.atv-next { right: 16px; }
.atv-load { position: absolute; display: inline-flex; align-items: center; gap: 10px; margin: 0; color: var(--atv-fg2); font-size: 13px; }
.atv-spin { width: 18px; height: 18px; border: 2px solid var(--atv-soft); border-top-color: var(--atv-fg); border-radius: 50%; animation: atv-spin .8s linear infinite; }
@keyframes atv-spin { to { transform: rotate(360deg); } }
.atv-file { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 420px; padding: 32px 28px; text-align: center;
  border: 1px solid var(--atv-soft); border-radius: var(--r-xl); background: var(--atv-glass); }
.atv-ficon { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: var(--r-lg); background: var(--atv-soft); }
.atv-ficon .ico, .atv-ficon svg { width: 36px; height: 36px; stroke-width: 1.5; }
.atv-fname { margin: 0; font: 600 15px/1.45 var(--font-sans); overflow-wrap: anywhere; }
.atv-note { margin: 0; font-size: 13px; line-height: 1.55; color: var(--atv-fg2); }
.atv-pdf { display: flex; align-items: center; justify-content: center; gap: 12px 16px; flex-wrap: wrap; padding: 8px 16px; font-size: 13px; color: var(--atv-fg2); }
.atv-pdf p { margin: 0; }

.atv-strip { list-style: none; margin: 0; padding: 10px 16px 12px; display: flex; gap: 8px; justify-content: center; overflow-x: auto; scrollbar-width: thin;
  border-top: 1px solid var(--atv-soft); }
.atv-strip li { flex: none; }
.atv-th { position: relative; display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; padding: 0; overflow: hidden; cursor: pointer;
  border: 1px solid var(--atv-soft); border-radius: var(--r-md); background: var(--atv-soft); color: var(--atv-fg); opacity: .62; transition: opacity .15s ease; }
.atv-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.atv-th .ico { width: 22px; height: 22px; }
.atv-th:hover { opacity: 1; }
.atv-th[aria-current="true"] { opacity: 1; outline: 2px solid var(--atv-fg); outline-offset: 2px; }
.atv-keys { margin: 0; padding: 0 16px 10px; text-align: center; font-size: 12px; color: var(--atv-fg2); }

/* จอแคบ: เครื่องมือย้ายลงล่าง (สองแถว: ซูม/ดาวน์โหลด · ภาพย่อ) · ปุ่มเลื่อนเล็กลง · ปัด/จีบนิ้วเป็นหลัก */
@media (max-width: 640px) {
  .atv { grid-template-rows: auto minmax(0, 1fr) auto auto auto; }
  .atv-top { min-height: 56px; padding: 6px 4px 6px 14px; gap: 10px; }
  .atv-count { min-width: 0; font-size: 13px; }
  .atv-tools { position: static; }
  .atv-zoom, .atv-tools [data-atv="original"] { display: none; }
  .atv-view { inset: 8px 8px; }
  .atv-nav { width: 44px; height: 44px; margin-top: -22px; }
  .atv-prev { left: 6px; }
  .atv-next { right: 6px; }
  .atv-strip { justify-content: flex-start; padding: 8px 12px 10px; }
  .atv-th { width: 48px; height: 48px; }
  .atv-keys { display: none; }
  .att-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
}
@media (pointer: coarse) { .atv-keys { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .att-thumb, .atv-img, .atv-nav, .atv-th { transition: none; }
  a.att-tile:hover .att-thumb { transform: none; }
  .atv-spin { animation: none; }
}
@media print { .atv { display: none; } }
