/* LabDrop — กรมท่าเข้ม (ink) + ฟ้าไซแอน (cyan) + เหลืองอำพัน
   แผงบนภาพกล้องเป็นกระจกเข้ม ตัวหนังสือใหญ่ กดด้วยนิ้วโป้งได้ */
:root {
  --ink: #0b1220;
  --ink-2: #111a2e;
  --ink-3: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --cyan: #22d3ee;
  --cyan-d: #0891b2;
  --amber: #fbbf24;
  --green: #22c55e;
  --red: #ef4444;
  --glass: rgba(11, 18, 32, 0.78);
  --glass-line: rgba(148, 163, 184, 0.22);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: system-ui, "Noto Sans Thai", "Sarabun", "Leelawadee UI", sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- ปุ่ม ---------- */
.btn {
  font-size: 16px; font-weight: 700; border: 0; border-radius: 14px;
  padding: 12px 16px; min-height: 46px; transition: transform .08s, background .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--cyan); color: var(--ink); }
.btn-soft { background: #e0f7fb; color: var(--cyan-d); }
.btn-ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; }
.btn-accent { background: var(--amber); color: var(--ink); }
.btn-sm { font-size: 14px; padding: 8px 12px; min-height: 38px; border-radius: 12px; }
.btn-big { font-size: 19px; padding: 16px 28px; min-height: 58px; border-radius: 18px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }

/* ---------- หน้าแรก ---------- */
#home { max-width: 720px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 18px calc(28px + var(--safe-b)); }
.hero { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.logo svg { width: 60px; height: 60px; display: block; }
.brand { font-size: 32px; font-weight: 900; letter-spacing: -.02em; }
.brand span { color: var(--cyan-d); }
.hero p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }
.support { border-radius: 14px; padding: 12px 14px; font-size: 14px; background: var(--surface); line-height: 1.5; }
.support b { display: block; font-size: 15px; }
.support.ok { background: #dcfce7; color: #14532d; }
.support.no { background: #fef3c7; color: #78350f; }
.support span { display: block; }

.models { display: grid; gap: 12px; }
.model {
  display: flex; gap: 14px; background: var(--surface); border-radius: var(--radius);
  padding: 14px; box-shadow: 0 1px 2px rgba(11,18,32,.06), 0 8px 24px rgba(11,18,32,.06);
  border: 2px solid transparent;
}
.model.highlight { border-color: var(--cyan); }
.model-art { flex: 0 0 120px; background: #0b1220; border-radius: 14px; display: grid; place-items: center; }
.model-art svg { width: 110px; height: 74px; }
.model-body { flex: 1; min-width: 0; }
.model h3 { font-size: 19px; }
.model p { margin: 4px 0 10px; color: var(--muted); font-size: 14px; }
.model-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.model.coming { opacity: .6; box-shadow: none; background: transparent; border: 1.5px dashed #cbd5e1; padding: 10px 14px; }
.model.coming p { margin-bottom: 0; }
.tag { font-size: 11px; font-weight: 700; background: #e2e8f0; color: var(--muted); border-radius: 99px; padding: 2px 8px; vertical-align: middle; }
@media (max-width: 460px) {
  .model { flex-direction: column; }
  .model-art { flex-basis: auto; height: 96px; }
}
.how ol { margin: 0; padding-left: 22px; line-height: 1.7; font-size: 15px; }
.tip { background: #e0f2fe; color: #0c4a6e; border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.55; }
.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 24px; }

/* ---------- ฉาก ---------- */
#stage { position: fixed; inset: 0; color: #e2e8f0; overflow: hidden; touch-action: none; }
body.in-3d #stage { background: radial-gradient(120% 90% at 50% 0%, #334155 0%, #1e293b 55%, #0b1220 100%); }
body.in-ar #stage { background: transparent; }
body.in-ar, body.in-ar html { background: transparent; }
#canvas-host canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; touch-action: none; }

.topbar {
  position: absolute; top: calc(10px + var(--safe-t)); left: 10px; right: 10px;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.top-title { background: var(--glass); border-radius: 12px; padding: 8px 12px; font-size: 16px; backdrop-filter: blur(8px); }
.badge {
  margin-left: auto; background: rgba(34, 211, 238, .9); color: var(--ink); font-weight: 800; font-size: 13px;
  padding: 7px 11px; border-radius: 99px;
}
.badge.warn { background: var(--amber); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--glass); color: #fff;
  font-size: 20px; display: grid; place-items: center; backdrop-filter: blur(8px); flex: 0 0 auto;
}
.icon-btn.play { background: var(--cyan); color: var(--ink); width: 56px; font-size: 22px; }

.hint {
  position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  background: var(--glass); padding: 10px 16px; border-radius: 99px; font-size: 15px; font-weight: 600;
  white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
.place-bar { position: absolute; left: 0; right: 0; bottom: calc(40px + var(--safe-b)); display: flex; justify-content: center; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(118px + var(--safe-t)); z-index: 30;
  background: #f8fafc; color: var(--ink); font-weight: 700; font-size: 14px; padding: 10px 14px;
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: calc(100% - 24px); text-align: center;
}
#home-toast { top: auto; bottom: calc(20px + var(--safe-b)); }

/* แผงล่าง */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  background: var(--glass); backdrop-filter: blur(12px); border-top: 1px solid var(--glass-line);
  border-radius: 20px 20px 0 0; padding: 10px 12px calc(10px + var(--safe-b));
  max-height: 62vh; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
}
body.in-ar .sheet { display: none; }
body.in-ar.placed .sheet { display: block; }
.readouts { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chip { flex: 0 0 auto; background: rgba(255,255,255,.07); border-radius: 10px; padding: 5px 9px; min-width: 64px; }
.chip span { display: block; font-size: 11px; color: #94a3b8; }
.chip b { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transport { display: flex; gap: 8px; align-items: center; }
.transport .icon-btn { background: rgba(255,255,255,.1); }
.transport .icon-btn.play { background: var(--cyan); }
.transport #btn-predict { margin-left: auto; }
.icon-btn.speed { width: auto; min-width: 58px; padding: 0 10px; font-size: 16px; font-weight: 800; }
.icon-btn.speed.slow { background: var(--amber); color: var(--ink); }

.seg { display: flex; gap: 4px; background: rgba(255,255,255,.08); border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 7px 10px; font-size: 14px; font-weight: 700; color: #cbd5e1; }
.seg button.on { background: #f8fafc; color: var(--ink); }
.seg button small { font-weight: 500; opacity: .7; }
.seg.small button { padding: 6px 8px; font-size: 13px; }

.tabs { display: flex; gap: 4px; margin-top: 10px; border-top: 1px solid var(--glass-line); padding-top: 8px; }
.tabs button { flex: 1; border: 0; background: transparent; color: #94a3b8; font-weight: 700; font-size: 14px; padding: 8px 4px; border-radius: 10px; }
.tabs button.on { background: rgba(34,211,238,.18); color: var(--cyan); }
.pane { padding-top: 10px; }

.field { display: block; margin-bottom: 12px; }
.field-label { display: flex; justify-content: space-between; font-size: 14px; color: #cbd5e1; margin-bottom: 4px; gap: 8px; }
.field-label output { color: #fff; font-weight: 800; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--cyan); height: 28px; }
.toggle { display: flex; gap: 10px; align-items: center; padding: 8px 2px; font-size: 15px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--cyan); }
#graph { width: 100%; height: 150px; display: block; margin-top: 8px; background: rgba(0,0,0,.2); border-radius: 10px; }
.theory ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.65; }
.theory li { margin-bottom: 4px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* การ์ดทายก่อนดู */
.sheet-card {
  position: absolute; left: 12px; right: 12px; max-width: 480px; margin: 0 auto; z-index: 20;
  top: calc(70px + var(--safe-t)); background: #f8fafc; color: var(--ink); border-radius: 18px;
  padding: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.45);
}
.sheet-card h3 { font-size: 18px; }
.sheet-card p { margin: 6px 0 12px; font-size: 15px; line-height: 1.5; }
.sheet-card .row { margin: 12px 0 0; justify-content: flex-end; }
.pr-input { display: flex; gap: 6px; align-items: center; }
.pr-input button { border: 0; background: #e2e8f0; border-radius: 10px; padding: 8px 6px; font-weight: 700; font-size: 13px; min-width: 44px; }
.pr-input input { flex: 1; min-width: 0; font: inherit; font-size: 22px; font-weight: 800; text-align: center; border: 2px solid #cbd5e1; border-radius: 12px; padding: 6px; }
.pr-input span { font-weight: 700; }
.result .pr-row { display: flex; justify-content: space-between; font-size: 16px; padding: 4px 0; }
.result .pr-row b { font-variant-numeric: tabular-nums; }
.verdict { font-weight: 800; font-size: 17px; border-radius: 10px; padding: 8px 10px; margin: 8px 0 10px !important; }
.verdict.great { background: #dcfce7; color: #14532d; }
.verdict.ok { background: #fef3c7; color: #78350f; }
.verdict.miss { background: #fee2e2; color: #7f1d1d; }
.result .btn { width: 100%; }
