/* ==========================================================================
   💎 THUNG MAKHAM MIAMI BEACH - CENTRAL CONTROL PORTAL
   IMPECCABLE DUAL-THEME DESIGN SYSTEM (LIGHT & DARK MODES)
   WCAG AA Contrast Compliant (≥4.5:1), Zero Invisibility, 60fps Micro-interactions
   ========================================================================== */

:root {
  --portal-font: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Global Font & Smooth Transition */
body, button, input, select, textarea {
  font-family: var(--portal-font) !important;
}

body {
  transition: background-color 0.25s ease, color 0.25s ease !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* PWA Standalone Safe Area */
@media all and (display-mode: standalone), (display-mode: fullscreen) {
  :root {
    --safe-top: max(env(safe-area-inset-top, 0px), 28px);
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
  }
}
.is-pwa-standalone {
  --safe-top: max(env(safe-area-inset-top, 0px), 28px);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
}

/* Fix Card Grid Spacing & Proportions */
main .grid {
  gap: 1.25rem !important;
}

/* ==========================================================================
   ☀️ 1. LIGHT MODE SPECIFICATIONS (html:not(.dark))
   Crisp Slate Navy Typography • Clean Glass Elevation • Zero Cyan Glow
   ========================================================================== */

html:not(.dark) body {
  background: #f8fafc !important;
  color: #0f172a !important;
}

/* Top Sticky Header */
html:not(.dark) header:not(.tmk-viewer-header),
html:not(.dark) .portal-main-header {
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border-bottom: 1px solid rgba(226, 232, 240, 0.95) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.03) !important;
}

html:not(.dark) header h2,
html:not(.dark) header span.font-bold,
html:not(.dark) .portal-main-header h2 {
  color: #0f172a !important;
}

html:not(.dark) header p,
html:not(.dark) header .text-slate-400,
html:not(.dark) header .text-slate-500 {
  color: #64748b !important;
}

/* Header Brand Badge ("Miami Beach") */
html:not(.dark) header span.rounded-full,
html:not(.dark) header .bg-cyan-500\/10,
html:not(.dark) header .bg-sky-500\/10 {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  color: #1d4ed8 !important;
  font-weight: 600 !important;
}

/* Header Clock / Date Pill */
html:not(.dark) header .bg-slate-900,
html:not(.dark) header .bg-slate-800 {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

/* Header Action Buttons (Theme Toggle, Notifications) */
html:not(.dark) header button {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  transition: all 0.2s ease !important;
}
html:not(.dark) header button:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

/* Top Marquee Notification Bar */
html:not(.dark) div:has(> .animate-marquee),
html:not(.dark) .bg-cyan-950,
html:not(.dark) [class*="bg-cyan-950"] {
  background: linear-gradient(90deg, #1e40af 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  border-bottom: 1px solid #1d4ed8 !important;
}
html:not(.dark) div:has(> .animate-marquee) * {
  color: #ffffff !important;
}

/* Main Hero Heading (h1) */
html:not(.dark) h1 {
  color: #0f172a !important;
  font-weight: 800 !important;
  letter-spacing: -0.025em !important;
  text-shadow: none !important;
}

/* Hero Subtitle */
html:not(.dark) main p.text-slate-400,
html:not(.dark) main p.text-slate-500,
html:not(.dark) p:has(+ div input[type="text"]) {
  color: #475569 !important;
  font-weight: 400 !important;
}

/* ==========================================================================
   🔍 LUXURY COMMAND SEARCH BAR SYSTEM (2026 SPOTLIGHT DESIGN)
   ========================================================================== */

/* Search Container Wrapper */
div:has(> input[placeholder*="ค้นหา"]) {
  min-height: 52px !important;
  border-radius: 18px !important;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  position: relative !important;
}

html:not(.dark) div:has(> input[placeholder*="ค้นหา"]) {
  background: rgba(255, 255, 255, 0.96) !important;
  backdrop-filter: blur(16px) !important;
  border: 1.5px solid rgba(203, 213, 225, 0.85) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.02) !important;
}

html:not(.dark) div:has(> input[placeholder*="ค้นหา"]):hover {
  border-color: #94a3b8 !important;
  box-shadow: 0 6px 24px -2px rgba(0, 0, 0, 0.09) !important;
}

html:not(.dark) div:has(> input[placeholder*="ค้นหา"]):focus-within {
  border-color: #0284c7 !important;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.16), 0 12px 32px -4px rgba(2, 132, 199, 0.15) !important;
  transform: translateY(-1px) !important;
}

html.dark div:has(> input[placeholder*="ค้นหา"]) {
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(20px) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.6) !important;
}

html.dark div:has(> input[placeholder*="ค้นหา"]):hover {
  border-color: rgba(255, 255, 255, 0.22) !important;
  box-shadow: 0 12px 35px -5px rgba(0, 0, 0, 0.7) !important;
}

html.dark div:has(> input[placeholder*="ค้นหา"]):focus-within {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.22), 0 14px 40px -4px rgba(2, 132, 199, 0.35) !important;
  transform: translateY(-1px) !important;
}

/* Reset input element inside search wrapper to prevent nested box visual */
div:has(> input[placeholder*="ค้นหา"]) input[type="text"] {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  padding: 12px 14px !important;
}

/* Search Icon Glow */
div:has(> input[placeholder*="ค้นหา"]) svg:first-child {
  width: 18px !important;
  height: 18px !important;
  margin-left: 14px !important;
  transition: color 0.2s ease, transform 0.2s ease !important;
}

html:not(.dark) div:has(> input[placeholder*="ค้นหา"]):focus-within svg:first-child {
  color: #0284c7 !important;
  transform: scale(1.1) !important;
}

html.dark div:has(> input[placeholder*="ค้นหา"]):focus-within svg:first-child {
  color: #38bdf8 !important;
  transform: scale(1.1) !important;
}

/* Hotkey Badge <kbd> */
.tmk-search-kbd {
  display: inline-flex !important;
  align-items: center !important;
  gap: 3px !important;
  padding: 3px 8px !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  border-radius: 7px !important;
  user-select: none !important;
  cursor: pointer !important;
  margin-right: 10px !important;
  transition: all 0.15s ease !important;
  line-height: 1.4 !important;
}

html:not(.dark) .tmk-search-kbd {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #475569 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
}

html:not(.dark) .tmk-search-kbd:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

html.dark .tmk-search-kbd {
  background: rgba(30, 41, 59, 0.9) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #94a3b8 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

html.dark .tmk-search-kbd:hover {
  background: #334155 !important;
  color: #f8fafc !important;
  border-color: #38bdf8 !important;
}

/* Search Results Counter Pill */
.tmk-search-counter-pill {
  font-size: 11px !important;
  font-weight: 600 !important;
  padding: 3px 9px !important;
  border-radius: 9999px !important;
  margin-right: 8px !important;
  white-space: nowrap !important;
  transition: all 0.2s ease !important;
}

html:not(.dark) .tmk-search-counter-pill {
  background: #eff6ff !important;
  color: #0284c7 !important;
  border: 1px solid #bfdbfe !important;
}

html.dark .tmk-search-counter-pill {
  background: rgba(2, 132, 199, 0.15) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.25) !important;
}

/* Quick Filter Chips Row */
.tmk-search-filter-chips {
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
  margin-top: 14px !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
}

.tmk-filter-chip {
  padding: 5px 12px !important;
  border-radius: 10px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  border: 1px solid transparent !important;
  user-select: none !important;
}

html:not(.dark) .tmk-filter-chip {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  color: #475569 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

html:not(.dark) .tmk-filter-chip:hover {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  transform: translateY(-1px) !important;
}

html:not(.dark) .tmk-filter-chip.active {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%) !important;
  border-color: #0284c7 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3) !important;
}

html.dark .tmk-filter-chip {
  background: rgba(15, 23, 42, 0.8) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #94a3b8 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

html.dark .tmk-filter-chip:hover {
  background: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: #f8fafc !important;
  transform: translateY(-1px) !important;
}

html.dark .tmk-filter-chip.active {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%) !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.45) !important;
}

/* Announcement Banner in Content */
html:not(.dark) .bg-cyan-500\/10,
html:not(.dark) .border-cyan-500\/20,
html:not(.dark) div.rounded-2xl:has(> span.bg-cyan-500) {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  color: #1e40af !important;
}
html:not(.dark) div.rounded-2xl:has(> span.bg-cyan-500) * {
  color: #1e40af !important;
}

/* Category Filter Tabs (Pills) ONLY */
html:not(.dark) main > div:not(.grid) button.rounded-xl,
html:not(.dark) main > div:not(.grid) button.rounded-full,
html:not(.dark) div.flex.flex-wrap.items-center.justify-center button {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #475569 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
}
html:not(.dark) main > div:not(.grid) button.rounded-xl:hover,
html:not(.dark) main > div:not(.grid) button.rounded-full:hover,
html:not(.dark) div.flex.flex-wrap.items-center.justify-center button:hover {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

/* Active Category Pill */
html:not(.dark) main > div:not(.grid) button.bg-cyan-600,
html:not(.dark) main > div:not(.grid) button.bg-blue-600,
html:not(.dark) main > div:not(.grid) button[class*="bg-cyan-"],
html:not(.dark) main > div:not(.grid) button[class*="bg-blue-"],
html:not(.dark) div.flex.flex-wrap.items-center.justify-center button[class*="bg-cyan-"],
html:not(.dark) div.flex.flex-wrap.items-center.justify-center button[class*="bg-blue-"] {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 600 !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3) !important;
}
html:not(.dark) main > div:not(.grid) button[class*="bg-cyan-"] *,
html:not(.dark) main > div:not(.grid) button[class*="bg-blue-"] *,
html:not(.dark) div.flex.flex-wrap.items-center.justify-center button[class*="bg-cyan-"] *,
html:not(.dark) div.flex.flex-wrap.items-center.justify-center button[class*="bg-blue-"] * {
  color: #ffffff !important;
}

/* System Health Status Badge ("🟢 สถานะระบบ: ปกติ 100%") */
html:not(.dark) .bg-emerald-950\/30,
html:not(.dark) .border-emerald-500\/20,
html:not(.dark) div.rounded-full:has(.bg-emerald-500) {
  background: #ecfdf5 !important;
  border: 1px solid #a7f3d0 !important;
  color: #065f46 !important;
  font-weight: 600 !important;
}
html:not(.dark) div.rounded-full:has(.bg-emerald-500) * {
  color: #065f46 !important;
}

/* Department Cards (.group) - Light Mode */
html:not(.dark) .group.rounded-2xl {
  background: #ffffff !important;
  border: 1px solid rgba(var(--card-theme-rgb, 203, 213, 225), 0.35) !important;
  border-top: 4px solid var(--card-theme-color, #2563eb) !important;
  border-radius: 20px !important;
  box-shadow: 0 4px 20px -2px rgba(var(--card-theme-rgb, 0, 0, 0), 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.02) !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease !important;
  position: relative !important;
}
html:not(.dark) .group.rounded-2xl:hover {
  transform: translateY(-5px) !important;
  box-shadow: 0 20px 35px -10px rgba(var(--card-theme-rgb, 0, 0, 0), 0.16), 0 0 20px -2px rgba(var(--card-theme-rgb, 37, 99, 235), 0.2) !important;
  border-color: rgba(var(--card-theme-rgb, 37, 99, 235), 0.5) !important;
  border-top: 4px solid var(--card-theme-color, #2563eb) !important;
}

/* Card Department Title */
html:not(.dark) .group h3,
html:not(.dark) .group h2,
html:not(.dark) .group .font-bold {
  color: #0f172a !important;
  font-weight: 700 !important;
}
html:not(.dark) .group:hover h3 {
  color: var(--color-accent, #2563eb) !important;
}

/* Card Department Description */
html:not(.dark) .group p {
  color: #475569 !important;
  font-size: 0.8125rem !important;
  line-height: 1.5 !important;
}

/* Card Action Button Row */
html:not(.dark) .group .border-t {
  border-top-color: #f1f5f9 !important;
}

/* Card Secondary Action Buttons (Copy, External Link, Color Picker) */
html:not(.dark) .group button[title],
html:not(.dark) .group a[title],
html:not(.dark) .group .tmk-color-picker-btn {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #475569 !important;
  border-radius: 10px !important;
  transition: all 0.2s ease !important;
}
html:not(.dark) .group button[title]:hover,
html:not(.dark) .group a[title]:hover,
html:not(.dark) .group .tmk-color-picker-btn:hover {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
}
html:not(.dark) .group button[title] svg,
html:not(.dark) .group a[title] svg {
  color: #475569 !important;
}
html:not(.dark) .group button[title]:hover svg,
html:not(.dark) .group a[title]:hover svg {
  color: #0f172a !important;
}

/* Card Latency Pill */
html:not(.dark) .group .bg-emerald-950\/40,
html:not(.dark) .group .bg-emerald-50 {
  background: #ecfdf5 !important;
  border: 1px solid #a7f3d0 !important;
  color: #047857 !important;
}
html:not(.dark) .group .bg-emerald-950\/40 *,
html:not(.dark) .group .bg-emerald-50 * {
  color: #047857 !important;
}

/* ==========================================================================
   🌙 2. DARK MODE SPECIFICATIONS (html.dark)
   Deep Obsidian Slate • High-Contrast Neon Accents • Pure White Text
   ========================================================================== */

html.dark body {
  background: #090d16 !important;
  color: #f8fafc !important;
}

/* Top Sticky Header */
html.dark header:not(.tmk-viewer-header),
html.dark .portal-main-header {
  background: rgba(9, 13, 22, 0.88) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 4px 25px -2px rgba(0, 0, 0, 0.6) !important;
}

html.dark header h2,
html.dark header span.font-bold,
html.dark .portal-main-header h2 {
  color: #ffffff !important;
}

html.dark header p,
html.dark header .text-slate-400 {
  color: #94a3b8 !important;
}

/* Header Clock / Date Pill */
html.dark header .bg-slate-900,
html.dark header .bg-slate-800 {
  background: #0f172a !important;
  border: 1px solid #1e293b !important;
  color: #cbd5e1 !important;
}

/* Header Action Buttons */
html.dark header button {
  background: #0f172a !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #cbd5e1 !important;
}
html.dark header button:hover {
  background: #1e293b !important;
  color: #ffffff !important;
}

/* Main Hero Heading (h1) */
html.dark h1 {
  color: #f8fafc !important;
  font-weight: 800 !important;
  letter-spacing: -0.025em !important;
}

/* Hero Subtitle */
html.dark main p.text-slate-400,
html.dark main p.text-slate-500 {
  color: #94a3b8 !important;
}

/* Dark mode search handled in unified Command Search Bar */

/* Category Filter Tabs (Pills) ONLY */
html.dark main > div:not(.grid) button.rounded-xl,
html.dark main > div:not(.grid) button.rounded-full,
html.dark div.flex.flex-wrap.items-center.justify-center button {
  background: #0f172a !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #94a3b8 !important;
  border-radius: 9999px !important;
}
html.dark main > div:not(.grid) button.rounded-xl:hover,
html.dark main > div:not(.grid) button.rounded-full:hover,
html.dark div.flex.flex-wrap.items-center.justify-center button:hover {
  background: #1e293b !important;
  color: #ffffff !important;
}
html.dark main > div:not(.grid) button[class*="bg-cyan-"],
html.dark main > div:not(.grid) button[class*="bg-blue-"],
html.dark div.flex.flex-wrap.items-center.justify-center button[class*="bg-cyan-"],
html.dark div.flex.flex-wrap.items-center.justify-center button[class*="bg-blue-"] {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  border: none !important;
}

/* Department Cards (.group) - Dark Mode */
html.dark .group.rounded-2xl {
  background: #0f172a !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-top: 4px solid var(--card-theme-color, #38bdf8) !important;
  border-radius: 20px !important;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6) !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease !important;
  position: relative !important;
}
html.dark .group.rounded-2xl:hover {
  transform: translateY(-5px) !important;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.8), 0 0 28px -4px rgba(var(--card-theme-rgb, 56, 189, 248), 0.32) !important;
  border-color: rgba(var(--card-theme-rgb, 56, 189, 248), 0.5) !important;
  border-top: 4px solid var(--card-theme-color, #38bdf8) !important;
}

/* Card Department Title */
html.dark .group h3,
html.dark .group h2,
html.dark .group .font-bold {
  color: #ffffff !important;
  font-weight: 700 !important;
}

/* Card Department Description */
html.dark .group p {
  color: #94a3b8 !important;
}

/* Card Action Button Row */
html.dark .group .border-t {
  border-top-color: rgba(255, 255, 255, 0.08) !important;
}

/* Card Secondary Action Buttons */
html.dark .group button[title],
html.dark .group a[title],
html.dark .group .tmk-color-picker-btn {
  background: #1e293b !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #94a3b8 !important;
  border-radius: 10px !important;
}
html.dark .group button[title]:hover,
html.dark .group a[title]:hover,
html.dark .group .tmk-color-picker-btn:hover {
  background: #334155 !important;
  color: #ffffff !important;
}

/* ==========================================================================
   🎯 3. CARD ACTION BUTTONS HIERARCHY (NO TEXT WRAPPING)
   Primary Full-Width Button + Sleek Secondary Utility Row
   ========================================================================== */

/* Card Action Container */
.group .mt-5.pt-4,
.group div.flex.items-center.gap-2:last-child {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  align-items: center !important;
}

/* Main Enter Button ("เข้าใช้งานระบบ") - Variable-Driven Dynamic Warehouse Theme */
.group button:not(.tmk-color-picker-btn):not([title]) {
  width: 100% !important;
  flex: 1 1 100% !important;
  padding: 11px 16px !important;
  font-size: 13.5px !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  border-radius: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  background: linear-gradient(135deg, var(--card-theme-color, #1d4ed8) 0%, rgba(var(--card-theme-rgb, 37, 99, 235), 0.85) 100%) !important;
  color: #ffffff !important;
  border: 1.5px solid rgba(var(--card-theme-rgb, 37, 99, 235), 0.45) !important;
  box-shadow: 0 4px 14px rgba(var(--card-theme-rgb, 37, 99, 235), 0.28) !important;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25) !important;
}
.group button:not(.tmk-color-picker-btn):not([title]) * {
  color: #ffffff !important;
}

/* Card Button HOVER */
.group button:not(.tmk-color-picker-btn):not([title]):hover,
.group:hover button:not(.tmk-color-picker-btn):not([title]) {
  background: linear-gradient(135deg, var(--card-theme-color, #1e40af) 0%, rgba(var(--card-theme-rgb, 29, 78, 216), 1) 100%) !important;
  color: #ffffff !important;
  border-color: rgba(var(--card-theme-rgb, 29, 78, 216), 0.85) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(var(--card-theme-rgb, 29, 78, 216), 0.45) !important;
  filter: brightness(1.1) !important;
}
.group button:not(.tmk-color-picker-btn):not([title]):hover *,
.group:hover button:not(.tmk-color-picker-btn):not([title]) * {
  color: #ffffff !important;
}

/* Dark mode card button */
html.dark .group button:not(.tmk-color-picker-btn):not([title]) {
  background: linear-gradient(135deg, var(--card-theme-color, #0284c7) 0%, rgba(var(--card-theme-rgb, 37, 99, 235), 0.88) 100%) !important;
  border: 1.5px solid rgba(var(--card-theme-rgb, 56, 189, 248), 0.5) !important;
  box-shadow: 0 4px 16px rgba(var(--card-theme-rgb, 2, 132, 199), 0.35) !important;
  color: #ffffff !important;
}
html.dark .group button:not(.tmk-color-picker-btn):not([title]):hover,
html.dark .group:hover button:not(.tmk-color-picker-btn):not([title]) {
  background: linear-gradient(135deg, var(--card-theme-color, #0369a1) 0%, rgba(var(--card-theme-rgb, 29, 78, 216), 1) 100%) !important;
  border-color: rgba(var(--card-theme-rgb, 56, 189, 248), 0.9) !important;
  box-shadow: 0 8px 24px rgba(var(--card-theme-rgb, 2, 132, 199), 0.55) !important;
  color: #ffffff !important;
  filter: brightness(1.12) !important;
}

/* Secondary Utility Row (Copy, External, Color) */
.group button[title],
.group a[title],
.group .tmk-color-picker-btn {
  flex: 1 1 calc(33.333% - 6px) !important;
  height: 38px !important;
  padding: 0 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 10px !important;
  cursor: pointer !important;
}

/* ==========================================================================
   🖼️ 4. EMBEDDED APP VIEWER MODAL (.tmk-viewer-header)
   Clean Fullscreen Interface with Seamless App Integration
   ========================================================================== */

.tmk-viewer-header {
  padding-top: max(env(safe-area-inset-top, 0px), var(--safe-top, 0.75rem)) !important;
  box-sizing: border-box !important;
}

@media (max-width: 768px) {
  .tmk-viewer-header {
    min-height: calc(3.75rem + env(safe-area-inset-top, 0px)) !important;
    padding-top: max(env(safe-area-inset-top, 0px), 28px) !important;
    padding-bottom: 0.5rem !important;
  }
}

/* Viewer Header Bar in Light Mode */
html:not(.dark) .tmk-viewer-header {
  background: rgba(255, 255, 255, 0.98) !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05) !important;
}
html:not(.dark) .tmk-viewer-header h2,
html:not(.dark) .tmk-viewer-header h3,
html:not(.dark) .tmk-viewer-header .text-white {
  color: #0f172a !important;
}
html:not(.dark) .tmk-viewer-header p,
html:not(.dark) .tmk-viewer-header .text-slate-400 {
  color: #64748b !important;
}

/* Back button in Light Mode */
html:not(.dark) .tmk-viewer-header button[title="กลับสู่หน้าหลัก"] {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  color: #1d4ed8 !important;
}
html:not(.dark) .tmk-viewer-header button[title="กลับสู่หน้าหลัก"] * {
  color: #1d4ed8 !important;
}

/* Device Switcher Container (The segmented pill) in Light Mode */
html:not(.dark) .tmk-viewer-header .bg-slate-950 {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
}

/* Inactive device buttons in Light Mode */
html:not(.dark) .tmk-viewer-header .bg-slate-950 button {
  background: transparent !important;
  border: none !important;
  color: #475569 !important;
  box-shadow: none !important;
  font-weight: 500 !important;
}
html:not(.dark) .tmk-viewer-header .bg-slate-950 button * {
  color: #475569 !important;
}
html:not(.dark) .tmk-viewer-header .bg-slate-950 button:hover {
  background: rgba(0, 0, 0, 0.06) !important;
  color: #0f172a !important;
}
html:not(.dark) .tmk-viewer-header .bg-slate-950 button:hover * {
  color: #0f172a !important;
}

/* Active device button in Light Mode ("อัตโนมัติ" or whichever is active) */
html:not(.dark) .tmk-viewer-header .bg-slate-950 button[class*="bg-cyan-"],
html:not(.dark) .tmk-viewer-header .bg-slate-950 button[class*="bg-blue-"],
html:not(.dark) .tmk-viewer-header .bg-slate-950 button.font-semibold {
  background: #2563eb !important;
  color: #ffffff !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3) !important;
}
html:not(.dark) .tmk-viewer-header .bg-slate-950 button[class*="bg-cyan-"] *,
html:not(.dark) .tmk-viewer-header .bg-slate-950 button[class*="bg-blue-"] *,
html:not(.dark) .tmk-viewer-header .bg-slate-950 button.font-semibold * {
  color: #ffffff !important;
}

/* Zoom controls container in Light Mode */
html:not(.dark) .tmk-viewer-header div.bg-slate-950:has(span.font-mono) {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}
html:not(.dark) .tmk-viewer-header div.bg-slate-950:has(span.font-mono) span {
  color: #0f172a !important;
}
html:not(.dark) .tmk-viewer-header div.bg-slate-950:has(span.font-mono) button {
  color: #475569 !important;
}
html:not(.dark) .tmk-viewer-header div.bg-slate-950:has(span.font-mono) button:hover {
  color: #0f172a !important;
}

/* Action buttons on the right (refresh, fullscreen, external link, close) in Light Mode */
html:not(.dark) .tmk-viewer-header > div:last-child > button,
html:not(.dark) .tmk-viewer-header > div:last-child > a {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}
html:not(.dark) .tmk-viewer-header > div:last-child > button *,
html:not(.dark) .tmk-viewer-header > div:last-child > a * {
  color: #334155 !important;
}
html:not(.dark) .tmk-viewer-header > div:last-child > button:hover,
html:not(.dark) .tmk-viewer-header > div:last-child > a:hover {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
html:not(.dark) .tmk-viewer-header > div:last-child > button:hover *,
html:not(.dark) .tmk-viewer-header > div:last-child > a:hover * {
  color: #0f172a !important;
}
html:not(.dark) .tmk-viewer-header button[title="ปิดหน้าต่าง"]:hover {
  background: #fee2e2 !important;
  border-color: #fca5a5 !important;
  color: #dc2626 !important;
}
html:not(.dark) .tmk-viewer-header button[title="ปิดหน้าต่าง"]:hover * {
  color: #dc2626 !important;
}

/* ==========================================================================
   📱 6. LUXURY SMARTPHONE & TABLET DEVICE SIMULATOR
   Studio Canvas Backdrop, Titanium Bezel, Dynamic Island Notch & Home Bar
   ========================================================================== */

/* Outer Studio Presentation Canvas */
html:not(.dark) div.bg-slate-950:has(iframe) {
  background: radial-gradient(circle at 50% 35%, #f1f5f9 0%, #cbd5e1 100%) !important;
}

html.dark div.bg-slate-950:has(iframe) {
  background: radial-gradient(circle at 50% 35%, #0f172a 0%, #020617 100%) !important;
}

/* Mobile Smartphone Chassis Simulator */
div[class*="max-w-[420px]"]:has(> iframe) {
  position: relative !important;
  width: 100% !important;
  max-width: 412px !important;
  height: min(840px, calc(100% - 48px)) !important;
  max-height: calc(100% - 40px) !important;
  border-radius: 46px !important;
  border: 11px solid #1e293b !important;
  box-shadow: 
    0 0 0 1px rgba(255, 255, 255, 0.15),
    0 25px 50px -12px rgba(0, 0, 0, 0.45),
    0 12px 24px -8px rgba(0, 0, 0, 0.3) !important;
  overflow: hidden !important;
  background: #000000 !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

html:not(.dark) div[class*="max-w-[420px]"]:has(> iframe) {
  border-color: #334155 !important;
  box-shadow: 
    0 0 0 1px rgba(0, 0, 0, 0.08),
    0 25px 60px -15px rgba(15, 23, 42, 0.25),
    0 12px 24px -8px rgba(15, 23, 42, 0.15) !important;
}

/* iPhone Dynamic Island / Speaker Notch */
div[class*="max-w-[420px]"]:has(> iframe)::before {
  content: '' !important;
  position: absolute !important;
  top: 10px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: 110px !important;
  height: 25px !important;
  background: #000000 !important;
  border-radius: 20px !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
}

/* iPhone Home Indicator Bar */
div[class*="max-w-[420px]"]:has(> iframe)::after {
  content: '' !important;
  position: absolute !important;
  bottom: 8px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: 130px !important;
  height: 4px !important;
  background: rgba(15, 23, 42, 0.6) !important;
  border-radius: 4px !important;
  z-index: 9999 !important;
  pointer-events: none !important;
}

html.dark div[class*="max-w-[420px]"]:has(> iframe)::after {
  background: rgba(255, 255, 255, 0.4) !important;
}

/* Inner iframe inside phone chassis */
div[class*="max-w-[420px]"]:has(> iframe) > iframe {
  border-radius: 36px !important;
  width: 100% !important;
  height: 100% !important;
}

/* Tablet iPad Chassis Simulator */
div[class*="max-w-[768px]"]:has(> iframe),
div[class*="max-w-[820px]"]:has(> iframe) {
  position: relative !important;
  width: 100% !important;
  max-width: 768px !important;
  height: min(920px, calc(100% - 48px)) !important;
  max-height: calc(100% - 40px) !important;
  border-radius: 28px !important;
  border: 10px solid #1e293b !important;
  box-shadow: 
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 25px 50px -12px rgba(0, 0, 0, 0.45) !important;
  overflow: hidden !important;
  background: #000000 !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

html:not(.dark) div[class*="max-w-[768px]"]:has(> iframe),
html:not(.dark) div[class*="max-w-[820px]"]:has(> iframe) {
  border-color: #334155 !important;
  box-shadow: 
    0 0 0 1px rgba(0, 0, 0, 0.08),
    0 25px 60px -15px rgba(15, 23, 42, 0.25) !important;
}

div[class*="max-w-[768px]"]:has(> iframe) > iframe,
div[class*="max-w-[820px]"]:has(> iframe) > iframe {
  border-radius: 18px !important;
}


