:root {
  --bg: #ffffff;
  --fg: #1f1f1f;
  --muted: #5f6368;
  --line: #e3e3e3;
  --card: #f6f7f9;
  --accent: #1a73e8;
  --accent-fg: #ffffff;
  --danger: #d93025;
  --sel: #1a73e8;
  --radius: 10px;
  --gap: 4px;
  --bar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --line: #2b2b2b;
    --card: #1e1e1e;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
.hidden { display: none !important; }

/* ---- ปุ่ม ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); white-space: nowrap;
  min-height: 40px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn svg { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* ---- แถบหัว ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--bg);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.topbar h1 { font-size: 17px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar > div > h1 { flex: none; }
.topbar .sub { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar .sub .tag { font-size: 12px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); padding: 1px 8px; border-radius: 999px; }

.wrap { padding: 16px; max-width: 1400px; margin: 0 auto; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); }
.field input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); min-width: 0;
}

/* ---- กริดรูปแบบ justified (เหมือน Google Photos) ---- */
.grid { padding: 0 var(--gap) calc(var(--bar-h) + 24px); touch-action: pan-x pan-y; } /* ไม่ให้เบราว์เซอร์ซูมหน้า: ถ่างนิ้วใช้เปลี่ยนคอลัมน์แทน */
/* คอลัมน์เยอะ (รูปเล็ก): ย่อปุ่มบนรูปลง */
.grid.dense .tile .chk, .grid.selecting.dense .tile .chk { width: 22px; height: 22px; top: 4px; left: 4px; }
.grid.dense .tile .chk svg { width: 13px; height: 13px; }
.grid.dense .tile .expand { width: 26px; height: 26px; right: 4px; bottom: 4px; }
.grid.dense .tile .expand svg { width: 14px; height: 14px; }
.grid .r { display: flex; gap: var(--gap); margin-bottom: var(--gap); }
.tile {
  position: relative; flex: none; overflow: hidden; background: var(--card);
  border-radius: 3px; cursor: pointer; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.tile img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform .15s ease, opacity .25s ease; opacity: 0;
  pointer-events: none;
}
.tile img.ok { opacity: 1; }
.tile .chk {
  position: absolute; top: 6px; left: 6px; width: 26px; height: 26px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.95);
  background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s; z-index: 2; padding: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}
.tile .chk svg { width: 16px; height: 16px; fill: #fff; display: none; }
.tile:hover .chk, .grid.selecting .tile .chk { opacity: 1; }
@media (hover: none) { .tile .chk { opacity: 0; } .grid.selecting .tile .chk { opacity: 1; } }
.tile.sel .chk { opacity: 1; background: var(--sel); border-color: #fff; }
.tile.sel .chk svg { display: block; }
.tile.sel img { transform: scale(.88); border-radius: 6px; }
.tile.sel { background: color-mix(in srgb, var(--sel) 22%, var(--bg)); }
.tile .badge {
  position: absolute; right: 6px; bottom: 6px; z-index: 2;
  font-size: 11px; color: #fff; background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 4px;
}

/* ไอคอนขยาย (ดูเต็มจอ) แสดงเฉพาะโหมดเลือก */
.tile .expand {
  position: absolute; right: 6px; bottom: 6px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.55); color: #fff; display: none; align-items: center; justify-content: center; padding: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,.35);
}
.tile .expand svg { width: 18px; height: 18px; fill: #fff; }
.grid.selecting .tile .expand { display: flex; }

/* ---- แถบเลือก/ดาวน์โหลดด้านล่าง ---- */
.selbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(0,0,0,.12);
  transform: translateY(110%); transition: transform .2s ease;
}
.selbar.show { transform: none; }
.selbar .count { flex: 1; min-width: 0; font-weight: 600; }
.selbar .count small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

/* ---- ไลต์บ็อกซ์ ---- */
.lb {
  position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column;
  touch-action: none;
}
.lb .lb-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top));
  background: linear-gradient(rgba(0,0,0,.6), transparent); color: #fff;
}
.lb .lb-top .t { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .btn { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.lb .btn.on { background: var(--accent); }
.lb .stage { flex: 1; position: relative; overflow: hidden; }
.lb .track { position: absolute; top: 0; bottom: 0; left: -100%; width: 300%; display: flex; will-change: transform; }
.lb .slide { width: 33.3333%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lb .slide img, .lb .slide video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-select: none; }
.lb .slide video { width: 100%; background: #000; }
.lb .stage { touch-action: none; }                 /* ให้เราจัดการถ่างนิ้ว/ลากเอง ไม่ให้เบราว์เซอร์ซูมทั้งหน้า */
.lb .slide img { will-change: transform; transform-origin: center center; }
.lb.zoomed .nav { opacity: 0; pointer-events: none; }  /* ซูมอยู่ซ่อนปุ่มเลื่อน (ลากดูรูปแทน) */
.lb.zoomed .slide img { cursor: grab; }
.tile .vbadge { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; pointer-events: none; }
.lb .nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.4); color: #fff; display: flex; align-items: center; justify-content: center;
}
.lb .nav svg { width: 28px; height: 28px; fill: #fff; }
.lb .nav.prev { left: 10px; } .lb .nav.next { right: 10px; }
@media (hover: none) { .lb .nav { display: none; } }

/* ---- toast / progress ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 20px); transform: translateX(-50%);
  background: #323232; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60;
  max-width: 90vw; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.3);
  pointer-events: none; /* ไม่บังการแตะ/ลากเลือกรูปด้านล่าง */
}
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--bg); color: var(--fg); border-radius: 14px; padding: 20px; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 12px 0; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---- หน้าแอดมิน ---- */
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.album-card { display: block; color: inherit; text-decoration: none; background: var(--card); border-radius: var(--radius); overflow: hidden; cursor: pointer; border: 1px solid var(--line); }
.album-card:hover { border-color: var(--accent); }
.album-card .cover { aspect-ratio: 4/3; background: var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-card .cover { position: relative; }
.album-card .newbadge { position: absolute; top: 8px; left: 8px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; background: #d93025; box-shadow: 0 1px 4px rgba(0,0,0,.35); pointer-events: none; }
.album-card .info { padding: 10px 12px; }
.album-card .info b { display: block; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; margin-bottom: 4px; }
.album-card .info small { display: block; }
.album-card .info small { color: var(--muted); }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center;
  color: var(--muted); margin: 12px 0; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.share {
  display: flex; gap: 8px; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; margin: 12px 0;
}
.share input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fg); font-size: 13px; }
.upl { margin: 8px 0; font-size: 13px; }
.upl .item { display: flex; gap: 8px; align-items: center; padding: 3px 0; color: var(--muted); }
.upl .item.err { color: var(--danger); }
.upl .badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: 13px; vertical-align: middle; }
.upl .badge.ok { background: #e6f4ea; color: #137333; border: 1px solid #a8dab5; }
.upl .badge.warn { background: #fff4d6; color: #7a5a00; border: 1px solid #f2d38a; }
.upl .bar.ok i { background: #1e8e3e; }
@media (prefers-color-scheme: dark) { .upl .badge.ok { background: #16331f; color: #81c995; border-color: #2e6b3f; } .upl .badge.warn { background: #3a2d0a; color: #ffe2a6; border-color: #5c4713; } }
.tile .del {
  position: absolute; top: 6px; right: 6px; z-index: 2; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.55); color: #fff; display: none; align-items: center; justify-content: center; padding: 0;
}
.tile .del svg { width: 16px; height: 16px; fill: #fff; }
.tile:hover .del { display: flex; }
@media (hover: none) { .tile .del { display: flex; } }

.topbar .ttl { flex: 1; min-width: 0; }

/* จอแคบ (หน้าอัลบั้ม): ปุ่มกลับ + ชื่ออัลบั้มอยู่แถวบน ปุ่มอยู่แถวล่าง */
.topbar .sub .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }                 /* หน้าอัลบั้ม (แอดมิน + ลูกค้า): ชื่ออยู่แถวบนเต็มแถว ปุ่มแถวล่าง */
  .topbar .ttl { flex: 1 1 calc(100% - 50px); }
  .topbar .ttl h1 { white-space: normal; line-height: 1.25; }  /* ชื่ออัลบั้มยาวให้ขึ้น 2 บรรทัดได้ ไม่ตัดทิ้ง */
  .topbar .btn { flex: 1; justify-content: center; }
  .topbar > a.btn.ghost:first-child { flex: none; }
  #allBtn { flex: 1 1 100%; }                                /* ลูกค้า: ปุ่มดาวน์โหลดทั้งหมดเต็มแถวของตัวเอง */
  #albums .topbar { flex-wrap: nowrap; }                     /* หน้ารวมอัลบั้ม: แถวเดียว (ปุ่มอยู่ในเมนู ☰) */
  #albums .topbar .btn { flex: none; }
}
/* หน้ารวมอัลบั้ม: จอกว้างปุ่มเรียงตามปกติ · จอแคบยุบลงเมนู ☰ และตัวกรองยุบไว้หลังปุ่ม ⚙ */
.more-btn, .flt-more { display: none; }
.more-menu, .filters-adv { display: contents; }
@media (max-width: 720px) {
  .more-btn { display: inline-flex; position: relative; }
  .more-menu { display: none; position: absolute; right: 12px; top: calc(100% + 4px); flex-direction: column; gap: 6px; min-width: 230px;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 30; }
  .more-menu.open { display: flex; }
  .more-menu .btn { justify-content: flex-start; width: 100%; }
  #albums .topbar { flex-wrap: nowrap; }
  #albums .topbar h1 { display: none; } /* จอแคบ: ตัดหัวข้อ "อัลบั้มทั้งหมด" ให้ปุ่มมีที่ */
  #albums .topbar #newAlbum { margin-right: auto; }
  #logout #meName { display: none; }
  .flt-more { display: inline-flex; white-space: nowrap; }
  .filters-adv { display: none; width: 100%; flex-wrap: wrap; gap: 8px; align-items: center; }
  .filters.open .filters-adv { display: flex; }
  .filters select { flex: 1 1 40%; min-width: 0; }
  .filters { padding: 8px 12px; }
  .year-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .year-chips .btn { white-space: nowrap; }
  .storage { font-size: 12px; }
}

/* ปุ่มเลือกในไลต์บ็อกซ์ */
.lb .lb-sel { gap: 6px; padding: 8px 14px; }
.lb .lb-sel.on { background: var(--accent); }
.lb .lb-count { font-size: 13px; opacity: .85; white-space: nowrap; }
@media (max-width: 480px) {
  .lb .lb-top .t .fn { display: none; }
  .lb .lb-top .btn { padding: 8px 10px; }
}

/* อัลบั้มที่ดูได้อย่างเดียว (ไม่ใช่ของเรา) */
.grid.readonly .tile .del { display: none !important; }
.grid.readonly .tile { cursor: default; }

/* โหมดเลือก: ให้เบราว์เซอร์จัดการเฉพาะการเลื่อนแนวตั้ง ลากแนวนอน = เลือกรูป */
.grid.selecting { touch-action: pan-y; }

.field input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 42px; }

/* ลากไฟล์มาวางที่ไหนก็ได้ในหน้าอัลบั้ม */
.drop-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; text-align: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg)); border: 4px dashed var(--accent); font-size: 20px;
  pointer-events: none;
}

/* ปุ่มลอยกลับขึ้นบน */
.totop {
  position: fixed; right: 16px; bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom)); z-index: 40;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); box-shadow: 0 4px 14px rgba(0,0,0,.22);
  display: flex; align-items: center; justify-content: center; padding: 0;
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.totop.show { opacity: 1; transform: none; pointer-events: auto; }
.totop svg { width: 22px; height: 22px; fill: currentColor; }
.totop.tobottom.lift { bottom: calc(var(--bar-h) + 16px + 54px + env(safe-area-inset-bottom)); } /* เมื่อปุ่มขึ้นบนแสดงอยู่ด้วย ปุ่มลงล่างสุดขยับขึ้นไปซ้อนข้างบน */

/* หน้าบันทึกกิจกรรม */
.loglist { display: flex; flex-direction: column; }
.logrow { display: grid; grid-template-columns: 150px 1fr; gap: 4px 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.logrow .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.logrow .who { color: var(--muted); font-size: 12px; }
.logrow .what b { font-weight: 600; }
.logrow .what a { color: var(--accent); }
.logrow.err .what b { color: var(--danger); }
.logrow .det { color: var(--muted); font-size: 13px; word-break: break-word; }
@media (max-width: 560px) { .logrow { grid-template-columns: 1fr; gap: 2px; } }

/* โหมดเลือกในหน้าแอดมิน: ซ่อนปุ่มถังขยะรายรูป */
.grid.selecting .tile .del { display: none !important; }

/* แถบกรองอัลบั้ม */
/* แถบค้นหา/ตัวกรองของหน้ารวมอัลบั้ม: ติดอยู่ใต้แถบบนตอนเลื่อนลง (เต็มความกว้าง) */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: var(--topbar-h, 56px); z-index: 19; }
.filters input, .filters select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--fg); font-size: 14px; }
.filters input[type="search"] { flex: 1; min-width: 160px; }
.todo-btn { background: #fff8e1; border-color: #f2d38a; color: #6b4e00; }
.todo-btn.on { background: #f2c94c; border-color: #d4a72c; color: #3b2800; }
@media (prefers-color-scheme: dark) { .todo-btn { background: #3a2d0a; border-color: #5c4713; color: #ffe2a6; } .todo-btn.on { background: #8a6a12; color: #fff; } }
/* เหลือง = ยังไม่ผูกลูกค้า · ฟ้า = ผูกแล้วแต่ลูกค้ายังล็อกอินไม่ได้ (สีเดียวกับป้ายในหน้าอัลบั้ม) */
.album-card.todo { background: #fff8e1; border-color: #f2d38a; }
.album-card.todo-blue { background: #eef4fe; border-color: #aecbfa; }
.todo-tag { display: inline-block; margin: 2px 6px 0 0; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.todo-tag.yellow { background: #f9e3a3; color: #5b3d00; }
.todo-tag.blue { background: #d2e3fc; color: #174ea6; }
.todo-tag.gray { background: var(--line); color: var(--muted); font-weight: 500; }
.todo-tag.green { background: #ceead6; color: #0d652d; }
@media (prefers-color-scheme: dark) { .todo-tag.green { background: #1e4620; color: #81c995; } }
@media (prefers-color-scheme: dark) {
  .album-card.todo { background: #3a2d0a; border-color: #5c4713; } .todo-tag.yellow { background: #5c4713; color: #ffe2a6; }
  .album-card.todo-blue { background: #1b2a44; border-color: #2d4a7a; } .todo-tag.blue { background: #2d4a7a; color: #aecbfa; }
}
/* มุมมองแถว: 1 แถว = 1 อัลบั้ม (รูปปกเล็ก · ชื่อ+ทริป · วันที่/รูป/ขนาด · ผู้สร้าง/ลูกค้า) */
.albums.list { display: flex; flex-direction: column; gap: 6px; }
.albums.list .album-card { display: grid; grid-template-columns: 96px 1fr; align-items: center; }
.albums.list .album-card .cover { aspect-ratio: 4/3; height: 72px; }
.albums.list .album-card .info { display: grid; grid-template-columns: minmax(200px, 1.6fr) 1fr 1fr; gap: 2px 16px; align-items: center; padding: 6px 14px; }
.albums.list .album-card .info b { margin: 0; grid-row: 1; }
.albums.list .album-card .info .tag { grid-row: 2; grid-column: 1; margin: 0; justify-self: start; }
.albums.list .album-card .info .meta { grid-row: 1; grid-column: 2; }
.albums.list .album-card .info .by { grid-row: 1; grid-column: 3; }
.albums.list .album-card .info .emails { grid-row: 2; grid-column: 2 / span 2; }
.albums.list .album-card .chk { top: 50%; transform: translateY(-50%); left: 10px; }
@media (max-width: 720px) {
  .albums.list .album-card .info { grid-template-columns: 1fr; }
  .albums.list .album-card .info .meta, .albums.list .album-card .info .by, .albums.list .album-card .info .emails { grid-row: auto; grid-column: 1; }
}
.album-card .tag { display: inline-block; font-size: 12px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); padding: 1px 8px; border-radius: 999px; margin: 2px 0 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.pick:hover { background: var(--card); border-color: var(--line); }
.pick img { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; background: var(--line); flex: none; }
.pick .ttl2 { flex: 1; min-width: 0; }
.pick .ttl2 b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .ttl2 small { color: var(--muted); }

/* เลือกหลายอัลบั้มในหน้ารวม */
.album-card { position: relative; }
.album-card .chk { position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255,255,255,.95);
  background: rgba(0,0,0,.3); display: none; align-items: center; justify-content: center; z-index: 2; padding: 0; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.album-card .chk svg { width: 16px; height: 16px; fill: #fff; display: none; }
.albums.selecting .album-card .chk { display: flex; }
.album-card.sel .chk { background: var(--accent); }
.album-card.sel .chk svg { display: block; }
.album-card.sel { outline: 3px solid var(--accent); }

/* footer พื้นที่เก็บข้อมูล */
/* แผงพื้นที่/สำรองข้อมูล: ลอยมุมขวาล่าง ย่อ/ขยายได้ (ซ่อนอัตโนมัติตอนแถบเลือกหลายรายการโผล่) */
.storage { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; width: auto;
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(0,0,0,.18); padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); margin: 0; }
.storage > * { max-width: 1400px; margin-left: auto; margin-right: auto; }
.storage .stbar { margin: 8px 0 0; }
.storage .st-detail { margin-top: 18px; } /* เว้นที่ให้ป้าย "10 GB ฟรี" ใต้แถบ ไม่ทับข้อความ */
.storage.collapsed .st-detail { display: none; }
.storage.collapsed .stbar { margin-bottom: 14px; }
.storage.collapsed { padding-bottom: 10px; }
body:has(.selbar.show) .storage { display: none; }
body:has(#storage:not(.hidden)) { padding-bottom: 150px; }
body:has(#storage.collapsed:not(.hidden)) { padding-bottom: 80px; }
.stbar { position: relative; height: 14px; background: var(--line); border-radius: 7px; margin-top: 10px; overflow: visible; }
.stbar > i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 7px; }
.stbar #stFill { background: var(--accent); }
.stbar #stOver { background: #e8710a; border-radius: 0 7px 7px 0; }
.stbar .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--fg); }
.stbar .mark em { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 3px; font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ชิปอีเมลลูกค้าในหน้าอัลบั้ม */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; max-width: 100%; }
.chip .x { width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--line); color: var(--fg); display: flex; align-items: center; justify-content: center; padding: 0; }
.chip .x svg { width: 12px; height: 12px; fill: currentColor; }
.chip small { color: var(--muted); }
.chip .lnk { background: none; border: 0; padding: 5px 4px 5px 12px; margin: -5px 0; font: inherit; color: inherit; cursor: pointer; border-radius: 999px; }
.chip .lnk:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.chip.warn { background: #fff4d6; border-color: #f2d38a; color: #6b4e00; }
.chip.warn small { color: #8a6a12; }
/* มีอีเมลแต่ไม่ใช่ gmail และยังไม่ได้ลงทะเบียนรหัสผ่าน → ล็อกอินด้วย Google ไม่ได้ */
.chip.done { background: var(--line); border-color: var(--line); color: var(--muted); }
.chip.done small { color: var(--muted); }
.chip.nogmail { background: #e8f0fe; border-color: #aecbfa; color: #174ea6; }
.chip.nogmail small { color: #3c6fc4; }
@media (prefers-color-scheme: dark) { .chip.nogmail { background: #1b2a44; border-color: #2d4a7a; color: #aecbfa; } .chip.nogmail small { color: #8ab4f8; } }
@media (prefers-color-scheme: dark) { .chip.warn { background: #3a2d0a; border-color: #5c4713; color: #ffe2a6; } .chip.warn small { color: #d8b86a; } }

/* ปุ่มตั้งปก (มุมล่างขวาของรูปในหน้าแอดมิน) */
.tile .coverbtn {
  position: absolute; right: 6px; bottom: 6px; z-index: 2; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.55); color: #fff; display: none; align-items: center; justify-content: center; padding: 0;
}
.tile .coverbtn svg { width: 16px; height: 16px; fill: #fff; }
.tile:hover .coverbtn { display: flex; }
@media (hover: none) { .tile .coverbtn { display: flex; } }
.tile.is-cover .coverbtn { display: flex; background: #f5b400; }
.tile.is-cover .coverbtn svg { fill: #fff; }
.grid.selecting .tile .coverbtn, .grid.readonly .tile .coverbtn { display: none !important; }

/* combobox ค้นหาทริป */
.combo-x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--line); color: var(--fg); font-size: 16px; line-height: 1; padding: 0; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 90; max-height: 260px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.combo-item { padding: 8px 12px; cursor: pointer; font-size: 14px; }
.combo-item small { color: var(--muted); }
.combo-item:hover, .combo-item.active { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
.combo-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* แถบเตือนเบราว์เซอร์ในแอป */
.inapp { position: sticky; top: 0; z-index: 100; display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: #fff4d6; color: #5b3d00; border-bottom: 1px solid #f0d58a; }
@media (prefers-color-scheme: dark) { .inapp { background: #3a2d0a; color: #ffe2a6; border-color: #5c4713; } }

/* แถบอัปโหลดล่างจอ: คลิกหัวแถบเพื่อขยายดูความคืบหน้าแต่ละอัลบั้ม */
.upbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 65; background: #fff4d6; color: #5b3d00; border-top: 1px solid #f0d58a; box-shadow: 0 -6px 20px rgba(0,0,0,.15); font-size: 14px; }
.upbar.is-ok { background: #e6f4ea; color: #137333; border-top-color: #a8dab5; }
.upbar.is-bad { background: #fce8e6; color: #a50e0e; border-top-color: #f5b5ae; }
.upbar-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); cursor: pointer; max-width: 1400px; margin: 0 auto; }
.upbar-caret { font-size: 12px; width: 12px; }
.upbar-track { position: relative; height: 6px; border-radius: 3px; background: rgba(0,0,0,.1); overflow: hidden; margin-top: 5px; display: flex; }
.upbar-track i { display: block; height: 100%; transition: width .4s; }
.upbar-track i.ok { background: #1e8e3e; }
.upbar-track i.bad { background: #d93025; }
.upbar-list { max-height: 55vh; overflow: auto; margin-top: 12px; border-top: 1px solid var(--line); }
.modal .upbar-track i.ok { background: #1e8e3e; }
.upbar-row { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.modal .upbar-track { background: var(--line); }
.upbar-row:hover b { text-decoration: underline; }
.upbar-row-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.upbar-row-top b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.upbar-row-top small { white-space: nowrap; opacity: .85; }
body:has(.upbar) .storage { display: none; }
@media (prefers-color-scheme: dark) {
  .upbar { background: #3a2d0a; color: #ffe2a6; border-top-color: #5c4713; }
  .upbar.is-ok { background: #16331f; color: #81c995; border-top-color: #2e6b3f; }
  .upbar.is-bad { background: #3c1513; color: #f6aea9; border-top-color: #7a2a24; }
  .upbar-track { background: rgba(255,255,255,.12); }
}

/* มุมมองตามทริป (2 ชั้น) */
.albums.grouped { display: block; }
.tgroup { margin-bottom: 8px; }
.tgroup-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.tgroup-head:hover { border-color: var(--accent); }
.tgroup-head.open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.tgroup-caret { width: 14px; transition: transform .15s; color: var(--muted); }
.tgroup-head.open .tgroup-caret { transform: rotate(90deg); }
.tgroup-cover { width: 64px; height: 44px; border-radius: 6px; overflow: hidden; background: var(--line); flex: none; }
.tgroup-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tgroup-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tgroup-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tgroup-title small { color: var(--muted); }
.tgroup-stats { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.tgroup-head.none b { color: var(--muted); }
.tgroup-body { padding: 10px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.albums.grouped.list .tgroup-body { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 720px) { .tgroup-stats { display: none; } }

/* ปุ่มเลือกปีเหนือรายการอัลบั้ม */
.year-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.year-chips .btn { min-height: 30px; padding: 3px 12px; font-size: 13px; }
.year-chips .btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* รายชื่อลูกค้า/ผู้จองในหน้าอัลบั้ม: 1 แถว 1 คน อ่านไล่ง่าย */
#bookerChips { flex-direction: column; align-items: flex-start; flex-wrap: nowrap; }
#bookerChips .chip { max-width: 100%; }
#bookerChips .chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.chip .seen { color: #137333; font-weight: 600; }
.chip .unseen { opacity: .75; }
@media (prefers-color-scheme: dark) { .chip .seen { color: #81c995; } }

/* หน้า "งานเบื้องหลัง" */
.badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
.badge.bad { background: #d93025; }
.tasks-summary { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.tasks-summary .card { padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); min-width: 120px; }
.tasks-summary .card b { display: block; font-size: 22px; }
.tasks-summary .card.bad b { color: #d93025; }
.tasks-worker { font-size: 13px; margin-bottom: 14px; }
.tasks-h { font-size: 15px; margin: 18px 0 4px; }
.taskrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: center; }
.taskrow .err { color: #a50e0e; font-size: 13px; }
.taskrow small { color: var(--muted); }

/* มือถือ: การ์ด 2 คอลัมน์ปกเล็ก · แถว = ปก 84px ซ้าย ข้อความกระชับ → เห็น 6-8 อัลบั้มต่อจอ */
@media (max-width: 720px) {
  .albums:not(.grouped) { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .albums .album-card .info { padding: 8px 10px; }
  .albums .album-card .info b { font-size: 14px; }
  .albums .album-card .info small { font-size: 11.5px; }
  .albums .album-card .tag { font-size: 11px; }
  .albums:not(.list) .album-card .info .emails, .albums:not(.list) .album-card .info .by { display: none; }
  .albums.list { display: flex; gap: 6px; }
  .albums.list .album-card { grid-template-columns: 84px 1fr; }
  .albums.list .album-card .cover { height: 64px; aspect-ratio: auto; }
  .albums.list .album-card .info { padding: 6px 10px; }
  .albums.list .album-card .info .emails { display: none; }
  .tgroup-body.albums { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* ตัวอย่างอีเมลใน modal แจ้งลูกค้า */
.notify-prev { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.notify-prev summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.notify-prev summary .muted { font-weight: 400; margin-left: 6px; }
.notify-prev-subj { font-size: 13px; margin: 6px 0 4px; padding: 4px 8px; background: var(--card); border-radius: 6px; overflow-wrap: anywhere; }
.notify-prev iframe { width: 100%; height: 320px; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: block; }
