/* style.css — คลังเอกสาร กลุ่มอุทกศาสตร์ · ชิวๆ มินิมอล น่ารัก (คุณโอสั่ง 10 ต.ค. 2569)
   สีทุกคู่วัด contrast WCAG แล้วก่อนวาง (ตัวหนังสือ --ink บนพื้นพาสเทล ≥ 11.4 · ขาวบนปุ่ม --blue 4.95 · ขาวบนน้ำเงิน 8.66)
   ข้อควรรู้: สีพาสเทลใช้เป็น "พื้น" เท่านั้น ตัวหนังสือบนพื้นพาสเทลใช้ --ink เสมอ */
:root {
  --bg: #f2f7fb;
  --card: #ffffff;
  --ink: #10243a;
  --ink2: #35506b;
  --navy: #1f4e79;
  --blue: #1a6fd1;
  --blue-dark: #1559a8;
  --teal-ink: #0b6f8c;
  --ok: #1a6b3c;
  --warn: #8a5300;
  --bad: #b3261e;
  --sky: #bfe3ff;
  --sun: #ffe08a;
  --mint: #c9f2e3;
  --coral: #ffd3c2;
  --lilac: #e6dcff;
  --butter: #fff1b8;
  --line: #d6e4f0;
  --shadow: 0 8px 22px rgba(31, 78, 121, .12);
  --r: 20px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.7 "Noto Sans Thai UI", "Noto Sans Thai", "Sarabun", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  min-height: 100vh; overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.3; margin: 0; text-wrap: balance; }
h1 { font-size: 28px; } h2 { font-size: 24px; } h3 { font-size: 20px; }
p { margin: .4em 0; }
a { color: var(--teal-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal-ink); outline-offset: 2px; border-radius: 8px; }
.ic { display: inline-flex; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- โครงหน้า ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .wrap { max-width: 980px; } }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(242, 247, 251, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 980px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: var(--navy); text-decoration: none; flex: 1; min-width: 0; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand small { display: block; font-weight: 400; font-size: 13px; color: var(--ink2); line-height: 1.2; }
.avatar { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--sun); color: var(--ink); font-weight: 700; font-size: 20px; cursor: pointer; flex: none; transition: transform .18s var(--ease); }
.avatar:hover { transform: scale(1.08) rotate(-4deg); }
.menu { position: absolute; right: 16px; top: 62px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; min-width: 230px; z-index: 30; animation: pop .22s var(--ease); }
.menu .who { padding: 8px 12px 10px; border-bottom: 1px dashed var(--line); margin-bottom: 4px; }
.menu .who b { display: block; }
.menu .who span { font-size: 14px; color: var(--ink2); word-break: break-all; }
.menu a, .menu button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 12px; text-decoration: none; color: var(--ink); cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--bg); }

/* ---------- ฮีโร่ + ค้นหา ---------- */
.hero { position: relative; margin: 14px 0 6px; padding: 22px 18px 18px; border-radius: 28px; background: var(--sky); overflow: hidden; isolation: isolate; }
.hero h1 { color: var(--navy); padding-right: 54px; }
.hero p { color: var(--ink); margin: 2px 0 14px; padding-right: 54px; }
.hero .waves { position: absolute; left: 0; right: 0; bottom: -2px; height: 54px; z-index: -1; opacity: .75; }
.hero .boat { position: absolute; right: 18px; top: 14px; font-size: 40px; animation: bob 3.2s ease-in-out infinite; z-index: 0; }
.hero .bub { position: absolute; z-index: -1; border-radius: 50%; background: #fff; opacity: .55; animation: rise 6s linear infinite; }
.search { position: relative; }
.search input[type="search"] { width: 100%; height: 58px; min-height: 58px; border-radius: 29px; border: 2px solid transparent; background: #fff; padding: 0 52px 0 56px; font-size: 19px; box-shadow: var(--shadow); }
.search input[type="search"]::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: none; border-color: var(--teal-ink); }
.search .ic-l { position: absolute; left: 18px; top: 17px; color: var(--teal-ink); }
.search .clear { position: absolute; right: 8px; top: 8px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--bg); cursor: pointer; color: var(--ink); }
.hint { font-size: 14px; color: var(--ink); margin-top: 8px; }

/* ---------- ไทล์หมวด ---------- */
/* มือถือ: หน้าแรกเป็นแถบเลื่อนข้าง (ใช้ชื่อสั้น) จะได้เห็นรายการเอกสารเร็ว · หน้าเลือกหมวดตอนอัปโหลด (.grid) เป็นตารางเต็มชื่อ */
@media (max-width: 639px) {
  .tiles:not(.grid) { display: flex; overflow-x: auto; gap: 8px; margin: 12px -16px; padding: 2px 44px 8px 16px; scroll-snap-type: x proximity; scroll-padding-left: 16px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
  .tiles:not(.grid)::-webkit-scrollbar { display: none; }
  .tiles:not(.grid) .tile { flex: none; min-height: 58px; padding: 8px 14px; scroll-snap-align: start; }
  .tiles:not(.grid) .full { display: none; }
}
@media (min-width: 640px) { .tile .short { display: none; } }
.tiles.grid .short { display: none; }
.tiles.grid .full { display: inline; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: flex; align-items: center; gap: 10px; text-align: left; border: 2px solid transparent; border-radius: 18px; padding: 10px 12px; cursor: pointer; background: var(--c, var(--butter)); color: var(--ink); min-height: 66px; transition: transform .18s var(--ease), box-shadow .18s var(--ease); }
.tile:hover { transform: translateY(-3px) rotate(-.6deg); box-shadow: var(--shadow); }
.tile[aria-pressed="true"] { border-color: var(--navy); box-shadow: 0 0 0 3px #fff inset; }
.tile .em { font-size: 28px; line-height: 1; flex: none; }
.tile .tx { font-size: 16px; line-height: 1.3; font-weight: 700; min-width: 0; }
.tile .n { display: block; font-weight: 400; font-size: 14px; color: var(--ink); }
.c1 { --c: var(--butter); } .c2 { --c: var(--sky); } .c3 { --c: var(--mint); } .c4 { --c: var(--coral); } .c5 { --c: var(--lilac); }
.c6 { --c: var(--sun); } .c7 { --c: var(--mint); } .c8 { --c: var(--butter); } .c9 { --c: var(--lilac); } .c10 { --c: var(--sky); } .c0 { --c: #fff; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.pill { white-space: nowrap; flex: none; border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 16px; cursor: pointer; font-size: 16px; min-height: 44px; transition: background .15s, transform .15s var(--ease); }
.pill:hover { transform: translateY(-1px); }
.pill[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
select, input[type=text], input[type=search], textarea { width: 100%; min-height: 52px; border: 2px solid var(--line); border-radius: 14px; background: #fff; padding: 10px 14px; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--teal-ink); }
.filters select { width: auto; min-width: 150px; border-radius: 999px; }

/* ---------- การ์ดเอกสาร ---------- */
.count { color: var(--ink2); margin: 6px 2px 8px; font-size: 16px; }
.list { display: grid; gap: 12px; }
@media (min-width: 900px) { .list { grid-template-columns: 1fr 1fr; } }
.card { display: flex; gap: 12px; text-align: left; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); cursor: pointer; color: var(--ink); animation: up .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); transition: transform .18s var(--ease); }
.card:hover { transform: translateY(-3px); }
.card-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; flex: none; background: var(--c, var(--butter)); }
.card-body { min-width: 0; flex: 1; }
.card-title { font-weight: 700; font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.card-sub { color: var(--ink2); font-size: 15px; line-height: 1.45; }
.card-note { font-size: 15px; margin-top: 2px; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--ink2); align-items: center; }
.tag { background: var(--bg); border-radius: 999px; padding: 1px 10px; color: var(--ink); font-size: 13px; }
.tag.ext { background: var(--navy); color: #fff; font-weight: 700; letter-spacing: 0; }
.tag.hit { background: var(--sun); }
.empty { text-align: center; padding: 36px 16px; color: var(--ink2); }
.empty .big { font-size: 60px; display: block; animation: bob 3.2s ease-in-out infinite; }
.skeleton { height: 92px; border-radius: var(--r); background: linear-gradient(90deg, #e4eef6 25%, #f4f9fd 50%, #e4eef6 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }

/* ---------- ปุ่ม ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 22px; border-radius: 999px; border: 2px solid var(--navy); background: #fff; color: var(--navy); font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .15s var(--ease), background .15s; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.sun { background: var(--sun); border-color: var(--sun); color: var(--ink); }
.btn[disabled], .btn.primary[disabled] { background: #d3deea; border-color: #d3deea; color: var(--ink2); cursor: not-allowed; transform: none; } /* ปุ่มที่กดไม่ได้: ไม่ใช้ความโปร่งใส (ตัวหนังสือจางเกินอ่านไม่ออก) */
.btn.wide { width: 100%; }
.fab { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 15; min-height: 60px; padding: 0 26px; font-size: 19px; box-shadow: 0 10px 26px rgba(26, 111, 209, .42); animation: wiggle 1.4s var(--ease) .8s 2; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- แผ่นรายละเอียด/กล่องยืนยัน ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(16, 36, 58, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 28px 28px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); animation: slide .3s var(--ease); }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 28px; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: -8px auto 12px; }
.sheet h2 { display: flex; gap: 10px; align-items: flex-start; }
dl.info { margin: 14px 0; display: grid; grid-template-columns: 8.5em 1fr; gap: 6px 12px; font-size: 16px; }
dl.info dt { color: var(--ink2); }
dl.info dd { margin: 0; overflow-wrap: anywhere; }
.banner { border-radius: 16px; padding: 12px 14px; margin: 10px 0; font-size: 16px; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: #fff6dc; color: #5f3a00; border: 2px solid var(--sun); }
.banner.info { background: var(--sky); color: var(--ink); }
.banner.bad { background: #ffe3df; color: #7a1913; }
.banner.ok { background: var(--mint); color: var(--ink); }

/* ---------- ฟอร์มอัปโหลด ---------- */
.steps h2 { margin: 18px 0 8px; }
.drop { display: grid; place-items: center; gap: 4px; text-align: center; padding: 26px 16px; border: 3px dashed var(--teal-ink); border-radius: 24px; background: #fff; cursor: pointer; width: 100%; color: var(--ink); transition: transform .18s var(--ease), background .18s; }
.drop:hover { background: var(--butter); transform: scale(1.01); }
.drop .big { font-size: 52px; animation: bob 3s ease-in-out infinite; }
.filebox { display: flex; gap: 12px; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 12px 14px; }
.filebox .nm { font-weight: 700; overflow-wrap: anywhere; }
.field { margin: 14px 0; }
.field > label, .field > .lb { display: block; font-weight: 700; margin-bottom: 6px; }
.field .req { color: var(--bad); }
.field small { display: block; color: var(--ink2); font-size: 14px; margin-top: 4px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.preview { background: var(--butter); border-radius: 16px; padding: 12px 14px; font-size: 15px; overflow-wrap: anywhere; }
.preview code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.check { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 14px; cursor: pointer; }
.check input { width: 26px; height: 26px; flex: none; margin-top: 3px; accent-color: var(--blue); }
.progress { height: 20px; border-radius: 10px; background: var(--sky); position: relative; margin: 38px 0 10px; }
.progress .fill { height: 100%; border-radius: 10px; background: var(--blue); width: 0; transition: width .25s linear; }
.progress .ship { position: absolute; top: -34px; font-size: 32px; transition: left .25s linear; transform: translateX(-50%); }
.done { text-align: center; padding: 18px 8px; position: relative; overflow: hidden; }
.done .big { font-size: 72px; display: block; animation: pop .5s var(--ease); }
.confetti { position: absolute; top: -20px; font-size: 22px; animation: fall 2.2s ease-in forwards; pointer-events: none; }

/* ---------- ทั่วไป ---------- */
.center { min-height: 100vh; display: grid; place-content: center; text-align: center; padding: 24px; gap: 6px; max-width: 560px; margin: 0 auto; }
.hero-big { font-size: 84px; line-height: 1; animation: bob 3.4s ease-in-out infinite; }
.gbtn { display: flex; justify-content: center; min-height: 52px; margin: 14px 0 6px; }
.small { font-size: 14px; color: var(--ink2); }
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--navy); color: #fff; border-radius: 999px; padding: 12px 22px; max-width: 92vw; opacity: 0; pointer-events: none; z-index: 60; transition: opacity .25s, transform .25s var(--ease); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); }
.offline { background: var(--sun); color: var(--ink); text-align: center; padding: 6px; font-size: 15px; }
table.t { width: 100%; border-collapse: collapse; font-size: 16px; }
table.t th, table.t td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--ink2); font-weight: 400; font-size: 14px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 10px; }

/* ---------- ลูกเล่น ---------- */
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } 20% { opacity: .55; } to { transform: translateY(-90px); opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-5deg) scale(1.05); } 40% { transform: rotate(5deg) scale(1.05); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(3deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fall { to { transform: translateY(340px) rotate(360deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
