:root{
  --rspg-header-purple:#432064;
  --rspg-header-purple-2:#542979;
  --rspg-header-gold:#e1b934;
  --rspg-header-text:#fff;
  --rspg-header-muted:#e8dff1;
  --rspg-header-line:rgba(255,255,255,.16);
}

/* ให้แผงค้นหาของหน้าสาธารณะลอยเหนือ Header ได้ */
.utility-bar{position:relative;z-index:10000;}

.rspg-site-header,
.rspg-site-header *{box-sizing:border-box;}

.rspg-site-header{
  position:sticky;
  top:0;
  z-index:9999;
  width:100%;
  color:var(--rspg-header-text);
  background:linear-gradient(110deg,var(--rspg-header-purple),var(--rspg-header-purple-2));
  border-bottom:1px solid rgba(255,255,255,.12);
  box-shadow:0 8px 24px rgba(31,16,47,.14);
  font-family:'Sarabun','Noto Sans Thai',Tahoma,sans-serif;
}

.rspg-header__inner{
  width:min(1440px,calc(100% - 40px));
  min-height:82px;
  margin:0 auto;
  display:flex;
  align-items:center;
  gap:24px;
}

.rspg-header__brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:320px;
  color:#fff !important;
  text-decoration:none !important;
}

.rspg-header__brand img{
  width:48px;
  height:48px;
  flex:0 0 48px;
  object-fit:contain;
  padding:3px;
  border-radius:10px;
  background:#fff;
  box-shadow:0 3px 10px rgba(20,8,35,.18);
}

.rspg-header__brand-text{display:block;min-width:0;line-height:1.25;}
.rspg-header__brand-text strong{
  display:block;
  color:#fff;
  font-family:'Chonburi','Sarabun',serif;
  font-size:17px;
  font-weight:400;
  white-space:nowrap;
}
.rspg-header__brand-text small{
  display:block;
  margin-top:4px;
  color:var(--rspg-header-muted);
  font-family:'Mitr','Sarabun',sans-serif;
  font-size:10.5px;
  letter-spacing:.025em;
}

.rspg-header__nav{margin-left:auto;align-self:stretch;display:flex;align-items:stretch;}
.rspg-header__menu,.rspg-header__dropdown{list-style:none;margin:0;padding:0;}
.rspg-header__menu{display:flex;align-items:stretch;gap:2px;}
.rspg-header__item{position:relative;display:flex;align-items:stretch;}
.rspg-header__item>a,.rspg-header__trigger{
  min-height:48px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  padding:0 12px;
  border:0;
  border-radius:10px;
  background:transparent;
  color:#f8f4fb !important;
  font:600 13px/1.2 'Sarabun','Noto Sans Thai',Tahoma,sans-serif;
  text-decoration:none !important;
  white-space:nowrap;
  cursor:pointer;
  transition:background .16s ease,color .16s ease;
}
.rspg-header__item>a:hover,.rspg-header__trigger:hover,
.rspg-header__item.is-active>a,.rspg-header__item.is-active>.rspg-header__trigger,
.rspg-header__item.is-open>.rspg-header__trigger{
  color:#fff !important;
  background:rgba(255,255,255,.13);
}
.rspg-header__item.is-active::after{
  content:'';
  position:absolute;
  left:12px;
  right:12px;
  bottom:10px;
  height:3px;
  border-radius:99px;
  background:var(--rspg-header-gold);
}
.rspg-header__chevron{
  width:7px;height:7px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;
  transform:rotate(45deg) translateY(-2px);transition:transform .16s ease;
}
.rspg-header__item.is-open .rspg-header__chevron,
.rspg-header__item:focus-within .rspg-header__chevron{transform:rotate(225deg) translate(-1px,-1px);}

.rspg-header__dropdown{
  position:absolute;
  top:calc(100% - 8px);
  left:0;
  z-index:20;
  min-width:245px;
  padding:8px;
  border:1px solid #e8dfee;
  border-radius:14px;
  background:#fff;
  box-shadow:0 18px 44px rgba(41,20,60,.22);
  opacity:0;
  visibility:hidden;
  transform:translateY(8px);
  transition:opacity .16s ease,visibility .16s ease,transform .16s ease;
}
.rspg-header__dropdown--end{left:auto;right:0;}
.rspg-header__dropdown li{display:block;}
.rspg-header__dropdown a{
  display:flex;
  align-items:center;
  min-height:40px;
  padding:9px 12px;
  border-radius:9px;
  color:#45364e !important;
  font:500 13px/1.35 'Sarabun','Noto Sans Thai',Tahoma,sans-serif;
  text-decoration:none !important;
  white-space:nowrap;
}
.rspg-header__dropdown a:hover,.rspg-header__dropdown a.is-active{
  color:var(--rspg-header-purple) !important;
  background:#f3edf8;
}
@media (hover:hover){
  .rspg-header__item--dropdown:hover>.rspg-header__dropdown,
  .rspg-header__account:hover>.rspg-header__dropdown{opacity:1;visibility:visible;transform:translateY(0);}
}
.rspg-header__item.is-open>.rspg-header__dropdown,
.rspg-header__item:focus-within>.rspg-header__dropdown{opacity:1;visibility:visible;transform:translateY(0);}

.rspg-header__account{margin-left:4px;}
.rspg-header__account-trigger{padding:5px 8px !important;min-width:150px;justify-content:flex-start;}
.rspg-header__avatar{
  width:34px;height:34px;flex:0 0 34px;display:grid;place-items:center;border-radius:50%;
  background:var(--rspg-header-gold);color:#3c2a04;font-weight:700;font-size:14px;
}
.rspg-header__account-copy{display:block;min-width:0;text-align:left;line-height:1.2;}
.rspg-header__account-copy strong{display:block;max-width:128px;overflow:hidden;text-overflow:ellipsis;color:#fff;font-size:12px;white-space:nowrap;}
.rspg-header__account-copy small{display:block;margin-top:3px;color:var(--rspg-header-muted);font-size:10px;font-weight:400;}
.rspg-header__mobile-toggle{display:none;}

/* ซ่อน Header เดิมเฉพาะหน้าที่เรียกใช้ Header กลางแล้ว */
body.rspg-has-unified-header>.topbar,
body.rspg-has-unified-header>.portal-topbar,
body.rspg-has-unified-header>.as-top,
body.rspg-has-unified-header>.ad-topbar,
body.rspg-has-unified-header>.top,
body.rspg-has-unified-header>header.top{display:none !important;}

/* แถบคำสั่งเฉพาะหน้าแบบประเมินยังจำเป็น (พิมพ์ผล/กลับรายการ) */
body.rspg-has-unified-header.rspg-assessment--review>header.top{
  display:flex !important;
  padding:10px 20px;
  border-bottom:1px solid #e2d9e9;
  background:#fff;
  color:#46334f;
  box-shadow:none;
}
body.rspg-has-unified-header.rspg-assessment--review>header.top a{
  color:#5b2f83;
  font-weight:600;
}
body.rspg-has-unified-header.rspg-assessment--review .workspace{
  height:calc(100vh - 233px);
}

@media (max-width:1180px){
  .rspg-header__inner{width:min(100% - 28px,1440px);min-height:74px;gap:14px;}
  .rspg-header__brand{min-width:0;margin-right:auto;}
  .rspg-header__brand img{width:44px;height:44px;flex-basis:44px;}
  .rspg-header__brand-text strong{font-size:15px;}
  .rspg-header__mobile-toggle{
    display:flex;align-items:center;gap:8px;padding:9px 12px;border:1px solid rgba(255,255,255,.28);
    border-radius:10px;background:rgba(255,255,255,.08);color:#fff;font:600 13px 'Sarabun',sans-serif;cursor:pointer;
  }
  .rspg-header__hamburger,.rspg-header__hamburger::before,.rspg-header__hamburger::after{
    width:18px;height:2px;display:block;border-radius:2px;background:currentColor;content:'';
  }
  .rspg-header__hamburger{position:relative;}
  .rspg-header__hamburger::before{position:absolute;top:-6px;left:0;}
  .rspg-header__hamburger::after{position:absolute;top:6px;left:0;}
  .rspg-header__nav{
    position:absolute;top:100%;left:0;right:0;display:none;margin:0;padding:10px 14px 16px;
    border-top:1px solid var(--rspg-header-line);background:var(--rspg-header-purple);
    box-shadow:0 16px 30px rgba(33,16,49,.2);max-height:calc(100vh - 74px);overflow:auto;
  }
  .rspg-site-header.is-mobile-open .rspg-header__nav{display:block;}
  .rspg-header__menu{display:block;}
  .rspg-header__item{display:block;}
  .rspg-header__item>a,.rspg-header__trigger{width:100%;min-height:44px;justify-content:space-between;padding:0 13px;}
  .rspg-header__item.is-active::after{left:12px;right:auto;top:12px;bottom:12px;width:3px;height:auto;}
  .rspg-header__dropdown,.rspg-header__dropdown--end{
    position:static;display:none;min-width:0;margin:2px 0 7px 12px;padding:5px;border:0;border-radius:10px;
    background:rgba(255,255,255,.96);box-shadow:none;opacity:1;visibility:visible;transform:none;
  }
  .rspg-header__item.is-open>.rspg-header__dropdown{display:block;}
  .rspg-header__dropdown a{white-space:normal;}
  .rspg-header__account{margin:4px 0 0;}
  .rspg-header__account-trigger{min-width:0 !important;}
  .rspg-header__account-copy{margin-right:auto;}
  .rspg-header__account-copy strong{max-width:none;}
}

@media (max-width:980px){
  body.rspg-has-unified-header.rspg-assessment--review .workspace{height:auto;}
}

@media (max-width:620px){
  .rspg-header__inner{width:calc(100% - 20px);min-height:68px;}
  .rspg-header__brand{gap:9px;}
  .rspg-header__brand img{width:40px;height:40px;flex-basis:40px;border-radius:8px;}
  .rspg-header__brand-text strong{font-family:'Sarabun',sans-serif;font-size:13px;font-weight:700;white-space:normal;line-height:1.15;}
  .rspg-header__brand-text small{font-size:9px;margin-top:2px;}
  .rspg-header__mobile-toggle span:last-child{display:none;}
  .rspg-header__mobile-toggle{padding:10px;}
}

@media print{
  .rspg-site-header{display:none !important;}
}
