/* ==========================================================================
   AVATAN ReFlow — Design System (Layout 1: All-in-One Studio)
   Futuristic Cyberpunk / Enterprise Tech Dashboard
   ========================================================================== */
:root {
  --fb: #00C2FF;
  --fb-deep: #0072FF;
  --fb-glow: rgba(0, 194, 255, 0.35);
  --line: #06C755;
  --line-deep: #05a648;
  --accent: #38BDF8;
  --accent-purple: #818CF8;
  --ink: #F8FAFC;
  --ink-2: #94A3B8;
  --ink-3: #64748B;
  --stroke: rgba(56, 189, 248, 0.16);
  --stroke-2: rgba(255, 255, 255, 0.08);
  --bg: #070B19;
  --sidebar-bg: rgba(9, 14, 33, 0.96);
  --card: rgba(15, 23, 42, 0.82);
  --card-inner: rgba(11, 18, 36, 0.85);
  --field-bg: rgba(11, 18, 36, 0.7);
  --seg-bg: rgba(11, 18, 36, 0.8);
  --seg-active-bg: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(0, 114, 255, 0.25));
  --block-head-bg: rgba(15, 23, 42, 0.95);
  --elevated: #0f172a;
  --topbar: rgba(7, 11, 25, 0.85);
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #10b981;
  --radius: 20px;
  --radius-sm: 13px;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.65);
  --font: 'Prompt', system-ui, sans-serif;
  --glow-opacity: 0.28;
}

/* ---------- LIGHT THEME (ตรีมสว่าง) ---------- */
:root[data-theme="light"] {
  --fb: #0284c7;
  --fb-deep: #0369a1;
  --fb-glow: rgba(2, 132, 199, 0.2);
  --line: #16a34a;
  --line-deep: #15803d;
  --accent: #0284c7;
  --accent-purple: #6366f1;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #64748b;
  --stroke: #e2e8f0;
  --stroke-2: #f1f5f9;
  --bg: #f8fafc;
  --sidebar-bg: #ffffff;
  --card: #ffffff;
  --card-inner: #f8fafc;
  --field-bg: #ffffff;
  --seg-bg: #f1f5f9;
  --seg-active-bg: #ffffff;
  --block-head-bg: #f8fafc;
  --elevated: #ffffff;
  --topbar: rgba(255, 255, 255, 0.95);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.08);
  --glow-opacity: 0.12;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
  transition: background-color .2s ease, color .2s ease;
}

/* ---------- Ambient Glow Lights ---------- */
.glow-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.glow-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: var(--glow-opacity);
  transition: opacity .3s ease;
}
.glow-1 {
  width: 600px; height: 600px;
  top: -150px; right: -100px;
  background: radial-gradient(circle, #00c2ff 0%, #0072ff 100%);
}
.glow-2 {
  width: 500px; height: 500px;
  bottom: -100px; left: -100px;
  background: radial-gradient(circle, #6366f1 0%, #3b82f6 100%);
}
.glow-3 {
  width: 450px; height: 450px;
  top: 40%; left: 35%;
  background: radial-gradient(circle, #06c755 0%, #00c2ff 100%);
  opacity: 0.08;
}

/* Gradient Text Class */
.gradient-text {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- App Layout (Sidebar + Main Workspace) ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Sidebar (Supports White in Light Mode) */
.sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: background .2s ease, border-color .2s ease;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 960px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: linear-gradient(165deg, rgba(16, 26, 46, 0.85), rgba(10, 16, 30, 0.95));
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), inset 0 0 15px rgba(59, 130, 246, 0.05);
  box-sizing: border-box;
}
:root[data-theme="light"] .brand {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
}
.brand-mark img, .brand-mark svg {
  width: 100%; height: 100%;
  max-width: 40px; max-height: 40px;
  object-fit: contain;
  display: block;
  border-radius: 50%;
  filter: drop-shadow(0 0 10px rgba(0, 194, 255, 0.45));
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--ink); line-height: 1.2; }
.brand-tag { font-size: 11.5px; color: var(--ink-2); margin-top: 1px; }

/* Navigation */
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; }
.nav-section-title, .nav-title {
  font-size: 11px; font-weight: 700; color: var(--ink-3); letter-spacing: .08em;
  padding: 0 14px; margin-bottom: 4px; text-transform: uppercase;
}
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: all .2s ease; text-align: left; font-family: var(--font);
}
.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item:hover { color: var(--ink); background: rgba(0, 194, 255, 0.06); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(0, 194, 255, 0.14), rgba(0, 114, 255, 0.14));
  color: var(--fb); border-color: rgba(56, 189, 248, 0.3); box-shadow: 0 4px 16px rgba(0, 194, 255, 0.12);
}
:root[data-theme="light"] .nav-item.active {
  background: #f0f9ff;
  color: #0284c7;
  border-color: #bae6fd;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08);
}
.nav-item .brand-ic { width: 18px; height: 18px; display: block; }
.nav-ic { width: 20px; height: 20px; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.nav-item.locked {
  opacity: 0.5;
  cursor: not-allowed !important;
}
.nav-item.locked:hover {
  background: transparent !important;
  color: var(--ink-2) !important;
}
.nav-item.locked::after {
  content: "🔒 ล็อก";
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 600;
  margin-left: auto;
  flex-shrink: 0;
}

/* Account Widget */
.account-card {
  background: var(--card-inner); border: 1px solid var(--stroke); border-radius: 16px; padding: 14px;
  box-shadow: var(--shadow-sm);
}
.account-status-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.account-status-title { font-size: 11px; color: var(--ink-3); font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.account-user { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.account-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--stroke); }

/* Main Workspace */
.main-workspace {
  flex: 1;
  padding: 24px 28px 60px;
  overflow-y: auto;
  position: relative;
  z-index: 1;
  max-width: calc(100vw - 270px);
}
@media (max-width: 960px) {
  .main-workspace { max-width: 100vw; padding: 20px 16px; }
}

/* Top HUD Grid */
.hud-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
@media (max-width: 1140px) { .hud-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .hud-grid { grid-template-columns: 1fr; } }

.hud-card {
  background: var(--card); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--stroke); border-radius: 18px; padding: 16px 18px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm);
  transition: .2s ease;
}
.card .hud-card {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}
.hud-card:hover { border-color: rgba(56, 189, 248, 0.4); transform: translateY(-1px); }
.hud-ic {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  font-size: 18px; flex-shrink: 0;
}
.hud-ic-fb { background: rgba(0, 194, 255, 0.12); border: 1px solid rgba(0, 194, 255, 0.25); color: var(--fb); }
.hud-ic-emerald { background: rgba(6, 199, 85, 0.12); border: 1px solid rgba(6, 199, 85, 0.25); color: var(--line); }
.hud-ic-cyan { background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.25); color: var(--accent); }
.hud-ic-indigo { background: rgba(99, 102, 241, 0.12); border: 1px solid rgba(99, 102, 241, 0.25); color: var(--accent-purple); }
.hud-ic-amber { background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.25); color: var(--warn); }
.hud-label { font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.hud-value { font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-accent { color: var(--fb); font-size: 16px; }
.text-emerald { color: var(--ok); }

/* Workbench 2-Panel & 2-Row Grids */
.workbench-rows {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.workbench-row, .workbench-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 22px;
  align-items: stretch;
}
@media (max-width: 1180px) { 
  .workbench-row, .workbench-grid { grid-template-columns: 1fr; align-items: start; } 
  .workbench-side { position: static; } 
  .card.chat-preview-box, .chat-preview-box { min-height: 480px; height: 500px; }
}

.workbench-main { display: flex; flex-direction: column; gap: 22px; }
.workbench-side { display: flex; flex-direction: column; gap: 22px; height: 100%; }

/* Cards */
.card {
  position: relative;
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.card:hover {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: var(--shadow-md), 0 0 20px rgba(56, 189, 248, 0.05);
}
.card-header-row {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--stroke); padding-bottom: 14px; margin-bottom: 16px;
}
.card-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15.5px; color: var(--ink); }
.card-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.4; }

/* Inputs & Form Controls */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.input, textarea, select {
  width: 100%; font-family: var(--font); font-size: 14px; color: var(--ink);
  padding: 11px 14px; border: 1px solid var(--stroke); border-radius: var(--radius-sm);
  background: var(--field-bg); transition: .2s ease; outline: none;
}
.input:focus, textarea:focus, select:focus {
  border-color: var(--accent); background: var(--card);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.hint { font-size: 11.5px; color: var(--ink-2); margin-top: 6px; }

.tip-box {
  padding: 13px 15px; background: rgba(0, 194, 255, 0.08); border: 1px solid rgba(0, 194, 255, 0.25);
  border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.55; font-family: inherit; color: var(--ink-2); display: flex; align-items: center; gap: 10px; margin-top: 14px;
}
.tip-box * { font-family: inherit; }
:root[data-theme="light"] .tip-box {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
}

/* Control Row 3 */
.ctrl-row-3 { display: grid; grid-template-columns: 1.3fr 1fr 1.3fr; gap: 12px; align-items: end; margin-bottom: 16px; }
@media (max-width: 768px) { .ctrl-row-3 { grid-template-columns: 1fr; } }
.ctrl-block { display: flex; flex-direction: column; }
.num-input { height: 48px; text-align: center; font-size: 16px; font-weight: 700; color: var(--fb); font-variant-numeric: tabular-nums; }
.num-input::placeholder { font-size: 13px; font-weight: 500; color: var(--ink-3); }

.seg { display: flex; gap: 6px; background: var(--seg-bg); padding: 5px; border-radius: 14px; height: 48px; border: 1px solid var(--stroke); }
.seg button {
  flex: 1; border: 0; background: transparent; font-family: var(--font); font-weight: 600; font-size: 13px;
  color: var(--ink-2); border-radius: 10px; cursor: pointer; transition: .2s ease; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.08); }
:root[data-theme="light"] .seg button:hover { background: rgba(0, 0, 0, 0.04); }
.seg button.active {
  background: var(--seg-active-bg);
  color: var(--fb); border: 1px solid var(--stroke); box-shadow: var(--shadow-sm);
}

.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--ink); margin-bottom: 4px; user-select: none; }
.check-row input { width: 18px; height: 18px; accent-color: var(--fb); cursor: pointer; flex-shrink: 0; }
.check-sub { font-size: 12px; margin: 0 0 14px 28px; }
.check-sub a { color: var(--ink-2); text-decoration: none; }
.check-sub a:hover { color: var(--danger); text-decoration: underline; }

.launch-options-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
  align-items: start;
}
.launch-opt-col {
  display: flex;
  flex-direction: column;
}
@media (max-width: 640px) {
  .launch-options-2col {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.clear-sent-row {
  margin: 4px 0 12px 0;
  font-size: 12.5px;
  display: flex;
  align-items: center;
}
.clear-sent-row a {
  color: var(--ink-2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color .15s;
}
.clear-sent-row a:hover {
  color: var(--danger);
  text-decoration: underline;
}

/* Buttons */
.btn {
  font-family: var(--font); font-weight: 600; font-size: 14px; cursor: pointer;
  border: 0; border-radius: var(--radius-sm); padding: 12px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s ease, box-shadow .25s ease, background .2s; width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #fff; background: linear-gradient(135deg, #00c2ff 0%, #0072ff 100%);
  box-shadow: 0 8px 24px rgba(0, 194, 255, 0.32);
}
.btn-primary:hover { box-shadow: 0 10px 30px rgba(0, 194, 255, 0.5); transform: translateY(-1px); }
.btn-fb {
  color: #fff; background: linear-gradient(135deg, #1877f2 0%, #0056b3 100%);
  box-shadow: 0 4px 14px rgba(24, 119, 242, 0.35);
}
.btn-fb:hover { box-shadow: 0 6px 20px rgba(24, 119, 242, 0.5); transform: translateY(-1px); }
.btn-indigo {
  color: #fff; background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn-indigo:hover { box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5); transform: translateY(-1px); }
.btn-line {
  color: #fff; background: linear-gradient(135deg, #06c755 0%, #10b981 100%);
  box-shadow: 0 8px 24px rgba(6, 199, 85, 0.32);
}
.btn-line:hover { box-shadow: 0 10px 30px rgba(6, 199, 85, 0.48); transform: translateY(-1px); }
.btn-ghost {
  background: var(--card-inner); color: var(--ink); border: 1px solid var(--stroke);
}
.btn-ghost:hover { background: rgba(0, 194, 255, 0.08); border-color: var(--stroke); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #dc2626); color: #fff; box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35); }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-sm { padding: 9px 15px; font-size: 12.5px; width: auto; }

/* 2-Column Top Layout & Inline Status Buttons */
.fb-top-grid, .line-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
  align-items: stretch;
}
.fb-top-grid > .card, .line-top-grid > .card {
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
@media (max-width: 990px) {
  .fb-top-grid, .line-top-grid {
    grid-template-columns: 1fr;
  }
}
.status-btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.status-btn-row .status-row {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-btn-row .btn {
  flex-shrink: 0;
  width: auto;
  white-space: nowrap;
}

/* Hide Redundant Page Chip & Duplicate Page Status Row */
#pageChip, .page-chip, #pageStatusRow {
  display: none !important;
}

/* Custom Rich Page Dropdown Selector with Search & Avatar */
#pageSelectWrap {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}
.rich-page-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--field-bg, rgba(15, 23, 42, 0.88));
  border: 1px solid var(--stroke, rgba(0, 194, 255, 0.35));
  border-radius: var(--radius-sm, 10px);
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: var(--shadow-sm);
  transition: all .2s ease;
  user-select: none;
}
.rich-page-trigger:hover {
  border-color: var(--fb, #00c2ff);
  background: rgba(0, 194, 255, 0.08);
}
.rich-page-trigger.open,
.rich-page-trigger:focus-visible {
  border-color: var(--fb, #00c2ff);
  box-shadow: 0 0 0 3px rgba(0, 194, 255, 0.22);
  outline: none;
}
.rich-page-trigger.open .rich-page-trigger-chevron {
  transform: rotate(180deg);
}
.rich-page-trigger-avatar {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  background-color: #0284c7;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
  overflow: hidden;
}
.rich-page-trigger-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.rich-page-trigger-chevron {
  font-size: 10px;
  color: var(--ink-2);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.rich-page-dropdown-menu,
.rich-page-box {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--card-bg, #0c1322);
  border: 1px solid rgba(0, 194, 255, 0.45);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}
.rich-page-dropdown-menu.hidden {
  display: none !important;
}
:root[data-theme="light"] .rich-page-dropdown-menu {
  background: #ffffff;
  border-color: #bae6fd;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}
.rich-page-search-wrap {
  padding: 6px 10px;
  border-bottom: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-inner, rgba(255, 255, 255, 0.03));
}
.rich-page-search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 12px;
  color: var(--ink);
}
.rich-page-list {
  max-height: 180px;
  min-height: 50px;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rich-page-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
  border: 1px solid transparent;
  user-select: none;
}
.rich-page-item:hover {
  background: rgba(0, 194, 255, 0.1);
  border-color: rgba(0, 194, 255, 0.25);
}
.rich-page-item.selected {
  background: rgba(0, 194, 255, 0.16);
  border-color: rgba(0, 194, 255, 0.4);
}
:root[data-theme="light"] .rich-page-item.selected {
  background: #e0f2fe;
  border-color: #bae6fd;
}
.rich-page-item-radio {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.8px solid var(--ink-3);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all .15s;
}
.rich-page-item.selected .rich-page-item-radio {
  border-color: var(--fb);
}
.rich-page-item.selected .rich-page-item-radio::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fb);
}
.rich-page-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  background-color: #0284c7;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
  overflow: hidden;
}
.rich-page-item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.rich-page-item.selected .rich-page-item-name {
  font-weight: 700;
  color: var(--fb);
}

/* Status Rows */
.status-row {
  display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600;
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px;
  border: 1px solid var(--stroke); background: var(--card-inner);
}
.status-row .sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.status-row.off { color: var(--ink-2); }
.status-row.ok { color: var(--ok); background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.3); }
.status-row.ok .sdot { background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: livepulse 2s infinite; }
@keyframes livepulse { 50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } }

/* Audience Lists */
.audience-stat {
  display: flex; align-items: baseline; gap: 12px; margin: 4px 0 16px; padding: 14px 18px;
  border-radius: 16px; background: linear-gradient(120deg, rgba(0, 194, 255, 0.1), rgba(99, 102, 241, 0.06));
  border: 1px solid rgba(0, 194, 255, 0.2);
}
:root[data-theme="light"] .audience-stat {
  background: #f0f9ff;
  border-color: #bae6fd;
}
.reclist {
  height: 220px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  padding: 10px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  align-content: start;
}
.reclist .empty, .empty-reclist-placeholder {
  grid-column: 1 / -1;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 180px;
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
  gap: 8px;
  user-select: none;
}
.rec-name-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--card-inner);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  transition: all 0.2s ease;
}
.rec-name-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.08);
  transform: translateY(-1px);
}
.rec-idx {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 7px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.rec-name-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.rec-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  flex-shrink: 0;
}

/* Progress */
.progress-wrap { display: block; }
.progress-wrap.hidden { display: none; }
.bcast-live { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--fb); margin-bottom: 14px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 10px var(--danger); animation: livepulse 1.3s infinite; flex-shrink: 0; }
.live-dot.done { background: var(--fb); box-shadow: 0 0 10px var(--fb-glow); animation: none; }
.live-speed { margin-left: auto; color: var(--ink-2); font-weight: 500; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bcast-pct { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.bcast-pct span { font-size: 40px; font-weight: 700; color: var(--fb); font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }
.bcast-pct small { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.bcast-bar { height: 14px; border-radius: 999px; background: var(--card-inner); border: 1px solid var(--stroke); overflow: hidden; position: relative; }
.bcast-fill {
  height: 100%; width: 0%; border-radius: 999px; position: relative; overflow: hidden;
  background: linear-gradient(90deg, #00c2ff, #38bdf8, #818cf8); box-shadow: 0 0 16px var(--fb-glow);
  transition: width .45s cubic-bezier(.4,0,.2,1);
}
.bcast-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  background-size: 30% 100%; background-repeat: no-repeat; animation: shimmer 1.3s linear infinite;
}
.bcast-now { margin: 14px 0; font-size: 13.5px; color: var(--ink-2); display: flex; align-items: center; gap: 10px; min-height: 20px; }
.bcast-now .spin { width: 16px; height: 16px; border: 2px solid var(--stroke); border-top-color: var(--fb); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
.bcast-now b { color: var(--ink); font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }
.live-warn {
  display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.3); font-size: 12.5px; line-height: 1.5; color: #d97706;
}
:root[data-theme="dark"] .live-warn { color: #fbbf24; }
.live-warn-ic { font-size: 20px; flex-shrink: 0; }
.live-warn b { color: var(--ink); }

.metrics { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 8px; }
.metric { background: var(--card-inner); border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 12px 10px; text-align: center; }
.metric b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.metric span { font-size: 11px; color: var(--ink-2); }
.metric.ok b { color: var(--ok); } .metric.err b { color: var(--danger); }

.loadbar { position: relative; height: 6px; border-radius: 999px; margin-top: 14px; overflow: hidden; background: rgba(0, 194, 255, 0.12); }
.loadbar .runner {
  position: absolute; top: 0; height: 100%; width: 40%; border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--fb) 30%, var(--accent) 70%, transparent);
  box-shadow: 0 0 14px var(--fb-glow); animation: loadrun 1.15s cubic-bezier(.45,.05,.35,1) infinite;
}
@keyframes loadrun { 0% { left: -40%; } 100% { left: 102%; } }
@keyframes shimmer { 0% { background-position: 120% 0; } 100% { background-position: -30% 0; } }

.fetchmsg { font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 10px; min-height: 18px; }
.statusline { font-size: 13px; color: var(--ink-2); margin-top: 12px; min-height: 18px; padding-left: 20px; position: relative; }
.statusline::before { content:''; position:absolute; left:0; top:6px; width:8px; height:8px; border-radius:50%; background:var(--fb); box-shadow:0 0 10px var(--fb-glow); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(0,194,255,0); } }

/* Rectangular Chat Live Preview (Direct Full-Area Single Card matching height) */
.card.chat-preview-box, .chat-preview-box, .phone {
  width: 100%; margin: 0; background: var(--card); border-radius: var(--radius-lg, 16px); padding: 0 !important;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-sm), 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  position: relative; box-sizing: border-box;
}
.phone-preview-card { display: contents !important; }
.phone-header-label { display: none !important; }
.phone::after { display: none !important; }
.screen { background: transparent; border-radius: 0; overflow: hidden; height: 100%; display: flex; flex-direction: column; min-height: 0; }

.msgr-head {
  background: rgba(15, 23, 42, 0.95); padding: 12px 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--stroke); color: var(--ink);
  backdrop-filter: blur(8px);
}
[data-theme="light"] .msgr-head {
  background: #f8fafc;
  border-bottom-color: #e2e8f0;
}
.msgr-head .back { color: var(--fb); font-size: 18px; font-weight: bold; cursor: pointer; display: none; }
.msgr-head .pav {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #0369a1); background-size: cover; background-position: center;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.msgr-head .pinfo { flex: 1; min-width: 0; }
.msgr-head .pname { font-weight: 700; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msgr-head .pstat { font-size: 11px; color: #10b981; margin-top: 1px; font-weight: 500; }
.msgr-head .icons { margin-left: auto; color: var(--ink-2); display: flex; gap: 8px; font-size: 13px; font-weight: 600; flex-shrink: 0; }

.chat { flex: 1; padding: 14px 12px; overflow-y: auto; background: #ffffff; display: flex; flex-direction: column; gap: 8px; }
[data-theme="dark"] .chat { background: #090e17; }
.day { text-align: center; font-size: 11px; color: #8c939d; margin: 2px 0 6px; }

/* Real Messenger Text Bubble */
.ph-bubble, .bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: 13.5px; line-height: 1.45;
  align-self: flex-end; background: #0084ff; color: #ffffff;
  border-bottom-right-radius: 4px; word-wrap: break-word; white-space: pre-wrap;
  box-shadow: 0 1px 3px rgba(0, 132, 255, 0.2); animation: pop .25s ease;
}

/* Real Messenger Image Attachment */
.ph-img, .bubble.img img {
  max-width: 82%; width: auto; max-height: 260px; border-radius: 18px; display: block;
  align-self: flex-end; object-fit: cover; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.08); animation: pop .25s ease; margin-left: auto;
}

@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.96); } }
.chat .placeholder { margin: auto; text-align: center; color: #8c939d; font-size: 12.5px; padding: 14px; }
.msgr-foot { display: none !important; }

/* LINE Preview */
.msgr-head.line-head .pav, .msgr-head .line-pav { background: linear-gradient(135deg, var(--line), #10b981); }
.line-chat { background: rgba(4, 8, 18, 0.9) !important; }
[data-theme="dark"] .line-chat { background: rgba(4, 8, 18, 0.9) !important; }
#lineChatPreviewCard .line-chat,
#linePreviewWrap .line-chat { background: rgba(4, 8, 18, 0.9) !important; }
.line-chat .day { color: #64748b; }
.line-chat .placeholder { color: #94a3b8; }
.line-bubble {
  align-self: flex-start; max-width: 85%; padding: 8px 12px; border-radius: 16px; border-top-left-radius: 3px;
  background: #fff; color: #1e293b; font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); animation: pop .3s cubic-bezier(.2,.8,.2,1);
}
.line-bubble.img { padding: 3px; background: #fff; }
.line-bubble.img img { width: 100%; border-radius: 14px; display: block; max-height: 240px; object-fit: cover; }
.line-progress { border: 1px solid rgba(6,199,85,.3); background: rgba(6,199,85,.1); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; }

/* LINE Image Upload Card */
.line-img-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-inner); border: 1px solid var(--stroke);
  border-radius: 14px; padding: 12px 14px; margin-top: 10px;
  box-shadow: var(--shadow-sm); animation: pop .25s ease;
}
.line-img-thumb {
  width: 48px; height: 48px; border-radius: 10px;
  object-fit: cover; border: 1px solid var(--stroke);
  flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.line-img-info { flex: 1; min-width: 0; }
.line-img-title { font-size: 13.5px; font-weight: 700; color: var(--ok); display: flex; align-items: center; gap: 6px; }
.line-img-desc { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; line-height: 1.4; }
.line-img-del-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--stroke); background: var(--seg-bg);
  color: var(--ink-3); font-size: 15px; font-weight: 700;
  cursor: pointer; display: grid; place-items: center;
  transition: all .2s ease; flex-shrink: 0;
}
.line-img-del-btn:hover {
  background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4); color: var(--danger);
}

/* Message Blocks */
.block { border: 1px solid var(--stroke); border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden; background: var(--card); box-shadow: var(--shadow-sm); }
.block-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--block-head-bg); font-size: 12.5px; font-weight: 600; color: var(--ink);
  border-bottom: 1px solid var(--stroke);
}
.block-head .bnum {
  width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, var(--fb), var(--fb-deep));
  color: #fff; display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
}
.block-head .bctrl { margin-left: auto; display: flex; gap: 4px; }
.block-head .bctrl button {
  width: 28px; height: 28px; border: 1px solid var(--stroke); border-radius: 8px;
  background: var(--card-inner); cursor: pointer; color: var(--ink-2); font-size: 13px;
  display: grid; place-items: center; transition: .15s;
}
.block-head .bctrl button:hover:not([disabled]) { background: var(--fb); color: #fff; border-color: var(--fb); }
.block-head .bctrl button[disabled] { opacity: .3; cursor: not-allowed; }
.block-head .bctrl .del:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.block-body { padding: 12px; }
.block-body textarea { min-height: 95px; border: 0; background: transparent; padding: 4px; resize: none; overflow: hidden; color: var(--ink); }
.block-body textarea:focus { box-shadow: none; }
.block-text-body { position: relative; }
.emoji-btn {
  display: none !important;
}

.reflow-emoji-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1000;
  width: 330px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.15);
  backdrop-filter: blur(16px);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: pop .18s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--ink);
}
[data-theme="light"] .reflow-emoji-popover {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

.reflow-emoji-header {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}
[data-theme="light"] .reflow-emoji-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

.reflow-emoji-search {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink);
  outline: none;
  transition: .15s;
}
[data-theme="light"] .reflow-emoji-search {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.reflow-emoji-search:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.reflow-emoji-close {
  background: transparent;
  border: none;
  color: var(--ink-2);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .15s;
}
.reflow-emoji-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.reflow-emoji-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.reflow-emoji-tabs::-webkit-scrollbar {
  display: none;
}
.reflow-emoji-tab {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
  flex-shrink: 0;
}
[data-theme="light"] .reflow-emoji-tab {
  background: #e2e8f0;
}
.reflow-emoji-tab:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.4);
}
.reflow-emoji-tab.active {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  border-color: #60a5fa;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.reflow-emoji-grid {
  max-height: 210px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding-right: 2px;
}
.reflow-emoji-grid::-webkit-scrollbar {
  width: 5px;
}
.reflow-emoji-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}
[data-theme="light"] .reflow-emoji-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

.emoji-item {
  border: 0;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px;
  line-height: 1;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  transition: transform .12s ease, background .12s ease;
  user-select: none;
}
.emoji-item:hover {
  background: rgba(56, 189, 248, 0.2);
  transform: scale(1.25);
}
.emoji-item:active {
  transform: scale(0.92);
}

.reflow-emoji-footer {
  font-size: 10.5px;
  color: var(--ink-2);
  text-align: center;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.block-img { display: flex; align-items: center; gap: 14px; }
.block-img img { width: 76px; height: 76px; object-fit: cover; border-radius: 12px; border: 1px solid var(--stroke); }
.block-img .iname { font-size: 12.5px; color: var(--ink-2); }
.block-add { display: flex; gap: 8px; }

/* History Details */
.badge { font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px; background: rgba(16,185,129,.15); color: var(--ok); white-space: nowrap; }
.hist-card { border: 1px solid var(--stroke); border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden; background: var(--card); transition: .2s; }
.hist-card[open] { box-shadow: var(--shadow-sm); border-color: rgba(56,189,248,.35); }
.hist-summary { display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer; list-style: none; user-select: none; }
.hist-summary::-webkit-details-marker { display: none; }
.hist-plat { font-size: 11.5px; font-weight: 700; padding: 4px 10px 4px 8px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; }
.hist-plat .plat-ic { width: 14px; height: 14px; flex-shrink: 0; display: block; }
.hist-plat.fb { background: rgba(0,194,255,.15); color: var(--fb); }
.hist-plat.line { background: rgba(6,199,85,.15); color: var(--line); }
.hist-summary::before { content: '▸'; color: var(--ink-2); transition: transform .15s; flex-shrink: 0; }
.hist-card[open] .hist-summary::before { transform: rotate(90deg); }
.hist-summary:hover { background: rgba(0, 194, 255, 0.04); }
.hist-when { font-size: 12px; color: var(--ink-2); white-space: nowrap; flex-shrink: 0; }
.hist-preview { flex: 1; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--ink); }
.hist-body { padding: 0 18px 18px; border-top: 1px solid var(--stroke); }
.hist-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 13px; color: var(--ink-2); margin: 16px 0; }
.hist-fulltext { background: var(--card-inner); border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 16px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; max-height: 320px; overflow-y: auto; color: var(--ink); }
.hist-actions { display: flex; gap: 10px; margin-top: 16px; }
.hist-actions .btn { width: auto; }

/* Support & Guide Layout */
.support-hero {
  display: none !important;
}
.support-wrap { max-width: 900px; margin: 0 auto; width: 100%; }
.support-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 768px) { .support-grid { grid-template-columns: 1fr; } }
.how-card { margin-bottom: 22px; }
.how-steps { display: flex; flex-direction: column; gap: 4px; }
.how-step { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--stroke); }
.how-step:last-child { border-bottom: 0; }
.how-num {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--fb), var(--accent)); color: #fff; font-weight: 700; font-size: 14px; box-shadow: 0 4px 12px var(--fb-glow);
}
.how-step b { font-size: 14.5px; color: var(--ink); }
.how-step p { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.55; }
.support-qr-card { text-align: center; }
.support-qr-card img { width: 160px; height: 160px; margin: 10px auto 14px; display: block; border-radius: 16px; border: 1px solid var(--stroke); background: #fff; padding: 8px; }
.support-qr-cap { font-size: 13px; color: var(--ink-2); }
.support-links { display: flex; flex-direction: column; gap: 12px; }
.support-link {
  display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--stroke);
  border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); transition: .2s; background: var(--card);
}
.support-link:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.support-link .si { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 18px; }
.support-link small { display: block; color: var(--ink-2); font-size: 12px; }

/* LINE Guide */
.line-guide { margin-top: 14px; border: 1px solid var(--stroke); border-radius: var(--radius-sm); overflow: hidden; }
.line-guide summary { cursor: pointer; padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--line); background: rgba(6,199,85,.08); user-select: none; }
.line-guide ol { margin: 0; padding: 14px 16px 14px 32px; display: flex; flex-direction: column; gap: 10px; }
.line-guide li { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.line-guide a { color: var(--accent); }

.uploadbox { border: 1.5px dashed var(--stroke); border-radius: var(--radius-sm); padding: 16px; text-align: center; cursor: pointer; transition: .2s; color: var(--ink-2); font-size: 13.5px; }
.uploadbox:hover { border-color: var(--accent); color: var(--accent); background: rgba(56, 189, 248, 0.06); }
.line-img-status { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--ink); min-height: 20px; }
.line-img-status .spin { width: 16px; height: 16px; border: 2px solid var(--stroke); border-top-color: var(--line); border-radius: 50%; animation: spin .7s linear infinite; }
.line-img-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 10px; border: 1px solid var(--stroke); }
.line-img-x { margin-left: auto; width: 26px; height: 26px; border: 0; border-radius: 8px; background: rgba(0,0,0,.08); color: var(--ink-2); cursor: pointer; font-size: 13px; }
.line-img-x:hover { background: var(--danger); color: #fff; }

/* Modals & Popups */
.modal-overlay {
  position: fixed; inset: 0; z-index: 99999; display: grid; place-items: center; padding: 24px;
  background: rgba(3, 7, 18, 0.75); backdrop-filter: blur(8px); animation: fadein .18s ease;
}
@keyframes fadein { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 460px; background: var(--card); border: 1px solid var(--stroke);
  border-radius: 24px; box-shadow: var(--shadow-lg); padding: 28px; animation: pop-in .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.modal.modal-lg { max-width: 500px; }
.modal-close {
  margin-left: auto; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--stroke);
  background: var(--card-inner); color: var(--ink-2); cursor: pointer; font-size: 15px;
  flex-shrink: 0; align-self: flex-start; transition: .15s;
}
.modal-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.modal-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.modal-icon {
  width: 54px; height: 54px; border-radius: 16px; flex-shrink: 0; display: grid; place-items: center; font-size: 28px;
  background: linear-gradient(135deg, #00c2ff, #0072ff); box-shadow: 0 8px 24px var(--fb-glow);
}
.modal-head h3 { font-size: 19px; font-weight: 700; color: var(--ink); }
.modal-head p { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.modal-summary { border-radius: var(--radius-sm); border: 1px solid var(--stroke); overflow: hidden; margin-bottom: 22px; background: var(--card-inner); }
.cs-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--stroke); font-size: 14px; }
.cs-row:last-child { border-bottom: 0; }
.cs-k { width: 68px; flex-shrink: 0; color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.cs-v { color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cs-big { font-size: 22px; color: var(--fb); font-variant-numeric: tabular-nums; font-weight: 700; }
.cs-mut { color: var(--ink-2); font-size: 12.5px; }
.cs-page { font-weight: 600; }
.cs-av {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg,var(--fb),var(--accent));
  background-size: cover; background-position: center; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; overflow: hidden;
}
.cs-preview { padding: 14px 16px; font-size: 13.5px; color: var(--ink); background: var(--card); line-height: 1.55; white-space: pre-wrap; }
.cs-warn { padding: 12px 16px; font-size: 13px; font-weight: 500; color: #d97706; background: rgba(245, 158, 11, 0.12); }
:root[data-theme="dark"] .cs-warn { color: #fbbf24; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; }
.modal-actions .btn-ghost { flex: 0 0 38%; }

/* ==========================================================================
   License & Renewal Modal Redesign (High-End SaaS / Glassmorphism)
   ========================================================================== */
#licenseModal {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(3, 7, 18, 0.65);
}

#licenseModal .modal.license-modal-box {
  max-width: 530px;
  width: 92vw;
  border-radius: 26px;
  padding: 32px 34px 26px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 30px 70px -15px rgba(0, 0, 0, 0.4), 0 0 40px rgba(0, 194, 255, 0.1);
  border: 1px solid var(--stroke);
  transition: all 0.3s ease;
}

:root[data-theme="dark"] #licenseModal .modal.license-modal-box {
  background: linear-gradient(165deg, rgba(17, 24, 43, 0.96) 0%, rgba(9, 14, 30, 0.99) 100%);
  border-color: rgba(56, 189, 248, 0.22);
  box-shadow: 0 35px 80px -15px rgba(0, 0, 0, 0.8), 0 0 50px rgba(0, 194, 255, 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

:root[data-theme="light"] #licenseModal .modal.license-modal-box {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.14), 0 0 35px rgba(2, 132, 199, 0.06), inset 0 1px 1px #ffffff;
}

/* Glowing Top Accent Line */
#licenseModal .modal.license-modal-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--fb), var(--accent), transparent);
  border-radius: 0 0 4px 4px;
  opacity: 0.9;
}

/* Modal Header */
#licenseModal .modal-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--stroke-2);
}

#licenseModal .modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: linear-gradient(135deg, #00C2FF 0%, #0072FF 100%);
  box-shadow: 0 10px 24px rgba(0, 194, 255, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#licenseModal .modal-head:hover .modal-icon {
  transform: scale(1.06) rotate(6deg);
}

#licenseModal .modal-head h3 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.25;
}

#licenseModal .modal-head p {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 3px;
}

#licenseModal .modal-close {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--seg-bg);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  margin-left: auto;
}

#licenseModal .modal-close:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
  transform: rotate(90deg);
}

/* License Body Container */
#licenseModal #licenseBody > div {
  padding: 0 !important;
}

/* The Info Card */
#licenseModal #licenseBody > div > div:first-child {
  border-radius: 18px !important;
  padding: 4px 0 !important;
  margin-bottom: 20px !important;
  overflow: hidden !important;
  border: 1px solid var(--stroke) !important;
  transition: all 0.25s ease !important;
}

:root[data-theme="dark"] #licenseModal #licenseBody > div > div:first-child {
  background: rgba(11, 18, 36, 0.7) !important;
  border-color: rgba(56, 189, 248, 0.16) !important;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05), 0 8px 24px rgba(0, 0, 0, 0.25) !important;
}

:root[data-theme="light"] #licenseModal #licenseBody > div > div:first-child {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04) !important;
}

/* Each Row in the Info Card */
#licenseModal #licenseBody > div > div:first-child > div {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 13px 22px !important;
  margin-bottom: 0 !important;
  border-bottom: 1px solid var(--stroke-2) !important;
  transition: background 0.15s ease !important;
}

#licenseModal #licenseBody > div > div:first-child > div:last-child {
  border-bottom: none !important;
}

#licenseModal #licenseBody > div > div:first-child > div:hover {
  background: rgba(56, 189, 248, 0.04) !important;
}

/* Labels (Left Side) */
#licenseModal #licenseBody > div > div:first-child > div > span:first-child {
  font-size: 13.5px !important;
  font-weight: 500 !important;
  color: var(--ink-2) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
}

/* Status Badge (Row 1) */
#licenseModal #licenseBody span[style*="border-radius:20px"] {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 6px 14px !important;
  border-radius: 9999px !important;
  font-size: 12.5px !important;
  font-weight: 700 !important;
  background: rgba(16, 185, 129, 0.14) !important;
  color: #10b981 !important;
  border: 1px solid rgba(16, 185, 129, 0.35) !important;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.18) !important;
  letter-spacing: 0.02em !important;
}

/* Package Name (Row 2) */
#licenseModal #licenseBody b {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: var(--ink) !important;
  display: inline-flex !important;
  align-items: center !important;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  background: var(--card) !important;
  border: 1px solid var(--stroke) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) !important;
}

/* License Key Monospace Tag (Row 3) */
#licenseModal #licenseBody code {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, Menlo, monospace !important;
  font-size: 12.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.07em !important;
  padding: 6px 14px !important;
  border-radius: 8px !important;
  user-select: all !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}

:root[data-theme="dark"] #licenseModal #licenseBody code {
  background: rgba(56, 189, 248, 0.1) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.32) !important;
  box-shadow: 0 2px 10px rgba(0, 194, 255, 0.12) !important;
}

:root[data-theme="light"] #licenseModal #licenseBody code {
  background: #e0f2fe !important;
  color: #0284c7 !important;
  border: 1px solid #bae6fd !important;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08) !important;
}

#licenseModal #licenseBody code:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* Device Limit (Row 4) */
#licenseModal #licenseBody > div > div:first-child > div:last-child span:last-child {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--ink) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  background: var(--card) !important;
  border: 1px solid var(--stroke) !important;
}

/* Bottom Actions Wrapper */
#licenseModal #licenseBody > div > div:last-child {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  margin-top: 18px !important;
  padding-top: 18px !important;
  border-top: 1px solid var(--stroke-2) !important;
  text-align: left !important;
}

/* Renewal Action Button */
.btn-lic-renew {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 10px 20px !important;
  font-size: 13.5px !important;
  font-weight: 700 !important;
  border-radius: 12px !important;
  text-decoration: none !important;
  background: linear-gradient(135deg, #00C2FF 0%, #0072FF 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 20px rgba(0, 194, 255, 0.35) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

.btn-lic-renew:hover {
  transform: translateY(-1.5px) !important;
  box-shadow: 0 8px 26px rgba(0, 194, 255, 0.5) !important;
  filter: brightness(1.08) !important;
}

/* Close Button (#btnLicCloseAction) */
#licenseModal #btnLicCloseAction {
  padding: 10px 20px !important;
  border-radius: 12px !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  border: 1px solid var(--stroke) !important;
  background: var(--seg-bg) !important;
  color: var(--ink-2) !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
}

#licenseModal #btnLicCloseAction:hover {
  background: var(--card-inner) !important;
  color: var(--ink) !important;
  border-color: var(--ink-3) !important;
  transform: translateY(-1px) !important;
}

/* Row icons */
.lic-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Footer Trust Badge */
.lic-trust-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.01em;
}

.lic-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  display: inline-block;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* License Lock Screen */
.license-lock {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px;
  background: var(--bg); backdrop-filter: blur(20px);
}
.lock-card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--stroke);
  border-radius: 28px; box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 194, 255, 0.15); padding: 40px 36px; text-align: center;
  animation: pop-in .35s cubic-bezier(.2,.8,.2,1);
}
.lock-logo { width: 92px; height: 92px; border-radius: 50%; box-shadow: 0 8px 28px rgba(0, 194, 255, 0.4); margin-bottom: 20px; object-fit: contain; }
.lock-card h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; color: var(--ink); letter-spacing: -0.02em; }
.lock-card > p { font-size: 13.5px; color: var(--ink-2); margin-bottom: 24px; }
.lock-card .lock-field { text-align: center; font-size: 15px; height: 48px; border-radius: 14px; margin-bottom: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.lock-card .btn { width: 100%; height: 48px; font-size: 15px; font-weight: 600; border-radius: 14px; }
.lock-msg { font-size: 13px; color: var(--danger); min-height: 20px; margin-top: 14px; font-weight: 500; }
.lock-buy { display: inline-block; margin-top: 10px; font-size: 13.5px; color: var(--accent); text-decoration: none; font-weight: 600; }
.lock-buy:hover { text-decoration: underline; }
/* Hide all toasts while license lock screen is visible */
.license-lock:not(.hidden) ~ #globalToast,
.license-lock:not(.hidden) ~ .toast-host { display: none !important; }

/* Toast Notifications */
.toast-host {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  display: flex; align-items: center; gap: 12px; background: var(--card); color: var(--ink);
  border: 1px solid var(--stroke); border-left: 4px solid var(--warn); border-radius: 14px;
  padding: 14px 22px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  opacity: 0; transform: translateY(-16px) scale(.96); transition: .3s cubic-bezier(.2,.8,.2,1);
}
.toast.show { opacity: 1; transform: none; }
.toast-ic { font-size: 18px; line-height: 1; }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--danger); }
.toast-success { border-left-color: var(--ok); }
.toast-info { border-left-color: var(--fb); }

.session-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--stroke);
  background: var(--card-inner); color: var(--ink-2); white-space: nowrap; flex-shrink: 0;
}
.session-pill #sessionText { white-space: nowrap; }
.session-pill .led { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.session-pill.on, .session-pill.ok { color: var(--ok); border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.12); }
.session-pill.on .led, .session-pill.ok .led { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.session-pill.warn { color: var(--danger); border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.12); }
.session-pill.warn .led { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--stroke);
  background: var(--card-inner); color: var(--ink); cursor: pointer; font-size: 16px;
  display: grid; place-items: center; transition: .2s ease; flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 0 12px var(--fb-glow); }

.kebab-wrap { position: relative; }
.kebab-menu {
  position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 60; min-width: 220px;
  background: var(--card); backdrop-filter: blur(20px);
  border: 1px solid var(--stroke); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 8px; animation: pop-in .18s ease;
}
.kmenu-item {
  width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--ink); padding: 10px 14px;
  border-radius: 10px; display: flex; align-items: center; gap: 10px; transition: .15s;
}
.kmenu-item:hover { background: rgba(56, 189, 248, 0.12); color: var(--accent); }
.kmenu-item.danger { color: var(--danger); }
.kmenu-item.danger:hover { background: rgba(239, 68, 68, 0.15); }
.kmenu-sep { height: 1px; background: var(--stroke); margin: 6px 8px; }

.hidden,
[hidden],
.modal-overlay.hidden,
#licenseModal.hidden,
#confirmModal.hidden,
#licenseLock,
.license-lock {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  z-index: -99999 !important;
}

.modal-overlay:not(.hidden) {
  display: grid !important;
  visibility: visible !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  z-index: 99999 !important;
}


/* LINE Live Preview Stretch to Match Main Workbench Height */
.panel-section[data-panel="line"] .workbench-grid {
  align-items: stretch;
}
.panel-section[data-panel="line"] .workbench-side {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.panel-section[data-panel="line"] .workbench-side > .card.chat-preview-box,
.panel-section[data-panel="line"] .workbench-side > .card:only-child,
.panel-section[data-panel="line"] .workbench-side > .chat-preview-box {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel-section[data-panel="line"] .chat-preview-box .line-chat,
.panel-section[data-panel="line"] .chat-preview-box .chat {
  flex: 1 1 auto;
  height: 100%;
  min-height: 250px;
}


/* FB Workbench & Card 4 Compact + Chat Preview Full Height */
.workbench-side > .card:first-child {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  flex: 0 0 auto;
  height: auto;
  min-height: auto;
}
.workbench-side > .card:first-child .card-title {
  margin-top: 0;
  padding-top: 0;
}
.workbench-side > .card:first-child #sendControls {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
}
.workbench-side > .card:first-child #btnSend {
  margin-top: 6px;
}

/* Chat Live Preview Stretching to Match Card 3 */
.workbench-side > .card.chat-preview-box,
.workbench-side > .chat-preview-box {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.workbench-side .card.chat-preview-box .chat,
.workbench-side .card.chat-preview-box .line-chat {
  flex: 1 1 auto;
  height: 100%;
  min-height: 250px;
}


/* History 2-Column Layout */
.history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
  width: 100%;
}
@media (max-width: 990px) {
  .history-grid {
    grid-template-columns: 1fr;
  }
}
.history-col {
  display: flex;
  flex-direction: column;
  min-height: 380px;
}
.hist-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hist-container > .empty {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  background: var(--card-inner);
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
  padding: 24px;
}


/* ================= STUDIO AI (POTOGEN STUDIO) SEAMLESS WRAPPER ================= */
[data-panel="potogen_studio"],
#potoShell,
#potoScroll,
#potoMainGrid {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

:root[data-theme="light"] [data-panel="potogen_studio"],
:root[data-theme="light"] #potoShell,
:root[data-theme="light"] #potoScroll,
:root[data-theme="light"] #potoMainGrid {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  color: #0f172a !important;
}

:root[data-theme="light"] [data-panel="potogen_studio"] .card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04) !important;
  color: #0f172a !important;
}

/* Number badges */
:root[data-theme="light"] [data-panel="potogen_studio"] span[style*="width:24px"] {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  color: #1d4ed8 !important;
}

/* Text Colors */
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="color:#fff"],
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="color: #fff"],
:root[data-theme="light"] [data-panel="potogen_studio"] span[style*="color:#fff"],
:root[data-theme="light"] [data-panel="potogen_studio"] span[style*="color: #fff"],
:root[data-theme="light"] [data-panel="potogen_studio"] label[style*="color:#fff"],
:root[data-theme="light"] [data-panel="potogen_studio"] label[style*="color: #fff"],
:root[data-theme="light"] [data-panel="potogen_studio"] label[style*="color:#cbd5e1"] {
  color: #0f172a !important;
}

:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="color:#94a3b8"],
:root[data-theme="light"] [data-panel="potogen_studio"] span[style*="color:#94a3b8"],
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="color:#64748b"] {
  color: #64748b !important;
}

/* Inner card boxes and wraps (Soft subtle styling - no double card frames) */
:root[data-theme="light"] [data-panel="potogen_studio"] .textarea-wrap {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #0f172a !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="background:rgba(15,23,42"],
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="background: rgba(15, 23, 42"],
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="background:rgba(6,9,16"],
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="background: rgba(6, 9, 16"] {
  background: #f8fafc !important;
  border-color: #f1f5f9 !important;
  box-shadow: none !important;
  color: #0f172a !important;
}

/* Inputs, Textareas, Selects */
:root[data-theme="light"] [data-panel="potogen_studio"] textarea,
:root[data-theme="light"] [data-panel="potogen_studio"] input[type="text"],
:root[data-theme="light"] [data-panel="potogen_studio"] input[type="password"],
:root[data-theme="light"] [data-panel="potogen_studio"] select {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

:root[data-theme="light"] [data-panel="potogen_studio"] textarea::placeholder,
:root[data-theme="light"] [data-panel="potogen_studio"] input::placeholder {
  color: #94a3b8 !important;
}

/* Template Chips */
:root[data-theme="light"] [data-panel="potogen_studio"] .template-chip {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .template-chip:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .template-chip.active {
  background: #eff6ff !important;
  border: 1px solid #3b82f6 !important;
  color: #1d4ed8 !important;
  font-weight: 600 !important;
}

/* Color Chips */
:root[data-theme="light"] [data-panel="potogen_studio"] .color-chip {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .color-chip:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

/* Small Buttons & Action Buttons */
:root[data-theme="light"] [data-panel="potogen_studio"] .btn-tiny,
:root[data-theme="light"] [data-panel="potogen_studio"] .btn-action.secondary {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .btn-tiny:hover,
:root[data-theme="light"] [data-panel="potogen_studio"] .btn-action.secondary:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

/* Gallery Showcase Box */
:root[data-theme="light"] [data-panel="potogen_studio"] #potoShowcaseBox {
  background: #f1f5f9 !important;
  border: 2px dashed #93c5fd !important;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.03), 0 4px 16px rgba(0, 0, 0, 0.05) !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] #potoShowcaseEmptyState {
  color: #64748b !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] #potoShowcaseEmptyState svg {
  stroke: #94a3b8 !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] #potoShowcasePlaceholder {
  background: rgba(255, 255, 255, 0.95) !important;
  color: #0f172a !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] #potoShowcaseTag {
  background: rgba(255, 255, 255, 0.95) !important;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe !important;
}

/* Gallery Slots & Time Filters */
:root[data-theme="light"] [data-panel="potogen_studio"] .poto-slot-skeleton {
  background: #f8fafc !important;
  border: 1px dashed #cbd5e1 !important;
  color: #94a3b8 !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .poto-slot-skeleton svg {
  stroke: #cbd5e1 !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .gal-chip {
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  color: #475569 !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .gal-chip.active {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6) !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] #potoPagePrev,
:root[data-theme="light"] [data-panel="potogen_studio"] #potoPageNext {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #475569 !important;
}

/* 4K Upscale Comparison Box */
:root[data-theme="light"] [data-panel="potogen_studio"] #potoUpDropBox {
  background: #f8fafc !important;
  border: 2px dashed #93c5fd !important;
  color: #0f172a !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] #potoUpResultBox {
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

/* Dividers & Borders */
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="border-top:1px solid rgba(255,255,255"],
:root[data-theme="light"] [data-panel="potogen_studio"] div[style*="border-bottom:1px solid rgba(255,255,255"] {
  border-color: #e2e8f0 !important;
}


/* Segmented Buttons in Studio AI (Scale & Noise Reduction) */
:root[data-theme="light"] [data-panel="potogen_studio"] .segmented-btn,
:root[data-theme="light"] [data-panel="potogen_studio"] button.segmented-btn {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #475569 !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .segmented-btn:hover,
:root[data-theme="light"] [data-panel="potogen_studio"] button.segmented-btn:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}
:root[data-theme="light"] [data-panel="potogen_studio"] .segmented-btn.active,
:root[data-theme="light"] [data-panel="potogen_studio"] button.segmented-btn.active {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6) !important;
  border: 1px solid #2563eb !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3) !important;
}

/* Studio AI App Footer */
:root[data-theme="light"] [data-panel="potogen_studio"] > div > div:last-child {
  background: #f8fafc !important;
  border-top: 1px solid #e2e8f0 !important;
  color: #64748b !important;
}


/* ===== SIDEBAR TOP ALIGNMENT & DEDICATED VISIBLE SCROLLBAR ===== */
.sidebar {
  justify-content: flex-start !important;
  gap: 8px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-width: thin !important;
  scrollbar-color: rgba(56, 189, 248, 0.6) rgba(15, 23, 42, 0.8) !important;
}
.sidebar-footer {
  margin-top: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}
.sidebar::-webkit-scrollbar {
  width: 7px !important;
  display: block !important;
}
.sidebar::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.8) !important;
  border-radius: 4px !important;
}
.sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #38bdf8, #2563eb) !important;
  border-radius: 4px !important;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5) !important;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: #60a5fa !important;
}
