/**
 * Compact profile picker — one pill on phones,
tablets,
and narrow screens (≤1400px).
 * Tap the chip to switch profiles; manage lives inside the dropdown footer.
 */

@media (max-width: 1400px) {
  html.is-compact-layout .profile-picker__display,
  html.is-compact-layout .profile-picker__dropdown-manage {
    text-transform: none !important;
    letter-spacing: normal !important;
    font-weight: inherit !important;
    filter: none !important;
    transform: none !important;
  }

  html.is-compact-layout .profile-picker-bar:not([hidden]) {
    gap: 0;
    min-width: 0;
  }

  html.is-compact-layout .profile-picker {
    display: block;
    width: 100%;
    min-width: 0;
  }

  html.is-compact-layout .profile-picker__field {
    position: relative;
    min-width: 0;
    width: 100%;
  }

  /* Legacy manage chip beside picker — removed on compact */
  html.is-compact-layout .profile-picker__manage,
  html.is-compact-layout .profile-picker__toggle {
    display: none !important;
  }

  /* ── Unified profile chip ─────────────────────────────── */
  html.is-compact-layout .profile-picker__control {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    min-height: var(--cockpit-touch, 40px) !important;
    padding: 0.35rem 0.62rem 0.35rem 0.58rem !important;
    border-radius: 999px !important;
    border: 1px solid rgba(202, 138, 4, 0.24) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.98),
      0 1px 4px rgba(63, 15, 25, 0.05) !important;
    cursor: pointer;
    transition:
      border-color 0.18s ease,
      box-shadow 0.18s ease,
      background 0.18s ease;
  }

  html.is-compact-layout .profile-picker__control:focus-within,
  html.is-compact-layout .profile-picker__field--open .profile-picker__control {
    border-color: rgba(185, 28, 28, 0.38) !important;
    box-shadow:
      0 0 0 3px rgba(185, 28, 28, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.98) !important;
    background: #fff !important;
  }

  html.is-compact-layout .profile-picker__control--locked {
    border-color: rgba(185, 28, 28, 0.28) !important;
    background: linear-gradient(180deg, rgba(255, 251, 235, 0.92) 0%, rgba(255, 255, 255, 0.98) 100%) !important;
  }

  html.is-compact-layout .profile-picker__avatar {
    grid-column: 1;
    grid-row: 1;
    flex: 0 0 auto;
    width: 28px !important;
    height: 28px !important;
    font-size: 0.64rem !important;
    border-radius: 999px !important;
    box-shadow: 0 1px 4px rgba(185, 28, 28, 0.16);
  }

  html.is-compact-layout .profile-picker__control--locked .profile-picker__avatar {
    position: relative;
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.95),
      0 0 0 3px rgba(185, 28, 28, 0.32);
  }

  html.is-compact-layout .profile-picker__control--locked .profile-picker__avatar::after {
    content: "";
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    border: 1.5px solid #fff;
    background: #b91c1c url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center / 7px no-repeat;
    box-shadow: 0 1px 3px rgba(63, 15, 25, 0.18);
  }

  html.is-compact-layout .profile-picker__display {
    grid-column: 2;
    grid-row: 1;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.35rem;
    position: relative;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent !important;
    text-align: center;
    cursor: pointer;
    font: inherit;
    color: inherit;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
  }

  html.is-compact-layout .profile-picker__display:hover,
  html.is-compact-layout .profile-picker__display:active {
    background: transparent !important;
    transform: none !important;
    box-shadow: none !important;
  }

  html.is-compact-layout .profile-picker__display:focus-visible {
    outline: none;
    border-radius: 999px;
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.24);
  }

  html.is-compact-layout .profile-picker__display-copy {
    grid-column: 1;
    justify-self: center;
    flex: 1 1 auto;
    min-width: 0;
    width: max-content;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding-inline: 0.15rem;
    text-align: center;
  }

  html.is-compact-layout .profile-picker__name {
    display: block;
    width: 100%;
    min-width: 0;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em !important;
    text-transform: none !important;
    color: var(--pf-text, #3f0f19);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
  }

  html.is-compact-layout .profile-picker__meta {
    display: none !important;
  }

  html.is-compact-layout .profile-picker__chevron {
    grid-column: 2;
    position: static;
    top: auto;
    right: auto;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    color: #78716c;
    background: rgba(254, 243, 199, 0.45);
    transform: none;
    transition: transform 0.18s ease, color 0.15s ease, background 0.15s ease;
  }

  html.is-compact-layout .profile-picker__chevron svg {
    width: 14px;
    height: 14px;
  }

  html.is-compact-layout .profile-picker__field--open .profile-picker__chevron {
    transform: rotate(180deg);
    color: #b91c1c;
    background: rgba(254, 226, 226, 0.55);
  }

  /* Search mode */
  html.is-compact-layout .profile-picker__field--search .profile-picker__display,
  html.is-compact-layout .profile-picker__field--search .profile-picker__chevron {
    display: none !important;
  }

  html.is-compact-layout .profile-picker__field:not(.profile-picker__field--search) .profile-picker__input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  html.is-compact-layout .profile-picker__field--search .profile-picker__input {
    grid-column: 2;
    grid-row: 1;
    position: static !important;
    flex: 1 1 auto;
    min-width: 0;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    clip: auto !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 0.84rem !important;
    font-weight: 650 !important;
    padding: 0 !important;
    text-align: center !important;
    color: var(--pf-text, #3f0f19) !important;
  }

  html.is-compact-layout .profile-picker__input::placeholder {
    color: rgba(122, 75, 18, 0.55);
    font-weight: 500;
  }

  /* ── Dropdown ──────────────────────────────────────────── */
  html.is-compact-layout .profile-picker__dropdown {
    top: calc(100% + 0.32rem);
    left: 0;
    right: 0;
    border-radius: 16px;
    border: 1px solid rgba(202, 138, 4, 0.24);
    background: #fff;
    box-shadow: 0 16px 40px rgba(63, 15, 25, 0.14);
    max-height: min(360px, 56dvh);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  html.is-compact-layout .profile-picker__list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.35rem;
  }

  html.is-compact-layout .profile-picker__option {
    min-height: 46px;
    padding: 0.42rem 0.55rem;
    gap: 0.55rem;
    border-radius: 12px;
  }

  html.is-compact-layout .profile-picker__option-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.66rem;
    border-radius: 999px;
  }

  html.is-compact-layout .profile-picker__option-name {
    font-size: 0.84rem;
  }

  html.is-compact-layout .profile-picker__option-meta {
    font-size: 0.68rem;
  }

  html.is-compact-layout .profile-picker__empty {
    padding: 0.85rem 0.75rem;
    margin: 0;
  }

  html.is-compact-layout .profile-picker__dropdown-footer {
    flex: 0 0 auto;
    padding: 0.35rem;
    border-top: 1px solid rgba(231, 201, 120, 0.45);
    background: linear-gradient(180deg, rgba(255, 253, 248, 0.6), rgba(255, 250, 242, 0.95));
  }

  html.is-compact-layout .profile-picker__dropdown-manage {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    min-height: 42px;
    padding: 0.55rem 0.75rem !important;
    border: none !important;
    border-radius: 12px !important;
    background: transparent !important;
    color: #7a4b12 !important;
    font-size: 0.82rem !important;
    font-weight: 650 !important;
    cursor: pointer;
    box-shadow: none !important;
    transition: background 0.15s ease, color 0.15s ease;
  }

  html.is-compact-layout .profile-picker__dropdown-manage svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    stroke: currentColor;
    opacity: 0.85;
  }

  html.is-compact-layout .profile-picker__dropdown-manage:hover,
  html.is-compact-layout .profile-picker__dropdown-manage:active {
    background: rgba(254, 243, 199, 0.45) !important;
    color: #b91c1c !important;
    transform: none !important;
    box-shadow: none !important;
  }

  html.is-compact-layout .profile-picker__dropdown-manage:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.24) !important;
  }
}

@media (max-width: 640px) {
  html.is-compact-layout .profile-picker__name {
    font-size: 0.8rem;
  }

  html.is-compact-layout .profile-picker__avatar {
    width: 26px !important;
    height: 26px !important;
    font-size: 0.6rem !important;
  }

  html.is-compact-layout .profile-picker__control {
    min-height: 38px !important;
    padding: 0.35rem 0.58rem 0.35rem 0.55rem !important;
  }
}

@media (max-width: 1400px) and (prefers-reduced-motion: reduce) {
  html.is-compact-layout .profile-picker__control,
  html.is-compact-layout .profile-picker__chevron,
  html.is-compact-layout .profile-picker__dropdown-manage {
    transition: none;
  }
}
