/* =========================================================
   Symptom to Cart v1.1 — Kasetlove Agricultural Intelligence
   อัปเดต Design System ให้ตรงกับ Brand Identity (Blue/Gold)
========================================================= */

:root {
  /* Kasetlove Core Brand Colors */
  --stc-primary: #0b4d8c; /* Kasetlove Blue */
  --stc-primary-d: #083865; /* Dark Blue Hover */
  --stc-primary-lt: #f0f6fc; /* Soft Blue */

  --stc-orange: #f4b400; /* Kasetlove Gold (แทนที่สีส้มเดิม) */
  --stc-orange-h: #ffd54a; /* Hover Gold */
  --stc-gold: #d7b140;
  --stc-danger: #c0392b; /* Kasetlove Red */

  /* Neutrals */
  --stc-bg: #f7f8f4; /* Organic Soft Background */
  --stc-surface: #ffffff;
  --stc-text: #1e1e1e;
  --stc-muted: #667085;
  --stc-border: rgba(0, 0, 0, 0.07);

  /* Shapes */
  --stc-radius-sm: 8px;
  --stc-radius-md: 14px;
  --stc-radius-lg: 20px;
  --stc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --stc-shadow-md: 0 8px 30px rgba(11, 77, 140, 0.08);
  --stc-font: "Prompt", system-ui, -apple-system, sans-serif;
}

/* ── App Shell ────────────────────────────────────────────────────────────── */

#stc-app {
  isolation: isolate;
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--stc-bg);
  /* เปลี่ยนลายจุดพื้นหลังให้เป็นสีน้ำเงินจางๆ แทนสีเขียว */
  background-image: radial-gradient(rgba(11, 77, 140, 0.025) 1px, transparent 1px);
  background-size: 18px 18px;
  font-family: var(--stc-font);
  font-size: 16px;
  color: var(--stc-text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 80px;
}

.stc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--stc-muted);
  font-size: 15px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.stc-header {
  /* เปลี่ยนพื้นหลังส่วนหัวเป็น Kasetlove Blue Gradient */
  background: linear-gradient(135deg, var(--stc-primary) 0%, var(--stc-primary-d) 100%);
  padding: 28px 20px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stc-header-deco {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  font-size: 72px;
  color: rgba(255, 255, 255, 0.05);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.stc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.stc-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stc-orange);
  animation: stcPulse 2s ease-in-out infinite;
}

/* อัปเดตเงากระพริบให้เป็นสีทอง (Kasetlove Gold RGB) */
@keyframes stcPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(244, 180, 0, 0.5);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(244, 180, 0, 0);
  }
}

.stc-header h1 {
  color: #fff;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 800;
  margin: 0 0 4px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
}

.stc-header p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  margin: 0;
}

/* ── Search Box (Omnibar) ─────────────────────────────────────────────────── */

.stc-search-wrap {
  max-width: 680px;
  margin: -20px auto 0;
  padding: 0 16px;
  position: relative;
  z-index: 10;
}

.stc-search-box {
  background: var(--stc-surface);
  border-radius: var(--stc-radius-lg);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
  padding: 20px;
}

.stc-omnibar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f4f7f4;
  border: 2px solid var(--stc-border);
  border-radius: var(--stc-radius-md);
  padding: 14px 16px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.stc-omnibar:focus-within {
  border-color: var(--stc-primary);
  /* เปลี่ยนเงา Focus เป็นสีน้ำเงินอ่อน */
  box-shadow: 0 0 0 3px rgba(11, 77, 140, 0.12);
  background: #fff;
}

.stc-omnibar-icon {
  font-size: 20px;
  flex-shrink: 0;
  color: var(--stc-primary);
}

.stc-omnibar input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--stc-font);
  font-size: 16px;
  color: var(--stc-text);
  outline: none;
  min-width: 0;
}

.stc-omnibar input::placeholder {
  color: #aab8b1;
  font-size: 15px;
}

.stc-omnibar-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: #aab8b1;
  font-size: 18px;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
  display: none;
}

.stc-omnibar-clear:hover {
  color: var(--stc-danger);
}
.stc-omnibar-clear.vis {
  display: block;
}

/* Quick hint chips */
.stc-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.stc-hint-label {
  font-size: 12px;
  color: var(--stc-muted);
  align-self: center;
  flex-shrink: 0;
}

.stc-hint {
  background: var(--stc-primary-lt);
  color: var(--stc-primary);
  /* ขอบสีน้ำเงินอ่อน */
  border: 1px solid rgba(11, 77, 140, 0.15);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.1s,
    color 0.15s;
  white-space: nowrap;
}

.stc-hint:hover {
  /* เมื่อ Hover ให้เป็นสีน้ำเงิน Kasetlove */
  background: var(--stc-primary);
  color: #fff;
  transform: translateY(-1px);
}

/* Analyze CTA */
.stc-analyze-btn {
  width: 100%;
  margin-top: 14px;
  /* เปลี่ยนปุ่มเป็น Kasetlove Gold Gradient */
  background: linear-gradient(135deg, var(--stc-orange) 0%, var(--stc-orange-h) 100%);
  color: var(--stc-primary-d); /* ตัวหนังสือสีน้ำเงินเข้มตัดกับสีทองตามสไตล์เว็บ */
  border: none;
  border-radius: var(--stc-radius-md);
  padding: 14px 20px;
  font-family: var(--stc-font);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition:
    opacity 0.2s,
    transform 0.15s,
    box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* เปลี่ยนเงาเป็นสีทอง */
  box-shadow: 0 4px 16px rgba(244, 180, 0, 0.35);
}

.stc-analyze-btn:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(244, 180, 0, 0.45);
}

.stc-analyze-btn:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  opacity: 0.8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Content Area ─────────────────────────────────────────────────────────── */

.stc-content {
  max-width: 720px;
  margin: 28px auto 0;
  padding: 0 16px;
}

/* ── State: Empty / Idle ──────────────────────────────────────────────────── */

.stc-idle {
  text-align: center;
  padding: 40px 20px;
}

.stc-idle-emoji {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
  animation: stcFloat 4s ease-in-out infinite;
}

@keyframes stcFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.stc-idle h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--stc-text);
  margin: 0 0 6px;
}

.stc-idle p {
  color: var(--stc-muted);
  font-size: 14px;
  margin: 0;
}

/* ── State: Loading ───────────────────────────────────────────────────────── */

.stc-analyzing {
  text-align: center;
  padding: 48px 20px;
}

.stc-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--stc-primary-lt);
  border-top-color: var(--stc-primary);
  border-radius: 50%;
  animation: stcSpin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes stcSpin {
  to {
    transform: rotate(360deg);
  }
}

.stc-analyzing p {
  color: var(--stc-muted);
  font-size: 14px;
}

.stc-analyzing strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--stc-primary);
  margin-bottom: 4px;
}

/* ── AI Analysis Card ─────────────────────────────────────────────────────── */

.stc-analysis-card {
  background: var(--stc-surface);
  border-radius: var(--stc-radius-md);
  border: 1px solid var(--stc-border);
  box-shadow: var(--stc-shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.stc-analysis-header {
  /* หัวการ์ดใช้สี Soft Blue gradient */
  background: linear-gradient(135deg, var(--stc-primary-lt) 0%, #e2eefa 100%);
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(11, 77, 140, 0.1);
}

.stc-analysis-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stc-analysis-intent {
  font-size: 15px;
  font-weight: 800;
  color: var(--stc-primary-d);
  flex: 1;
  min-width: 0;
}

.stc-urgency {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.stc-urgency-high {
  background: #fff1ef;
  color: #c0392b;
  border: 1px solid #fecaca;
}
.stc-urgency-medium {
  background: #fffdf5;
  color: #b45309;
  border: 1px solid #fde68a;
}
.stc-urgency-low {
  background: var(--stc-primary-lt);
  color: var(--stc-primary);
  border: 1px solid rgba(11, 77, 140, 0.2);
}

.stc-cause {
  font-size: 13px;
  color: var(--stc-muted);
  margin-top: 4px;
}

.stc-analysis-body {
  padding: 16px 18px;
}

.stc-explanation {
  font-size: 14.5px;
  color: var(--stc-text);
  line-height: 1.7;
  margin: 0 0 10px;
}

.stc-best-practice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fffdf5;
  border: 1px solid #fde68a;
  border-radius: var(--stc-radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: #92400e;
}

.stc-best-practice-icon {
  flex-shrink: 0;
  font-size: 16px;
}

/* ── Product Section ──────────────────────────────────────────────────────── */

.stc-products-section {
  margin-bottom: 24px;
}

.stc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.stc-section-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--stc-primary); /* เปลี่ยนเป็นสีน้ำเงินเพื่อเน้น */
  display: flex;
  align-items: center;
  gap: 7px;
}

.stc-source-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--stc-primary);
  background: var(--stc-primary-lt);
  border: 1px solid rgba(11, 77, 140, 0.15);
  padding: 3px 10px;
  border-radius: 999px;
}

/* ── Product Grid ─────────────────────────────────────────────────────────── */

.stc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 12px;
}

/* ── Product Card ─────────────────────────────────────────────────────────── */

.stc-card {
  display: flex;
  flex-direction: column;
  background: var(--stc-surface);
  border-radius: var(--stc-radius-md);
  border: 1px solid var(--stc-border);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  position: relative;
  box-shadow: var(--stc-shadow-sm);
}

.stc-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(11, 77, 140, 0.08);
  text-decoration: none;
}

.stc-card.best {
  border-color: var(--stc-orange);
  box-shadow:
    0 0 0 1px var(--stc-orange),
    var(--stc-shadow-sm);
}

/* Image */
.stc-card-img {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f6f7f2;
}

.stc-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stc-card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #cbd5e1;
}

/* Badges */
.stc-badge-best {
  position: absolute;
  top: 7px;
  left: 7px;
  background: linear-gradient(135deg, var(--stc-orange), #c9a22a);
  color: var(--stc-primary-d);
  font-size: 9.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  z-index: 2;
}

.stc-badge-rec {
  position: absolute;
  top: 7px;
  left: 7px;
  background: var(--stc-danger);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  z-index: 2;
}

.stc-badge-source {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  z-index: 2;
}

/* Card Body */
.stc-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 4px;
}

.stc-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--stc-text);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stc-stars {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
}

.stc-star-full {
  color: var(--stc-orange);
}
.stc-star-half {
  color: var(--stc-orange);
  opacity: 0.6;
}
.stc-star-empty {
  color: #d1d5db;
}
.stc-rating-num {
  font-size: 11px;
  color: var(--stc-muted);
  margin-left: 3px;
}

.stc-sold {
  font-size: 11px;
  color: var(--stc-muted);
  margin: 0;
}

.stc-card-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #f1f3f5;
}

/* ปล่อยสีของ Shopee และ Lazada ไว้ให้ตรงกับแบรนด์จริง */
.stc-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #ee4d2d;
  padding: 5px 10px;
  border-radius: 999px;
  width: 100%;
  justify-content: center;
}

.stc-cta.lazada {
  background: #0f146d;
}

/* ── No Results ───────────────────────────────────────────────────────────── */

.stc-no-products {
  text-align: center;
  padding: 32px 20px;
  background: var(--stc-surface);
  border-radius: var(--stc-radius-md);
  border: 1px dashed var(--stc-border);
  color: var(--stc-muted);
  font-size: 14px;
}

/* ── Error ────────────────────────────────────────────────────────────────── */

.stc-error {
  background: #fff1ef;
  border: 1px solid #fecaca;
  border-radius: var(--stc-radius-md);
  padding: 20px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.stc-error-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.stc-error-text {
  font-size: 14px;
  color: var(--stc-danger);
}

/* ── Disclaimer ───────────────────────────────────────────────────────────── */

.stc-disclaimer {
  font-size: 11.5px;
  color: #b0bab5;
  text-align: center;
  margin: 16px 0 0;
  line-height: 1.6;
}

/* ── New Search btn ───────────────────────────────────────────────────────── */

.stc-new-search {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  background: none;
  border: 2px solid var(--stc-primary);
  border-radius: var(--stc-radius-md);
  padding: 12px 20px;
  font-family: var(--stc-font);
  font-size: 15px;
  font-weight: 600;
  color: var(--stc-primary);
  cursor: pointer;
  margin-top: 8px;
  transition:
    background 0.15s,
    color 0.15s;
}

.stc-new-search:hover {
  background: var(--stc-primary);
  color: #fff;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 500px) {
  .stc-header {
    padding: 22px 16px 20px;
  }
  .stc-header h1 {
    font-size: 1.15rem;
  }
  .stc-search-wrap {
    padding: 0 12px;
  }
  .stc-search-box {
    padding: 16px;
  }
  .stc-content {
    padding: 0 12px;
  }
  .stc-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stc-card-title {
    font-size: 12px;
  }
}
/* =========================================================
   FIX: ปัญหาช่องค้นหาและปุ่ม X ล้นขอบจอมือถือ
========================================================= */

/* 1. บังคับให้คำนวณความกว้างรวม Padding (กล่องจะได้ไม่บวมล้นจอ) */
#stc-app,
#stc-app * {
  box-sizing: border-box !important;
}

/* 2. คุมความกว้างของกล่องค้นหาให้หดอยู่ในขอบ 100% */
#stc-app .stc-search-wrap,
#stc-app .stc-search-box,
#stc-app .stc-omnibar {
  width: 100% !important;
  max-width: 100% !important;
}

/* 3. ปรับระยะขอบ (Padding) ในจอมือถือให้พอดี ไม่เบียดกัน */
@media (max-width: 768px) {
  #stc-app .stc-search-wrap {
    padding: 0 16px !important;
  }

  #stc-app .stc-search-box {
    padding: 16px 14px !important;
  }

  #stc-app .stc-omnibar {
    padding: 12px 14px !important;
    gap: 8px !important;
  }

  /* ปรับปุ่มเคลียร์ (X) ให้แสดงผลพอดี ไม่ชิดขอบจอเกินไป */
  #stc-app .stc-omnibar-clear {
    padding: 0 4px !important;
    font-size: 20px !important;
    margin-right: 2px !important;
  }
}
/* =========================================================
   MOBILE EDGE-TO-EDGE (ปรับการ์ดให้เต็มความกว้างจอมือถือ)
========================================================= */

@media (max-width: 768px) {
  /* 1. ลบขอบ (Padding) ของ Container หลักออกเพื่อให้ขยายได้ชิดขอบจอ */
  #stc-app .stc-search-wrap,
  #stc-app .stc-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* 2. กล่องค้นหา, การ์ดวิเคราะห์ และกล่อง Error ให้ลบความมนและขอบซ้าย-ขวาออก */
  #stc-app .stc-search-box,
  #stc-app .stc-analysis-card,
  #stc-app .stc-error,
  #stc-app .stc-no-products {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }

  /* จัดช่องไฟด้านในของกล่องค้นหาใหม่ให้สมดุล */
  #stc-app .stc-search-box {
    padding: 24px 16px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05) !important;
  }

  /* 3. ดันส่วนที่ "ไม่ควรชิดขอบจอ" (เช่น หน้าโหลด, กริดสินค้า) ให้กลับมามีระยะห่าง 16px */
  #stc-app .stc-products-section,
  #stc-app .stc-idle,
  #stc-app .stc-analyzing {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* 4. ปรับขนาดปุ่ม "ค้นหาอาการใหม่" ด้านล่างสุด ให้หดกลับมาและมีขอบซ้าย-ขวาพอดี */
  #stc-app .stc-new-search {
    width: calc(100% - 32px) !important;
    margin-left: 16px !important;
    margin-right: 16px !important;
    margin-bottom: 24px !important;
  }
}

/* =========================================================
   MODE 2: FLOATING (ปุ่มลอยมุมจอ)
========================================================= */
.stc-app.stc-mode-floating {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  width: auto;
  min-height: auto;
  padding: 0;
  background: transparent;
}
.stc-fab {
  background: linear-gradient(135deg, var(--stc-orange), var(--stc-orange-h));
  color: var(--stc-primary-d);
  border: none;
  padding: 14px 24px;
  border-radius: 99px;
  font-family: var(--stc-font);
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(244, 180, 0, 0.4);
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}
.stc-fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(244, 180, 0, 0.5);
}

.stc-floating-panel {
  position: absolute;
  bottom: 75px;
  right: 0;
  width: 420px;
  max-width: calc(100vw - 40px);
  background: var(--stc-bg);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--stc-border);
}
.stc-floating-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.stc-floating-scroll {
  max-height: 75vh;
  overflow-y: auto;
  padding-bottom: 24px;
}
.stc-fab-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stc-mode-floating .stc-header {
  padding: 24px 16px 36px;
  border-radius: 0;
}
.stc-mode-floating .stc-search-wrap {
  margin-top: -24px;
}
.stc-mode-floating .stc-search-box {
  padding: 16px;
}

/* =========================================================
   MODE 3: HEADER (ช่องค้นหาบนเมนู / Dropdown)
========================================================= */
.stc-app.stc-mode-header {
  position: relative !important;
  width: 100%;
  max-width: 400px; /* ขยายความกว้างช่องค้นหาให้ดูสมดุล */
  margin: 0 auto; /* จัดกึ่งกลาง */
  min-height: auto;
  padding: 0;
  background: transparent;
  z-index: 99999;
}

/* ซ่อนองค์ประกอบที่ไม่จำเป็น */
.stc-mode-header .stc-header,
.stc-mode-header .stc-hints,
.stc-mode-header .stc-analyze-btn {
  display: none !important;
}

.stc-mode-header .stc-search-wrap {
  margin: 0;
  padding: 0;
  max-width: 100%;
}
.stc-mode-header .stc-search-box {
  padding: 0;
  box-shadow: none;
  background: transparent;
  border-radius: 0;
}

/* ดีไซน์ช่องค้นหาบน Header */
.stc-mode-header .stc-omnibar {
  border-radius: 50px !important;
  background: #ffffff !important;
  padding: 8px 16px !important;
  border: 1px solid var(--stc-border) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
  transition: all 0.3s ease;
}

.stc-mode-header .stc-omnibar:focus-within {
  border-color: var(--stc-primary) !important;
  box-shadow: 0 6px 16px rgba(11, 77, 140, 0.15) !important;
}

/* ดีไซน์กล่อง Dropdown ผลลัพธ์ (แก้ปัญหาเบี้ยวซ้าย/ล้นจอ) */
.stc-mode-header .stc-content {
  position: absolute !important;
  top: calc(100% + 12px) !important;
  left: 50% !important; /* จัดกึ่งกลางสัมพันธ์กับช่องค้นหา */
  right: auto !important;
  transform: translateX(-50%) translateY(10px); /* ดึงกลับมาตรงกลางเป๊ะๆ */
  width: 500px !important;
  max-width: 92vw !important; /* ป้องกันการล้นหน้าจอในมือถือ */
  background: var(--stc-bg) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2) !important;
  border-radius: 16px !important;
  max-height: 80vh !important;
  overflow-y: auto !important;
  z-index: 99999;
  padding: 0 !important;
  border: 1px solid var(--stc-border) !important;
  opacity: 0;
  pointer-events: none;
  visibility: hidden; /* ซ่อนกล่องขาวตอนไม่มีเนื้อหา */
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* แสดงกล่องเมื่อมี Class dropdown-open */
.stc-mode-header.dropdown-open .stc-content {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ระยะขอบด้านในเนื้อหา */
.stc-mode-header .stc-content > div {
  padding: 20px;
}
.stc-mode-header .stc-error {
  margin: 16px;
}

/* ปรับแต่งปุ่ม ปิด (X) ให้ดูพรีเมียมขึ้น */
.stc-fab-close {
  background: rgba(255, 255, 255, 0.2) !important;
  color: #fff !important;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  transition: all 0.2s ease;
}
.stc-fab-close:hover {
  background: rgba(255, 255, 255, 0.4) !important;
  transform: scale(1.1);
}

/* ปรับให้โหมด Floating แสดงผลเต็มจอบนมือถือ */
@media (max-width: 500px) {
  .stc-floating-panel {
    bottom: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 20px 20px 0 0 !important; /* มนแค่ขอบบน */
    border: none !important;
  }
  .stc-floating-scroll {
    max-height: 85vh !important; /* ให้สูงขึ้นบนมือถือ */
  }
}

/* =========================================================
   SUPER FIX: บังคับสีขาวใน Header ของ AI ทุกโหมด (กัน Theme ทับ 100%)
========================================================= */

.stc-header h1,
.stc-app .stc-header h1,
.stc-floating-panel .stc-header h1 {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important; /* ป้องกันธีมที่ใช้ Gradient/Fill Text */
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}

.stc-header p,
.stc-app .stc-header p,
.stc-floating-panel .stc-header p {
  color: rgba(255, 255, 255, 0.9) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.9) !important;
}

.stc-header .stc-badge,
.stc-app .stc-header .stc-badge {
  color: #ffffff !important;
}
