.top-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px 0 16px;
  background: var(--bg-app);
}

.top-bar-start {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 0 1 auto;
}

.top-bar-search {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.top-bar-end {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
}

.brand-mark .icon {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.brand-name {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-product {
  font-weight: 500;
  color: var(--fg-muted);
}

/* ---- mailbox switcher ---- */

.switcher-slot {
  min-width: 0;
}

.mailbox-switcher {
  position: relative;
  min-width: 0;
}

.switcher-button {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 340px;
  min-width: 0;
  height: 42px;
  padding: 0 10px 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg-raised);
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.switcher-button:hover {
  border-color: var(--fg-subtle);
}

.switcher-button[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.switcher-avatar {
  display: inline-flex;
}

.switcher-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.switcher-address {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switcher-name {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switcher-chevron {
  color: var(--fg-muted);
  margin-left: 2px;
}

/* ---- search ---- */

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 640px;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--fg-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--bg-hover);
  outline: none;
}

.search-input::placeholder {
  color: var(--fg-subtle);
}

.search-input:focus {
  background: var(--bg-raised);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  position: absolute;
  right: 4px;
  width: 32px;
  height: 32px;
}

.search-back {
  display: none;
}

/* ---- console and account ---- */

.console-link {
  min-height: 36px;
  font-size: var(--text-sm);
}

.account {
  position: relative;
}

.account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.account-avatar {
  width: 32px;
  height: 32px;
  background: var(--hue-5-bg);
  color: var(--hue-5-fg);
  font-size: var(--text-xs);
}

.account-button:hover .account-avatar,
.account-button[aria-expanded="true"] .account-avatar {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

@media (max-width: 1100px) {
  .top-bar {
    gap: 8px;
    padding: 0 8px;
  }

  .brand-product {
    display: none;
  }
}

@media (max-width: 900px) {
  .console-label {
    display: none;
  }

  .console-link {
    width: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--fg-muted);
  }
}

@media (max-width: 760px) {
  .brand {
    display: none;
  }

  .top-bar-start {
    flex: 1 1 auto;
    gap: 4px;
  }

  .switcher-button {
    max-width: 100%;
    height: 40px;
    gap: 8px;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }

  .switcher-name {
    display: none;
  }

  .top-bar-search {
    display: none;
  }

  .search-toggle {
    display: inline-flex;
  }

  .top-bar.is-searching .top-bar-search {
    display: flex;
    position: absolute;
    z-index: 35;
    inset: 0;
    align-items: center;
    padding: 0 8px;
    background: var(--bg-app);
  }

  .top-bar.is-searching .search-back {
    display: inline-flex;
    flex: 0 0 auto;
    margin-right: 4px;
  }

  .top-bar.is-searching .search-icon {
    display: none;
  }

  .top-bar.is-searching .search-input {
    padding-left: 12px;
  }
}
