:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --line: #e7e3db;
  --text: #17150f;
  --text-2: #5c574d;
  --muted: #8f897d;
  /* ดำทองตามโลโก้ AGGIE */
  --brand: #b8924a;
  --brand-ink: #7a5a1e;
  --brand-soft: #f7f0de;
  --on-brand: #17120a; /* ตัวหนังสือบนพื้นทอง */
  --btn-grad: linear-gradient(160deg, #d9bf78 0%, #b8924a 55%, #a07a35 100%);
  --rail: #0b0b0b;
  --rail-text: #a9a294;
  --rail-on: #dcc07a;
  --bubble-in: #f0eeea;
  /* การ์ดลอย (หน้าแรก): เงาจาง แยกการ์ดด้วยระยะห่างมากกว่าเงา */
  --float: 0 18px 36px -24px rgba(23, 18, 10, .26), 0 4px 12px -6px rgba(23, 18, 10, .08);
  --float-up: 0 26px 46px -26px rgba(23, 18, 10, .32), 0 8px 16px -8px rgba(23, 18, 10, .1);
  --amber: #a16207;
  --amber-soft: #fef3c7;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --fb: #1877f2;
  --line-green: #06c755;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 6px 20px rgba(16, 24, 20, .07);
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ฝั่งตัวแทน: Manrope (ตัวเลข/อังกฤษ) + Anuphan (ไทย) แบบงาน rondesignlab
   หน้าโรงงานใช้ธีมเดียวกันตั้งแต่ 24 ต.ค. (factory.html มี body.agent-app, factory.js มี .shell.agent)
   แก้กฎ .shell.agent / body.agent-app ที่โดนชิ้นส่วนร่วม (แถบซ้าย แถบล่าง ปุ่ม ป้าย toast) ต้องเปิดดูหน้าโรงงานด้วย */
body.agent-app { --font: 'Manrope', 'Anuphan', system-ui, -apple-system, 'Segoe UI', sans-serif; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

#app { flex: 1; min-height: 0; display: flex; }

/* ---------- ไอคอน / ปุ่ม ---------- */
.ic { width: 20px; height: 20px; flex: none; }
.ic.xl { width: 44px; height: 44px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r);
  background: var(--surface-2); color: var(--text);
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn.sm { height: 32px; padding: 0 10px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn.sm .ic { width: 16px; height: 16px; }
.btn.block { width: 100%; height: 46px; }
.btn.primary { background: var(--btn-grad); color: var(--on-brand); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn.soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn.danger { background: var(--red); color: #fff; }
.btn.fb { background: var(--fb); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .rail-item:focus-visible, .conv:focus-visible { outline: 3px solid rgba(184, 146, 74, .45); outline-offset: 2px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.avatar {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-ink); font-weight: 700;
}
.avatar.sm { width: 34px; height: 34px; font-size: 14px; background: #2a251b; color: var(--rail-on); }

.tag {
  display: inline-block; margin-top: 6px; padding: 1px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }

/* ---------- หน้าเข้าสู่ระบบ / เชื่อมเพจ ---------- */
.auth { flex: 1; display: grid; place-items: center; padding: 24px 16px; overflow: auto; }
.auth-card {
  width: 100%; max-width: 380px;
  padding: 32px 28px; background: var(--surface);
  border-radius: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.auth-card.wide { max-width: 440px; }
/* โลโก้เป็นรูป ข้อความ Hey AGGIE ยังอยู่ให้โปรแกรมอ่านหน้าจอ แต่ไม่แสดง */
.brand-lg { height: 150px; font-size: 0; color: transparent; background: url(logo-login.webp) center / contain no-repeat; }
.auth-sub { margin: -6px 0 6px; color: var(--text-2); }
.auth-help { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.field input {
  height: 46px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); font-weight: 400; color: var(--text);
}
.field input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(184, 146, 74, .2); }
.form-error { margin: 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--red-soft); color: var(--red); font-size: 14px; }
.connect-title { margin: 4px 0 0; font-size: 21px; }
.steps { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; }
.steps b {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-ink); font-size: 14px;
}
.note {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 0; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-2); font-size: 13.5px;
}
.note .ic { width: 18px; height: 18px; margin-top: 2px; }

/* ---------- โครงหลัก ---------- */
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.shell-body { flex: 1; min-height: 0; display: flex; position: relative; }

.topbar { flex: none; padding: 8px 10px; background: var(--rail); }
.brand-box { width: 80px; height: 66px; font-size: 0; color: transparent; background: url(logo-bar.webp) left center / contain no-repeat; }

.rail {
  flex: none; width: 76px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 0; background: var(--rail); color: var(--rail-text);
}
.rail-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 64px; padding: 8px 0; border: 0; border-radius: 12px;
  background: transparent; color: inherit; font-size: 12px; cursor: pointer;
}
.rail-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.rail-item.on { background: rgba(220, 192, 122, .14); color: var(--rail-on); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dot {
  position: absolute; top: 4px; right: 12px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #ef4444; color: #fff; font-size: 11px; font-style: normal; font-weight: 700; line-height: 18px; text-align: center;
}

.tabbar { display: none; }

/* ฝั่งตัวแทนบนคอม (แบบ ค): ไม่มีแถบบนดำ แถบเมนูซ้ายเป็นกระจกขาวลอย เห็นแสงทองลอดผ่าน โลโก้อยู่บนสุดของแถบ
   เมนูที่เลือกเป็นแคปซูลดำไอคอนทอง — หน้าโรงงาน (.shell เฉยๆ) กับมือถือไม่เปลี่ยน */
@media (min-width: 768px) {
  .shell.agent .topbar { display: none; }
  /* แสงทองก้อนเดียวมุมบนซ้าย ลอดผ่านแถบเมนู ที่เหลือเป็นพื้นเทาอ่อน */
  .shell.agent .shell-body { background: radial-gradient(28% 42% at 0% 0%, rgba(246, 210, 122, .6), transparent), var(--bg); }
  /* หน้าแรก: แสงทองกับเงาดำหลังการ์ดกระจก (กระจกต้องมีสีด้านหลังถึงจะเห็นผล) */
  .shell.agent[data-view="home"] .shell-body {
    background:
      radial-gradient(24% 40% at 18% 30%, rgba(214, 152, 58, .85), transparent 72%),
      radial-gradient(16% 34% at 52% 26%, rgba(23, 18, 10, .42), transparent 72%),
      radial-gradient(24% 40% at 82% 26%, rgba(230, 170, 80, .7), transparent 72%),
      radial-gradient(28% 36% at 40% 82%, rgba(214, 152, 58, .35), transparent 72%),
      #e8e5df;
  }
  .shell.agent .col-home { background: transparent; }
  .shell.agent .col-home::before { display: none; }
  .shell.agent .rail {
    margin: 12px; border: 1px solid rgba(255, 255, 255, .75); border-radius: 24px;
    background: rgba(255, 255, 255, .5); color: #4d473d;
    -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%);
    box-shadow: 0 20px 44px -26px rgba(23, 18, 10, .35), inset 0 1px 0 rgba(255, 255, 255, .9);
  }
  .shell.agent .rail::before { content: ''; flex: none; width: 64px; height: 53px; margin: 0 0 10px; background: url(logo-bar.webp) center / contain no-repeat; }
  .shell.agent .rail-item:hover { background: rgba(23, 18, 10, .06); color: var(--text); }
  /* เมนูที่เปิดอยู่: ไม่มีแคปซูลดำแล้ว (เก็ทสั่ง 23 ต.ค.) เหลือแค่ไฟส่อง ตัวหนังสือทองเข้มแบบแถบล่างมือถือ */
  .shell.agent .rail-item.on { background: transparent; color: var(--brand-ink); font-weight: 600; }
  /* ไฟส่องเมนูที่เปิดอยู่ (แบบเดียวกับแถบล่างมือถือ): แถบไฟทองด้านบน + แสงกรวยส่องลงมาที่ไอคอน */
  .shell.agent .rail-item.on::before {
    content: ''; position: absolute; top: -5px; left: 50%;
    width: 30px; height: 3px; margin-left: -15px; border-radius: 3px;
    background: #d9b25c; box-shadow: 0 0 10px rgba(240, 190, 90, .9);
  }
  .shell.agent .rail-item.on > span::before {
    content: ''; position: absolute; top: -3px; left: 50%;
    width: 56px; height: 36px; margin-left: -28px;
    background: linear-gradient(180deg, rgba(246, 205, 110, .6), rgba(246, 205, 110, 0));
    clip-path: polygon(36% 0, 64% 0, 100% 100%, 0 100%);
    pointer-events: none;
  }
}

/* ---------- รายการแชท ---------- */
.col-list {
  flex: none; width: 340px; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
}
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 10px; }
.list-title { font-size: 22px; font-weight: 700; }
.page-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 160px;
  padding: 4px 10px 4px 6px; border-radius: 999px;
  background: #e8f0fe; color: var(--fb); font-size: 12.5px; font-weight: 600;
}
.page-chip .ic { width: 16px; height: 16px; }
.page-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search {
  display: flex; align-items: center; gap: 8px;
  margin: 0 16px 8px; padding: 0 12px; height: 40px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.conv { display: flex; gap: 12px; padding: 10px; border-radius: var(--r); }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--brand-soft); }
.conv-body { flex: 1; min-width: 0; }
.conv-top, .conv-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top time { flex: none; font-size: 12px; color: var(--muted); }
.conv-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 14px; }
.conv.unread .conv-top b, .conv.unread .conv-preview { font-weight: 700; color: var(--text); }
.badge {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--brand); color: var(--on-brand); font-size: 12px; font-style: normal; font-weight: 700; line-height: 20px; text-align: center;
}
/* แบบร่างพี่เบ็นหน้า 2–3: แท็บ Facebook / LINE + ช่องค้นหา แถวตัวกรอง (เพจทั้งหมด / แสดงแชททั้งหมด / ที่ยังไม่ได้อ่าน)
   รูปลูกค้ากับรูปเพจ (เฉพาะเฟซบุ๊ก) — รูปเพจเป็นวงเล็กซ้อนมุมขวาล่าง */
.chat-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 16px 14px 8px; }
.chat-top .search { flex: 1 1 120px; margin: 0; }
.src-tabs { display: flex; gap: 6px; }
.src-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2);
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.src-tab .ic { width: 16px; height: 16px; }
.src-tab.fb.on { background: var(--fb); border-color: var(--fb); color: #fff; }
.src-tab.line.on { background: var(--line-green); border-color: var(--line-green); color: #fff; }
.chat-filter { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 14px 10px; }
.flt {
  height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer;
}
.flt.on { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
select.flt { padding-right: 6px; }
.av-pair { flex: none; display: flex; gap: 6px; }
.av-pair .pg { background: var(--blue-soft); color: var(--fb); }

/* ---------- ห้องแชท ---------- */
.col-chat { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.empty-chat { flex: 1; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); }
.empty-chat p { margin: 0; }
.chat-head {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.chat-head .back { display: none; margin-left: -8px; }
.chat-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-who small { color: var(--muted); font-size: 12.5px; }
.chat-who .warn { color: var(--red); }

.msgs {
  flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2);
  scrollbar-width: thin; scrollbar-color: rgba(0, 0, 0, .15) transparent;
}
.day-sep { display: flex; justify-content: center; margin: 10px 0 4px; }
.day-sep span { padding: 2px 10px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; }
.sys { align-self: center; margin: 6px 0; padding: 4px 12px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 12.5px; }
.msg { display: flex; flex-direction: column; max-width: min(75%, 520px); }
/* ข้อความลูกค้า: วงกลมตัวย่อชื่ออยู่ซ้าย ชิดล่างของฟอง เวลาอยู่ใต้ฟอง */
.msg.in { align-self: flex-start; display: grid; grid-template-columns: 32px minmax(0, auto); column-gap: 8px; justify-items: start; }
.msg.in > .avatar { grid-row: 1; align-self: end; width: 32px; height: 32px; font-size: 13px; }
.msg.in > :not(.avatar) { grid-column: 2; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg time { margin: 2px 6px 4px; font-size: 11px; color: var(--muted); }
.bubble { padding: 10px 16px; border-radius: 16px; background: var(--surface); font-size: 14.5px; line-height: 1.55; white-space: normal; overflow-wrap: anywhere; }
.msg.in .bubble { border: 1px solid var(--line); border-top-left-radius: 6px; box-shadow: 0 4px 12px -2px rgba(0, 0, 0, .08); }
.msg.out .bubble { background: var(--btn-grad); color: var(--on-brand); border-top-right-radius: 6px; box-shadow: 0 8px 24px -4px rgba(184, 146, 74, .45); }
.muted-bubble { color: var(--muted); font-style: italic; }
.msg.out .muted-bubble { background: var(--surface); color: var(--muted); border: 1px solid var(--line); box-shadow: none; }
/* ข้อความใหม่เลื่อนเข้ามาจากด้านข้าง (ข้อความเก่าไม่ขยับ) */
.msg.enter.in { animation: msg-in-l .35s cubic-bezier(.22, 1, .36, 1) both; }
.msg.enter.out { animation: msg-in-r .35s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes msg-in-l { from { opacity: 0; transform: translate(-20px, 12px) scale(.96); } }
@keyframes msg-in-r { from { opacity: 0; transform: translate(20px, 12px) scale(.96); } }
@media (prefers-reduced-motion: reduce) { .msg.enter.in, .msg.enter.out { animation: none; } }

/* ช่องพิมพ์ (แบบร่างหน้า 4): ปุ่มกลม สร้างออเดอร์ / ส่งรูป / ตอบไว + กล่องพิมพ์
   ไม่มีไมค์ (เก็ทสั่งเอาออก 24 ต.ค.) ปุ่มส่งแบบแชททั่วไปอยู่ขวาสุดแทนที่ไมค์ (เก็ทสั่ง 24 ต.ค.) — Enter / ปุ่ม "ส่ง" บนแป้นพิมพ์มือถือก็ยังส่งได้ */
.chat-foot { position: relative; flex: none; }
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface);
}
.cbtns { flex: none; display: flex; gap: 6px; }
.cbtn {
  display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
  border: 0; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink);
  font-size: 11.5px; font-weight: 500; line-height: 1.15; text-align: center; cursor: pointer;
}
.cbtn:hover:not(:disabled) { background: #f1e5c4; }
.cbtn:disabled { opacity: .45; cursor: not-allowed; }
.composer textarea {
  flex: 1; min-width: 0; min-height: 48px; max-height: 140px; padding: 12px 16px; resize: none;
  border: 1px solid var(--line); border-radius: 24px; background: var(--surface-2); outline: none; line-height: 1.4;
}
.composer textarea:focus { border-color: var(--brand); background: #fff; }
.c-send {
  flex: none; display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
  border: 0; border-radius: 50%; background: var(--btn-grad); color: var(--on-brand); cursor: pointer;
}
.c-send .ic { width: 19px; height: 19px; }
/* กล่องว่าง = ปุ่มจาง กดแล้วไม่ส่งอะไร */
.composer:has(textarea:placeholder-shown) .c-send { opacity: .45; cursor: default; }
.locked-note { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 48px; margin: 0; color: var(--text-2); font-size: 13.5px; }
.qr-pop {
  position: absolute; left: 12px; right: 12px; bottom: 100%; z-index: 5; margin-bottom: 8px; padding: 8px;
  max-height: 50vh; overflow-y: auto; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--float-up);
  display: flex; flex-direction: column; gap: 4px;
}
.qr-pop button { padding: 10px 14px; border: 0; border-radius: var(--r); background: var(--surface-2); text-align: left; cursor: pointer; }
.qr-pop button:hover { background: var(--brand-soft); }
.qr-pop p { margin: 6px 8px; color: var(--text-2); font-size: 14px; }
.qr-pop a { color: var(--brand-ink); text-decoration: underline; }
.pic { display: block; max-width: min(240px, 100%); max-height: 280px; border-radius: 16px; object-fit: cover; }

/* ---------- หน้าต่างสร้างออเดอร์ข้างห้องแชท ---------- */
.col-panel {
  display: none; flex: none; width: 380px; min-height: 0;
  flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto;
}
.panel-open .col-panel { display: flex; }
.scrim { display: none; }
.panel-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 18px; background: var(--surface); }
.panel-head b { font-size: 18px; }
.status {
  display: flex; align-items: center; gap: 6px;
  margin: 0 18px 12px; padding: 10px 12px; border-radius: var(--r); font-weight: 600; font-size: 14.5px;
}
.status.amber { background: var(--amber-soft); color: var(--amber); }
.status.blue { background: var(--blue-soft); color: var(--blue); }
.status.green { background: var(--green-soft); color: var(--green); }
.total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; font-size: 15px; }
.total b { font-size: 20px; color: var(--brand-ink); }

.panel-foot {
  position: sticky; bottom: 0; margin-top: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
}
.panel-foot .total { padding-top: 0; }
.hint { margin: 0; font-size: 13px; color: var(--text-2); }

/* ---------- สร้างออเดอร์ (แบบร่างหน้า 5) และเลือกสินค้า (หน้า 14) ----------
   ใช้ทั้งในหน้าต่างข้างแชท และหน้าเต็มของ "สร้างเอง" — กว้างพอ (หน้าเต็มบนคอม) แบ่งซ้าย–ขวา */
.oform, .picker { min-height: 100%; display: flex; flex-direction: column; background: var(--surface); }
.oform-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.oform-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.oform-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.oform-body { container: oform / inline-size; padding: 16px 18px 20px; }
.oform-cols, .oform-col { display: flex; flex-direction: column; gap: 14px; }
@container oform (min-width: 760px) {
  .oform-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; align-items: start; }
}
.field textarea {
  min-height: 96px; padding: 12px 14px; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
  font-weight: 400; color: var(--text); line-height: 1.5; outline: none;
}
.field textarea:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(184, 146, 74, .2); }
.field.raw textarea { width: min(100%, 280px); height: 120px; min-height: 0; }
.of-amounts { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px 10px; }
.of-lb { font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.of-amounts output { display: block; height: 44px; line-height: 44px; padding: 0 12px; border-radius: var(--r); background: var(--brand-soft); color: var(--brand-ink); font-weight: 500; white-space: nowrap; overflow: hidden; }
.sfx { display: flex; align-items: center; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.sfx:focus-within { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(184, 146, 74, .2); }
.sfx.invalid { border-color: var(--red); background: #fff; }
.sfx input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; outline: none; color: var(--text); }
.sfx i, .sfx-out > i { font-style: normal; color: var(--text-2); }
.sfx-out { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sfx-out .sfx { flex: 1; }
.prod-field {
  min-height: 46px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
  color: var(--text); font-weight: 400; text-align: left; line-height: 1.4; cursor: pointer;
}
.prod-field.empty { color: var(--muted); }
.prod-field:hover { border-color: var(--brand); }
.field.invalid :is(input, textarea, .prod-field) { border-color: var(--red); background: #fff; }
.pay { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pay-btn { height: 46px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 15px; font-weight: 500; cursor: pointer; }
.pay-btn.on { background: var(--btn-grad); border-color: transparent; color: var(--on-brand); }
.pay.invalid .pay-btn { border-color: var(--red); }
.area { position: relative; }
.area-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 4; display: none; margin-top: 4px; padding: 6px;
  max-height: 260px; overflow-y: auto; border-radius: var(--r); background: var(--surface); box-shadow: var(--float-up);
}
.area-list.open { display: block; }
.area-list button { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); font-weight: 400; text-align: left; cursor: pointer; }
.area-list button:hover { background: var(--brand-soft); }
.area-list p { margin: 6px 10px; color: var(--muted); font-weight: 400; }

/* เลือกสินค้า: แคบ (หน้าต่างข้างแชท/มือถือ) แบ่ง 2 แถว รูป+ชื่อ / จำนวน ราคารวม แถมฟรี — กว้างพอเรียงแถวเดียวแบบในแบบร่าง */
.pick-list { container: picklist / inline-size; flex: 1; padding: 14px 14px 16px; background: var(--bg); }
.pick-grid { display: grid; gap: 10px; }
.pick-head { border-bottom: 0; background: var(--bg); }
.pick-card {
  display: grid; grid-template-columns: 80px minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid transparent; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow);
}
.pick-card .item-photo { width: 80px; height: 62px; }
.pick-card.picked { border-color: var(--brand); }
.pk-stock { display: contents; } /* กว้างพอ: คลัง กับจำนวนขวดเป็นคนละช่องในตาราง 2×2 แบบหน้าสินค้า */
.pick-ctl {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px 12px;
  padding-left: 14px; border-left: 1px dashed var(--line); font-size: 14px;
}
.pick-lb { color: var(--text-2); }
.qty { grid-column: 2 / -1; display: flex; align-items: center; gap: 6px; }
.qty .icon-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); }
.qty .icon-btn .ic { width: 16px; height: 16px; }
.qty input { width: 64px; height: 34px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); text-align: center; outline: none; }
.qty input:focus { border-color: var(--brand); background: #fff; }
.pick-sum { color: var(--brand-ink); }
.free-chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.free-chk input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
/* แคบ (มือถือ / หน้าต่างข้างแชท): ยังเป็นแถวเดียว แต่ชื่อ ราคา คลัง เรียงลง และย่อปุ่มจำนวน */
@container picklist (max-width: 599px) {
  .pick-card { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; padding: 12px; }
  .pick-card .item-photo { width: 52px; height: 52px; font-size: 10.5px; text-align: center; }
  .pick-card .item-info { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
  .pk-stock { display: block; white-space: nowrap; }
  .pick-ctl { grid-template-columns: auto auto; gap: 6px 8px; padding-left: 10px; font-size: 13px; }
  .qty { grid-column: auto; gap: 3px; }
  .qty .icon-btn { width: 26px; height: 26px; }
  .qty .icon-btn .ic { width: 14px; height: 14px; }
  .qty input { width: 32px; height: 26px; }
  .free-chk { grid-column: 1 / -1; }
}
@container picklist (min-width: 1100px) { .pick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* หน้าเต็มของ "สร้างเอง": บนคอมเป็นการ์ดใหญ่เต็มความกว้าง */
.opage { min-height: 100%; }
@media (min-width: 768px) {
  .opage { padding: 16px 24px 24px; }
  .opage > :is(.oform, .picker) { min-height: 0; border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: clip; }
}

/* ---------- ออเดอร์ / สินค้า / ตั้งค่า (หัวหน้า + รายการการ์ด) ---------- */
.col-orders { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; background: var(--bg); }
.orders-head {
  position: sticky; top: 0; z-index: 1; max-width: 808px; margin: 0 auto; padding: 18px 24px 12px; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.orders-head .btn { flex: none; }
.orders-list { max-width: 808px; margin: 0 auto; padding: 0 24px 32px; display: flex; flex-direction: column; gap: 10px; }
.orders-list.top { padding-top: 18px; } /* หน้าสินค้าไม่มีหัวเรื่อง (แบบร่างหน้า 13) */
.group { margin: 10px 0 0; font-size: 14px; color: var(--text-2); }
.order { padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }

/* หน้าออเดอร์ (แบบร่างหน้า 6–11): แท็บ 6 อัน + ค้นหาคีย์เวิด + สร้างเลขพัสดุ/ส่งออเดอร์ + ลบออเดอร์
   การ์ด: ไอคอนช่องทาง (เพจ/LINE/สร้างเอง) ชื่อ เบอร์ [เลขพัสดุ สถานะ] / สินค้า / วันที่ซื้อ ยอด (COD|โอนแล้ว)
   กดค้างที่การ์ด = โหมดเลือก มีช่องติ๊กใต้ไอคอนช่องทาง */
.ohead {
  position: sticky; top: 0; z-index: 3; padding: 18px 24px 12px; background: var(--bg);
  display: grid; grid-template-columns: minmax(0, 1fr) 260px; grid-template-areas: "tabs tools" "sub sub"; align-items: center; gap: 10px 16px;
}
.otabs { grid-area: tabs; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.otabs::-webkit-scrollbar { display: none; }
.otab {
  flex: none; display: inline-flex; align-items: center; height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2);
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.otab:hover { color: var(--text); }
.otab.on { background: var(--rail); border-color: var(--rail); color: var(--rail-on); }
.otools { grid-area: tools; display: flex; flex-direction: column; gap: 8px; }
.otools .search { margin: 0; background: var(--surface); }
.otools .btn { width: 100%; height: auto; min-height: 40px; padding: 6px 12px; flex-wrap: wrap; gap: 0; white-space: normal; line-height: 1.25; }
.btn.danger-soft { background: var(--red-soft); color: var(--red); }
.osub { grid-area: sub; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.osub:empty { display: none; }
.oadd { margin-left: auto; }
.chip-btn {
  height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text-2); font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.chip-btn.on { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.chip-btn:disabled { opacity: .45; cursor: not-allowed; }
.ocard {
  display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px;
  padding: 14px 16px; border: 2px solid transparent; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.ocard.src-fb { background: #eaf2fe; }
.ocard.src-line { background: #e8f7ec; }
.ocard.src-self { background: #efede8; }
.ocard.sel { border-color: var(--brand); }
.ocard-side { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.src-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 9px; font-weight: 600; letter-spacing: .02em; }
.src-ic .ic { width: 16px; height: 16px; }
.src-ic.fb { background: var(--fb); }
.src-ic.line { background: var(--line-green); }
.src-ic.self { background: var(--muted); font-size: 11px; }
.ochk { display: grid; place-items: center; width: 26px; height: 26px; border: 2px solid var(--line); border-radius: 8px; background: var(--surface); color: #fff; }
.ochk.on { border-color: var(--brand); background: var(--brand); }
.ochk .ic { width: 16px; height: 16px; stroke-width: 3; }
.ocard-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ocard-top { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
.oname { font-size: 15.5px; font-weight: 600; }
a.oname:hover { color: var(--brand-ink); text-decoration: underline; }
.ophone { color: var(--text-2); font-variant-numeric: tabular-nums; }
.otr { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; } /* เลขพัสดุกับสถานะขึ้นบรรทัดใหม่ไปด้วยกัน */
.otrack { color: var(--brand-ink); font-weight: 600; }
.st-dot {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  color: #fff; font-size: 8.5px; font-weight: 600; line-height: 1.1; text-align: center; letter-spacing: -.01em;
}
.st-wait { width: auto; height: auto; color: var(--red); }
.st-wait .ic { width: 22px; height: 22px; }
.st-loaded { background: #c97fd0; }
.st-packed { background: #24a148; }
.st-picked { background: #4b4740; }
.st-transit { background: #2f9fe0; }
.st-delivered { background: #8455ef; }
.st-cod { background: #e59a2f; }
.st-cancelled { background: #dc3f44; }
.st-problem { background: #0f8aa1; }
.st-returned { background: #16aecb; }
.oline { font-size: 14.5px; }
.olb { color: var(--text-2); }
.obottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; }
.osum { color: var(--brand-ink); }
.onote { margin: 4px 0 0; color: var(--amber); font-size: 13px; }
.oact { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ---------- การ์ดรายการ (หน้าสินค้า) ---------- */
.item-card { padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; }
.item-photo { flex: none; width: 88px; height: 66px; border-radius: var(--r); background: var(--surface-2); color: var(--muted); font-size: 12.5px; display: grid; place-items: center; }
.item-info { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; align-items: baseline; }
.item-info > * { min-width: 0; overflow-wrap: anywhere; }
.item-card .item-info .item-name { font-weight: 700; } /* ตัวอังกฤษ Manrope ที่ 500 ดูบางกว่าคำไทย */
.item-price { color: var(--brand-ink); }
.free { color: var(--green); font-weight: 600; }
.empty-note { margin: 24px 0; text-align: center; color: var(--muted); }

/* ---------- ตั้งค่า ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row > span { display: flex; flex-direction: column; min-width: 0; }
.reply-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.reply-list li { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 12px; border-radius: var(--r); background: var(--surface-2); }
.reply-list li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.reply-add { display: flex; gap: 8px; }
.reply-add .field { flex: 1; min-width: 0; }
.reply-add .btn { height: 46px; }

/* ---------- หน้าฟอร์ม (คีย์ออเดอร์) ---------- */
.col-page { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; background: var(--bg); }
.card { padding: 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.card h3 { margin: 0; font-size: 15px; }
.card .search { margin: 0; }
.field small { font-weight: 400; color: var(--muted); }
.field.invalid input { border-color: var(--red); background: #fff; }

/* ---------- หน้าแรก: การ์ดลอยมีมิติบนพื้นหลังเบลอ แบบ rondesignlab โทนดำทอง (คอมใช้เต็มความกว้าง) ---------- */
.col-home { position: relative; isolation: isolate; flex: 1; min-width: 0; min-height: 0; overflow-y: auto; background: #ebe8e2; container: home / inline-size; }
/* แสงทองกับเงาดำเบลอๆ หลังการ์ดกระจก (มือถือ — บนคอมใช้พื้นของ .shell-body แทน) */
.col-home::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 22% at 18% 26%, rgba(205, 150, 62, .85), transparent 70%),
    radial-gradient(50% 18% at 78% 34%, rgba(23, 18, 10, .55), transparent 70%),
    radial-gradient(60% 22% at 40% 60%, rgba(226, 168, 82, .6), transparent 70%);
  filter: blur(30px);
}
.home { padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 40px; }
.home-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.home-hello { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.home-hello small { color: var(--text-2); font-size: 14px; line-height: 1.4; }
.home-hello h1 { margin: 0 0 2px; font-size: 40px; font-weight: 500; line-height: 1.15; }
.home-set, .home-logo { display: none; }
.home-sec h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 18px; font-weight: 500; }
.home-sec h2 em { min-width: 24px; padding: 0 8px; border-radius: 999px; background: var(--rail); color: var(--rail-on); font-size: 12.5px; font-style: normal; line-height: 24px; text-align: center; }

/* การ์ดกระจกฝ้าแบบการแจ้งเตือน iPhone: เห็นแสงด้านหลังเบลอๆ ขอบบนซ้ายมีเส้นแสง (inset คือเส้นแสงขอบกระจก ไม่ใช่เงาบุ๋ม) */
.stat, .task, .task-none {
  background: rgba(255, 255, 255, .36);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  box-shadow:
    inset 1.5px 1.5px 0 rgba(255, 255, 255, .9),
    inset -1px -1px 0 rgba(255, 255, 255, .5),
    inset 0 0 20px rgba(255, 255, 255, .22),
    0 18px 40px -24px rgba(23, 18, 10, .35);
  transition: transform .2s, box-shadow .2s;
}
/* การ์ดกระจกสีทอง: มีใบเดียวในหน้า (ยังไม่อ่าน) */
.stat:nth-child(1) { background: rgba(238, 196, 104, .45); }
/* ชี้แล้วลอยขึ้นนิดเดียว เส้นแสงขอบยังอยู่ครบ เงาด้านนอกเข้มขึ้นนิดหน่อย */
.stat:hover, .task:hover {
  transform: translateY(-2px);
  box-shadow:
    inset 1.5px 1.5px 0 rgba(255, 255, 255, .9),
    inset -1px -1px 0 rgba(255, 255, 255, .5),
    inset 0 0 20px rgba(255, 255, 255, .22),
    0 24px 46px -24px rgba(23, 18, 10, .45);
}

/* วงกระจก (ไอคอน) กับปุ่มลูกศรเล็กสีดำ (การ์ดงาน) */
.well {
  display: grid; place-items: center; flex: none; border-radius: 50%; font-style: normal;
  background: rgba(255, 255, 255, .42);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .95),
    inset -1px -1px 0 rgba(255, 255, 255, .4),
    0 8px 18px -10px rgba(23, 18, 10, .35);
}
.sock { flex: none; display: grid; padding: 3px; border-radius: 50%; background: transparent; }
.go {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-style: normal; color: #fff;
  background: rgba(20, 18, 15, .8);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .35),
    inset -1px -1px 0 rgba(255, 255, 255, .12),
    0 6px 14px -6px rgba(0, 0, 0, .45);
}
.go .ic { width: 14px; height: 14px; }

/* ตัวเลขวันนี้: การ์ดแยก 3 ใบ — ใบแรกทองนวล ที่เหลือขาว ตัวเลขใหญ่แต่บาง กดได้ทั้งใบ */
.home-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; container: stats / inline-size; }
.stat { display: flex; flex-direction: column; min-width: 0; padding: 16px 16px 18px; border-radius: 30px; color: var(--text); }
.stat-ic { align-self: flex-start; width: 40px; height: 40px; margin-bottom: 18px; color: var(--text-2); }
.stat-ic .ic { width: 18px; height: 18px; }
.stat-label { font-size: 13.5px; line-height: 1.35; color: var(--text-2); }
.stat-label span { display: inline-block; white-space: nowrap; } /* ขึ้นบรรทัดใหม่ได้เฉพาะระหว่างคำ ไม่ตัดกลางคำ */
.stat-num { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin-top: 4px; }
.stat-num b { font-size: 48px; font-weight: 500; line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat-num small { font-size: 13px; font-weight: 400; color: var(--text-2); }
.stat:nth-child(1) .stat-ic { background: rgba(120, 70, 10, .08); color: var(--on-brand); }
.stat:nth-child(1) .stat-label, .stat:nth-child(1) .stat-num small { color: rgba(23, 18, 10, .7); }
/* การ์ดตัวเลขแคบ (มือถือ / จอกลาง) ย่อขนาดลง */
@container stats (max-width: 440px) {
  .stat { padding: 12px 12px 14px; border-radius: 24px; }
  .stat-ic { width: 30px; height: 30px; margin-bottom: 12px; }
  .stat-ic .ic { width: 15px; height: 15px; }
  .stat-label { font-size: 12px; }
  .stat-num { gap: 0 3px; margin-top: 2px; }
  .stat-num b { font-size: 36px; }
  .stat-num small { font-size: 12px; }
}

/* ทางลัด (เฉพาะคอม — มือถือใช้แถบล่างแทน): วงกลมขาว 4 ปุ่มชิดกันเป็นกลุ่ม ช่องกว้างคงที่ เรียงจากซ้าย
   (ขยับซ้าย 16px ให้วงกลมแรกตรงแนวหัวข้อ "ทางลัด") */
.shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0, 96px)); justify-content: start; gap: 8px; margin-left: -16px; }
.shortcut { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-2); text-align: center; }
.sc-ic {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; color: var(--text);
  background: rgba(255, 255, 255, .42);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .95),
    inset -1px -1px 0 rgba(255, 255, 255, .4),
    0 8px 18px -10px rgba(23, 18, 10, .35);
  transition: transform .2s, color .2s;
}
.shortcut:hover .sc-ic { transform: translateY(-2px); color: var(--brand-ink); }
.sc-label span { display: inline-block; white-space: nowrap; } /* ขึ้นบรรทัดใหม่ได้เฉพาะระหว่างคำ */
.sc-ic .ic { width: 24px; height: 24px; }
/* ไฟส่องตอนชี้ (แบบ ฉ): แถบไฟทองเหนือวงกลม + แสงกรวยส่องลงมา — กด Tab บนคีย์บอร์ดก็เห็น */
.shortcut::before {   /* แถบไฟโค้ง: ใช้ขอบบนของวงกลมใหญ่ที่มองไม่เห็น ลอยเหนือปุ่ม */
  content: ''; position: absolute; top: -9px; left: 50%;
  width: 80px; height: 80px; margin-left: -40px; box-sizing: border-box;
  border: 3px solid transparent; border-top-color: #d9b25c; border-radius: 50%;
  filter: drop-shadow(0 0 5px rgba(240, 190, 90, .95));
  pointer-events: none; opacity: 0; transition: opacity .25s;
}
.shortcut::after {
  content: ''; position: absolute; top: -6px; left: 50%;
  width: 70px; height: 62px; margin-left: -35px;
  background: linear-gradient(180deg, rgba(246, 205, 110, .6), rgba(246, 205, 110, 0));
  clip-path: polygon(36% 0, 64% 0, 100% 100%, 0 100%);
  pointer-events: none; opacity: 0; transition: opacity .25s;
}
.shortcut:hover::before, .shortcut:hover::after,
.shortcut:focus-visible::before, .shortcut:focus-visible::after { opacity: 1; }

/* งานที่ต้องทำ: การ์ดขาว ไอคอนในหลุมเว้า ป้ายอยู่ใต้ข้อความ ลูกศรดำเล็ก */
.tasks { display: flex; flex-direction: column; gap: 10px; }
.task { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 6px 14px; padding: 16px 16px 16px 18px; border-radius: 30px; }
.task-ic { grid-row: 1 / span 2; align-self: start; width: 44px; height: 44px; }
.task-ic.red { background: rgba(254, 226, 226, .72); color: var(--red); }
.task-ic.blue { background: rgba(219, 234, 254, .72); color: var(--blue); }
.task-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.task-body small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ชื่องานยาวได้ 2 บรรทัด ไม่ถูกตัดตอนช่องแคบ */
.task-body b { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 15px; font-weight: 500; line-height: 1.4; }
.task-body small { color: var(--text-2); font-size: 13px; line-height: 1.4; }
.nw { white-space: nowrap; } /* วลีที่ห้ามตัดกลาง เช่น "ก่อนหมดเวลา" */
.task .tag { grid-column: 2; justify-self: start; margin: 0; }
.task .sock { grid-column: 3; grid-row: 1 / span 2; }
.task-none { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 20px; border-radius: 30px; color: var(--text-2); }
.task-none .ic { color: var(--green); }
/* งานที่ต้องทำบนคอม: ช่องกว้างพอ (≥560px) วางการ์ดงาน 2 ใบต่อแถว ลำดับเดิม ซ้ายไปขวาแล้วบนลงล่าง — มือถือเรียงทีละใบเหมือนเดิม */
.home-tasks { container: tasks / inline-size; }
@container tasks (min-width: 560px) {
  .tasks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- จอคอม: ดูจากความกว้างพื้นที่เนื้อหา มือถือยังเรียงลงล่างเหมือนเดิม ---------- */
.col-orders { container: list / inline-size; }

/* หน้าแรกแบ่งซ้าย–ขวา: ซ้ายตัวเลขกับทางลัด ขวางานที่ต้องทำ */
@container home (min-width: 760px) {
  .home { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 40px 32px; }
  .home-hero { grid-column: 1 / -1; }
  .home-stats, .home-short { grid-column: 1; }
  .home-tasks { grid-column: 2; grid-row: 2 / span 2; }
}

/* รายการเต็มความกว้างจอ เรียงการ์ดได้หลายใบต่อแถว (ใบละอย่างน้อย 420px: จอ 1180 ได้ 2 ใบ จอ 1440 ขึ้นไปได้ 3 ใบ) */
@container list (min-width: 880px) {
  .orders-head, .orders-list { max-width: none; }
  .orders-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); align-items: start; }
  .orders-list .group, .orders-list .empty-note { grid-column: 1 / -1; }
}

/* ---------- หน้าต่างถามยืนยัน (สร้างเลขพัสดุ / ลบ / ยกเลิกออเดอร์) ---------- */
.modal-scrim { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(23, 18, 10, .38); }
.modal { width: min(400px, 100%); display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: 24px; background: var(--surface); box-shadow: var(--float-up); }
.modal h3 { margin: 0; font-size: 18px; font-weight: 500; }
.modal p { margin: 0; color: var(--text-2); font-size: 14.5px; line-height: 1.55; }
.modal-btns { display: flex; gap: 10px; margin-top: 8px; }
.modal-btns .btn { flex: 1; height: 46px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: #17150f; color: #fff; font-size: 14px;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- จอกลาง: หน้าต่างสร้างออเดอร์ลอยทับ ---------- */
@media (max-width: 1179px) {
  .col-panel {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 20;
    width: min(400px, 100%); box-shadow: -8px 0 30px rgba(0, 0, 0, .12);
  }
  .panel-open .scrim { display: block; position: absolute; inset: 0; z-index: 15; background: rgba(0, 0, 0, .35); }
}

/* ---------- มือถือ ---------- */
@media (max-width: 767px) {
  .rail { display: none; }
  .topbar { padding: 8px 16px; }
  .shell[data-view="chat"] .topbar, .shell[data-view="form"] .topbar, .shell[data-view="form"] .tabbar { display: none; }
  .shell-body { flex-direction: column; }
  .shell-body > section { flex: 1; min-height: 0; }
  .col-list { width: 100%; border-right: 0; }
  .shell[data-view="list"] .col-chat { display: none; }
  .shell[data-view="chat"] .col-list { display: none; }
  .shell[data-view="chat"] .tabbar { display: none; }
  .chat-head { padding: 8px 12px; gap: 10px; }
  .chat-head .back { display: inline-grid; }
  .chat-head .avatar { width: 38px; height: 38px; }
  .chat-head .btn { padding: 0 12px; }
  .msgs { padding: 12px; }
  .chat-top { padding: 12px 12px 8px; }
  .chat-filter { padding: 0 12px 8px; }
  .composer { gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .cbtns { gap: 5px; }
  .cbtn { width: 44px; height: 44px; font-size: 10.5px; }
  .composer textarea { min-height: 44px; padding: 11px 14px; border-radius: 22px; }
  .c-send { width: 44px; height: 44px; }
  .oform-body { padding: 14px 14px 20px; }
  .col-panel { width: 100%; box-shadow: none; }
  .tabbar {
    flex: none; display: flex;
    background: var(--rail);
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* แถบล่างฝั่งตัวแทน (แบบที่ 3 ในรูปที่เก็ทส่งมา): แคปซูลลอยเหนือเนื้อหา ปุ่มกลางวงกลมทอง = หน้าแรก
     เป็นกระจกขาวแบบการ์ดหน้าแรก (เก็ทสั่ง 23 ต.ค. ให้เห็นไฟส่องชัด)
     เนื้อหาเลื่อนลอดใต้แถบได้ จึงเว้นที่ล่างของรายการไว้ 90px+ — หน้าโรงงานไม่เปลี่ยน */
  .shell.agent { position: relative; }
  .shell.agent .tabbar {
    position: absolute; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
    height: 62px; padding: 0 4px; border: 1px solid transparent; border-radius: 22px;
    background: rgba(255, 255, 255, .36);
    -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
    box-shadow:
      inset 1.5px 1.5px 0 rgba(255, 255, 255, .9),
      inset -1px -1px 0 rgba(255, 255, 255, .5),
      inset 0 0 20px rgba(255, 255, 255, .22),
      0 18px 40px -24px rgba(23, 18, 10, .35);
  }
  .shell.agent .tabbar a { justify-content: flex-end; padding: 0 0 10px; white-space: nowrap; color: var(--text-2); }
  .shell.agent .tabbar a.on { color: var(--brand-ink); }
  .shell.agent .tabbar a.on::after { content: ''; position: absolute; bottom: 4px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
  .shell.agent .tabbar .dot { top: 6px; }
  /* ไฟส่องแท็บที่เปิดอยู่ (แบบ 2): แถบไฟทองบนขอบแถบ + แสงกรวยส่องลงมาที่ไอคอน
     ปุ่มหน้าแรกเป็นวงกลมทองยื่นขึ้นเหนือแถบ ไฟจึงย้ายไปอยู่เหนือวงกลม */
  .shell.agent .tabbar a.on::before {
    content: ''; position: absolute; top: 0; left: 50%;
    width: 30px; height: 3px; margin-left: -15px; border-radius: 3px;
    background: #d9b25c; box-shadow: 0 0 10px rgba(240, 190, 90, .9);
  }
  .shell.agent .tabbar a.on > span::before {
    content: ''; position: absolute; top: 2px; left: 50%;
    width: 56px; height: 34px; margin-left: -28px;
    background: linear-gradient(180deg, rgba(246, 205, 110, .6), rgba(246, 205, 110, 0));
    clip-path: polygon(36% 0, 64% 0, 100% 100%, 0 100%);
    pointer-events: none;
  }
  .shell.agent .tabbar a.on:has(.tab-fab)::before { top: -34px; }
  .shell.agent .tabbar a.on:has(.tab-fab) > span::before { top: -31px; width: 62px; height: 54px; margin-left: -31px; }
  .tab-fab {
    flex: none; display: grid; place-items: center; width: 56px; height: 56px;
    border: 5px solid rgba(255, 255, 255, .55); border-radius: 50%; background: var(--btn-grad) padding-box; color: var(--on-brand);
    font-style: normal; box-shadow: 0 6px 16px -4px rgba(184, 146, 74, .6);
  }
  .tab-fab .ic { width: 22px; height: 22px; }
  .shell.agent .conv-list { padding-bottom: 92px; }
  .shell.agent .orders-list { padding-bottom: 96px; }
  .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }
  /* หน้าแรกมือถือ: พื้นสว่างมีแสงทองฟุ้งเหมือนคอม โลโก้อยู่ในหัว (ซ่อนแถบโลโก้ด้านบน)
     ทางลัดซ่อน เพราะซ้ำกับแถบล่าง */
  .shell[data-view="home"] .topbar { display: none; }
  .home { padding: 8px 16px 100px; gap: 32px; }
  .home-hero { position: relative; flex-direction: column; gap: 4px; }
  .home-logo { display: block; width: 80px; height: 66px; margin-bottom: 6px; background: url(logo-bar.webp) left center / contain no-repeat; }
  .home-set { position: absolute; top: 12px; right: 0; display: inline-grid; background: rgba(255, 255, 255, .6); color: var(--text-2); }
  .home-set:hover:not(:disabled) { background: #fff; }
  .home-stats { gap: 8px; }
  .home-hello h1 { font-size: 30px; }
  .home-short { display: none; }
  /* การ์ด "ส่งโรงงานวันนี้" อยู่บนเงาดำพอดี ตัวหนังสือเทาเข้มขึ้นให้อ่านง่าย */
  .stat:nth-child(3) .stat-label, .stat:nth-child(3) .stat-num small { color: #45413a; }
  .tabbar a {
    position: relative; flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 6px; color: var(--rail-text); font-size: 12px;
  }
  .tabbar a.on { color: var(--rail-on); font-weight: 600; }
  .tabbar .dot { right: calc(50% - 26px); top: 3px; }
  .orders-head { padding: 14px 16px 10px; }
  .ohead { grid-template-columns: minmax(0, 1fr) 136px; padding: 12px 12px 8px; gap: 8px; }
  .otabs { align-self: start; }
  .otools .search { padding: 0 10px; }
  .otools .btn { min-height: 36px; padding: 5px 8px; font-size: 12.5px; }
  .orders-list.top { padding-top: 12px; }
  .ocard { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 12px 14px; }
  .orders-list { padding: 0 12px 24px; }
  .auth-card { padding: 28px 20px; }
}

/* ---------- ฝั่งตัวแทน หน้าอื่น (แชท ออเดอร์ SKU ฟอร์ม เข้าสู่ระบบ เชื่อมเพจ) แบบเดียวกับหน้าแรก ----------
   การ์ดมุมมน 24px ของข้างในมนตาม เงาด้านนอกจางๆ หัวข้อไม่หนา (ความต่างมาจากขนาด) หน่วยตัวเล็กสีเทา
   ใช้ body.agent-app ทุกกฎ — หน้าโรงงานก็ใช้ body.agent-app ด้วย (ธีมเดียวกัน 24 ต.ค.) */
body.agent-app { --r-sm: 10px; --r: 14px; --r-lg: 24px; --shadow: var(--float); }
body.agent-app .auth-card { border-radius: 28px; }
body.agent-app .card { padding: 20px; }
body.agent-app .order, body.agent-app .item-card { padding: 16px 18px; }
body.agent-app .orders-list .group { margin-top: 18px; }

/* ตัวหนังสือ: หัวข้อหน้าและตัวหนาเดิมเหลือ 500 ใช้ 600 เฉพาะชื่อแชทที่ยังไม่อ่าน */
body.agent-app :is(.list-title, .connect-title, .group, .btn, .tag, .field, .status),
body.agent-app :is(.col-list, .col-chat, .col-panel, .col-orders, .col-page, .auth) :is(b, h3) { font-weight: 500; }
body.agent-app .conv-top b { font-weight: 600; }
body.agent-app .badge { font-weight: 600; }
/* หน่วย "บาท" ตัวเล็กสีเทาชิดตัวเลข (เฉพาะราคาตัวหนา ในบรรทัดเล็กสีเทาอยู่แล้วให้เหมือนข้อความรอบข้าง) */
body.agent-app .unit { display: inline; margin: 0; font-size: inherit; font-weight: inherit; color: inherit; }
body.agent-app b > .unit { font-size: .78em; font-weight: 400; color: var(--muted); }

/* ฟองแชทขาออกสีทองคงไว้ ลดแค่แสงเรือง */
body.agent-app .msg.out .bubble { box-shadow: 0 4px 12px -6px rgba(184, 146, 74, .4); }

/* ของที่ลอยทับหน้า (toast และแผงบิลตอนลอยทับบนจอกลาง/มือถือ): กระจกฝ้าแบบเดียวกับแถบเมนูซ้าย */
body.agent-app .toast {
  border: 1px solid rgba(255, 255, 255, .75); background: rgba(255, 255, 255, .72); color: var(--text);
  -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%);
  box-shadow: 0 20px 44px -26px rgba(23, 18, 10, .35), 0 6px 16px -10px rgba(23, 18, 10, .2);
}
@media (max-width: 1179px) {
  body.agent-app .col-panel {
    border-left: 1px solid rgba(255, 255, 255, .75); background: rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: blur(24px) saturate(150%); backdrop-filter: blur(24px) saturate(150%);
  }
  /* หัวกับท้ายแผงเป็นกระจกสีเดียวกับแผง ของที่เลื่อนลอดใต้จะเบลอ */
  body.agent-app :is(.panel-head, .panel-foot) {
    background: transparent;
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  }
  /* ฉากมืดอยู่เฉพาะด้านซ้ายของแผง ไม่ลอดใต้กระจก (กระจกจะได้ไม่เป็นสีเทา) */
  body.agent-app .panel-open .scrim { right: min(400px, 100%); }
}
@media (max-width: 767px) {
  body.agent-app .panel-open .scrim { display: none; } /* มือถือแผงเต็มจอ ไม่มีที่ให้กดข้างนอก */
}

/* ---------- หน้าแรกฝั่งตัวแทน 2 โหมด: เข้ม (ค่าเริ่มต้น) / สว่าง — html[data-home] ตั้งจาก app.js ----------
   พื้นโหมดเข้ม = ดำเกือบสนิทอมน้ำตาลนิดๆ (เก็ทเลือก "ดำขึ้นระดับ 2" 23 ต.ค.)
   แสงทองแยก 2 ชั้น (::before / ::after) ไหลสวนกัน 26 วิ กับ 34 วิ ขยับด้วย transform อย่างเดียว
   ริบบิ้นทองโค้ง (เก็ทเลือก "แบบ 2" แทนวงกลม: คอม 23 ต.ค., มือถือ 24 ต.ค.) ชั้นใหญ่กว่าจอ 15% ทุกด้าน ไหลแล้วไม่เห็นขอบ
   พื้นกับริบบิ้นอยู่ที่ .shell-body (ไม่เลื่อน) — ห้ามย้ายไปไว้ใน .col-home ที่เลื่อนได้ ชั้นแสงที่ใหญ่กว่าจอ
   จะทำให้หน้าแรกบนมือถือเลื่อนข้าง/เลื่อนลงไปที่ว่างได้ (เจอ 24 ต.ค.) */
/* ริบบิ้น: เลื่อน เอียง และยืดหดช้าๆ ให้เส้นโค้งดูเหมือนทองเหลวไหล */
@keyframes gold-ribbon-a { 0% { transform: translate3d(-6%, 0, 0) rotate(-3deg) scale(1, 1); } 50% { transform: translate3d(2%, 3%, 0) rotate(2deg) scale(1.05, 1.15); } 100% { transform: translate3d(7%, -2%, 0) rotate(-1deg) scale(1, .92); } }
@keyframes gold-ribbon-b { 0% { transform: translate3d(5%, 0, 0) rotate(2deg) scale(1, 1); } 50% { transform: translate3d(-3%, -3%, 0) rotate(-3deg) scale(1.08, .9); } 100% { transform: translate3d(-7%, 2%, 0) rotate(1deg) scale(1, 1.1); } }

html[data-home] .shell.agent[data-view="home"] .shell-body { overflow: hidden; isolation: isolate; }
html[data-home="dark"] .shell.agent[data-view="home"] .shell-body { background: linear-gradient(160deg, #131110 0%, #0e0d0b 60%, #0b0a09 100%); }
html[data-home="light"] .shell.agent[data-view="home"] .shell-body { background: #ebe6dc; }
html[data-home] .shell.agent[data-view="home"] .shell-body::before,
html[data-home] .shell.agent[data-view="home"] .shell-body::after { content: ''; position: absolute; inset: -15%; z-index: -1; pointer-events: none; filter: blur(14px); will-change: transform; }
html[data-home] .shell.agent[data-view="home"] .shell-body::before { animation: gold-ribbon-a 26s ease-in-out infinite alternate; }
html[data-home] .shell.agent[data-view="home"] .shell-body::after { animation: gold-ribbon-b 34s ease-in-out infinite alternate; }

@media (min-width: 768px) {
  /* ริบบิ้นคอม: ::before = 2 เส้นจากมุมล่างซ้าย, ::after = 1 เส้นมุมบนขวา (วงรีที่เห็นแค่ขอบ) */
  html[data-home="dark"] .shell.agent[data-view="home"] .shell-body::before { background: radial-gradient(ellipse 62% 40% at 28% 104%, transparent 60%, rgba(222, 168, 64, .26) 67%, rgba(242, 206, 124, .42) 70.5%, rgba(222, 168, 64, .24) 74%, transparent 81%), radial-gradient(ellipse 46% 30% at 18% 96%, transparent 62%, rgba(206, 152, 60, .18) 69%, rgba(230, 186, 96, .26) 72%, transparent 79%); }
  html[data-home="dark"] .shell.agent[data-view="home"] .shell-body::after { background: radial-gradient(ellipse 56% 36% at 82% -4%, transparent 58%, rgba(236, 196, 104, .2) 66%, rgba(246, 214, 140, .34) 69.5%, rgba(236, 196, 104, .18) 73%, transparent 80%); }
  html[data-home="light"] .shell.agent[data-view="home"] .shell-body::before { background: radial-gradient(ellipse 62% 40% at 28% 104%, transparent 60%, rgba(214, 160, 62, .26) 67%, rgba(228, 176, 76, .44) 70.5%, rgba(214, 160, 62, .24) 74%, transparent 81%), radial-gradient(ellipse 46% 30% at 18% 96%, transparent 62%, rgba(200, 150, 64, .16) 69%, rgba(214, 160, 70, .26) 72%, transparent 79%); }
  html[data-home="light"] .shell.agent[data-view="home"] .shell-body::after { background: radial-gradient(ellipse 56% 36% at 82% -4%, transparent 58%, rgba(236, 200, 112, .24) 66%, rgba(228, 176, 76, .38) 69.5%, rgba(236, 200, 112, .2) 73%, transparent 80%); }
  /* แถบเมนูซ้ายโหมดเข้ม: กระจกเข้ม */
  html[data-home="dark"] .shell.agent[data-view="home"] .rail { border-color: rgba(255, 255, 255, .1); background: rgba(24, 21, 18, .42); color: rgba(244, 239, 228, .62); box-shadow: 0 20px 44px -26px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .12); }
  html[data-home="dark"] .shell.agent[data-view="home"] .rail-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
  html[data-home="dark"] .shell.agent[data-view="home"] .avatar.sm { box-shadow: 0 0 0 1px rgba(220, 192, 122, .55); }
}
@media (max-width: 767px) {
  /* มือถือ: เนื้อหาโปร่งให้เห็นพื้นกับริบบิ้นของ .shell-body และปิดวงแสงเดิมของ .col-home */
  html[data-home] .shell.agent[data-view="home"] .col-home { background: transparent; }
  html[data-home] .shell.agent[data-view="home"] .col-home::before { display: none; }
  html[data-home="dark"] .shell.agent[data-view="home"] .shell-body { background: linear-gradient(170deg, #131110 0%, #0b0a09 100%); }
  html[data-home] .shell.agent[data-view="home"] .shell-body::before,
  html[data-home] .shell.agent[data-view="home"] .shell-body::after { filter: blur(10px); }
  /* ริบบิ้นมือถือ: จอแคบ เส้นโค้งจึงพาดผ่านกลางจอ (ลงมาจากมุมขวาบน + โค้งขึ้นจากมุมซ้ายล่าง) ลอดหลังการ์ดกระจก */
  html[data-home="dark"] .shell.agent[data-view="home"] .shell-body::before { background: radial-gradient(ellipse 103% 58% at 3.5% 93%, transparent 63%, rgba(222, 168, 64, .26) 67.5%, rgba(242, 206, 124, .42) 70.5%, rgba(222, 168, 64, .24) 73.5%, transparent 78%), radial-gradient(ellipse 80% 46% at 0% 96%, transparent 64%, rgba(206, 152, 60, .18) 68.5%, rgba(230, 186, 96, .26) 71%, transparent 75.5%); }
  html[data-home="dark"] .shell.agent[data-view="home"] .shell-body::after { background: radial-gradient(ellipse 75% 48% at 100% 5%, transparent 62%, rgba(236, 196, 104, .2) 66.5%, rgba(246, 214, 140, .34) 69.5%, rgba(236, 196, 104, .18) 72.5%, transparent 77%); }
  html[data-home="light"] .shell.agent[data-view="home"] .shell-body::before { background: radial-gradient(ellipse 103% 58% at 3.5% 93%, transparent 63%, rgba(214, 160, 62, .26) 67.5%, rgba(228, 176, 76, .44) 70.5%, rgba(214, 160, 62, .24) 73.5%, transparent 78%), radial-gradient(ellipse 80% 46% at 0% 96%, transparent 64%, rgba(200, 150, 64, .16) 68.5%, rgba(214, 160, 70, .26) 71%, transparent 75.5%); }
  html[data-home="light"] .shell.agent[data-view="home"] .shell-body::after { background: radial-gradient(ellipse 75% 48% at 100% 5%, transparent 62%, rgba(236, 200, 112, .24) 66.5%, rgba(228, 176, 76, .38) 69.5%, rgba(236, 200, 112, .2) 72.5%, transparent 77%); }
  html[data-home="dark"] .shell.agent[data-view="home"] .tabbar { background: rgba(30, 27, 23, .5); box-shadow: inset 1.5px 1.5px 0 rgba(255, 255, 255, .2), inset -1px -1px 0 rgba(255, 255, 255, .06), 0 18px 40px -24px rgba(0, 0, 0, .7); }
  html[data-home="dark"] .shell.agent[data-view="home"] .home-set { background: rgba(255, 255, 255, .1); color: var(--text-2); }
  html[data-home="dark"] .shell.agent[data-view="home"] .home-set:hover:not(:disabled) { background: rgba(255, 255, 255, .18); } /* เดิมชี้แล้วเป็นวงขาว ไอคอนครีมจะหายไป */
  html[data-home="dark"] .shell.agent[data-view="home"] .stat:nth-child(3) :is(.stat-label, .stat-num small) { color: var(--text-2); }
  /* ปุ่มสลับโหมดอยู่ซ้ายปุ่มตั้งค่า (มุมขวาบนของหน้าแรก) */
  .theme-sw { position: absolute; top: 10px; right: 46px; }
}
/* คนที่ตั้งเครื่องให้ลดการเคลื่อนไหว: แสงอยู่นิ่ง */
@media (prefers-reduced-motion: reduce) {
  html[data-home] .shell.agent[data-view="home"] .shell-body::before,
  html[data-home] .shell.agent[data-view="home"] .shell-body::after { animation: none; }
}

/* โหมดเข้ม: ตัวหนังสือครีม การ์ดกระจกเข้ม ไอคอนทอง */
html[data-home="dark"] .shell.agent[data-view="home"] { --text: #f4efe4; --text-2: rgba(244, 239, 228, .66); --muted: rgba(244, 239, 228, .5); --brand-ink: #e6c677; color: var(--text); }
/* การ์ดเข้มเร่งสีด้านหลังน้อยลง (125%) แสงทองไหลผ่านแล้วการ์ดใบอื่นจะไม่กลายเป็นสีส้มเหมือนการ์ดทอง */
html[data-home="dark"] .shell.agent[data-view="home"] :is(.stat, .task, .task-none) {
  background: rgba(255, 255, 255, .07);
  -webkit-backdrop-filter: blur(22px) saturate(125%); backdrop-filter: blur(22px) saturate(125%);
  box-shadow: inset 1.5px 1.5px 0 rgba(255, 255, 255, .22), inset -1px -1px 0 rgba(255, 255, 255, .06), inset 0 0 20px rgba(255, 255, 255, .04), 0 18px 40px -24px rgba(0, 0, 0, .7);
}
html[data-home="dark"] .shell.agent[data-view="home"] :is(.stat, .task):hover { box-shadow: inset 1.5px 1.5px 0 rgba(255, 255, 255, .26), inset -1px -1px 0 rgba(255, 255, 255, .08), inset 0 0 20px rgba(255, 255, 255, .05), 0 24px 46px -24px rgba(0, 0, 0, .8); }
/* การ์ดทองใบเดียว: ทองไล่เงาแบบขอบโลโก้ ตัวหนังสือดำ */
html[data-home="dark"] .shell.agent[data-view="home"] .stat:nth-child(1) { background: linear-gradient(150deg, rgba(242, 216, 146, .9), rgba(198, 154, 72, .78)); color: #1b160d; box-shadow: inset 1.5px 1.5px 0 rgba(255, 246, 214, .9), inset -1px -1px 0 rgba(255, 246, 214, .35), 0 18px 40px -22px rgba(0, 0, 0, .7); }
html[data-home="dark"] .shell.agent[data-view="home"] :is(.well, .sc-ic) { background: rgba(255, 255, 255, .09); box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .25), inset -1px -1px 0 rgba(255, 255, 255, .06), 0 8px 18px -10px rgba(0, 0, 0, .6); }
html[data-home="dark"] .shell.agent[data-view="home"] :is(.stat-ic, .sc-ic) { color: #e2c57c; }
html[data-home="dark"] .shell.agent[data-view="home"] .stat:nth-child(1) .stat-ic { background: rgba(255, 255, 255, .35); color: #1b160d; box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .8), 0 6px 14px -8px rgba(80, 50, 10, .5); }
html[data-home="dark"] .shell.agent[data-view="home"] .task-ic.red { background: rgba(239, 68, 68, .16); color: #fca5a5; }
html[data-home="dark"] .shell.agent[data-view="home"] .task-ic.blue { background: rgba(96, 165, 250, .16); color: #93c5fd; }
html[data-home="dark"] .shell.agent[data-view="home"] .tag.red { background: rgba(239, 68, 68, .16); color: #fca5a5; }
html[data-home="dark"] .shell.agent[data-view="home"] .tag.blue { background: rgba(96, 165, 250, .16); color: #a9cbfd; }
/* ปุ่มลูกศร: วงกลมครีมไอคอนดำ (แบบตัว A ขาวบนโลโก้) */
html[data-home="dark"] .shell.agent[data-view="home"] .go { background: rgba(244, 239, 228, .92); color: #1b160d; box-shadow: inset 1px 1px 0 #fff, 0 6px 14px -6px rgba(0, 0, 0, .6); }
html[data-home="dark"] .shell.agent[data-view="home"] .home-sec h2 em { background: #d9b25c; color: #1b160d; }

/* ปุ่มสลับโหมด: แคปซูลกระจก 2 ปุ่ม ปุ่มที่เลือกเป็นวงกลมทอง (คอมอยู่มุมขวาบนของหัวหน้าแรก) */
.theme-sw {
  flex: none; display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: rgba(255, 255, 255, .42);
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .95), inset -1px -1px 0 rgba(255, 255, 255, .4), 0 8px 18px -10px rgba(23, 18, 10, .35);
}
.theme-sw button {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .2s, color .2s;
}
.theme-sw button:hover { color: var(--text); }
.theme-sw button[aria-pressed="true"] { background: var(--btn-grad); color: var(--on-brand); box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .5), 0 4px 10px -4px rgba(184, 146, 74, .6); }
.theme-sw button:focus-visible { outline: 3px solid rgba(184, 146, 74, .45); outline-offset: 2px; }
.theme-sw .ic { width: 17px; height: 17px; }
html[data-home="dark"] .shell.agent[data-view="home"] .theme-sw { background: rgba(255, 255, 255, .09); box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .25), inset -1px -1px 0 rgba(255, 255, 255, .06), 0 8px 18px -10px rgba(0, 0, 0, .6); }
