.top-actions-account-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 36px;
  padding: 3px 12px;
  border: 1px solid #403653;
  border-radius: 10px;
  background: linear-gradient(135deg,#211a31,#15151e);
  color: #f5f0fb;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.account-link:hover { border-color: #9b7aed; background: #2a2040; transform: translateY(-1px); }
.account-link .avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  overflow: hidden;
  border: 1px solid #8166c7;
  border-radius: 50%;
  background: linear-gradient(135deg,#6244ab,#242039);
  font-size: 11px;
}
.account-link .avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.account-link .avatar.has-image { border-radius: 8px; }
.account-label { font-size: 12px; font-weight: 750; line-height: 1; }
.topbar:not(.has-header-ad) > .top-actions { grid-column: 3; }

.topbar.has-header-ad {
  --editor-header-height: 102px;
  height: var(--editor-header-height);
  flex: 0 0 var(--editor-header-height);
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,728px) minmax(0,1fr);
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-inline: 12px;
  position: relative;
  background: #0c0c12;
}
.studio:not(.phone-preview-layout) .topbar.has-header-ad ~ .workspace { flex: 1 1 0; height: auto; min-height: 0; }
.topbar.has-header-ad > .header-identity {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  width: 100%;
  height: 70px;
  padding: 0;
}
.topbar.has-header-ad .header-identity > .brand {
  flex: 0 0 clamp(106px,7.8vw,132px);
  width: auto;
  min-width: 0;
  height: 42px;
  justify-content: center;
  padding: 0 8px;
  border: 0;
}
.topbar.has-header-ad .header-identity > .brand img { display: block; width: 100%; max-width: 125px; }
.topbar.has-header-ad > .header-ad-placement {
  grid-column: 2;
  justify-self: center;
  align-self: center;
  position: relative;
  inset: auto;
  transform: none;
  width: 100%;
  max-width: 728px;
  min-width: 0;
  z-index: 1;
}
.topbar.has-header-ad > .top-actions {
  grid-column: 3;
  justify-self: end;
  align-self: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: min(222px,100%);
  min-width: 0;
  height: 70px;
  padding: 0;
}
.topbar.has-header-ad .top-actions-account-row { justify-content: space-between; width: 100%; }
.topbar.has-header-ad .editor-language { border-color: transparent; background: transparent; padding-inline: 2px; }
.topbar.has-header-ad .editor-language:hover { border-color: transparent; background: #211a31; }
.topbar.has-header-ad .account-link {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 30px;
  justify-content: flex-start;
  padding: 0 2px;
  border-color: transparent;
  background: transparent;
}
.topbar.has-header-ad .account-link:hover { border-color: #403653; background: #211a31; }
.topbar.has-header-ad .account-link .avatar { width: 30px; height: 30px; flex-basis: 30px; }
.topbar.has-header-ad .account-label { font-size: 13px; }
.topbar.has-header-ad .export-button { width: 100%; min-height: 36px; padding: 7px 10px; }

.editor-ad-slot { width: 100%; max-width: 728px; aspect-ratio: 728/90; position: relative; overflow: hidden; margin-inline: auto; background: #111219; border: 1px solid #3a304d; border-radius: 8px; }
.editor-ad-slot iframe { position: absolute; top: 0; left: 0; width: 728px; height: 90px; border: 0; transform: scale(var(--ad-scale,1)); transform-origin: top left; background: transparent; }
.editor-ad-slot--adsense { width: 728px; border: 0; overflow: visible; }
.export-progress-dialog.has-export-ads { width: min(780px,calc(100vw - 28px)); max-height: calc(100vh - 24px); overflow-y: auto; padding: 18px 24px; }
.export-ad-placement { width: min(728px,100%); margin-inline: auto; }
.export-ad-placement--top { margin-bottom: 18px; }
.export-ad-placement--bottom { margin-top: 18px; }

@media (min-width: 1101px) and (max-width: 1450px) {
  .topbar.has-header-ad .header-identity > .brand { flex-basis: 48px; padding: 0; }
  .topbar.has-header-ad .header-identity > .brand img { width: 34px; content: url("../brand/medbaa-symbol.svg"); }
}
@media (min-width: 1101px) and (max-width: 1299px) {
  .topbar.has-header-ad { grid-template-columns: minmax(0,1fr) minmax(0,calc(100vw - 580px)) minmax(0,1fr); }
}
@media (max-width: 1100px) {
  .topbar.has-header-ad { --editor-header-height: 164px; grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: 62px minmax(0,1fr); gap: 2px 8px; padding-inline: 9px; }
  .topbar.has-header-ad > .header-identity { grid-column: 1; grid-row: 1; height: 55px; }
  .topbar.has-header-ad > .top-actions { grid-column: 2; grid-row: 1; justify-self: stretch; flex-direction: row; align-items: center; width: auto; height: 55px; gap: 7px; }
  .topbar.has-header-ad .top-actions-account-row { width: auto; flex: 0 1 auto; }
  .topbar.has-header-ad .export-button { flex: 1 1 auto; width: auto; min-height: 36px; }
  .topbar.has-header-ad > .header-ad-placement { grid-column: 1/-1; grid-row: 2; width: min(728px,calc(100vw - 24px)); }
  .topbar.has-header-ad ~ .workspace .library-panel { top: var(--editor-header-height); }
}
@media (min-width: 1101px) and (max-width: 1400px) {
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) { --editor-header-height: 164px; grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: 62px minmax(0,1fr); }
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) > .header-identity { grid-column: 1; grid-row: 1; height: 55px; }
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) > .top-actions { grid-column: 2; grid-row: 1; justify-self: stretch; flex-direction: row; align-items: center; width: auto; height: 55px; }
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) .top-actions-account-row { width: auto; }
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) .export-button { flex: 1; width: auto; }
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) > .header-ad-placement { grid-column: 1/-1; grid-row: 2; width: 728px; }
}
@media (max-width: 900px) {
  .topbar.has-header-ad > .top-actions { flex-direction: column; align-items: stretch; gap: 2px; padding: 3px 6px; }
  .topbar.has-header-ad .top-actions-account-row { width: 100%; }
  .topbar.has-header-ad .account-link { min-height: 25px; padding-block: 0; }
  .topbar.has-header-ad .account-link .avatar { width: 22px; height: 22px; flex-basis: 22px; }
  .topbar.has-header-ad .export-button { flex: 0 0 25px; align-self: stretch; width: 100%; min-height: 25px; padding-block: 2px; font-size: 11px; }
}
@media (min-width: 521px) and (max-width: 800px) {
  .topbar.has-header-ad .editor-language { display: inline-flex; }
  .topbar.has-header-ad .export-button b { display: inline; }
}
@media (max-width: 700px) {
  .topbar.has-header-ad .header-identity > .brand { flex-basis: 44px; padding-inline: 2px; }
  .topbar.has-header-ad .header-identity > .brand img { width: 29px; height: 29px; object-fit: cover; object-position: left; }
}
@media (max-width: 520px) {
  .topbar.has-header-ad { --editor-header-height: 56px; grid-template-rows: 56px; }
  .topbar.has-header-ad > .header-identity,.topbar.has-header-ad > .top-actions { height: 50px; }
  .account-label { display: none; }
  .topbar.has-header-ad .account-link { flex: 0 0 auto; padding-inline: 4px; }
}
@media (max-width: 1100px) and (max-height: 820px) {
  .topbar.has-header-ad { --editor-header-height: 62px; grid-template-rows: 62px; }
  .topbar.has-header-ad > .header-ad-placement { display: none; }
}
@media (max-width: 1400px) and (max-height: 820px) {
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) { --editor-header-height: 62px; grid-template-rows: 62px; }
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) > .header-ad-placement { display: none; }
}
@media (max-width: 751px) {
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) { --editor-header-height: 62px; grid-template-rows: 62px; }
  .topbar.has-header-ad:has(.editor-ad-slot--adsense) > .header-ad-placement { display: none; }
}
@media (max-width: 520px) and (max-height: 820px) {
  .topbar.has-header-ad { --editor-header-height: 56px; grid-template-rows: 56px; }
}
