/* ============================================================
   Toy Stock — app.css (ใช้ร่วมกับแดชบอร์ด: tokens, ปุ่ม, ชิป, ฟอร์ม, ชีต)
   สีทั้งหมดเป็นตัวแปรบน :root — โหมดมืดอยู่ใน 2 บล็อกด้านล่าง (ต้องแก้ให้ตรงกันทั้งคู่)
   ขนาดตัวอักษร: html[data-font=s|m|l] → ทุกอย่างใช้ rem
   ============================================================ */
:root {
  --bg: #f5f1e9;
  --bg-2: #efe9dd;
  --surface: #ffffff;
  --surface-2: #f6f2ea;
  --surface-3: #ece6da;
  --ink: #1e1b2a;
  --ink-2: #565266;
  --ink-3: #8c8899;
  --line: #e4ddcf;
  --line-2: #d6cebd;
  --accent: #ff5b35;
  --accent-2: #ff8a3d;
  --accent-ink: #ffffff;
  --accent-soft: #ffe6dc;
  --accent-text: #d93d18;
  --good: #16956a;
  --good-soft: #dcf4ea;
  --warn: #c98a00;
  --danger: #d6363a;
  --danger-soft: #fde3e3;
  --scrim: rgba(24, 20, 34, .46);
  --shadow-1: 0 1px 2px rgba(40, 30, 20, .06), 0 2px 8px rgba(40, 30, 20, .05);
  --shadow-2: 0 2px 6px rgba(40, 30, 20, .07), 0 14px 36px rgba(40, 30, 20, .12);
  --tag-l: 93%; --tag-s: 85%; --tag-tl: 30%; --tag-ts: 60%;
  --ph-l: 90%;
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 4.4rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121119; --bg-2: #18171f; --surface: #1c1b25; --surface-2: #23222d; --surface-3: #2c2b38;
    --ink: #f3f1f8; --ink-2: #b7b3c6; --ink-3: #7e7a90; --line: #2d2c39; --line-2: #3a3948;
    --accent: #ff6c47; --accent-2: #ff9a52; --accent-ink: #1a0d08; --accent-soft: #3b211a; --accent-text: #ff9a7c;
    --good: #3ccf97; --good-soft: #163328; --warn: #f0b93a; --danger: #ff6b6e; --danger-soft: #3a1c1f;
    --scrim: rgba(0, 0, 0, .6);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 10px 40px rgba(0, 0, 0, .5);
    --tag-l: 22%; --tag-s: 35%; --tag-tl: 80%; --tag-ts: 80%; --ph-l: 24%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121119; --bg-2: #18171f; --surface: #1c1b25; --surface-2: #23222d; --surface-3: #2c2b38;
  --ink: #f3f1f8; --ink-2: #b7b3c6; --ink-3: #7e7a90; --line: #2d2c39; --line-2: #3a3948;
  --accent: #ff6c47; --accent-2: #ff9a52; --accent-ink: #1a0d08; --accent-soft: #3b211a; --accent-text: #ff9a7c;
  --good: #3ccf97; --good-soft: #163328; --warn: #f0b93a; --danger: #ff6b6e; --danger-soft: #3a1c1f;
  --scrim: rgba(0, 0, 0, .6);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 10px 40px rgba(0, 0, 0, .5);
  --tag-l: 22%; --tag-s: 35%; --tag-tl: 80%; --tag-ts: 80%; --ph-l: 24%;
  color-scheme: dark;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html[data-font="s"] { font-size: 14.5px; }
html[data-font="m"] { font-size: 16px; }
html[data-font="l"] { font-size: 19.5px; }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1rem; line-height: 1.5; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-width: 100%; }
a { color: var(--accent-text); }
.hidden { display: none !important; }
.ico { width: 1.25em; height: 1.25em; flex: none; display: inline-block; vertical-align: middle; }
.muted { color: var(--ink-3); }
.brandfont, h1, h2, h3 { font-family: 'Mitr', 'IBM Plex Sans Thai', sans-serif; font-weight: 500; letter-spacing: 0; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.9rem; padding: .55rem 1.15rem; border-radius: 999px;
  background: var(--surface-3); color: var(--ink); font-weight: 600; white-space: nowrap;
  transition: transform .12s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.good { background: var(--good-soft); color: var(--good); }
.btn.block { width: 100%; }
.btn.sm { min-height: 2.3rem; padding: .3rem .85rem; font-size: .9rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.iconbtn {
  width: 2.75rem; height: 2.75rem; border-radius: 50%; display: inline-grid; place-items: center;
  color: var(--ink-2); flex: none; transition: background .15s;
}
.iconbtn:hover { background: var(--surface-3); }
.iconbtn.on { background: var(--ink); color: var(--bg); }
.linkbtn { color: var(--accent-text); font-weight: 600; padding: .25rem .1rem; }

/* ---------- ชิป / แท็ก ---------- */
.chips { display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none; padding: .15rem 0; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; flex: none;
  min-height: 2.3rem; padding: .3rem .95rem; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink-2);
  font-size: .92rem; font-weight: 500; white-space: nowrap; transition: all .15s;
}
.chip .n { font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.on .n { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.chip.add { border-style: dashed; color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.chip .av { width: 1.5rem; height: 1.5rem; font-size: .72rem; margin-left: -.55rem; }
.tag {
  display: inline-flex; align-items: center; padding: .08rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.6;
  background: hsl(var(--h, 20) var(--tag-s) var(--tag-l)); color: hsl(var(--h, 20) var(--tag-ts) var(--tag-tl));
}
.tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip.tagpick.on { background: hsl(var(--h) 60% 36%); border-color: hsl(var(--h) 60% 36%); color: #fff; }

/* ---------- avatar ---------- */
.av {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: hsl(var(--h, 20) 70% 58%); color: #fff; font-weight: 700; font-size: .95rem;
  font-family: 'Mitr', sans-serif; border: 2px solid var(--surface);
}
.av.lg { width: 4rem; height: 4rem; font-size: 1.6rem; }

/* ---------- ฟอร์ม ---------- */
.field { display: grid; gap: .4rem; margin-bottom: 1.05rem; }
.field > label, .lbl { font-weight: 600; font-size: .92rem; color: var(--ink-2); display: flex; align-items: center; gap: .4rem; }
.lbl .opt { font-weight: 400; color: var(--ink-3); font-size: .82rem; }
.inp {
  width: 100%; min-height: 3rem; padding: .65rem .95rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
textarea.inp { min-height: 5.5rem; resize: vertical; }
.inp::placeholder { color: var(--ink-3); }
.affix { position: relative; }
.affix > span { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 600; pointer-events: none; }
.affix > .inp { padding-left: 2.1rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.hint { font-size: .85rem; color: var(--ink-3); }
.hint.warn { color: var(--warn); }
.hint.good { color: var(--good); }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); }
.stepper button { width: 3rem; height: 3rem; font-size: 1.4rem; color: var(--ink-2); display: grid; place-items: center; }
.stepper input { width: 3.6rem; text-align: center; border: 0; background: none; font-weight: 700; font-size: 1.1rem; outline: none; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 999px; padding: .25rem; gap: .2rem; }
.seg button { min-height: 2.4rem; padding: .3rem 1rem; border-radius: 999px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: .35rem; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg.full { display: flex; }
.seg.full button { flex: 1; justify-content: center; }
.switch { position: relative; width: 3.2rem; height: 1.9rem; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; transition: background .2s; }
.switch i::after { content: ''; position: absolute; left: .2rem; top: .2rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(1.3rem); }
.swrow { display: flex; align-items: center; gap: .9rem; padding: .9rem 0; }
.swrow > div { flex: 1; min-width: 0; }
.swrow b { display: block; font-weight: 600; }
.swrow small { color: var(--ink-3); font-size: .85rem; }

/* ============================================================
   APP SHELL — มือถือ: แถบบน + เมนูล่าง  /  คอม (≥900px): แถบซ้าย
   ============================================================ */
.app { min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.main { padding: 0 1rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); max-width: 1400px; margin: 0 auto; }
.topbar { padding: calc(.8rem + env(safe-area-inset-top)) 0 .1rem; }
.topbar .hrow { display: flex; align-items: center; gap: .6rem; min-height: 2.75rem; }
.topbar h1 { font-size: 1.45rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .seg button { min-height: 2.1rem; padding: .2rem .8rem; font-size: .88rem; }
.topbar .summary { font-size: .85rem; color: var(--ink-3); margin-top: -.1rem; }
.stick {
  position: sticky; top: 0; z-index: 20; margin: 0 -1rem; padding: calc(.5rem + env(safe-area-inset-top)) 1rem .5rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.toolbar { display: flex; gap: .5rem; align-items: center; }
.search { position: relative; flex: 1; min-width: 0; }
.search .ico { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 2.9rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
  padding: 0 2.6rem 0 2.75rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.search .clr { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); width: 2.3rem; height: 2.3rem; }
.toolbar .iconbtn { background: var(--surface); border: 1.5px solid var(--line); width: 2.9rem; height: 2.9rem; }
.filters { display: grid; gap: .45rem; }
.filters:empty { display: none; }

.bnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 0 .4rem env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.bnav button { display: grid; justify-items: center; gap: .1rem; color: var(--ink-3); font-size: .74rem; font-weight: 600; padding: .3rem 0; }
.bnav button .ico { width: 1.55rem; height: 1.55rem; }
.bnav button.on { color: var(--accent-text); }
.bnav .fab {
  width: 3.6rem; height: 3.6rem; border-radius: 50%; margin: -1.6rem auto 0; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent-2), var(--accent)); color: #fff;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent), 0 0 0 5px var(--bg);
}
.bnav .fab .ico { width: 1.8rem; height: 1.8rem; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 15.5rem 1fr; }
  .bnav { display: none; }
  .side {
    display: flex; flex-direction: column; gap: .3rem; position: sticky; top: 0; height: 100vh;
    padding: 1.4rem 1rem; border-right: 1px solid var(--line); background: var(--bg-2);
  }
  .side .brand { margin: 0 .4rem 1.4rem; }
  .side .nav { display: flex; align-items: center; gap: .8rem; padding: .75rem .95rem; border-radius: 14px; color: var(--ink-2); font-weight: 600; text-align: left; }
  .side .nav:hover { background: var(--surface-3); }
  .side .nav.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
  .side .nav.on .ico { color: var(--accent); }
  .side .nav .n { margin-left: auto; font-size: .8rem; color: var(--ink-3); }
  .side .addbtn { margin: .4rem 0 1rem; }
  .side .me { margin-top: auto; display: flex; align-items: center; gap: .7rem; padding: .7rem; border-radius: 14px; text-align: left; }
  .side .me:hover { background: var(--surface-3); }
  .side .me b { display: block; font-weight: 600; }
  .side .me small { color: var(--ink-3); font-size: .8rem; }
  .main { padding: 0 2rem 3rem; width: 100%; }
  .topbar { padding: 1.6rem 0 .3rem; }
  .stick { margin: 0 -2rem; padding: .7rem 2rem; }
  .topbar h1 { font-size: 1.75rem; }
  .topbar .mobile-only { display: none; }
}

.brand { display: flex; align-items: center; gap: .65rem; }
.brand .logo {
  width: 2.6rem; height: 2.6rem; border-radius: 12px; display: grid; place-items: center; flex: none; overflow: hidden;
  background: linear-gradient(140deg, var(--accent-2), var(--accent)); color: #fff;
}
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand .logo .ico { width: 1.6rem; height: 1.6rem; }
.brand b { font-family: 'Mitr', sans-serif; font-weight: 600; font-size: 1.2rem; line-height: 1.1; display: block; }
.brand small { color: var(--ink-3); font-size: .78rem; }

/* ---------- การ์ด / รายการ ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-top: .6rem; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: 1.1rem; } }
html[data-font="l"] .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { html[data-font="l"] .grid { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); } }
.card {
  display: flex; flex-direction: column; text-align: left; border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-1); overflow: hidden; transition: transform .15s, box-shadow .15s; position: relative;
}
.card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card:active { transform: scale(.98); }
.ph { position: relative; aspect-ratio: 1; background: hsl(var(--h, 20) 45% var(--ph-l)); overflow: hidden; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: hsl(var(--h, 20) 45% 55%); }
.ph .noimg .ico { width: 42%; height: 42%; stroke-width: 1.4; }
.card .body { padding: .6rem .75rem .75rem; display: grid; gap: .3rem; }
.card .nm { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; min-height: 1.4rem; }
.card .own { display: flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--ink-2); }
.card .own .av { width: 1.4rem; height: 1.4rem; font-size: .66rem; border-width: 0; }
.badge {
  position: absolute; z-index: 1; display: inline-flex; align-items: center; gap: .25rem;
  padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: rgba(20, 16, 30, .72); color: #fff; backdrop-filter: blur(6px);
}
.badge.qty { top: .5rem; right: .5rem; }
.badge.priv { top: .5rem; left: .5rem; padding: .25rem; }
.badge.priv .ico { width: 1rem; height: 1rem; }
.badge.have { bottom: .5rem; left: .5rem; background: var(--good); }
.badge.gone { bottom: .5rem; left: .5rem; background: rgba(60, 56, 70, .85); }
.card.gone .ph img, .card.gone .ph .noimg, .lrow.gone .thumb { filter: grayscale(1); opacity: .45; }
.card.gone .body { opacity: .55; }
.lrow.gone > div:not(.thumb) { opacity: .55; }

.list { display: grid; gap: .55rem; margin-top: .6rem; }
.lrow {
  display: flex; align-items: center; gap: .85rem; padding: .55rem .8rem .55rem .55rem; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-1); text-align: left; width: 100%;
}
.lrow:hover { box-shadow: var(--shadow-2); }
.lrow .thumb { width: 4.2rem; height: 4.2rem; border-radius: 12px; flex: none; aspect-ratio: 1; }
.lrow .mid { flex: 1; min-width: 0; display: grid; gap: .2rem; }
.lrow .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .sub { font-size: .84rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: .5rem; align-items: center; }
.lrow .sub .ico { width: 1em; height: 1em; }
.lrow .end { text-align: right; flex: none; display: grid; gap: .1rem; }
.lrow .end b { font-size: 1.05rem; }
.lrow .end small { color: var(--ink-3); font-size: .8rem; }
.lrow .end .gonetxt { color: var(--ink-3); font-size: .8rem; font-weight: 600; }

.section-title { margin: 1.6rem 0 .2rem; font-size: .9rem; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: .6rem; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); display: grid; justify-items: center; gap: .6rem; }
.empty .art { width: min(16rem, 70vw); aspect-ratio: 1; position: relative; display: grid; place-items: center; }
.empty .art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .3s; }
.empty .art.ok img { opacity: 1; }
.empty .art.ok .fallback { visibility: hidden; }
.empty .fallback { width: 62%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .fallback .ico { width: 50%; height: 50%; stroke-width: 1.4; }
.empty h3 { font-size: 1.25rem; }
.empty p { margin: 0; color: var(--ink-3); max-width: 24rem; }

/* ---------- ชีต / ป๊อปอัพ ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: var(--scrim); opacity: 0; transition: opacity .22s; }
.scrim.in { opacity: 1; }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; max-height: 94vh; max-height: 94dvh;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet.in { transform: none; }
.sheet .grab { width: 2.6rem; height: .3rem; border-radius: 9px; background: var(--line-2); margin: .55rem auto 0; flex: none; }
.sheet .shead { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem .4rem 1.2rem; flex: none; }
.sheet .shead h2 { flex: 1; font-size: 1.25rem; min-width: 0; }
.sheet .sbody { overflow-y: auto; padding: .4rem 1.2rem 1.2rem; overscroll-behavior: contain; flex: 1; min-height: 0; }
.sheet .sfoot { padding: .8rem 1.2rem calc(.8rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: .6rem; flex: none; background: var(--surface); border-radius: 0; }
.sheet .sfoot .btn { flex: 1; }
.sheet.full { top: 0; max-height: none; border-radius: 0; }
.sheet.full .grab { display: none; }
.sheet.full .shead { padding-top: calc(.6rem + env(safe-area-inset-top)); }
@media (min-width: 900px) {
  .sheet, .sheet.full {
    left: 50%; top: 50%; bottom: auto; right: auto; width: min(40rem, 92vw); max-height: 90vh;
    border-radius: 24px; transform: translate(-50%, -46%) scale(.97); opacity: 0; transition: transform .22s, opacity .22s;
  }
  .sheet.in, .sheet.full.in { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.wide { width: min(58rem, 94vw); }
  .sheet .grab { display: none; }
  .sheet .shead { padding-top: 1rem; }
  .sheet .sfoot { border-radius: 0 0 24px 24px; padding-bottom: .9rem; }
}

/* รายละเอียดของเล่น */
.detail { display: grid; gap: 1.1rem; }
@media (min-width: 900px) {
  .sheet.wide .detail { grid-template-columns: 1.05fr 1fr; align-items: start; }
  .sheet.wide .detail > .gallery { position: sticky; top: 0; }
}
.gallery { position: relative; border-radius: 18px; overflow: hidden; background: var(--surface-2); }
.gallery .track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery .track::-webkit-scrollbar { display: none; }
.gallery .slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 4 / 3; }
@media (min-width: 900px) { .gallery .slide { aspect-ratio: 1; } }
.gallery .slide img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.gallery .dots { position: absolute; bottom: .6rem; left: 0; right: 0; display: flex; justify-content: center; gap: .35rem; }
.gallery .dots i { width: .45rem; height: .45rem; border-radius: 50%; background: rgba(255,255,255,.55); }
.gallery .dots i.on { background: #fff; width: 1.2rem; border-radius: 9px; }
.gallery .count { position: absolute; top: .6rem; right: .6rem; }
.gallery.gone img { filter: grayscale(1); opacity: .6; }
.dname { font-size: 1.5rem; line-height: 1.3; }
.status-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .75rem; border-radius: 999px; font-size: .85rem; font-weight: 600; background: var(--surface-3); color: var(--ink-2); }
.status-pill.good { background: var(--good-soft); color: var(--good); }
.status-pill.wish { background: var(--accent-soft); color: var(--accent-text); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.fact { background: var(--surface-2); border-radius: 14px; padding: .65rem .8rem; min-width: 0; }
.fact.wide { grid-column: 1 / -1; }
.fact small { display: flex; align-items: center; gap: .35rem; color: var(--ink-3); font-size: .8rem; font-weight: 600; }
.fact small .ico { width: 1em; height: 1em; }
.fact b { display: block; font-weight: 600; font-size: 1.02rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.fact b.big { font-size: 1.3rem; }
.timeline { display: grid; gap: .5rem; }
.tl { display: flex; gap: .7rem; align-items: flex-start; font-size: .9rem; }
.tl .dot { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink-2); }
.tl .dot .ico { width: 1rem; height: 1rem; }
.tl .dot.out { background: var(--accent-soft); color: var(--accent-text); }
.tl .dot.in { background: var(--good-soft); color: var(--good); }
.tl small { color: var(--ink-3); display: block; }
.callout { display: flex; gap: .7rem; align-items: center; padding: .8rem .95rem; border-radius: 14px; background: var(--good-soft); color: var(--good); font-weight: 600; }
.callout.warn { background: var(--accent-soft); color: var(--accent-text); }
.callout .ico { width: 1.4rem; height: 1.4rem; }
.owner-row { display: flex; align-items: center; gap: .6rem; }
.owner-row b { font-weight: 600; }

/* ฟอร์มรูป */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.4rem, 1fr)); gap: .55rem; }
.pthumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-3); }
.pthumb img { width: 100%; height: 100%; object-fit: cover; }
.pthumb .x { position: absolute; top: .25rem; right: .25rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.pthumb .x .ico { width: 1rem; height: 1rem; }
.pthumb .cover { position: absolute; left: .3rem; bottom: .3rem; font-size: .68rem; font-weight: 700; background: var(--accent); color: #fff; padding: .05rem .45rem; border-radius: 9px; }
.pthumb .star { position: absolute; left: .25rem; bottom: .25rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; }
.pthumb .star .ico { width: 1rem; height: 1rem; }
.pthumb .up { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.4); color: #fff; font-size: .78rem; font-weight: 700; }
.pthumb.err .up { background: rgba(200,30,30,.65); }
.photo-add { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .6rem; }
.photo-add label {
  display: flex; align-items: center; justify-content: center; gap: .55rem; min-height: 3.6rem; border-radius: 16px; cursor: pointer;
  border: 2px dashed var(--line-2); color: var(--ink-2); font-weight: 600; background: var(--surface-2); text-align: center; padding: .4rem;
}
.photo-add label:active { transform: scale(.98); }
.photo-add label .ico { width: 1.5rem; height: 1.5rem; color: var(--accent); }
.photo-add input { display: none; }
.photo-hero { display: grid; place-items: center; gap: .3rem; padding: 1.6rem .8rem; border-radius: 18px; background: var(--surface-2); border: 2px dashed var(--line-2); color: var(--ink-3); text-align: center; }
.photo-hero .ico { width: 2.6rem; height: 2.6rem; color: var(--accent); stroke-width: 1.5; }
.quick { display: flex; flex-wrap: wrap; gap: .35rem; }
.quick button { font-size: .82rem; padding: .2rem .7rem; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font-weight: 500; }
.kindseg { margin-bottom: 1.1rem; }

/* ---------- เมนูป๊อป ---------- */
.menu {
  position: fixed; z-index: 70; min-width: 13rem; padding: .4rem; border-radius: 16px; background: var(--surface);
  box-shadow: var(--shadow-2); border: 1px solid var(--line); display: grid;
}
.menu button { display: flex; align-items: center; gap: .65rem; padding: .7rem .8rem; border-radius: 10px; text-align: left; font-weight: 500; }
.menu button:hover { background: var(--surface-2); }
.menu button.on { color: var(--accent-text); font-weight: 700; }
.menu button .ck { margin-left: auto; }

/* ---------- ซูมรูป ---------- */
.zoom { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; align-items: center; justify-content: center; }
.zoom img { max-width: 100%; max-height: 100%; object-fit: contain; }
.zoom .iconbtn { position: absolute; top: calc(.8rem + env(safe-area-inset-top)); right: .8rem; background: rgba(255,255,255,.15); color: #fff; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 2.8rem + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 1rem); opacity: 0; transition: all .25s; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: .7rem 1.2rem; border-radius: 999px; font-weight: 600;
  box-shadow: var(--shadow-2); max-width: 90vw; text-align: center;
}
.toast.in { transform: translate(-50%, 0); opacity: 1; }
.toast.err { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 2rem; } }

/* ---------- ตั้งค่า ---------- */
.settings { display: grid; gap: 1rem; margin-top: .6rem; max-width: 46rem; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 1rem 1.15rem; }
.panel > h3 { font-size: 1.05rem; margin-bottom: .4rem; display: flex; align-items: center; gap: .5rem; }
.panel > h3 .ico { color: var(--accent); }
.panel .sep { height: 1px; background: var(--line); margin: .2rem 0; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; flex-wrap: wrap; }
.setrow > div:first-child { min-width: 0; flex: 1 1 7rem; }
.setrow > .seg { margin-left: auto; max-width: 100%; }
.seg button { white-space: nowrap; min-width: 0; }
@media (max-width: 600px) {
  .setrow > .seg { flex: 1 1 100%; }
  .setrow > .seg button { flex: 1; justify-content: center; padding: .3rem .4rem; }
}
@media (max-width: 420px) { .setrow > .seg .ico { display: none; } }
.main, .settings, .panel { min-width: 0; }
.setrow b { font-weight: 600; display: block; }
.setrow small { color: var(--ink-3); font-size: .85rem; }
.profile { display: flex; align-items: center; gap: 1rem; }
.profile h2 { font-size: 1.35rem; }
.install-card {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.15rem; border-radius: var(--radius);
  background: linear-gradient(130deg, var(--accent-2), var(--accent)); color: #fff;
}
.install-card .ico.big { width: 2.6rem; height: 2.6rem; flex: none; }
.install-card div { flex: 1; min-width: 0; }
.install-card b { display: block; font-size: 1.05rem; }
.install-card small { opacity: .9; }
.install-card .btn { background: #fff; color: var(--accent-text); box-shadow: none; }
.fontseg button:nth-child(1) { font-size: .85rem; }
.fontseg button:nth-child(2) { font-size: 1rem; }
.fontseg button:nth-child(3) { font-size: 1.22rem; }
.taglist { display: grid; gap: .1rem; }
.tagrow { display: flex; align-items: center; gap: .3rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.tagrow:last-child { border-bottom: 0; }
.tagrow .tag { font-size: .9rem; padding: .2rem .8rem; }
.tagrow .n { color: var(--ink-3); font-size: .85rem; margin-left: .4rem; flex: 1; }
.tagrow .iconbtn { width: 2.4rem; height: 2.4rem; }
.tagrow.off .tag { opacity: .45; text-decoration: line-through; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface-2); border-radius: 14px; padding: .75rem .85rem; }
.stat small { color: var(--ink-3); font-size: .8rem; font-weight: 600; display: block; }
.stat b { font-family: 'Mitr', sans-serif; font-weight: 500; font-size: 1.45rem; line-height: 1.2; }
.bars { display: grid; gap: .45rem; margin-top: .8rem; }
.bar { display: grid; grid-template-columns: 6.5rem 1fr 2.5rem; gap: .6rem; align-items: center; font-size: .88rem; }
.bar .track { height: .7rem; background: var(--surface-3); border-radius: 9px; overflow: hidden; }
.bar .fill { height: 100%; background: hsl(var(--h, 20) 70% 55%); border-radius: 9px; }
.bar span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar span:last-child { text-align: right; color: var(--ink-3); font-weight: 600; }
.steps { margin: .4rem 0 0; padding-left: 1.3rem; display: grid; gap: .55rem; }
.steps .ico { color: var(--accent); }

/* ---------- ล็อกอิน ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1.2rem calc(1.5rem + env(safe-area-inset-bottom)); }
.login .box { width: 100%; max-width: 24rem; display: grid; gap: 1.1rem; text-align: center; }
.login .hero { width: min(20rem, 82vw); aspect-ratio: 1; margin: 0 auto; position: relative; display: grid; place-items: center; }
.login .hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .3s; }
.login .hero.ok img { opacity: 1; }
.login .hero.ok .fallback { visibility: hidden; }
.login .hero .fallback {
  width: 70%; aspect-ratio: 1; border-radius: 30%; display: grid; place-items: center; transform: rotate(-6deg);
  background: linear-gradient(140deg, var(--accent-2), var(--accent)); color: #fff; box-shadow: 0 20px 50px color-mix(in srgb, var(--accent) 40%, transparent);
}
.login .hero .fallback .ico { width: 58%; height: 58%; stroke-width: 1.5; }
.login h1 { font-size: 2rem; }
.login p { margin: 0; color: var(--ink-2); }
.login .inp { text-align: center; font-size: 1.2rem; min-height: 3.5rem; border-radius: 999px; }
.login .btn { min-height: 3.4rem; font-size: 1.08rem; }
.pindots { display: flex; justify-content: center; gap: 1rem; margin: .4rem 0; }
.pindots i { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--ink-3); transition: all .15s; }
.pindots i.on { background: var(--accent); border-color: var(--accent); transform: scale(1.1); }
.pindots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; max-width: 18rem; margin: 0 auto; width: 100%; }
.pinpad button { height: 4.1rem; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-1); font-size: 1.6rem; font-weight: 600; font-family: 'Mitr', sans-serif; }
.pinpad button:active { background: var(--surface-3); transform: scale(.96); }
.pinpad button.fn { background: transparent; box-shadow: none; font-size: 1rem; color: var(--ink-2); }
.pinpad button.fn .ico { width: 1.6rem; height: 1.6rem; }
.err-text { color: var(--danger); font-weight: 600; min-height: 1.5rem; margin: 0; }
.spinner { width: 2rem; height: 2rem; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 3rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
