/* SPIRIZ Shift Check — คอนกรีต · เหล็กเจาะรู · โต๊ะแดง
   ความโดดเด่นอยู่ที่เดียว: การ์ดกราไฟต์ลายเหล็กเจาะรู (สรุปวันนี้) ที่เหลือเงียบและเรียบ */
:root {
  --concrete: #E6E5E1;   /* พื้นหลัง */
  --slab: #F7F7F4;       /* พื้นผิวการ์ด */
  --graphite: #24272A;   /* ตัวอักษร / การ์ดหลัก */
  --steel: #747C83;      /* ตัวอักษรรอง */
  --line: #D4D2CB;
  --brand: #FF3131;      /* แดงโลโก้ SPiRiZ */
  --red: #E5302C;        /* สถานะไม่ผ่าน (เข้มกว่าโลโก้เล็กน้อย ให้อ่านง่ายบนพื้นขาว) */
  --red-bg: #FBE6E2;
  --green: #2D8655;
  --green-bg: #E1F1E7;
  --amber: #C98516;
  --amber-bg: #FBEFD7;
  --blue: #3D6A9C;
  --blue-bg: #E3ECF6;
  --display: "Bai Jamjuree", "IBM Plex Sans Thai", system-ui, sans-serif;
  --body: "IBM Plex Sans Thai", system-ui, sans-serif;
  --perf: radial-gradient(circle, rgba(255,255,255,.075) 1.3px, transparent 1.5px) 0 0 / 9px 9px;
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--concrete); color: var(--graphite); font: 16px/1.5 var(--body); -webkit-tap-highlight-color: transparent; }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- top bar ---------- */
#top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px; background: rgba(230,229,225,.92); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 9px; }
.brand img:first-child { height: 26px; width: 26px; }
.brand img:last-child { height: 17px; width: auto; }
#who:empty { display: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--graphite); color: #fff; font: 600 15px var(--display); cursor: pointer; }
#netbar { margin: 0 14px 8px; padding: 9px 14px; border-radius: 12px; background: var(--amber-bg); color: #7a5208; font-size: 14px; }
main { max-width: 560px; margin: 0 auto; padding: 4px 14px 0; }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.005em; }
h1 { font-size: 26px; line-height: 1.15; font-weight: 700; }
h2 { font-size: 20px; line-height: 1.25; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--steel); }
.small { font-size: 13px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.page-head .grow { min-width: 0; }
.page-head p { margin: 2px 0 0; }
.back { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--slab); display: grid; place-items: center; flex: none; cursor: pointer; }

/* ---------- surfaces ---------- */
.panel { background: var(--slab); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.group { background: var(--slab); border-radius: 16px; margin-bottom: 12px; overflow: hidden; }
.group > .row-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid #ebe9e3; }
.group > .row-item:first-child { border-top: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 22px 4px 10px; }
.section-title h2 { font-size: 18px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.empty { text-align: center; color: var(--steel); padding: 34px 16px; }

/* ---------- hero (สรุปวันนี้) — จุดเด่นเดียวของแอป ---------- */
.hero { position: relative; background: var(--perf), var(--graphite); color: #EDEDEA; border-radius: 22px; padding: 18px 18px 16px; margin-bottom: 8px; overflow: hidden; }
.hero .date { font: 600 15px var(--display); color: #B9BDC0; }
.hero .count { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 2px; }
.hero .count b { font: 700 64px/0.95 var(--display); letter-spacing: -.02em; color: #fff; }
.hero .count span { font: 500 22px var(--display); color: #8E959A; }
.hero .caption { color: #C9CCCE; font-size: 15px; }
.plates { display: flex; flex-wrap: wrap; gap: 5px; margin: 14px 0 12px; }
.plates i { width: 16px; height: 16px; border-radius: 4px; background: rgba(255,255,255,.13); }
.plates i.g { background: #4CC17F; } .plates i.r { background: var(--red); } .plates i.y { background: #E8A93A; } .plates i.b { background: #6E9BD0; } .plates i.x { background: #8C99A8; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.hero .tag { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.09); color: #DADDDF; }
.hero .tag.night { background: rgba(232,169,58,.18); color: #F2C77A; }
.hero .warn { margin-top: 12px; font-size: 13px; color: #B9BDC0; }
.hero .warn b { color: #fff; }
.hero input[type=date] { position: absolute; right: 14px; top: 14px; width: auto; padding: 4px 8px; font-size: 13px; background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 8px; color-scheme: dark; }

/* ---------- รอบ + โซน ---------- */
.round-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 4px 10px; }
.round-head h2 { font-size: 18px; }
.round-head .when { font-size: 14px; color: var(--steel); }
.round-head .when.open { color: var(--green); font-weight: 600; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 92px; text-align: left; border: 0; border-radius: 14px;
  background: var(--slab); padding: 12px 12px 12px 16px; cursor: pointer; overflow: hidden; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #CFCdC6; }
.tile b { font: 600 16px/1.25 var(--display); }
.tile .st { font-size: 13px; color: var(--steel); }
.tile .sc { position: absolute; right: 12px; top: 10px; font: 700 15px var(--display); }
.tile.g::before { background: var(--green); } .tile.g .st { color: var(--green); }
.tile.r { background: var(--red-bg); } .tile.r::before { background: var(--red); } .tile.r .st, .tile.r .sc { color: var(--red); font-weight: 600; }
.tile.y::before { background: var(--amber); } .tile.y .st, .tile.y .sc { color: var(--amber); }
.tile.b::before { background: var(--blue); } .tile.b .st { color: var(--blue); }
.tile.x::before { background: #8C99A8; }
.tile.locked { opacity: .55; }
.tile:active { transform: scale(.98); }

/* ---------- chips / status ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: #E4E2DC; color: var(--steel); white-space: nowrap; }
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.bad { background: var(--red-bg); color: var(--red); }
.chip.warn { background: var(--amber-bg); color: var(--amber); }
.chip.info { background: var(--blue-bg); color: var(--blue); }
.score { font: 700 30px/1 var(--display); }
.score.g { color: var(--green); } .score.r { color: var(--red); } .score.y { color: var(--amber); }

/* ---------- ผลของโซน ---------- */
.verdict { border-radius: 18px; padding: 16px; margin-bottom: 12px; background: var(--slab); }
.verdict.r { background: var(--red-bg); } .verdict.g { background: var(--green-bg); } .verdict.y { background: var(--amber-bg); }
.verdict .big { font: 700 52px/1 var(--display); letter-spacing: -.02em; }
.verdict.r .big { color: var(--red); } .verdict.g .big { color: var(--green); } .verdict.y .big { color: var(--amber); }
.verdict p { margin: 6px 0 0; }

/* ---------- มุมถ่ายรูป ---------- */
.point { background: var(--slab); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.point-top { display: flex; gap: 12px; align-items: center; }
.point-top .thumb { width: 64px; height: 84px; }
.point-top .thumb.land { width: 104px; height: 78px; }
.point h3 { font-size: 15px; line-height: 1.3; }
.point .crit { font-size: 13px; color: var(--steel); margin-top: 2px; }
.thumb { border-radius: 10px; object-fit: cover; background: #DEDCD6; flex: none; display: grid; place-items: center; color: var(--steel); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.pair.land { grid-template-columns: 1fr; }
.pair figure { margin: 0; } .pair figcaption { font-size: 12px; color: var(--steel); margin-bottom: 4px; }
.shot { position: relative; background: #DEDCD6; border-radius: 12px; overflow: hidden; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .box { position: absolute; border: 3px solid var(--red); border-radius: 6px; box-shadow: 0 0 0 1px rgba(255,255,255,.6); }
.shot .box span { position: absolute; top: -22px; left: -3px; background: var(--red); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 5px; white-space: nowrap; }

/* ---------- buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 600; background: var(--graphite); color: #fff; cursor: pointer; text-decoration: none; }
.btn.block { width: 100%; }
.btn.red { background: var(--red); } .btn.green { background: var(--green); }
.btn.ghost { background: transparent; color: var(--graphite); border: 1.5px solid var(--line); }
.btn.light { background: #E4E2DC; color: var(--graphite); }
.btn.sm { padding: 8px 12px; border-radius: 11px; font-size: 14px; }
.btn:disabled { opacity: .4; }
.btn:active { transform: scale(.98); }
.sticky-cta { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); z-index: 4; margin-top: 14px; }
.sticky-cta .btn { box-shadow: 0 8px 24px rgba(36,39,42,.25); }
input, select, textarea { width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--graphite); }
label { display: block; font-size: 14px; color: var(--steel); margin: 12px 0 5px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--graphite); }
.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--graphite); font-size: 14px; }
details > summary { cursor: pointer; list-style: none; } details > summary::-webkit-details-marker { display: none; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid #ebe9e3; } th { color: var(--steel); font-weight: 500; }

/* ---------- segmented tabs (ตั้งค่า) ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -14px 14px; padding: 0 14px 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 0; border-radius: 99px; padding: 8px 14px; background: #DCDAD4; color: var(--graphite); font-size: 14px; cursor: pointer; }
.tabs button.on { background: var(--graphite); color: #fff; }

/* ---------- เดือน ---------- */
.month-big { display: flex; align-items: baseline; gap: 10px; }
.month-big b { font: 700 56px/1 var(--display); }
.month-big b.zero { color: var(--green); } .month-big b.some { color: var(--red); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.cal .h { font-size: 12px; color: var(--steel); text-align: center; }
.cal .d { aspect-ratio: 1; border-radius: 10px; background: #ECEAE5; display: grid; place-items: center; font: 600 14px var(--display); color: var(--steel); position: relative; }
.cal .d.g { background: var(--green-bg); color: var(--green); }
.cal .d.r { background: var(--red); color: #fff; }
.cal .d.p { background: #fff; color: var(--graphite); box-shadow: inset 0 0 0 1.5px var(--line); }
.cal .d.off { background: transparent; color: #B5B3AD; }
.cal .d small { position: absolute; bottom: 2px; font-size: 10px; }
.person { display: flex; align-items: center; gap: 12px; }
.person .av { width: 40px; height: 40px; border-radius: 50%; background: var(--graphite); color: #fff; display: grid; place-items: center; font: 600 16px var(--display); flex: none; }
.bonus b { font: 700 18px var(--display); }

/* ---------- bottom nav ---------- */
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; background: rgba(247,247,244,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav:empty { display: none; }
#nav a { flex: 1; max-width: 140px; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--steel); text-decoration: none; position: relative; }
#nav a svg { width: 24px; height: 24px; }
#nav a.on { color: var(--graphite); font-weight: 600; }
#nav a.on::after { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
#nav .badge { position: absolute; top: 9px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font: 600 11px/17px var(--display); text-align: center; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 10px); background: var(--graphite); color: #fff;
  padding: 11px 16px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; z-index: 60; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- sheet (เลื่อนขึ้นจากล่าง) ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(20,22,24,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--slab); border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #CFCDC6; margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- PIN (แบบปลดล็อก iPhone) ---------- */
.lock { position: fixed; inset: 0; z-index: 30; background: var(--perf), var(--graphite); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) 24px calc(20px + env(safe-area-inset-bottom)); }
.lock .brand { flex-direction: column; gap: 14px; margin-bottom: 26px; }
.lock .brand img:first-child { width: 68px; height: 68px; }
.lock .brand img:last-child { height: 22px; }
.lock h2 { font-size: 20px; text-align: center; }
.lock .sub { color: #A9AFB3; font-size: 14px; text-align: center; margin-top: 4px; min-height: 21px; }
.lock .sub.err { color: #FF8B7B; }
.dots { display: flex; gap: 16px; margin: 22px 0 30px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #fff; transition: background .1s; }
.dots i.on { background: #fff; }
.dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 26px; }
.pad button { width: 76px; height: 76px; border-radius: 50%; border: 0; background: rgba(255,255,255,.13); color: #fff; font: 500 30px/1 var(--display); cursor: pointer; }
.pad button:active { background: rgba(255,255,255,.35); }
.pad button.fn { background: transparent; font: 500 15px var(--body); }
.pad button.empty { visibility: hidden; }
.lock .link { margin-top: 22px; background: none; border: 0; color: #C9CCCE; font-size: 14px; text-decoration: underline; cursor: pointer; }
.lock form { width: 100%; max-width: 320px; }
.lock input { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; font-size: 18px; text-align: center; }
.lock input::placeholder { color: #8E959A; }
.lock input:focus { border-color: #fff; }
.lock .btn { margin-top: 12px; background: #fff; color: var(--graphite); }

/* ---------- camera ---------- */
.cam { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; color: #fff; }
.cam .bar { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
.cam .bar .grow { font-size: 14px; }
.cam .x { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; font-size: 18px; }
.stage { position: relative; width: 100%; margin: 0 auto; overflow: hidden; background: #111; }
.stage video, .stage .ghost { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage .ghost { pointer-events: none; }
.stage .grid { position: absolute; inset: 0; pointer-events: none; background:
  linear-gradient(#fff3,#fff3) 33.3% 0/1px 100% no-repeat, linear-gradient(#fff3,#fff3) 66.6% 0/1px 100% no-repeat,
  linear-gradient(#fff3,#fff3) 0 33.3%/100% 1px no-repeat, linear-gradient(#fff3,#fff3) 0 66.6%/100% 1px no-repeat; }
.align { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 8px; font-size: 13px; text-shadow: 0 1px 2px #000; }
.meter { height: 8px; border-radius: 9px; background: rgba(255,255,255,.2); overflow: hidden; flex: 1; }
.meter i { display: block; height: 100%; }
.cam .ctl { padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.cam .ctl .row { justify-content: center; }
.cam .hint { text-align: center; font-size: 13px; color: #F2C77A; padding: 0 14px 6px; }
.shutter { width: 74px; height: 74px; border-radius: 50%; background: #fff; border: 5px solid rgba(255,255,255,.4); background-clip: padding-box; cursor: pointer; }
input[type=range] { padding: 0; border: 0; background: transparent; accent-color: #fff; }

/* ---------- ผลหลังถ่าย ---------- */
.result { position: fixed; inset: 0; z-index: 55; background: #151719; color: #fff; overflow: auto; }
.result .inner { max-width: 520px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); }
.result .pct { font: 700 64px/1 var(--display); text-align: center; margin-top: 14px; }
.result .pct.g { color: #5BCB8C; } .result .pct.r { color: #FF7A66; } .result .pct.y { color: #F2BC5A; }
.result .lbl { text-align: center; color: #A9AFB3; font-size: 14px; }
.result .why { text-align: center; margin: 10px 0 16px; font-size: 15px; }
.result .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); }
