/* =========================================================
   โยนเผือก (เดิมชื่อเผือกร้อน) — สไตล์ (ธีมม่วงเผือก ตามระบบดีไซน์ t-educator.com)
   ส่วนบนสุดคัดลอกจาก MasterTemplate/tokens.css — ห้ามแก้ตรงนี้ ให้แก้ที่ต้นทางแล้วคัดลอกมาใหม่
   ========================================================= */
/* =========================================================
   Master Template — Design tokens (single source of truth)
   ---------------------------------------------------------
   ใช้ไฟล์นี้กับทุกแอปในซีรีส์ เพื่อให้สี ขนาด และธีมมืดตรงกัน
   • โหลดฟอนต์: IBM Plex Sans Thai (400/500/600) จาก Google Fonts
   • ธีม: ตามระบบปฏิบัติการ หรือบังคับด้วย <html data-theme="light|dark">
   • อธิบายเหตุผลทั้งหมดอยู่ใน DESIGN-SYSTEM.md
   Version 1.0 · พ.ย. 2569 · สีหลัก: ฟ้าอมเขียว (Bootstrap "info") + โทนมูจิ
   ========================================================= */

/* ---------- Design tokens (light) ---------- */
:root {
  color-scheme: light;
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  --radius-lg: 14px;
  --radius: 10px;

  --bg: #f2f5f5;
  --surface: #ffffff;
  --surface-2: #f8fafa;
  --surface-3: #edf1f1;
  --border: #e2e8e8;
  --border-strong: #d0d9d9;

  --text: #152022;
  --text-2: #4b5859;
  --text-3: #7f8b8b;
  --hover: rgba(16, 42, 46, 0.045);

  --accent: #12808f;
  --accent-hover: #0f6f7c;
  --accent-soft: #e2f1f3;
  --accent-text: #0f6b77;
  --accent-ring: rgba(18, 128, 143, 0.22);
  --on-accent: #ffffff;

  /* sidebar + topbar ("chrome") — Bootstrap "info" teal */
  --chrome: #17a2b8;
  --chrome-ink: #117a8b;              /* teal text on white (active item, badges) */
  --on-chrome: #ffffff;
  --on-chrome-2: rgba(255, 255, 255, 0.88);
  --on-chrome-3: rgba(255, 255, 255, 0.76);
  --chrome-hover: rgba(255, 255, 255, 0.15);
  --chrome-line: rgba(255, 255, 255, 0.22);

  /* chart chrome */
  --grid: #e7eded;
  --axis: #c2cccc;
  --prev: #bec8c8;
  --spark: #bec8c8;

  /* status */
  --good-text: #4a7656;
  --good-soft: #e6efe8;
  --warn-text: #80652f;
  --warn-soft: #f3ecdc;
  --bad: #d27a63;
  --bad-text: #9f5646;
  --bad-soft: #f5e7e2;

  --shadow-sm: 0 1px 2px rgba(16, 42, 46, 0.05);
  --shadow-lg: 0 16px 40px -12px rgba(16, 42, 46, 0.2), 0 2px 6px rgba(16, 42, 46, 0.05);
  --tip-bg: #182325;
  --tip-text: #f2f5f5;
  --overlay: rgba(10, 10, 9, 0.45);   /* พื้นหลังทึบใต้ drawer/dialog */
  /* soft decorative tints (muji / pastel) */
  --tint-blue: #4c7888;
  --tint-orange: #94654a;
  --tint-green: #52775c;
  --tint-pink: #955e6a;
  --tint-violet: #6c628a;
}

/* ---------- Design tokens (dark) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1112;
    --surface: #161d1e;
    --surface-2: #1a2223;
    --surface-3: #212a2b;
    --border: #263132;
    --border-strong: #334142;
    --text: #e8eeee;
    --text-2: #b6c2c2;
    --text-3: #849191;
    --hover: rgba(255, 255, 255, 0.05);
    --accent: #17899a;
    --accent-hover: #1f9db0;
    --accent-soft: rgba(23, 162, 184, 0.16);
    --accent-text: #86d0dc;
    --accent-ring: rgba(23, 162, 184, 0.35);
    --chrome: #0f7483;
    --chrome-ink: #0f7483;
    --chrome-hover: rgba(255, 255, 255, 0.12);
    --chrome-line: rgba(255, 255, 255, 0.16);
    --grid: #243031;
    --axis: #354243;
    --prev: #4d5b5c;
    --spark: #4a5859;
    --good-text: #93bd9e;
    --good-soft: rgba(120, 168, 132, 0.16);
    --warn-text: #d8bf85;
    --warn-soft: rgba(216, 191, 133, 0.14);
    --bad-text: #e3a291;
    --bad-soft: rgba(210, 122, 99, 0.18);
    --shadow-sm: none;
    --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --tip-bg: #e8eeee;
    --tip-text: #152022;
    --overlay: rgba(0, 0, 0, 0.6);
    --tint-blue: #8db6c3;
    --tint-orange: #d0a080;
    --tint-green: #93b89c;
    --tint-pink: #d09aa5;
    --tint-violet: #aea4c8;
    --bad: #d9826c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1112;
  --surface: #161d1e;
  --surface-2: #1a2223;
  --surface-3: #212a2b;
  --border: #263132;
  --border-strong: #334142;
  --text: #e8eeee;
  --text-2: #b6c2c2;
  --text-3: #849191;
  --hover: rgba(255, 255, 255, 0.05);
  --accent: #17899a;
  --accent-hover: #1f9db0;
  --accent-soft: rgba(23, 162, 184, 0.16);
  --accent-text: #86d0dc;
  --accent-ring: rgba(23, 162, 184, 0.35);
  --chrome: #0f7483;
  --chrome-ink: #0f7483;
  --chrome-hover: rgba(255, 255, 255, 0.12);
  --chrome-line: rgba(255, 255, 255, 0.16);
  --grid: #243031;
  --axis: #354243;
  --prev: #4d5b5c;
  --spark: #4a5859;
  --good-text: #93bd9e;
  --good-soft: rgba(120, 168, 132, 0.16);
  --warn-text: #d8bf85;
  --warn-soft: rgba(216, 191, 133, 0.14);
  --bad-text: #e3a291;
  --bad-soft: rgba(210, 122, 99, 0.18);
  --shadow-sm: none;
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --tip-bg: #e8eeee;
  --tip-text: #152022;
  --overlay: rgba(0, 0, 0, 0.6);
  --tint-blue: #8db6c3;
  --tint-orange: #d0a080;
  --tint-green: #93b89c;
  --tint-pink: #d09aa5;
  --tint-violet: #aea4c8;
  --bad: #d9826c;
}

/* ---------- Type scale & spacing (ค่าที่แอปต้นแบบใช้) ---------- */
:root {
  --fs-kpi: 28px;        /* ตัวเลขใหญ่บนการ์ด KPI · 600 */
  --fs-title: 26px;      /* หัวข้อหน้า · 600 (มือถือ 22px) */
  --fs-stat: 18px;       /* ตัวเลขสรุปในการ์ด · 600 */
  --fs-card-title: 15.5px; /* หัวข้อการ์ด · 600 */
  --fs-body: 14px;       /* เนื้อหาหลัก · 400 */
  --fs-ui: 13.5px;       /* เมนู ปุ่ม ตาราง · 500 */
  --fs-sub: 13px;        /* คำอธิบายใต้หัวข้อ */
  --fs-meta: 12.5px;     /* หัวตาราง tooltip ข้อความประกอบ */
  --fs-label: 12px;      /* ป้ายกลุ่มเมนู badge */
  --fs-tick: 11.5px;     /* แกนกราฟ kbd · เล็กสุดที่ใช้ */
  --lh-body: 1.55;       /* ภาษาไทยต้องเผื่อสระบน/ล่าง */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;       /* gap ระหว่างการ์ด */
  --space-5: 20px;       /* padding การ์ด */
  --space-6: 24px;
  --space-7: 28px;       /* padding เนื้อหา (desktop) */

  --radius-sm: 8px;
  --radius-pill: 999px;
  --content-max: 1480px;
}


/* ---------- ธีมม่วงของโยนเผือก (ชุดเดียวกับแอปม่วงในซีรีส์) ---------- */
:root {
  --chrome: #7952b3; --chrome-ink: #5f3d94;
  --accent: #6a45a6; --accent-hover: #5b3a91; --accent-soft: #efe9f7; --accent-text: #5a3a8f; --accent-ring: rgba(121, 82, 179, 0.22);
  --bg: #f4f3f7; --surface-2: #f9f8fb; --surface-3: #eeebf3; --border: #e5e2ec; --border-strong: #d4cfde;
  --text: #1c1826; --text-2: #524c5e; --text-3: #837d8e; --hover: rgba(40, 24, 70, 0.045);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chrome: #4e3480; --chrome-ink: #4e3480;
    --accent: #7d58bb; --accent-hover: #8e6bc9; --accent-soft: rgba(140, 102, 200, 0.18); --accent-text: #cbb8ec; --accent-ring: rgba(140, 102, 200, 0.38);
    --bg: #0f0d13; --surface: #18151d; --surface-2: #1d1a23; --surface-3: #25212c; --border: #2c2735; --border-strong: #3a3445;
    --text: #ece9f1; --text-2: #bdb7c8; --text-3: #8b8597; --hover: rgba(255, 255, 255, 0.05);
  }
}
:root[data-theme="dark"] {
  --chrome: #4e3480; --chrome-ink: #4e3480;
  --accent: #7d58bb; --accent-hover: #8e6bc9; --accent-soft: rgba(140, 102, 200, 0.18); --accent-text: #cbb8ec; --accent-ring: rgba(140, 102, 200, 0.38);
  --bg: #0f0d13; --surface: #18151d; --surface-2: #1d1a23; --surface-3: #25212c; --border: #2c2735; --border-strong: #3a3445;
  --text: #ece9f1; --text-2: #bdb7c8; --text-3: #8b8597; --hover: rgba(255, 255, 255, 0.05);
}

/* ชื่อตัวแปรเดิมของโยนเผือก → token กลาง (โค้ดส่วนล่างใช้ชื่อเดิมต่อได้) */
:root {
  --ink: var(--text); --ink-2: var(--text-2); --ink-3: var(--text-3); --line: var(--border);
  --taro: var(--accent); --taro-ink: var(--accent-text); --taro-soft: var(--accent-soft);
  --hot: var(--tint-orange); --hot-ink: var(--tint-orange); --hot-soft: color-mix(in srgb, var(--tint-orange) 13%, var(--surface));
  --cool: var(--tint-blue); --cool-ink: var(--tint-blue); --cool-soft: color-mix(in srgb, var(--tint-blue) 15%, var(--surface));
  --ok: var(--good-text); --danger: var(--bad-text); --danger-soft: var(--bad-soft);
  --r: var(--radius-lg); --r-sm: var(--radius);
  --font-display: var(--font); --font-body: var(--font);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-weight: 600; line-height: 1.3; margin: 0; }
p { margin: 0; }
a { color: var(--accent-text); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 var(--space-7); }
main.wrap { flex: 1 0 auto; padding-top: var(--space-6); padding-bottom: var(--space-7); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.fine { font-size: var(--fs-meta); color: var(--text-3); }

/* ------------------------------------------------------------ navbar + footer (เหมือนทุกแอปในซีรีส์) */
.xn { position: sticky; top: 0; z-index: 40; background: var(--chrome); color: var(--on-chrome); }
.xn-wrap { max-width: 1080px; height: var(--topbar-h); margin: 0 auto; padding: 0 var(--space-7); display: flex; align-items: center; gap: var(--space-4); }
.xn :focus-visible { outline-color: var(--on-chrome); }
.xn-brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; color: inherit; text-decoration: none; }
.xn-logo { width: 34px; height: 34px; flex: none; display: grid; place-items: center; padding: 2px; border-radius: 9px; background: #fff; }
.xn-tx { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.xn-tx b { font-size: var(--fs-card-title); font-weight: 600; }
.xn-tx span { font-size: var(--fs-label); color: var(--on-chrome-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xn-links { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }
.xn-link { display: inline-flex; align-items: center; gap: var(--space-2); height: 38px; padding: 0 var(--space-3); border: 0; border-radius: 9px; background: transparent; color: var(--on-chrome); font-size: var(--fs-ui); font-weight: 500; text-decoration: none; cursor: pointer; transition: background .15s; }
.xn-link:hover { background: var(--chrome-hover); }
.xn-link svg { width: 18px; height: 18px; flex: none; }
.xn-icon { width: 38px; padding: 0; justify-content: center; }
.xn .t-sun { display: none; }
:root[data-theme="dark"] .xn .t-sun { display: block; }
:root[data-theme="dark"] .xn .t-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .xn .t-sun { display: block; }
  :root:not([data-theme="light"]) .xn .t-moon { display: none; }
}
.xf { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-3); font-size: var(--fs-meta); }
.xf-wrap { max-width: 1080px; margin: 0 auto; padding: var(--space-4) var(--space-7) calc(var(--space-4) + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-1) var(--space-4); }
.xf b { color: var(--text-2); font-weight: 500; }
.xf a { color: var(--accent-text); }

/* ------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 500;
  font-size: var(--fs-ui);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-meta); }
.btn-lg { min-height: 50px; padding: 0 26px; font-size: var(--fs-card-title); }
/* ปุ่มหลัก (โยน / เปิดวง) */
.btn-hot, .btn-hot:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-hot:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
/* ปุ่มรองสีเผือก */
.btn-taro { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.btn-taro:hover { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); border-color: transparent; }
.btn-cool { background: var(--cool-soft); border-color: transparent; color: var(--cool-ink); }
.btn-cool:hover { background: color-mix(in srgb, var(--tint-blue) 24%, var(--surface)); border-color: transparent; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--bad-text) 35%, transparent); color: var(--bad-text); }
.btn-danger:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad-text) 35%, transparent); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-pressed="false"] { opacity: .55; }

/* ------------------------------------------------------------ mascot (ตัวการ์ตูนเผือก + แอนิเมชัน) */
.mascot { display: block; width: 100%; height: 100%; overflow: visible; }
.mascot .steam path { animation: steam 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center bottom; }
.mascot .steam path:nth-child(2) { animation-delay: .9s; }
.mascot .steam path:nth-child(3) { animation-delay: 1.7s; }
.mascot .frost path { animation: twinkle 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.mascot .frost path:nth-child(2) { animation-delay: 1.1s; }
.mascot-body { transform-origin: 60px 110px; }
.wobble .mascot-body, .hero-mascot:hover .mascot-body, .xn-brand:hover .mascot-body { animation: wobble .9s ease-in-out; }
.hero-mascot .mascot-body { animation: bob 3.2s ease-in-out infinite; }
.hero-mascot.wobble .mascot-body, .hero-mascot:hover .mascot-body { animation: wobble .9s ease-in-out; }
@keyframes steam {
  0% { opacity: 0; transform: translateY(6px) scaleY(.85); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px) scaleY(1.05); }
}
@keyframes twinkle { 0%, 100% { opacity: .3; transform: scale(.7); } 50% { opacity: 1; transform: scale(1); } }
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  60% { transform: rotate(5deg); }
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ------------------------------------------------------------ ป้ายวง + แถบเตือน */
.room-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--fs-ui);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.presence { font-size: var(--fs-sub); color: var(--text-2); white-space: nowrap; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.banner {
  position: sticky;
  top: calc(var(--topbar-h) + 8px);
  z-index: 30;
  margin: 8px auto 0;
  width: fit-content;
  max-width: calc(100% - 32px);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn-text);
  font-size: var(--fs-sub);
}

/* ------------------------------------------------------------ หน้าแรก */
.hero { display: grid; justify-items: center; text-align: center; gap: 12px; padding: var(--space-5) 0 var(--space-7); }
.hero-mascot { width: 156px; height: 156px; margin-bottom: -4px; cursor: pointer; }
.brand-title { font-size: clamp(36px, 8vw, 52px); font-weight: 600; line-height: 1.2; color: var(--text); }
.tagline { font-size: clamp(15px, 3.6vw, 17px); color: var(--text-2); max-width: 32em; }
.hero-actions { margin-top: 8px; }
.join {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin-top: 18px;
  width: min(100%, 420px);
}
.join label { font-size: var(--fs-sub); color: var(--text-3); }
.join-row { display: flex; gap: 8px; width: 100%; }
.join-row input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .16em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.join-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.join-row input::placeholder { letter-spacing: 0; font-size: 15px; font-weight: 400; color: var(--text-3); text-transform: none; }
.join-row .btn { min-height: 46px; }

.my-rooms { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.my-rooms .label { width: 100%; font-size: var(--fs-meta); color: var(--text-3); }

.steps { padding: var(--space-6) var(--space-5); }
.steps h2 { font-size: 20px; text-align: center; margin-bottom: var(--space-5); }
.steps ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.steps li { display: grid; align-content: start; gap: 6px; padding: var(--space-5); border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.steps li b { font-weight: 600; font-size: var(--fs-card-title); }
.steps li p { color: var(--text-2); font-size: var(--fs-body); }
.step-n {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.steps li:last-child .step-n { background: var(--cool-soft); color: var(--cool-ink); }
.steps .fine { text-align: center; margin-top: var(--space-5); }
@media (max-width: 720px) { .steps ol { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ หน้าคนรับ */
.host-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: var(--space-5); }
.host-head .hh-left { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.host-head h1 { font-size: var(--fs-title); }
.host {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
.qr-card {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  display: grid;
  gap: 16px;
  padding: 20px;
  text-align: center;
}
.qr-box {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
  cursor: zoom-in;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.qr-box svg { display: block; width: 100%; height: 100%; }
.qr-info { display: grid; gap: 10px; min-width: 0; }
.qr-label { font-size: var(--fs-card-title); font-weight: 600; color: var(--accent-text); }
.room-code {
  font-weight: 600;
  font-size: 38px;
  letter-spacing: .12em;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.link-row { display: flex; gap: 6px; }
.link-row input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-meta);
}
.qr-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }

.feed-panel { min-width: 0; }
.feed-head { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 14px; }
.feed-head h2 { font-size: 20px; }
.hot-count { font-size: var(--fs-sub); color: var(--hot-ink); }
.empty { display: grid; justify-items: center; gap: 10px; padding: 48px 20px; text-align: center; color: var(--text-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.empty .empty-mascot { width: 116px; height: 116px; }
.empty b { font-weight: 600; font-size: var(--fs-card-title); color: var(--text); }
.empty p { max-width: 34em; font-size: var(--fs-body); }

@media (max-width: 900px) {
  .host { grid-template-columns: 1fr; gap: 16px; }
  .qr-card { position: static; grid-template-columns: 132px minmax(0, 1fr); align-items: center; text-align: left; padding: 14px; gap: 14px; }
  .room-code { font-size: 30px; }
  .qr-label { font-size: var(--fs-ui); }
  .qr-actions { justify-content: flex-start; }
  .qr-card .fine { display: none; }
}
@media (max-width: 640px) {
  .topbar-actions { width: 100%; }
  .topbar-actions .btn-cool { margin-right: auto; }
}
@media (max-width: 420px) {
  .qr-card { grid-template-columns: 104px minmax(0, 1fr); }
  .room-code { font-size: 24px; }
  .link-row { display: none; }
}

/* ------------------------------------------------------------ รายการเผือก */
.feed { display: grid; gap: 12px; }
.potato { display: flex; gap: 10px; align-items: flex-start; }
.potato.enter { animation: land .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes land {
  0% { opacity: 0; transform: translateY(-18px) scale(.96); }
  100% { opacity: 1; transform: none; }
}
.avatar {
  --h: 270;
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: hsl(var(--h) 45% 90%);
  color: hsl(var(--h) 35% 32%);
  font-weight: 600;
  font-size: 15px;
}
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 22% 28%); color: hsl(var(--h) 50% 86%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 22% 28%); color: hsl(var(--h) 50% 86%); } }

.bubble {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px var(--radius-lg) var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.potato.is-hot .bubble { border-color: color-mix(in srgb, var(--hot) 35%, var(--border)); }
.meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: var(--fs-meta); color: var(--text-3); }
.meta .who { font-weight: 600; font-size: var(--fs-body); color: var(--text); }
.meta .ttl { margin-left: auto; color: var(--hot-ink); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; }
.text .link { color: var(--accent-text); font-weight: 500; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.big-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 500;
  text-decoration: none;
}
.big-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.file { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-info { display: grid; min-width: 0; }
.file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: var(--fs-meta); color: var(--text-3); }
.file-badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 54px;
  border-radius: 8px 16px 8px 8px;
  background: var(--k-bg, var(--surface-3));
  color: var(--k-ink, var(--text-2));
  font-weight: 600;
  font-size: 12px;
}
/* สีป้ายชนิดไฟล์ โทนมูจิ */
.kind-slides { --k-bg: #f3e4da; --k-ink: #94654a; }
.kind-pdf { --k-bg: #f5e7e2; --k-ink: #9f5646; }
.kind-doc { --k-bg: #e1ebf0; --k-ink: #4c7888; }
.kind-sheet { --k-bg: #e6efe8; --k-ink: #4a7656; }
.kind-image { --k-bg: #ece7f4; --k-ink: #6c628a; }
.kind-video { --k-bg: #f2e3e7; --k-ink: #955e6a; }
.kind-audio { --k-bg: #e0eeec; --k-ink: #4a7a74; }
.kind-archive { --k-bg: #f0e9dc; --k-ink: #80652f; }
:root[data-theme="dark"] .file-badge { background: color-mix(in srgb, var(--k-ink, #8b8597) 30%, var(--surface)); color: color-mix(in srgb, var(--k-ink, #bdb7c8) 40%, #fff); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .file-badge { background: color-mix(in srgb, var(--k-ink, #8b8597) 30%, var(--surface)); color: color-mix(in srgb, var(--k-ink, #bdb7c8) 40%, #fff); }
}
.preview {
  display: block;
  max-width: min(100%, 420px);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.preview img { display: block; width: 100%; max-height: 320px; object-fit: contain; }

.progress { display: grid; gap: 4px; font-size: var(--fs-meta); color: var(--text-2); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--p, 0%); border-radius: inherit; background: var(--accent); transition: width .3s ease; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { min-height: 38px; }
.btn.nudge { animation: nudge 1.2s ease-in-out 2; }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cool) 45%, transparent); } 50% { box-shadow: 0 0 0 8px transparent; } }

/* stubs (เย็นแล้ว / หมดเวลา) */
.stub {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 48px;
  font-size: var(--fs-sub);
  color: var(--text-3);
  min-width: 0;
}
.stub .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stub .tag { flex: none; padding: 1px 8px; border-radius: 99px; background: var(--cool-soft); color: var(--cool-ink); }
.stub.is-expired .tag, .stub.is-closed .tag { background: var(--surface-3); color: var(--text-3); }

.new-pill {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  transform: translateX(-50%);
  box-shadow: var(--shadow-lg);
}

/* ------------------------------------------------------------ หน้าโยนเผือก */
.throw { display: grid; gap: 18px; align-content: start; }
.throw-intro { display: flex; gap: 16px; align-items: center; padding: 16px 20px; }
.intro-mascot { width: 76px; height: 76px; flex: none; }
.throw-intro h1 { font-size: 20px; }
.throw-intro h1 .code { color: var(--accent-text); letter-spacing: .06em; }
.throw-intro p { color: var(--text-2); font-size: var(--fs-body); margin-top: 2px; }
.name-field { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: var(--fs-sub); color: var(--text-2); }
.name-field input {
  flex: 1;
  min-width: 0;
  max-width: 220px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--fs-body);
  outline: none;
}
.name-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.mine .potato { justify-content: flex-end; }
.mine .bubble {
  flex: 0 1 auto;
  max-width: min(88%, 560px);
  border-radius: var(--radius-lg) 6px var(--radius-lg) var(--radius-lg);
}
.mine .potato.is-hot .bubble, .mine .potato.is-sending .bubble { background: var(--hot-soft); border-color: transparent; }
.mine .potato.is-uploading .bubble, .mine .potato.is-queued .bubble, .mine .potato.is-finishing .bubble { background: var(--surface); }
.mine .potato.is-cooled .bubble { background: var(--cool-soft); border-color: transparent; }
.mine .potato.is-expired .bubble, .mine .potato.is-closed .bubble { opacity: .7; }
.mine .potato.is-cooled .text, .mine .potato.is-expired .text { color: var(--text-2); }
.mine .potato.is-failed .bubble { border-color: color-mix(in srgb, var(--bad-text) 45%, var(--border)); }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: var(--fs-meta); color: var(--text-2); }
.status .chip { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.is-hot .status .chip { color: var(--hot-ink); }
.is-cooled .status .chip { color: var(--cool-ink); }
.is-failed .status .chip { color: var(--bad-text); }
.status .when { color: var(--text-3); }
.status .btn { min-height: 30px; padding: 0 12px; font-size: var(--fs-meta); }
.status .grow { flex: 1; }

.throw-empty { display: grid; justify-items: center; gap: 8px; padding: 28px 16px; text-align: center; color: var(--text-2); }
.throw-empty b { font-weight: 600; font-size: var(--fs-card-title); color: var(--text); }

.composer {
  position: sticky;
  bottom: 0;
  z-index: 15;
  width: 100%;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
}
.composer-inner { display: flex; align-items: flex-end; gap: 8px; max-width: 1080px; margin: 0 auto; padding: 0 var(--space-7); }
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  max-height: 180px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  resize: none;
  font-size: 16px;
  line-height: 1.45;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }
.composer .btn-hot { min-height: 46px; padding: 0 22px; font-size: var(--fs-card-title); }
.composer .icon-btn { width: 46px; height: 46px; background: var(--accent-soft); color: var(--accent-text); }
.composer-meta { max-width: 1080px; margin: 6px auto 0; padding: 0 var(--space-7); display: flex; flex-wrap: wrap; justify-content: center; gap: 0 6px; font-size: var(--fs-label); line-height: 1.5; color: var(--text-3); text-align: center; }
.composer-meta a { color: var(--accent-text); }
/* หน้าโยน: แถบพิมพ์คือส่วนล่างสุดของจอแบบแอปแชต จึงย้ายเครดิตมาไว้ใต้แถบพิมพ์แทนแถบ footer (footer กลับมาเมื่อวงเลิก) */
.page-throw:has(#composer:not([hidden])) .xf { display: none; }
/* หน้าจอสถานะ (ไม่พบวง / วงเลิก) ไม่ต้องโชว์หัว "รับเผือก วง ······" */
.page-host:has(#stateScreen:not([hidden])) .host-head { display: none; }

.drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 60;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--accent-soft) 90%, transparent);
  color: var(--accent-text);
  font-size: 24px;
  font-weight: 600;
  pointer-events: none;
}

/* ------------------------------------------------------------ หน้าจอสถานะ + QR เต็มจอ */
.state-screen { display: grid; place-items: center; padding: 32px 0; min-height: 56vh; }
.state-card { display: grid; justify-items: center; gap: 12px; max-width: 440px; padding: 32px 24px; text-align: center; }
.state-card .state-mascot { width: 116px; height: 116px; }
.state-card h1 { font-size: 22px; }
.state-card p { color: var(--text-2); }
.state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }

.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(16, 10, 28, .82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: zoom-out;
}
.qr-big {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(92vw, 78vh, 640px);
  padding: clamp(16px, 3vw, 28px);
  border-radius: 24px;
  background: #fff;
  color: #1c1826;
  text-align: center;
}
.qr-big .qr-svg { width: 100%; aspect-ratio: 1; }
.qr-big .qr-svg svg { display: block; width: 100%; height: 100%; }
.qr-big .big-title { font-weight: 600; font-size: clamp(20px, 3.2vw, 32px); color: #5f3d94; }
.qr-big .big-code { font-weight: 600; font-size: clamp(30px, 6vw, 60px); letter-spacing: .14em; line-height: 1; }
.qr-big .big-url { font-size: clamp(13px, 1.8vw, 18px); color: #524c5e; overflow-wrap: anywhere; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 70;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--tip-bg);
  color: var(--tip-text);
  font-size: var(--fs-ui);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad-text); color: #fff; }

@media (max-width: 767px) {
  .wrap, .xn-wrap, .xf-wrap, .composer-inner, .composer-meta { padding-left: var(--space-4); padding-right: var(--space-4); }
  .composer textarea { padding: 11px 12px; }
  .composer .btn-hot { padding: 0 16px; }
  main.wrap { padding-top: var(--space-5); padding-bottom: var(--space-6); }
  .xn-tx span { display: none; }
  .host-head h1 { font-size: 22px; }
}
@media (max-width: 479px) {
  .xn-link .xn-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------ full-screen viewer (รูป/วิดีโอ) */
body.viewer-open { overflow: hidden; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #000;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}
.viewer.idle, .viewer.idle .vw-stage { cursor: none; }
.vw-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.vw-stage.zoomed { cursor: grab; }
.vw-stage.dragging { cursor: grabbing; }
.vw-stage img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
  opacity: 0;
  transition: opacity .2s ease;
  -webkit-user-drag: none;
  will-change: transform;
}
.vw-stage img.ready { opacity: 1; }
.vw-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.viewer.is-video .vw-stage { touch-action: auto; }

.vw-top {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left));
  background: linear-gradient(rgba(0, 0, 0, .72), rgba(0, 0, 0, 0));
  transition: opacity .25s ease;
}
.viewer.is-video .vw-top { padding-bottom: 20px; }
.vw-title { display: grid; min-width: 0; flex: 1 1 200px; }
.vw-name { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-sub { font-size: 13px; color: rgba(255, 255, 255, .7); }
.vw-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.vw-group { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 999px; background: rgba(255, 255, 255, .12); }
.vw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font: 500 14px var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.vw-group .vw-btn { background: transparent; }
.vw-btn:hover { background: rgba(255, 255, 255, .26); }
.vw-btn:disabled { opacity: .5; }
.vw-zoom { min-width: 62px; font-variant-numeric: tabular-nums; }
.vw-cool { background: rgba(141, 182, 195, .32); }
.vw-close { font-size: 18px; }
.vw-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 56px;
  height: 56px;
  margin-top: -28px;
  padding: 0;
  font-size: 34px;
  line-height: 1;
  background: rgba(0, 0, 0, .35);
  transition: opacity .25s ease;
}
.vw-prev { left: max(12px, env(safe-area-inset-left)); }
.vw-next { right: max(12px, env(safe-area-inset-right)); }
.viewer.is-video .vw-nav { top: 40%; }
.vw-hint {
  position: absolute;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 2;
  max-width: calc(100% - 32px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .6);
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity .4s ease;
  pointer-events: none;
}
.vw-hint.show { opacity: 1; }
.vw-msg {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(440px, calc(100% - 32px));
  padding: 24px;
  border-radius: 20px;
  background: rgba(30, 24, 40, .92);
  text-align: center;
  transform: translate(-50%, -50%);
}
.vw-msg span { color: rgba(255, 255, 255, .75); font-size: 14.5px; }
.viewer.idle .vw-top, .viewer.idle .vw-nav { opacity: 0; pointer-events: none; }
@media (max-width: 640px) {
  .vw-btn { height: 36px; min-width: 36px; padding: 0 10px; font-size: 13.5px; }
  .vw-fit, .vw-zoom { display: none; }
  .vw-nav { width: 44px; height: 44px; margin-top: -22px; font-size: 28px; }
}

/* ปุ่มดูตัวอย่างในรายการเผือก */
button.preview {
  position: relative;
  padding: 0;
  border: 1px solid var(--border);
  cursor: zoom-in;
  font: inherit;
  color: inherit;
}
.preview video { display: block; width: 100%; max-height: 320px; object-fit: contain; background: #000; pointer-events: none; }
.preview .play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 26px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.preview .open-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12.5px;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.preview:hover .open-hint, .preview:focus-visible .open-hint { opacity: 1; }
button.preview { width: min(100%, 420px); background: var(--surface-2); }

/* โลโก้ KruKits ในแถบบน (19 พ.ย. 2569) */
.xn-brand .kk-logo{display:block;flex:none;width:auto;fill:currentColor}
.xn-brand .kk-logo+.xn-tx{padding-left:12px;border-left:1px solid var(--chrome-line)}
@media (max-width:767px){.xn-brand .kk-logo+.xn-tx{display:none}}
