/* ShwTube header — single source of truth for desktop/mobile and RTL/LTR. */
.yt-header{position:fixed;inset:0 0 auto 0;height:var(--header-h);z-index:1000;background:var(--surface);border-bottom:1px solid var(--line);isolation:isolate}
.yt-header-inner{height:100%;width:100%;display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,760px) minmax(0,1fr);align-items:center;gap:20px;padding:0 18px;direction:inherit}
.header-start,.header-end{display:flex;align-items:center;min-width:0;gap:8px}
.header-start{justify-self:start}
.header-end{justify-self:end}
.menu-btn,.header-icon,.mobile-search-toggle{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;flex:0 0 40px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--text);cursor:pointer;text-decoration:none}
.menu-btn:hover,.header-icon:hover,.mobile-search-toggle:hover{background:var(--hover)}
.icon-search{width:18px;height:18px;border:2px solid currentColor;border-radius:50%;position:relative;display:block}
.icon-search::after{content:"";position:absolute;width:7px;height:2px;background:currentColor;border-radius:2px;right:-5px;bottom:-2px;transform:rotate(45deg);transform-origin:left center}
.account-icon{position:relative;display:inline-flex;align-items:flex-end;justify-content:center;overflow:hidden;width:34px;height:34px;border-radius:50%;background:#ff6600;flex:0 0 34px}
.account-icon::before{content:"";position:absolute;top:7px;width:9px;height:9px;border-radius:50%;background:#fff}
.account-icon::after{content:"";position:absolute;bottom:5px;width:18px;height:10px;border-radius:10px 10px 5px 5px;background:#fff}
.account-icon>span{display:none}
.brand{display:inline-flex;align-items:center;gap:7px;min-width:0;text-decoration:none;color:var(--text);font-weight:800;font-size:20px;letter-spacing:-.4px;white-space:nowrap}
html[dir="ltr"] .brand{flex-direction:row-reverse}
html[dir="rtl"] .brand{flex-direction:row}
.brand-name{display:inline-block;overflow:hidden;text-overflow:ellipsis}
.brand-mark{width:34px;height:24px;flex:0 0 34px;border-radius:8px;background:var(--accent);display:grid;place-items:center;position:relative}
.brand-mark::after{content:"";width:0;height:0;border-left:8px solid #fff;border-top:5px solid transparent;border-bottom:5px solid transparent;margin-left:2px}
.brand-country{align-self:flex-start;margin-top:4px;font-size:10px;color:var(--muted)}
.header-search{display:flex;align-items:center;justify-self:center;width:100%;max-width:760px;min-width:0}
.header-search input{width:100%;min-width:0;height:40px;border:1px solid var(--line);border-inline-end:0;border-radius:20px 0 0 20px;padding:0 18px;background:var(--bg);color:var(--text);outline:none}
html[dir="rtl"] .header-search input{border-radius:0 20px 20px 0;border-inline-start:0;border-inline-end:1px solid var(--line)}
.header-search input:focus{border-color:#1c62b9;box-shadow:0 0 0 1px #1c62b9}
.header-search button{width:64px;height:40px;flex:0 0 64px;border:1px solid var(--line);border-radius:0 20px 20px 0;background:var(--surface-2);color:var(--text);cursor:pointer}
html[dir="rtl"] .header-search button{border-radius:20px 0 0 20px}
.header-search button:hover{background:var(--surface-3)}
.create-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:40px;padding:0 14px;border-radius:20px;background:var(--surface-2);color:var(--text);text-decoration:none;font-weight:600;white-space:nowrap}
.create-btn:hover{background:var(--surface-3)}
.account-link{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:40px;color:var(--text);text-decoration:none}
.account-text{font-weight:600;white-space:nowrap}
.account-icon{width:34px;height:34px;border-radius:50%;background:#ff6600;color:#fff;font-size:14px}
.header-avatar{width:34px;height:34px;flex:0 0 34px;border-radius:50%;object-fit:cover;background:var(--surface-2)}
.mobile-search-toggle{display:none}
.header-end .theme-btn{display:inline-flex}

@media (max-width:980px){
  :root{--header-h:56px;--sidebar-w:0px}
  .yt-header{height:var(--header-h);overflow:visible}
  .yt-header-inner{display:grid;grid-template-columns:auto minmax(38px,1fr) auto;align-items:center;gap:7px;padding:0 10px}
  .header-start,.header-end{min-width:0;gap:5px}
  .header-start{grid-column:1}
  .mobile-search-toggle{display:inline-flex;grid-column:2;justify-self:center}
  .header-end{grid-column:3;justify-self:end;margin-inline-start:0}
  html[dir="rtl"] .header-start{grid-column:3;justify-self:end}
  html[dir="rtl"] .mobile-search-toggle{grid-column:2}
  html[dir="rtl"] .header-end{grid-column:1;justify-self:start}
  .header-search{display:none;position:absolute;top:calc(100% + 8px);left:8px;right:8px;width:auto;max-width:none;margin:0;padding:5px;border:1px solid var(--line);border-radius:24px;background:var(--surface);box-shadow:0 8px 28px rgba(0,0,0,.16);z-index:1100}
  body.mobile-search-open .header-search{display:flex}
  .header-search input{height:40px;border:0!important;border-radius:20px!important;box-shadow:none!important;padding:0 13px}
  .header-search button{height:40px;width:44px;flex-basis:44px;border:0;border-radius:50%!important}
  .brand{font-size:18px;gap:5px}
  .brand-mark{width:30px;height:21px;flex-basis:30px;border-radius:6px}
  .brand-country{display:none}
  .menu-btn,.mobile-search-toggle{width:38px;height:38px;flex-basis:38px}
  .menu-btn .material-icon,.mobile-search-toggle .material-icon{font-size:23px}
  .header-end .theme-btn{display:none}
  .create-btn{height:38px;min-width:38px;padding:0 10px;border-radius:19px;gap:4px;font-size:12px}
  .create-btn .material-icon{font-size:21px}
  .account-link{min-height:38px}
  .account-text{display:none}
  .account-icon,.header-avatar{width:32px;height:32px;flex-basis:32px}
  .account-icon::before{top:7px;width:8px;height:8px}
  .account-icon::after{bottom:5px;width:17px;height:9px}

}

@media (max-width:520px){
  .yt-header-inner{padding:0 7px;gap:5px}
  .brand-name{max-width:82px}
  .brand{font-size:17px}
  .create-btn{width:38px;padding:0}
  .create-btn>span:last-child{display:none}
  .header-start,.header-end{gap:3px}
}

@media (max-width:360px){
  .brand-name{max-width:68px}
  .menu-btn,.mobile-search-toggle{width:36px;height:36px;flex-basis:36px}
  .create-btn{width:36px;height:36px}
  .account-icon,.header-avatar{width:30px;height:30px;flex-basis:30px}
}

/* v118 — mobile RTL/LTR final alignment.
   The page already uses header-start/header-end; older app.css rules target
   brand-wrap/header-actions and must not participate in the mobile header. */
@media (max-width:980px){
  .yt-header,
  .yt-header-inner{overflow:visible!important}

  .yt-header-inner{
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    flex-direction:row!important;
    width:100%!important;
    height:56px!important;
    padding:0 8px!important;
    gap:8px!important;
    direction:ltr!important;
  }

  .header-start,
  .header-end{
    display:flex!important;
    align-items:center!important;
    flex:0 0 auto!important;
    min-width:0!important;
    margin:0!important;
    width:auto!important;
    gap:5px!important;
  }

  .header-start{order:1!important;justify-self:auto!important}
  .mobile-search-toggle{order:2!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;flex:0 0 38px!important;width:38px!important;height:38px!important;position:relative!important;z-index:2!important;color:var(--text)!important;background:transparent!important}
  .mobile-search-toggle .icon-search{display:block!important;width:18px!important;height:18px!important;flex:0 0 18px!important;border:2px solid currentColor!important;border-radius:50%!important;position:relative!important;color:var(--text)!important;opacity:1!important;visibility:visible!important}
  .mobile-search-toggle .icon-search::after{content:""!important;display:block!important;position:absolute!important;width:7px!important;height:2px!important;right:-5px!important;bottom:-2px!important;background:currentColor!important;border-radius:2px!important;transform:rotate(45deg)!important;transform-origin:left center!important}
  .header-end{order:3!important;justify-self:auto!important}

  /* Physical mirroring: Arabic controls are on the right, actions on the left.
     English keeps the existing left-to-right arrangement unchanged. */
  html[dir="rtl"] .header-start{order:3!important;justify-self:flex-end!important}
  html[dir="rtl"] .mobile-search-toggle{order:2!important;justify-self:center!important}
  html[dir="rtl"] .header-end{order:1!important;justify-self:flex-start!important}
  html[dir="ltr"] .header-start{order:1!important;justify-self:flex-start!important}
  html[dir="ltr"] .mobile-search-toggle{order:2!important;justify-self:center!important}
  html[dir="ltr"] .header-end{order:3!important;justify-self:flex-end!important}

  html[dir="rtl"] .header-start,
  html[dir="rtl"] .header-end{direction:rtl!important}
  html[dir="ltr"] .header-start,
  html[dir="ltr"] .header-end{direction:ltr!important}

  .brand{display:inline-flex!important;flex:0 0 auto!important;max-width:none!important}
  .brand-name{max-width:none!important}

  .header-end .theme-btn{display:none!important}
  .create-btn{display:inline-flex!important;flex:0 0 auto!important;width:38px!important;height:38px!important;min-width:38px!important;padding:0!important;border-radius:50%!important}
  .create-btn > span:last-child{display:none!important}
  .account-link{display:inline-flex!important;flex:0 0 auto!important;min-height:38px!important}
  .account-text{display:none!important}
  .account-icon,.header-avatar{width:32px!important;height:32px!important;flex:0 0 32px!important}

  /* The full search input remains hidden until the search icon is pressed. */
  .header-search{
    display:none!important;
    position:absolute!important;
    top:calc(100% + 8px)!important;
    left:8px!important;
    right:8px!important;
    width:auto!important;
    max-width:none!important;
    margin:0!important;
    padding:5px!important;
    z-index:1100!important;
  }
  body.mobile-search-open .header-search{display:flex!important}
}

@media (max-width:520px){
  .yt-header-inner{padding:0 6px!important;gap:5px!important}
  .header-start,.header-end{gap:3px!important}
  .mobile-search-toggle{width:36px!important;height:36px!important;flex-basis:36px!important}
  .menu-btn{width:36px!important;height:36px!important;flex-basis:36px!important}
  .create-btn{width:36px!important;height:36px!important;min-width:36px!important}
  .account-icon,.header-avatar{width:30px!important;height:30px!important;flex-basis:30px!important}
}
