/* ===== ฟอนต์: Kanit (หัวข้อ) + ค่าเริ่มต้นของเบราว์เซอร์ (เนื้อหา) ===== */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* ----- ธีมสี มจพ. (พระนครเหนือ) — ส้ม/ดำ ----- */
  --navy: #16130f;
  --navy-2: #2a2118;
  --primary: #e2661a;
  --primary-2: #f5872e;
  --primary-3: #ffa94d;
  --accent: #c0392b;
  --accent-2: #ff6b3d;
  --bg: #f4eee6;
  --surface: #ffffff;
  --surface-2: #faf6f1;
  --text: #1f1a15;
  --muted: #8a7d70;
  --border: #ece3d8;
  --ok: #15a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(60, 35, 10, 0.10);
  --shadow-lg: 0 24px 60px rgba(60, 35, 10, 0.18);
  --radius: 18px;
  --glass: rgba(255, 255, 255, 0.72);
  --font-head: 'Kanit', sans-serif;
  --font-body: sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0; font-family: var(--font-body); font-size: 18px; line-height: 1.55;
  color: var(--text); background: var(--bg); min-height: 100vh; position: relative; overflow-x: hidden;
}
body::before {
  content: ''; position: fixed; inset: -20% -20% auto -20%; height: 80vh; z-index: -2;
  background:
    radial-gradient(45% 55% at 18% 20%, rgba(245,135,46,0.30), transparent 60%),
    radial-gradient(40% 50% at 85% 12%, rgba(192,57,43,0.22), transparent 60%),
    radial-gradient(50% 60% at 60% 0%, rgba(255,169,77,0.20), transparent 55%);
  filter: blur(20px); animation: floatBg 18s ease-in-out infinite alternate;
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(rgba(60,35,10,0.04) 1px, transparent 1px); background-size: 22px 22px;
}
@keyframes floatBg { 0% { transform: translate3d(0,0,0) scale(1); } 100% { transform: translate3d(0,18px,0) scale(1.06); } }

h1, h2, h3, h4, .head { font-family: var(--font-head); font-weight: 600; letter-spacing: .2px; }
a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-2); }

/* ===== Top bar (glass) ===== */
.topbar {
  background: rgba(22, 19, 15, 0.78);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  color: #fff; padding: 14px 28px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50; border-bottom: 1px solid rgba(255,255,255,0.08); box-shadow: 0 8px 30px rgba(0,0,0,0.18);
}
.topbar .brand { font-family: var(--font-head); font-weight: 700; font-size: 20px; line-height: 1.1; display:flex; flex-direction:column; }
.topbar .brand small { font-family: var(--font-body); font-weight: 400; font-size: 12.5px; color: #d9c4ae; margin-top:2px; }
.topbar .spacer { flex: 1; }
.topbar .navlink { color:#e9d9c8; margin-left:20px; font-family:var(--font-head); font-size:15px; position:relative; transition: color .15s; }
.topbar .navlink:hover { color:#fff; }
.topbar .navlink.active { color:#fff; }
.topbar .navlink.active::after { content:''; position:absolute; left:0; right:0; bottom:-7px; height:3px; border-radius:3px; background:linear-gradient(90deg,var(--primary),var(--primary-3)); }

/* ===== Layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 32px 24px 70px; position: relative; z-index: 1; }
.container.narrow { max-width: 560px; }
.page-title {
  font-size: 34px; margin: 6px 0 4px; font-weight: 700;
  background: linear-gradient(100deg, var(--navy), var(--primary) 130%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.page-sub { color: var(--muted); margin: 0 0 24px; font-size: 17px; }

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-head); font-size: 16px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; border: none; padding: 11px 22px; border-radius: 12px; cursor: pointer;
  box-shadow: 0 8px 20px rgba(226,102,26,0.30);
  transition: transform .08s ease, box-shadow .2s ease, filter .15s ease; text-decoration: none;
}
.btn::after {
  content:''; position:absolute; top:0; left:-120%; width:60%; height:100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.45), transparent);
  transform: skewX(-20deg); transition: left .55s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(226,102,26,0.40); text-decoration:none; color:#fff; }
.btn:hover::after { left: 130%; }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; justify-content: center; }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); box-shadow:none; }
.btn.ghost:hover { background: rgba(226,102,26,0.08); color: var(--primary); }
.btn.dark { background: linear-gradient(135deg, #2a2118, #4a3a2a); box-shadow: 0 8px 20px rgba(0,0,0,0.25); }
.btn.ok { background: linear-gradient(135deg, #15a34a, #1fbf5b); box-shadow:0 8px 20px rgba(21,163,74,.3); }
.btn.warn { background: linear-gradient(135deg, #d97706, #f59e0b); box-shadow:0 8px 20px rgba(217,119,6,.3); }
.btn.danger { background: linear-gradient(135deg, #dc2626, #ef4444); box-shadow:0 8px 20px rgba(220,38,38,.3); }
.btn.sm { padding: 7px 14px; font-size: 14px; border-radius: 10px; }

/* ===== Cards / panels ===== */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); position: relative; }

/* ===== Auth ===== */
.auth-wrap { min-height: calc(100vh - 62px); display: grid; place-items: center; padding: 36px 16px; }
.auth-card { width: 100%; max-width: 450px; position: relative; animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }
.auth-card.panel { background: var(--glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border:1px solid rgba(255,255,255,0.6); box-shadow: var(--shadow-lg); padding: 34px 30px; }
.auth-card::before { content:''; position:absolute; inset:-1.5px; border-radius: calc(var(--radius) + 2px); z-index:-1; background: linear-gradient(135deg, var(--primary), var(--accent), var(--primary-3)); filter: blur(10px); opacity:.35; }
.auth-card .logo { width:78px; height:78px; margin:0 auto 6px; border-radius:22px; display:grid; place-items:center; font-size:38px; background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: 0 14px 30px rgba(226,102,26,0.45); animation: floaty 4s ease-in-out infinite; }
@keyframes floaty { 0%,100%{ transform: translateY(0) rotate(-2deg);} 50%{ transform: translateY(-7px) rotate(2deg);} }
.auth-card h1 { text-align: center; color: var(--navy); margin: 12px 0 2px; font-size:26px; }
.auth-card .muted { text-align: center; color: var(--muted); margin-bottom: 18px; }

label { display: block; font-family: var(--font-head); font-weight: 500; font-size: 15px; margin: 16px 0 6px; color: var(--navy); }
.req { color: var(--danger); }
input, textarea, select { width: 100%; font-family: var(--font-body); font-size: 17px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(226,102,26,0.16); background:#fff; }
textarea { resize: vertical; min-height: 92px; }
.field-help { font-size: 14px; color: var(--muted); margin-top: 5px; }
.pin-input { letter-spacing: 10px; text-align: center; font-size: 24px; font-family: var(--font-head); }

.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 16px; }
.alert.error { background: #fde8e8; color: #9b1c1c; border: 1px solid #f5c2c2; }
.alert.ok { background: #e7f6ec; color: #166534; border: 1px solid #b7e1c5; }
.alert.info { background: #fff1e3; color: #9a4a12; border: 1px solid #ffd9b3; }

/* ===== Progress ===== */
.progress-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; overflow:hidden; }
.progress-bar { flex: 1; min-width: 220px; height: 16px; background: #ece0d2; border-radius: 99px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.08); }
.progress-bar > span { display: block; height: 100%; border-radius: 99px; transition: width .5s; position:relative; background: linear-gradient(90deg, var(--primary), var(--primary-3)); }
.progress-bar > span::after { content:''; position:absolute; inset:0; background: linear-gradient(100deg, transparent, rgba(255,255,255,.5), transparent); background-size: 200% 100%; animation: shimmer 2.2s linear infinite; }
@keyframes shimmer { 0%{ background-position: 200% 0; } 100%{ background-position: -200% 0; } }

/* ===== Lab cards grid ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 22px; }
.lab-card {
  --accent: var(--primary); position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 210px;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s; animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
.grid .lab-card:nth-child(1){animation-delay:.03s}.grid .lab-card:nth-child(2){animation-delay:.08s}
.grid .lab-card:nth-child(3){animation-delay:.13s}.grid .lab-card:nth-child(4){animation-delay:.18s}
.grid .lab-card:nth-child(5){animation-delay:.23s}.grid .lab-card:nth-child(6){animation-delay:.28s}
.grid .lab-card:nth-child(7){animation-delay:.33s}.grid .lab-card:nth-child(8){animation-delay:.38s}
@keyframes rise { from{ opacity:0; transform: translateY(18px); } to{ opacity:1; transform:none; } }
.lab-card:hover { transform: translateY(-7px) scale(1.012); box-shadow: 0 26px 55px rgba(60,35,10,0.22); }

/* แล็บที่ยังไม่เปิด: ขาว-ดำ + ปริศนา */
.lab-card.locked { filter: grayscale(1); opacity: .92; }
.lab-card.locked .card-top { background: linear-gradient(135deg, #5c5c5c, #1f1f1f); }
.lab-card.locked:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.lab-card.locked:hover .card-top .icon { transform: none; }
.lab-card.locked .card-top .icon { opacity: .85; }
.mystery { letter-spacing: 6px; font-weight: 700; }

.lab-card:hover .card-top .icon { transform: scale(1.12) rotate(-6deg); }
.lab-card .card-top { padding: 20px 20px 16px; color: #fff; position: relative; overflow:hidden; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 58%, #000 42%)); }
.lab-card .card-top::after { content:''; position:absolute; top:-40%; right:-10%; width:160px; height:160px; border-radius:50%; background: radial-gradient(circle, rgba(255,255,255,.35), transparent 70%); }
.lab-card .card-top .icon { font-size: 34px; display:inline-block; transition: transform .25s ease; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }
.lab-card .card-top h3 { margin: 10px 0 2px; font-size: 19px; line-height: 1.25; }
.lab-card .card-top .sub { font-size: 14px; opacity: .92; }
.lab-card .card-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 13px; flex: 1; }
.lab-card .card-body .meta { color: var(--muted); font-size: 15px; flex: 1; }
.lab-card .card-actions { display:flex; gap:8px; align-items:center; }

.card-top.pattern-stripes::before { content:''; position:absolute; inset:0; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 10px, transparent 10px 20px); }
.card-top.pattern-dots::before { content:''; position:absolute; inset:0; background-image: radial-gradient(rgba(255,255,255,.22) 2px, transparent 2px); background-size: 16px 16px; }
.card-top.pattern-grid::before { content:''; position:absolute; inset:0; background-image: linear-gradient(rgba(255,255,255,.14) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.14) 1px, transparent 1px); background-size: 20px 20px; }
.card-top.pattern-gradient::before { content:''; position:absolute; inset:0; background-image: radial-gradient(circle at 85% 15%, rgba(255,255,255,.28), transparent 45%); }

/* ===== Status badges ===== */
.badge { display:inline-flex; align-items:center; gap:7px; font-family: var(--font-head); font-size: 13px; font-weight: 500; padding: 5px 12px; border-radius: 99px; }
.badge::before { content:''; width:8px; height:8px; border-radius:50%; background: currentColor; }
.badge.closed { background:#f1ece5; color:#7c7165; }
.badge.open { background:#fff1e3; color:#c4570f; }
.badge.open::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ box-shadow:0 0 0 0 rgba(196,87,15,.5);} 50%{ box-shadow:0 0 0 5px rgba(196,87,15,0);} }
.badge.submitted { background:#fff3e0; color:#b45309; }
.badge.complete { background:#e7f6ec; color:#15803d; }

/* ===== Lab detail ===== */
.lab-detail-head { border-radius: var(--radius); color:#fff; padding: 30px; margin: 16px 0 24px; box-shadow: var(--shadow-lg); position:relative; overflow:hidden; animation: rise .5s both; }
.lab-detail-head::after { content:''; position:absolute; top:-60px; right:-40px; width:240px; height:240px; border-radius:50%; background: radial-gradient(circle, rgba(255,255,255,.25), transparent 70%); }
.lab-detail-head .icon { font-size: 46px; filter: drop-shadow(0 6px 12px rgba(0,0,0,.3)); }
.lab-detail-head h1 { margin: 8px 0 2px; font-size:30px; }
.lab-detail-head .sub { opacity:.93; }
.two-col { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
.instruction ol, .instruction ul { padding-left: 20px; }
.instruction p { margin: 8px 0; }
.instruction li { margin: 6px 0; }

.poem { background: linear-gradient(135deg, var(--navy), #3a2c1d); color: #ffe9d4; border-radius: 16px; padding: 26px 30px 26px 36px; font-family: var(--font-head); font-weight: 400; font-size: 20px; line-height: 1.95; white-space: pre; border-left: 5px solid var(--primary-2); margin-bottom: 18px; overflow-x:auto; position:relative; box-shadow: inset 0 0 40px rgba(0,0,0,.25); }
.poem::before { content:'\201C'; position:absolute; top:2px; left:10px; font-size:54px; color: var(--primary-3); opacity:.5; font-family:Georgia,serif; }

.attach-list { list-style:none; padding:0; margin: 10px 0 0; }
.attach-list li { display:flex; align-items:center; gap:10px; padding:12px 14px; background:var(--surface-2); border:1px solid var(--border); border-radius:12px; margin-bottom:9px; transition: border-color .15s, transform .12s; }
.attach-list li:hover { border-color: var(--primary); transform: translateX(3px); }
.attach-list .fname { flex:1; }

/* ===== Peers ===== */
.peer-card { border:1px solid var(--border); border-radius:16px; padding:18px 20px; background:var(--surface); box-shadow: var(--shadow); margin-bottom:16px; transition: transform .12s, box-shadow .15s; animation: rise .4s both; }
.peer-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.peer-card.me { box-shadow: 0 0 0 2px rgba(226,102,26,.22), var(--shadow); }
.peer-head { display:flex; align-items:center; gap:10px; margin-bottom:10px; flex-wrap:wrap; }
.peer-name { font-family: var(--font-head); font-weight:500; }
.peer-field { margin: 10px 0; }
.peer-field .k { font-family: var(--font-head); font-size:14px; color: var(--primary); font-weight:500; }
.peer-field .v { white-space: pre-wrap; }
.chip { display:inline-block; background:var(--surface-2); border:1px solid var(--border); border-radius:9px; padding:2px 10px; font-size:14px; }

/* ===== Tables (admin) ===== */
.table { width:100%; border-collapse: collapse; background:var(--surface); border-radius: var(--radius); overflow:hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 13px 15px; text-align:left; border-bottom:1px solid var(--border); font-size:16px; }
.table th { font-family: var(--font-head); font-weight:500; background:var(--surface-2); color:var(--navy); }
.table tr:last-child td { border-bottom:none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fff7ef; }
.table .num { text-align:center; }
.mini-bar { height:9px; background:#ece0d2; border-radius:99px; overflow:hidden; min-width:120px; }
.mini-bar > span { display:block; height:100%; background:linear-gradient(90deg,var(--primary),var(--primary-3)); }

.toolbar { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:22px; }
.stat-row { display:flex; gap:18px; flex-wrap:wrap; margin-bottom:24px; }
.stat { background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:18px 22px; box-shadow:var(--shadow); flex:1; min-width:150px; position:relative; overflow:hidden; transition: transform .15s; }
.stat:hover { transform: translateY(-3px); }
.stat::after { content:''; position:absolute; top:-30px; right:-30px; width:90px; height:90px; border-radius:50%; background: radial-gradient(circle, rgba(245,135,46,.18), transparent 70%); }
.stat .n { font-family:var(--font-head); font-weight:700; font-size:34px; line-height:1; background: linear-gradient(120deg, var(--primary), var(--accent)); -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; }
.stat .l { color:var(--muted); font-size:15px; margin-top:4px; }

details.add-lab { margin-top:26px; background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:8px 20px; box-shadow:var(--shadow); }
details.add-lab summary { cursor:pointer; font-family:var(--font-head); font-weight:500; padding:10px 0; color:var(--navy); }
.row2 { display:grid; grid-template-columns:1fr 1fr; gap:14px; }

/* ===== Footer ===== */
.footer { text-align:center; color:var(--muted); font-size:14px; padding: 28px; position:relative; z-index:1; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  body { font-size: 17px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .container { padding: 22px 16px 56px; }
  .page-title { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) { *, body::before { animation: none !important; transition: none !important; } }

/* ===== Nav badge (จำนวนคำถาม/คอมเมนต์) ===== */
.nav-badge { display:inline-flex; align-items:center; justify-content:center; min-width:20px; height:20px; padding:0 6px; margin-left:2px;
  font-family:var(--font-head); font-size:12px; font-weight:600; line-height:1; color:#fff; border-radius:99px;
  background:linear-gradient(135deg,var(--primary),var(--accent)); box-shadow:0 2px 8px rgba(226,102,26,.5); vertical-align:middle; }
/* ===== Participants page ===== */
.lab-chips { display:flex; flex-wrap:wrap; gap:5px; }
.lab-chip { width:24px; height:24px; border-radius:7px; display:inline-grid; place-items:center; font-size:13px; border:1px solid var(--border); cursor:default; }
.lab-chip.none { background:#f1ece5; color:#a99e92; }
.lab-chip.submitted { background:#fff3e0; color:#b45309; border-color:#ffd9a8; }
.lab-chip.complete { background:#e7f6ec; color:#15803d; border-color:#b7e1c5; }

/* ── ความยินยอมการใช้ข้อมูล (consent / data privacy) ── */
.consent-box {
  margin-top: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 14px 16px;
}
.consent-title {
  font-family: var(--font-head);
  color: var(--navy);
  font-size: 15px;
  margin-bottom: 6px;
}
.consent-text {
  font-size: 14px;
  line-height: 1.7;
  color: #5a5048;
  margin: 0 0 12px;
}
.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 14.5px;
  color: var(--navy);
  line-height: 1.6;
}
.consent-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex: 0 0 auto;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── auth card แบบกว้าง + จัด input เป็น grid responsive ── */
.auth-card.wide { max-width: 760px; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 20px; text-align: left; }
.auth-grid .field { display: flex; flex-direction: column; min-width: 0; }
.auth-grid .field label { margin-top: 12px; }
.auth-grid .col-full { grid-column: 1 / -1; }
@media (max-width: 600px) {
  .auth-card.wide { max-width: 460px; }
  .auth-grid { grid-template-columns: 1fr; }
}
