.topbar .brand {
  grid-template-columns: auto minmax(190px, 1fr) minmax(330px, auto) auto 116px;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.header-user {
  box-sizing: border-box;
  min-width: 330px;
  min-height: 62px;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.35rem 0.35rem 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: 0 8px 22px rgb(0 0 0 / 0.06);
}

.header-user > span {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  line-height: 1.2;
}

.header-user > span strong {
  overflow: hidden;
  color: var(--foreground);
  font-size: 0.84rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-user > span small {
  display: block;
  margin: 2px 0 0;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  line-height: 1.2;
}

.header-user .account-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  color: var(--brand-cyan);
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.header-user .account-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.header-user .header-logout button {
  min-height: 36px;
  border: 0;
  background: var(--muted);
  font-size: 0.76rem;
}

.topbar .freshness {
  height: 62px;
  min-height: 62px;
  padding: 0 14px;
  align-items: center;
}

.topbar .freshness .status-dot {
  top: 0;
  margin-left: 0;
}

.header-toggle {
  width: 116px;
  min-width: 116px;
  height: 62px;
  min-height: 62px;
  border-radius: var(--radius-md);
}

.topbar-actions .header-shortcuts {
  min-height: 60px;
  align-items: flex-end;
}

.topbar-actions .help-link {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--foreground);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

.topbar-actions .help-link:hover,
.topbar-actions .help-link:focus-visible {
  border-color: var(--brand-cyan);
  background: var(--muted);
}

.topbar-actions .help-link:focus-visible {
  outline: 2px solid var(--brand-cyan);
  outline-offset: 2px;
}

.header-toggle strong,
.topbar.is-collapsed .header-toggle strong {
  width: 60px;
  color: var(--foreground);
  font-size: 12px !important;
  font-weight: 700;
  line-height: 1;
  text-align: left;
}

.topbar.is-collapsed .brand {
  grid-template-columns: auto minmax(150px, 1fr) minmax(330px, auto) auto 116px;
}

.topbar.is-collapsed .brand-copy > strong {
  font-size: 17px;
}

.topbar.is-collapsed .header-user {
  display: flex;
}

.topbar.is-collapsed .header-user > span strong {
  font-size: 0.84rem;
}

.topbar.is-collapsed .header-user > span small {
  display: block;
}

@media (max-width: 1320px) {
  .topbar .brand-marks {
    min-width: 210px;
  }

  .topbar .rouch-mark {
    width: 148px;
  }

  .header-user {
    min-width: 300px;
  }

  .topbar .brand,
  .topbar.is-collapsed .brand {
    grid-template-columns: auto minmax(170px, 1fr) minmax(300px, auto) auto 116px;
    gap: var(--space-3);
  }
}

@media (max-width: 1120px) {
  .topbar .brand,
  .topbar.is-collapsed .brand {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .topbar .brand-marks {
    grid-column: 1;
    grid-row: 1;
  }

  .brand-copy {
    grid-column: 2 / 4;
    grid-row: 1;
  }

  .header-user {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  .topbar .freshness {
    grid-column: 2;
    grid-row: 2;
  }

  .header-toggle {
    grid-column: 3;
    grid-row: 2;
  }
}

@media (max-width: 720px) {
  .topbar .brand,
  .topbar.is-collapsed .brand {
    grid-template-columns: minmax(0, 1fr) 116px;
  }

  .topbar .brand-marks,
  .topbar.is-collapsed .brand-marks {
    grid-column: 1 / 3;
    grid-row: 1;
  }

  .brand-copy {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .header-user,
  .topbar.is-collapsed .header-user {
    width: 100%;
    min-width: 0;
    grid-column: 1 / 3;
    grid-row: 3;
    justify-self: stretch;
  }

  .topbar .freshness,
  .topbar.is-collapsed .freshness {
    grid-column: 1;
    grid-row: 4;
    justify-self: stretch;
  }

  .header-toggle,
  .topbar.is-collapsed .header-toggle {
    grid-column: 2;
    grid-row: 4;
  }

  .topbar.is-collapsed .brand-copy {
    display: none;
  }

  .topbar.is-collapsed .header-user {
    grid-row: 2;
  }

  .topbar.is-collapsed .freshness,
  .topbar.is-collapsed .header-toggle {
    grid-row: 3;
  }
}

@media (max-width: 560px) {
  .header-user {
    justify-content: flex-end;
    padding-left: 0.75rem;
  }
}

/* Jeton sémantique NSES 0.67 pour les liens textuels. */
:root,
[data-theme="gray"],
[data-theme="dark"] {
  --link: #81D3E4;
}

[data-theme="light"] {
  --link: #08745E;
}

.advisor-reason a,
footer a,
.header-user .account-link {
  color: var(--link);
  font-weight: 700;
  text-decoration: underline solid;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.advisor-reason a:hover,
footer a:hover,
.header-user .account-link:hover {
  color: var(--link);
  text-decoration-thickness: 2px;
}

/* Dimensionnement optique des marques du bandeau.
   Le PNG NSK contient une zone transparente importante : sa hauteur de boîte
   doit donc être supérieure à celle suggérée par son empreinte visible. */
.topbar .brand-marks {
  min-width: 308px;
  gap: 14px;
}

.topbar .nsk-portal-link {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
}

.topbar .nsk-portal-link:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 3px;
}

.topbar .nsk-mark {
  width: auto;
  height: 78px;
  flex: 0 0 auto;
}

.topbar .rouch-mark {
  width: 190px;
  height: auto;
  flex: 0 0 auto;
}

.topbar.is-collapsed .nsk-mark {
  width: auto;
  height: 58px;
}

.topbar.is-collapsed .rouch-mark {
  width: 142px;
}

@media (max-width: 1320px) {
  .topbar:not(.is-collapsed) .brand-marks {
    min-width: 278px;
  }

  .topbar:not(.is-collapsed) .nsk-mark {
    height: 70px;
  }

  .topbar:not(.is-collapsed) .rouch-mark {
    width: 168px;
  }
}

@media (max-width: 720px) {
  .topbar:not(.is-collapsed) .brand-marks,
  .topbar.is-collapsed .brand-marks {
    min-width: 0;
    gap: 10px;
  }

  .topbar:not(.is-collapsed) .nsk-mark,
  .topbar.is-collapsed .nsk-mark {
    width: auto;
    height: 60px;
  }

  .topbar:not(.is-collapsed) .rouch-mark,
  .topbar.is-collapsed .rouch-mark {
    width: 146px;
  }
}

@media (max-width: 420px) {
  .topbar:not(.is-collapsed) .nsk-mark,
  .topbar.is-collapsed .nsk-mark {
    height: 52px;
  }

  .topbar:not(.is-collapsed) .rouch-mark,
  .topbar.is-collapsed .rouch-mark {
    width: 128px;
  }
}
